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
import sys from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object class ApprovalSettings(_serialization.Model): """The approval settings. :ivar is_approval_required: Determines whether approval is required or not. :vartype is_approval_required: bool :ivar is_approval_required_for_extension: Determines whether approval is required for assignment extension. :vartype is_approval_required_for_extension: bool :ivar is_requestor_justification_required: Determine whether requestor justification is required. :vartype is_requestor_justification_required: bool :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :vartype approval_mode: str or ~azure.mgmt.authorization.v2022_04_01.models.ApprovalMode :ivar approval_stages: The approval stages of the request. :vartype approval_stages: list[~azure.mgmt.authorization.v2022_04_01.models.ApprovalStage] """ _attribute_map = { "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, "approval_mode": {"key": "approvalMode", "type": "str"}, "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, } def __init__( self, *, is_approval_required: Optional[bool] = None, is_approval_required_for_extension: Optional[bool] = None, is_requestor_justification_required: Optional[bool] = None, approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, approval_stages: Optional[List["_models.ApprovalStage"]] = None, **kwargs: Any ) -> None: """ :keyword is_approval_required: Determines whether approval is required or not. :paramtype is_approval_required: bool :keyword is_approval_required_for_extension: Determines whether approval is required for assignment extension. :paramtype is_approval_required_for_extension: bool :keyword is_requestor_justification_required: Determine whether requestor justification is required. :paramtype is_requestor_justification_required: bool :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :paramtype approval_mode: str or ~azure.mgmt.authorization.v2022_04_01.models.ApprovalMode :keyword approval_stages: The approval stages of the request. :paramtype approval_stages: list[~azure.mgmt.authorization.v2022_04_01.models.ApprovalStage] """ super().__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension self.is_requestor_justification_required = is_requestor_justification_required self.approval_mode = approval_mode self.approval_stages = approval_stages class ApprovalStage(_serialization.Model): """The approval stage. :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. :vartype approval_stage_time_out_in_days: int :ivar is_approver_justification_required: Determines whether approver need to provide justification for his decision. :vartype is_approver_justification_required: bool :ivar escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :vartype escalation_time_in_minutes: int :ivar primary_approvers: The primary approver of the request. :vartype primary_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. :vartype is_escalation_enabled: bool :ivar escalation_approvers: The escalation approver of the request. :vartype escalation_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] """ _attribute_map = { "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, } def __init__( self, *, approval_stage_time_out_in_days: Optional[int] = None, is_approver_justification_required: Optional[bool] = None, escalation_time_in_minutes: Optional[int] = None, primary_approvers: Optional[List["_models.UserSet"]] = None, is_escalation_enabled: Optional[bool] = None, escalation_approvers: Optional[List["_models.UserSet"]] = None, **kwargs: Any ) -> None: """ :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed out. :paramtype approval_stage_time_out_in_days: int :keyword is_approver_justification_required: Determines whether approver need to provide justification for his decision. :paramtype is_approver_justification_required: bool :keyword escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :paramtype escalation_time_in_minutes: int :keyword primary_approvers: The primary approver of the request. :paramtype primary_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. :paramtype is_escalation_enabled: bool :keyword escalation_approvers: The escalation approver of the request. :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] """ super().__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required self.escalation_time_in_minutes = escalation_time_in_minutes self.primary_approvers = primary_approvers self.is_escalation_enabled = is_escalation_enabled self.escalation_approvers = escalation_approvers class DenyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deny Assignment. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The deny assignment ID. :vartype id: str :ivar name: The deny assignment name. :vartype name: str :ivar type: The deny assignment type. :vartype type: str :ivar deny_assignment_name: The display name of the deny assignment. :vartype deny_assignment_name: str :ivar description: The description of the deny assignment. :vartype description: str :ivar permissions: An array of permissions that are denied by the deny assignment. :vartype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignmentPermission] :ivar scope: The deny assignment scope. :vartype scope: str :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :vartype do_not_apply_to_child_scopes: bool :ivar principals: Array of principals to which the deny assignment applies. :vartype principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :ivar exclude_principals: Array of principals to which the deny assignment does not apply. :vartype exclude_principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :vartype is_system_protected: bool :ivar condition: The conditions on the deny assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "deny_assignment_name": {"key": "properties.denyAssignmentName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[DenyAssignmentPermission]"}, "scope": {"key": "properties.scope", "type": "str"}, "do_not_apply_to_child_scopes": {"key": "properties.doNotApplyToChildScopes", "type": "bool"}, "principals": {"key": "properties.principals", "type": "[Principal]"}, "exclude_principals": {"key": "properties.excludePrincipals", "type": "[Principal]"}, "is_system_protected": {"key": "properties.isSystemProtected", "type": "bool"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, description: Optional[str] = None, permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, scope: Optional[str] = None, do_not_apply_to_child_scopes: Optional[bool] = None, principals: Optional[List["_models.Principal"]] = None, exclude_principals: Optional[List["_models.Principal"]] = None, is_system_protected: Optional[bool] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: The display name of the deny assignment. :paramtype deny_assignment_name: str :keyword description: The description of the deny assignment. :paramtype description: str :keyword permissions: An array of permissions that are denied by the deny assignment. :paramtype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignmentPermission] :keyword scope: The deny assignment scope. :paramtype scope: str :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :paramtype do_not_apply_to_child_scopes: bool :keyword principals: Array of principals to which the deny assignment applies. :paramtype principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :keyword exclude_principals: Array of principals to which the deny assignment does not apply. :paramtype exclude_principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :paramtype is_system_protected: bool :keyword condition: The conditions on the deny assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. :paramtype condition_version: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.deny_assignment_name = deny_assignment_name self.description = description self.permissions = permissions self.scope = scope self.do_not_apply_to_child_scopes = do_not_apply_to_child_scopes self.principals = principals self.exclude_principals = exclude_principals self.is_system_protected = is_system_protected self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None class DenyAssignmentFilter(_serialization.Model): """Deny Assignments filter. :ivar deny_assignment_name: Return deny assignment with specified name. :vartype deny_assignment_name: str :ivar principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :vartype principal_id: str :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :vartype gdpr_export_principal_id: str """ _attribute_map = { "deny_assignment_name": {"key": "denyAssignmentName", "type": "str"}, "principal_id": {"key": "principalId", "type": "str"}, "gdpr_export_principal_id": {"key": "gdprExportPrincipalId", "type": "str"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, principal_id: Optional[str] = None, gdpr_export_principal_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: Return deny assignment with specified name. :paramtype deny_assignment_name: str :keyword principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :paramtype principal_id: str :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :paramtype gdpr_export_principal_id: str """ super().__init__(**kwargs) self.deny_assignment_name = deny_assignment_name self.principal_id = principal_id self.gdpr_export_principal_id = gdpr_export_principal_id class DenyAssignmentListResult(_serialization.Model): """Deny assignment list operation result. :ivar value: Deny assignment list. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[DenyAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Deny assignment list. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class DenyAssignmentPermission(_serialization.Model): """Deny assignment permissions. :ivar actions: Actions to which the deny assignment does not grant access. :vartype actions: list[str] :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. :vartype not_actions: list[str] :ivar data_actions: Data actions to which the deny assignment does not grant access. :vartype data_actions: list[str] :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :vartype not_data_actions: list[str] :ivar condition: The conditions on the Deny assignment permission. This limits the resources it applies to. :vartype condition: str :ivar condition_version: Version of the condition. :vartype condition_version: str """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, "condition": {"key": "condition", "type": "str"}, "condition_version": {"key": "conditionVersion", "type": "str"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword actions: Actions to which the deny assignment does not grant access. :paramtype actions: list[str] :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. :paramtype not_actions: list[str] :keyword data_actions: Data actions to which the deny assignment does not grant access. :paramtype data_actions: list[str] :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :paramtype not_data_actions: list[str] :keyword condition: The conditions on the Deny assignment permission. This limits the resources it applies to. :paramtype condition: str :keyword condition_version: Version of the condition. :paramtype condition_version: str """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions self.condition = condition self.condition_version = condition_version class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2022_04_01.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class Permission(_serialization.Model): """Role definition permissions. :ivar actions: Allowed actions. :vartype actions: list[str] :ivar not_actions: Denied actions. :vartype not_actions: list[str] :ivar data_actions: Allowed Data actions. :vartype data_actions: list[str] :ivar not_data_actions: Denied Data actions. :vartype not_data_actions: list[str] """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Allowed actions. :paramtype actions: list[str] :keyword not_actions: Denied actions. :paramtype not_actions: list[str] :keyword data_actions: Allowed Data actions. :paramtype data_actions: list[str] :keyword not_data_actions: Denied Data actions. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions class PermissionGetResult(_serialization.Model): """Permissions information. :ivar value: An array of permissions. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Permission]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: An array of permissions. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email class ProviderOperation(_serialization.Model): """Operation. :ivar name: The operation name. :vartype name: str :ivar display_name: The operation display name. :vartype display_name: str :ivar description: The operation description. :vartype description: str :ivar origin: The operation origin. :vartype origin: str :ivar properties: The operation properties. :vartype properties: JSON :ivar is_data_action: The dataAction flag to specify the operation type. :vartype is_data_action: bool """ _attribute_map = { "name": {"key": "name", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "description": {"key": "description", "type": "str"}, "origin": {"key": "origin", "type": "str"}, "properties": {"key": "properties", "type": "object"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, } def __init__( self, *, name: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, origin: Optional[str] = None, properties: Optional[JSON] = None, is_data_action: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword name: The operation name. :paramtype name: str :keyword display_name: The operation display name. :paramtype display_name: str :keyword description: The operation description. :paramtype description: str :keyword origin: The operation origin. :paramtype origin: str :keyword properties: The operation properties. :paramtype properties: JSON :keyword is_data_action: The dataAction flag to specify the operation type. :paramtype is_data_action: bool """ super().__init__(**kwargs) self.name = name self.display_name = display_name self.description = description self.origin = origin self.properties = properties self.is_data_action = is_data_action class ProviderOperationsMetadata(_serialization.Model): """Provider Operations metadata. :ivar id: The provider id. :vartype id: str :ivar name: The provider name. :vartype name: str :ivar type: The provider type. :vartype type: str :ivar display_name: The provider display name. :vartype display_name: str :ivar resource_types: The provider resource types. :vartype resource_types: list[~azure.mgmt.authorization.v2022_04_01.models.ResourceType] :ivar operations: The provider operations. :vartype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "resource_types": {"key": "resourceTypes", "type": "[ResourceType]"}, "operations": {"key": "operations", "type": "[ProviderOperation]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, display_name: Optional[str] = None, resource_types: Optional[List["_models.ResourceType"]] = None, operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs: Any ) -> None: """ :keyword id: The provider id. :paramtype id: str :keyword name: The provider name. :paramtype name: str :keyword type: The provider type. :paramtype type: str :keyword display_name: The provider display name. :paramtype display_name: str :keyword resource_types: The provider resource types. :paramtype resource_types: list[~azure.mgmt.authorization.v2022_04_01.models.ResourceType] :keyword operations: The provider operations. :paramtype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ super().__init__(**kwargs) self.id = id self.name = name self.type = type self.display_name = display_name self.resource_types = resource_types self.operations = operations class ProviderOperationsMetadataListResult(_serialization.Model): """Provider operations metadata list. :ivar value: The list of providers. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[ProviderOperationsMetadata]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.ProviderOperationsMetadata"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The list of providers. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class ResourceType(_serialization.Model): """Resource Type. :ivar name: The resource type name. :vartype name: str :ivar display_name: The resource type display name. :vartype display_name: str :ivar operations: The resource type operations. :vartype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ _attribute_map = { "name": {"key": "name", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "operations": {"key": "operations", "type": "[ProviderOperation]"}, } def __init__( self, *, name: Optional[str] = None, display_name: Optional[str] = None, operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs: Any ) -> None: """ :keyword name: The resource type name. :paramtype name: str :keyword display_name: The resource type display name. :paramtype display_name: str :keyword operations: The resource type operations. :paramtype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ super().__init__(**kwargs) self.name = name self.display_name = display_name self.operations = operations class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Union[str, "_models.PrincipalType"] = "User", description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently the only accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role assignment create parameters. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "scope": {"readonly": True}, "role_definition_id": {"required": True}, "principal_id": {"required": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Union[str, "_models.PrincipalType"] = "User", description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently the only accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] :ivar next_link: The skipToken to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignment"]] = None, **kwargs: Any) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role definition ID. :vartype id: str :ivar name: The role definition name. :vartype name: str :ivar type: The role definition type. :vartype type: str :ivar role_name: The role name. :vartype role_name: str :ivar description: The role definition description. :vartype description: str :ivar role_type: The role type. :vartype role_type: str :ivar permissions: Role definition permissions. :vartype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :ivar assignable_scopes: Role definition assignable scopes. :vartype assignable_scopes: list[str] :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "role_name": {"key": "properties.roleName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "role_type": {"key": "properties.type", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[Permission]"}, "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, } def __init__( self, *, role_name: Optional[str] = None, description: Optional[str] = None, role_type: Optional[str] = None, permissions: Optional[List["_models.Permission"]] = None, assignable_scopes: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword role_name: The role name. :paramtype role_name: str :keyword description: The role definition description. :paramtype description: str :keyword role_type: The role type. :paramtype role_type: str :keyword permissions: Role definition permissions. :paramtype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :keyword assignable_scopes: Role definition assignable scopes. :paramtype assignable_scopes: list[str] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.role_name = role_name self.description = description self.role_type = role_type self.permissions = permissions self.assignable_scopes = assignable_scopes self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None class RoleDefinitionFilter(_serialization.Model): """Role Definitions filter. :ivar role_name: Returns role definition with the specific name. :vartype role_name: str :ivar type: Returns role definition with the specific type. :vartype type: str """ _attribute_map = { "role_name": {"key": "roleName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: """ :keyword role_name: Returns role definition with the specific name. :paramtype role_name: str :keyword type: Returns role definition with the specific type. :paramtype type: str """ super().__init__(**kwargs) self.role_name = role_name self.type = type class RoleDefinitionListResult(_serialization.Model): """Role definition list operation result. :ivar value: Role definition list. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role definition list. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyRule(_serialization.Model): """The role management policy rule. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, } _subtype_map = { "rule_type": { "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", } } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget """ super().__init__(**kwargs) self.id = id self.rule_type: Optional[str] = None self.target = target class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar setting: The approval setting. :vartype setting: ~azure.mgmt.authorization.v2022_04_01.models.ApprovalSettings """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "setting": {"key": "setting", "type": "ApprovalSettings"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, setting: Optional["_models.ApprovalSettings"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword setting: The approval setting. :paramtype setting: ~azure.mgmt.authorization.v2022_04_01.models.ApprovalSettings """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyApprovalRule" self.setting = setting class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): """The role management policy authentication context rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar is_enabled: The value indicating if rule is enabled. :vartype is_enabled: bool :ivar claim_value: The claim value. :vartype claim_value: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "claim_value": {"key": "claimValue", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_enabled: Optional[bool] = None, claim_value: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword is_enabled: The value indicating if rule is enabled. :paramtype is_enabled: bool :keyword claim_value: The claim value. :paramtype claim_value: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" self.is_enabled = is_enabled self.claim_value = claim_value class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy enablement rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar enabled_rules: The list of enabled rules. :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_04_01.models.EnablementRules] """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "enabled_rules": {"key": "enabledRules", "type": "[str]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword enabled_rules: The list of enabled rules. :paramtype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_04_01.models.EnablementRules] """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyEnablementRule" self.enabled_rules = enabled_rules class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar is_expiration_required: The value indicating whether expiration is required. :vartype is_expiration_required: bool :ivar maximum_duration: The maximum duration of expiration in timespan. :vartype maximum_duration: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, "maximum_duration": {"key": "maximumDuration", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_expiration_required: Optional[bool] = None, maximum_duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword is_expiration_required: The value indicating whether expiration is required. :paramtype is_expiration_required: bool :keyword maximum_duration: The maximum duration of expiration in timespan. :paramtype maximum_duration: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyExpirationRule" self.is_expiration_required = is_expiration_required self.maximum_duration = maximum_duration class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar notification_type: The type of notification. "Email" :vartype notification_type: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationDeliveryMechanism :ivar notification_level: The notification level. Known values are: "None", "Critical", and "All". :vartype notification_level: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationLevel :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :vartype recipient_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RecipientType :ivar notification_recipients: The list of notification recipients. :vartype notification_recipients: list[str] :ivar is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :vartype is_default_recipients_enabled: bool """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "notification_type": {"key": "notificationType", "type": "str"}, "notification_level": {"key": "notificationLevel", "type": "str"}, "recipient_type": {"key": "recipientType", "type": "str"}, "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, notification_recipients: Optional[List[str]] = None, is_default_recipients_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword notification_type: The type of notification. "Email" :paramtype notification_type: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationDeliveryMechanism :keyword notification_level: The notification level. Known values are: "None", "Critical", and "All". :paramtype notification_level: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationLevel :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :paramtype recipient_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RecipientType :keyword notification_recipients: The list of notification recipients. :paramtype notification_recipients: list[str] :keyword is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :paramtype is_default_recipients_enabled: bool """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyNotificationRule" self.notification_type = notification_type self.notification_level = notification_level self.recipient_type = recipient_type self.notification_recipients = notification_recipients self.is_default_recipients_enabled = is_default_recipients_enabled class RoleManagementPolicyRuleTarget(_serialization.Model): """The role management policy rule target. :ivar caller: The caller of the setting. :vartype caller: str :ivar operations: The type of operation. :vartype operations: list[str] :ivar level: The assignment level to which rule is applied. :vartype level: str :ivar target_objects: The list of target objects. :vartype target_objects: list[str] :ivar inheritable_settings: The list of inheritable settings. :vartype inheritable_settings: list[str] :ivar enforced_settings: The list of enforced settings. :vartype enforced_settings: list[str] """ _attribute_map = { "caller": {"key": "caller", "type": "str"}, "operations": {"key": "operations", "type": "[str]"}, "level": {"key": "level", "type": "str"}, "target_objects": {"key": "targetObjects", "type": "[str]"}, "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, } def __init__( self, *, caller: Optional[str] = None, operations: Optional[List[str]] = None, level: Optional[str] = None, target_objects: Optional[List[str]] = None, inheritable_settings: Optional[List[str]] = None, enforced_settings: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword caller: The caller of the setting. :paramtype caller: str :keyword operations: The type of operation. :paramtype operations: list[str] :keyword level: The assignment level to which rule is applied. :paramtype level: str :keyword target_objects: The list of target objects. :paramtype target_objects: list[str] :keyword inheritable_settings: The list of inheritable settings. :paramtype inheritable_settings: list[str] :keyword enforced_settings: The list of enforced settings. :paramtype enforced_settings: list[str] """ super().__init__(**kwargs) self.caller = caller self.operations = operations self.level = level self.target_objects = target_objects self.inheritable_settings = inheritable_settings self.enforced_settings = enforced_settings class UserSet(_serialization.Model): """The detail of a user. :ivar user_type: The type of user. Known values are: "User" and "Group". :vartype user_type: str or ~azure.mgmt.authorization.v2022_04_01.models.UserType :ivar is_backup: The value indicating whether the user is a backup fallback approver. :vartype is_backup: bool :ivar id: The object id of the user. :vartype id: str :ivar description: The description of the user. :vartype description: str """ _attribute_map = { "user_type": {"key": "userType", "type": "str"}, "is_backup": {"key": "isBackup", "type": "bool"}, "id": {"key": "id", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__( self, *, user_type: Optional[Union[str, "_models.UserType"]] = None, is_backup: Optional[bool] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin description: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword user_type: The type of user. Known values are: "User" and "Group". :paramtype user_type: str or ~azure.mgmt.authorization.v2022_04_01.models.UserType :keyword is_backup: The value indicating whether the user is a backup fallback approver. :paramtype is_backup: bool :keyword id: The object id of the user. :paramtype id: str :keyword description: The description of the user. :paramtype description: str """ super().__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup self.id = id self.description = description class ValidationResponse(_serialization.Model): """Validation response. Variables are only populated by the server, and will be ignored when sending a request. :ivar is_valid: Whether or not validation succeeded. :vartype is_valid: bool :ivar error_info: Failed validation result details. :vartype error_info: ~azure.mgmt.authorization.v2022_04_01.models.ValidationResponseErrorInfo """ _validation = { "is_valid": {"readonly": True}, } _attribute_map = { "is_valid": {"key": "isValid", "type": "bool"}, "error_info": {"key": "errorInfo", "type": "ValidationResponseErrorInfo"}, } def __init__(self, *, error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs: Any) -> None: """ :keyword error_info: Failed validation result details. :paramtype error_info: ~azure.mgmt.authorization.v2022_04_01.models.ValidationResponseErrorInfo """ super().__init__(**kwargs) self.is_valid = None self.error_info = error_info class ValidationResponseErrorInfo(_serialization.Model): """Failed validation result details. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: Error code indicating why validation failed. :vartype code: str :ivar message: Message indicating why validation failed. :vartype message: str """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_04_01/models/_models_py3.py
_models_py3.py
import sys from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object class ApprovalSettings(_serialization.Model): """The approval settings. :ivar is_approval_required: Determines whether approval is required or not. :vartype is_approval_required: bool :ivar is_approval_required_for_extension: Determines whether approval is required for assignment extension. :vartype is_approval_required_for_extension: bool :ivar is_requestor_justification_required: Determine whether requestor justification is required. :vartype is_requestor_justification_required: bool :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :vartype approval_mode: str or ~azure.mgmt.authorization.v2022_04_01.models.ApprovalMode :ivar approval_stages: The approval stages of the request. :vartype approval_stages: list[~azure.mgmt.authorization.v2022_04_01.models.ApprovalStage] """ _attribute_map = { "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, "approval_mode": {"key": "approvalMode", "type": "str"}, "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, } def __init__( self, *, is_approval_required: Optional[bool] = None, is_approval_required_for_extension: Optional[bool] = None, is_requestor_justification_required: Optional[bool] = None, approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, approval_stages: Optional[List["_models.ApprovalStage"]] = None, **kwargs: Any ) -> None: """ :keyword is_approval_required: Determines whether approval is required or not. :paramtype is_approval_required: bool :keyword is_approval_required_for_extension: Determines whether approval is required for assignment extension. :paramtype is_approval_required_for_extension: bool :keyword is_requestor_justification_required: Determine whether requestor justification is required. :paramtype is_requestor_justification_required: bool :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :paramtype approval_mode: str or ~azure.mgmt.authorization.v2022_04_01.models.ApprovalMode :keyword approval_stages: The approval stages of the request. :paramtype approval_stages: list[~azure.mgmt.authorization.v2022_04_01.models.ApprovalStage] """ super().__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension self.is_requestor_justification_required = is_requestor_justification_required self.approval_mode = approval_mode self.approval_stages = approval_stages class ApprovalStage(_serialization.Model): """The approval stage. :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. :vartype approval_stage_time_out_in_days: int :ivar is_approver_justification_required: Determines whether approver need to provide justification for his decision. :vartype is_approver_justification_required: bool :ivar escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :vartype escalation_time_in_minutes: int :ivar primary_approvers: The primary approver of the request. :vartype primary_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. :vartype is_escalation_enabled: bool :ivar escalation_approvers: The escalation approver of the request. :vartype escalation_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] """ _attribute_map = { "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, } def __init__( self, *, approval_stage_time_out_in_days: Optional[int] = None, is_approver_justification_required: Optional[bool] = None, escalation_time_in_minutes: Optional[int] = None, primary_approvers: Optional[List["_models.UserSet"]] = None, is_escalation_enabled: Optional[bool] = None, escalation_approvers: Optional[List["_models.UserSet"]] = None, **kwargs: Any ) -> None: """ :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed out. :paramtype approval_stage_time_out_in_days: int :keyword is_approver_justification_required: Determines whether approver need to provide justification for his decision. :paramtype is_approver_justification_required: bool :keyword escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :paramtype escalation_time_in_minutes: int :keyword primary_approvers: The primary approver of the request. :paramtype primary_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. :paramtype is_escalation_enabled: bool :keyword escalation_approvers: The escalation approver of the request. :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2022_04_01.models.UserSet] """ super().__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required self.escalation_time_in_minutes = escalation_time_in_minutes self.primary_approvers = primary_approvers self.is_escalation_enabled = is_escalation_enabled self.escalation_approvers = escalation_approvers class DenyAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Deny Assignment. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The deny assignment ID. :vartype id: str :ivar name: The deny assignment name. :vartype name: str :ivar type: The deny assignment type. :vartype type: str :ivar deny_assignment_name: The display name of the deny assignment. :vartype deny_assignment_name: str :ivar description: The description of the deny assignment. :vartype description: str :ivar permissions: An array of permissions that are denied by the deny assignment. :vartype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignmentPermission] :ivar scope: The deny assignment scope. :vartype scope: str :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :vartype do_not_apply_to_child_scopes: bool :ivar principals: Array of principals to which the deny assignment applies. :vartype principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :ivar exclude_principals: Array of principals to which the deny assignment does not apply. :vartype exclude_principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :vartype is_system_protected: bool :ivar condition: The conditions on the deny assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "deny_assignment_name": {"key": "properties.denyAssignmentName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[DenyAssignmentPermission]"}, "scope": {"key": "properties.scope", "type": "str"}, "do_not_apply_to_child_scopes": {"key": "properties.doNotApplyToChildScopes", "type": "bool"}, "principals": {"key": "properties.principals", "type": "[Principal]"}, "exclude_principals": {"key": "properties.excludePrincipals", "type": "[Principal]"}, "is_system_protected": {"key": "properties.isSystemProtected", "type": "bool"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, description: Optional[str] = None, permissions: Optional[List["_models.DenyAssignmentPermission"]] = None, scope: Optional[str] = None, do_not_apply_to_child_scopes: Optional[bool] = None, principals: Optional[List["_models.Principal"]] = None, exclude_principals: Optional[List["_models.Principal"]] = None, is_system_protected: Optional[bool] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: The display name of the deny assignment. :paramtype deny_assignment_name: str :keyword description: The description of the deny assignment. :paramtype description: str :keyword permissions: An array of permissions that are denied by the deny assignment. :paramtype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignmentPermission] :keyword scope: The deny assignment scope. :paramtype scope: str :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. :paramtype do_not_apply_to_child_scopes: bool :keyword principals: Array of principals to which the deny assignment applies. :paramtype principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :keyword exclude_principals: Array of principals to which the deny assignment does not apply. :paramtype exclude_principals: list[~azure.mgmt.authorization.v2022_04_01.models.Principal] :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. :paramtype is_system_protected: bool :keyword condition: The conditions on the deny assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. :paramtype condition_version: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.deny_assignment_name = deny_assignment_name self.description = description self.permissions = permissions self.scope = scope self.do_not_apply_to_child_scopes = do_not_apply_to_child_scopes self.principals = principals self.exclude_principals = exclude_principals self.is_system_protected = is_system_protected self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None class DenyAssignmentFilter(_serialization.Model): """Deny Assignments filter. :ivar deny_assignment_name: Return deny assignment with specified name. :vartype deny_assignment_name: str :ivar principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :vartype principal_id: str :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :vartype gdpr_export_principal_id: str """ _attribute_map = { "deny_assignment_name": {"key": "denyAssignmentName", "type": "str"}, "principal_id": {"key": "principalId", "type": "str"}, "gdpr_export_principal_id": {"key": "gdprExportPrincipalId", "type": "str"}, } def __init__( self, *, deny_assignment_name: Optional[str] = None, principal_id: Optional[str] = None, gdpr_export_principal_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword deny_assignment_name: Return deny assignment with specified name. :paramtype deny_assignment_name: str :keyword principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. :paramtype principal_id: str :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. :paramtype gdpr_export_principal_id: str """ super().__init__(**kwargs) self.deny_assignment_name = deny_assignment_name self.principal_id = principal_id self.gdpr_export_principal_id = gdpr_export_principal_id class DenyAssignmentListResult(_serialization.Model): """Deny assignment list operation result. :ivar value: Deny assignment list. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[DenyAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.DenyAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Deny assignment list. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.DenyAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class DenyAssignmentPermission(_serialization.Model): """Deny assignment permissions. :ivar actions: Actions to which the deny assignment does not grant access. :vartype actions: list[str] :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. :vartype not_actions: list[str] :ivar data_actions: Data actions to which the deny assignment does not grant access. :vartype data_actions: list[str] :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :vartype not_data_actions: list[str] :ivar condition: The conditions on the Deny assignment permission. This limits the resources it applies to. :vartype condition: str :ivar condition_version: Version of the condition. :vartype condition_version: str """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, "condition": {"key": "condition", "type": "str"}, "condition_version": {"key": "conditionVersion", "type": "str"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword actions: Actions to which the deny assignment does not grant access. :paramtype actions: list[str] :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. :paramtype not_actions: list[str] :keyword data_actions: Data actions to which the deny assignment does not grant access. :paramtype data_actions: list[str] :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant access. :paramtype not_data_actions: list[str] :keyword condition: The conditions on the Deny assignment permission. This limits the resources it applies to. :paramtype condition: str :keyword condition_version: Version of the condition. :paramtype condition_version: str """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions self.condition = condition self.condition_version = condition_version class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2022_04_01.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2022_04_01.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class Permission(_serialization.Model): """Role definition permissions. :ivar actions: Allowed actions. :vartype actions: list[str] :ivar not_actions: Denied actions. :vartype not_actions: list[str] :ivar data_actions: Allowed Data actions. :vartype data_actions: list[str] :ivar not_data_actions: Denied Data actions. :vartype not_data_actions: list[str] """ _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Allowed actions. :paramtype actions: list[str] :keyword not_actions: Denied actions. :paramtype not_actions: list[str] :keyword data_actions: Allowed Data actions. :paramtype data_actions: list[str] :keyword not_data_actions: Denied Data actions. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions class PermissionGetResult(_serialization.Model): """Permissions information. :ivar value: An array of permissions. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Permission]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: An array of permissions. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email class ProviderOperation(_serialization.Model): """Operation. :ivar name: The operation name. :vartype name: str :ivar display_name: The operation display name. :vartype display_name: str :ivar description: The operation description. :vartype description: str :ivar origin: The operation origin. :vartype origin: str :ivar properties: The operation properties. :vartype properties: JSON :ivar is_data_action: The dataAction flag to specify the operation type. :vartype is_data_action: bool """ _attribute_map = { "name": {"key": "name", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "description": {"key": "description", "type": "str"}, "origin": {"key": "origin", "type": "str"}, "properties": {"key": "properties", "type": "object"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, } def __init__( self, *, name: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, origin: Optional[str] = None, properties: Optional[JSON] = None, is_data_action: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword name: The operation name. :paramtype name: str :keyword display_name: The operation display name. :paramtype display_name: str :keyword description: The operation description. :paramtype description: str :keyword origin: The operation origin. :paramtype origin: str :keyword properties: The operation properties. :paramtype properties: JSON :keyword is_data_action: The dataAction flag to specify the operation type. :paramtype is_data_action: bool """ super().__init__(**kwargs) self.name = name self.display_name = display_name self.description = description self.origin = origin self.properties = properties self.is_data_action = is_data_action class ProviderOperationsMetadata(_serialization.Model): """Provider Operations metadata. :ivar id: The provider id. :vartype id: str :ivar name: The provider name. :vartype name: str :ivar type: The provider type. :vartype type: str :ivar display_name: The provider display name. :vartype display_name: str :ivar resource_types: The provider resource types. :vartype resource_types: list[~azure.mgmt.authorization.v2022_04_01.models.ResourceType] :ivar operations: The provider operations. :vartype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "resource_types": {"key": "resourceTypes", "type": "[ResourceType]"}, "operations": {"key": "operations", "type": "[ProviderOperation]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, display_name: Optional[str] = None, resource_types: Optional[List["_models.ResourceType"]] = None, operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs: Any ) -> None: """ :keyword id: The provider id. :paramtype id: str :keyword name: The provider name. :paramtype name: str :keyword type: The provider type. :paramtype type: str :keyword display_name: The provider display name. :paramtype display_name: str :keyword resource_types: The provider resource types. :paramtype resource_types: list[~azure.mgmt.authorization.v2022_04_01.models.ResourceType] :keyword operations: The provider operations. :paramtype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ super().__init__(**kwargs) self.id = id self.name = name self.type = type self.display_name = display_name self.resource_types = resource_types self.operations = operations class ProviderOperationsMetadataListResult(_serialization.Model): """Provider operations metadata list. :ivar value: The list of providers. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[ProviderOperationsMetadata]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.ProviderOperationsMetadata"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The list of providers. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperationsMetadata] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class ResourceType(_serialization.Model): """Resource Type. :ivar name: The resource type name. :vartype name: str :ivar display_name: The resource type display name. :vartype display_name: str :ivar operations: The resource type operations. :vartype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ _attribute_map = { "name": {"key": "name", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "operations": {"key": "operations", "type": "[ProviderOperation]"}, } def __init__( self, *, name: Optional[str] = None, display_name: Optional[str] = None, operations: Optional[List["_models.ProviderOperation"]] = None, **kwargs: Any ) -> None: """ :keyword name: The resource type name. :paramtype name: str :keyword display_name: The resource type display name. :paramtype display_name: str :keyword operations: The resource type operations. :paramtype operations: list[~azure.mgmt.authorization.v2022_04_01.models.ProviderOperation] """ super().__init__(**kwargs) self.name = name self.display_name = display_name self.operations = operations class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "scope": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Union[str, "_models.PrincipalType"] = "User", description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently the only accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role assignment create parameters. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "scope": {"readonly": True}, "role_definition_id": {"required": True}, "principal_id": {"required": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Union[str, "_models.PrincipalType"] = "User", description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", "ForeignGroup", and "Device". :paramtype principal_type: str or ~azure.mgmt.authorization.v2022_04_01.models.PrincipalType :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently the only accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.scope = None self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.description = description self.condition = condition self.condition_version = condition_version self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] :ivar next_link: The skipToken to use for getting the next set of results. :vartype next_link: str """ _validation = { "next_link": {"readonly": True}, } _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.RoleAssignment"]] = None, **kwargs: Any) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleAssignment] """ super().__init__(**kwargs) self.value = value self.next_link = None class RoleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role definition ID. :vartype id: str :ivar name: The role definition name. :vartype name: str :ivar type: The role definition type. :vartype type: str :ivar role_name: The role name. :vartype role_name: str :ivar description: The role definition description. :vartype description: str :ivar role_type: The role type. :vartype role_type: str :ivar permissions: Role definition permissions. :vartype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :ivar assignable_scopes: Role definition assignable scopes. :vartype assignable_scopes: list[str] :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "role_name": {"key": "properties.roleName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "role_type": {"key": "properties.type", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[Permission]"}, "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, } def __init__( self, *, role_name: Optional[str] = None, description: Optional[str] = None, role_type: Optional[str] = None, permissions: Optional[List["_models.Permission"]] = None, assignable_scopes: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword role_name: The role name. :paramtype role_name: str :keyword description: The role definition description. :paramtype description: str :keyword role_type: The role type. :paramtype role_type: str :keyword permissions: Role definition permissions. :paramtype permissions: list[~azure.mgmt.authorization.v2022_04_01.models.Permission] :keyword assignable_scopes: Role definition assignable scopes. :paramtype assignable_scopes: list[str] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.role_name = role_name self.description = description self.role_type = role_type self.permissions = permissions self.assignable_scopes = assignable_scopes self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None class RoleDefinitionFilter(_serialization.Model): """Role Definitions filter. :ivar role_name: Returns role definition with the specific name. :vartype role_name: str :ivar type: Returns role definition with the specific type. :vartype type: str """ _attribute_map = { "role_name": {"key": "roleName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: """ :keyword role_name: Returns role definition with the specific name. :paramtype role_name: str :keyword type: Returns role definition with the specific type. :paramtype type: str """ super().__init__(**kwargs) self.role_name = role_name self.type = type class RoleDefinitionListResult(_serialization.Model): """Role definition list operation result. :ivar value: Role definition list. :vartype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role definition list. :paramtype value: list[~azure.mgmt.authorization.v2022_04_01.models.RoleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyRule(_serialization.Model): """The role management policy rule. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, } _subtype_map = { "rule_type": { "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", } } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget """ super().__init__(**kwargs) self.id = id self.rule_type: Optional[str] = None self.target = target class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar setting: The approval setting. :vartype setting: ~azure.mgmt.authorization.v2022_04_01.models.ApprovalSettings """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "setting": {"key": "setting", "type": "ApprovalSettings"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, setting: Optional["_models.ApprovalSettings"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword setting: The approval setting. :paramtype setting: ~azure.mgmt.authorization.v2022_04_01.models.ApprovalSettings """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyApprovalRule" self.setting = setting class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): """The role management policy authentication context rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar is_enabled: The value indicating if rule is enabled. :vartype is_enabled: bool :ivar claim_value: The claim value. :vartype claim_value: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "claim_value": {"key": "claimValue", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_enabled: Optional[bool] = None, claim_value: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword is_enabled: The value indicating if rule is enabled. :paramtype is_enabled: bool :keyword claim_value: The claim value. :paramtype claim_value: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" self.is_enabled = is_enabled self.claim_value = claim_value class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy enablement rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar enabled_rules: The list of enabled rules. :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_04_01.models.EnablementRules] """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "enabled_rules": {"key": "enabledRules", "type": "[str]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword enabled_rules: The list of enabled rules. :paramtype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_04_01.models.EnablementRules] """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyEnablementRule" self.enabled_rules = enabled_rules class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar is_expiration_required: The value indicating whether expiration is required. :vartype is_expiration_required: bool :ivar maximum_duration: The maximum duration of expiration in timespan. :vartype maximum_duration: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, "maximum_duration": {"key": "maximumDuration", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_expiration_required: Optional[bool] = None, maximum_duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword is_expiration_required: The value indicating whether expiration is required. :paramtype is_expiration_required: bool :keyword maximum_duration: The maximum duration of expiration in timespan. :paramtype maximum_duration: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyExpirationRule" self.is_expiration_required = is_expiration_required self.maximum_duration = maximum_duration class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :ivar notification_type: The type of notification. "Email" :vartype notification_type: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationDeliveryMechanism :ivar notification_level: The notification level. Known values are: "None", "Critical", and "All". :vartype notification_level: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationLevel :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :vartype recipient_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RecipientType :ivar notification_recipients: The list of notification recipients. :vartype notification_recipients: list[str] :ivar is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :vartype is_default_recipients_enabled: bool """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "notification_type": {"key": "notificationType", "type": "str"}, "notification_level": {"key": "notificationLevel", "type": "str"}, "recipient_type": {"key": "recipientType", "type": "str"}, "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, notification_recipients: Optional[List[str]] = None, is_default_recipients_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_04_01.models.RoleManagementPolicyRuleTarget :keyword notification_type: The type of notification. "Email" :paramtype notification_type: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationDeliveryMechanism :keyword notification_level: The notification level. Known values are: "None", "Critical", and "All". :paramtype notification_level: str or ~azure.mgmt.authorization.v2022_04_01.models.NotificationLevel :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :paramtype recipient_type: str or ~azure.mgmt.authorization.v2022_04_01.models.RecipientType :keyword notification_recipients: The list of notification recipients. :paramtype notification_recipients: list[str] :keyword is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :paramtype is_default_recipients_enabled: bool """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyNotificationRule" self.notification_type = notification_type self.notification_level = notification_level self.recipient_type = recipient_type self.notification_recipients = notification_recipients self.is_default_recipients_enabled = is_default_recipients_enabled class RoleManagementPolicyRuleTarget(_serialization.Model): """The role management policy rule target. :ivar caller: The caller of the setting. :vartype caller: str :ivar operations: The type of operation. :vartype operations: list[str] :ivar level: The assignment level to which rule is applied. :vartype level: str :ivar target_objects: The list of target objects. :vartype target_objects: list[str] :ivar inheritable_settings: The list of inheritable settings. :vartype inheritable_settings: list[str] :ivar enforced_settings: The list of enforced settings. :vartype enforced_settings: list[str] """ _attribute_map = { "caller": {"key": "caller", "type": "str"}, "operations": {"key": "operations", "type": "[str]"}, "level": {"key": "level", "type": "str"}, "target_objects": {"key": "targetObjects", "type": "[str]"}, "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, } def __init__( self, *, caller: Optional[str] = None, operations: Optional[List[str]] = None, level: Optional[str] = None, target_objects: Optional[List[str]] = None, inheritable_settings: Optional[List[str]] = None, enforced_settings: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword caller: The caller of the setting. :paramtype caller: str :keyword operations: The type of operation. :paramtype operations: list[str] :keyword level: The assignment level to which rule is applied. :paramtype level: str :keyword target_objects: The list of target objects. :paramtype target_objects: list[str] :keyword inheritable_settings: The list of inheritable settings. :paramtype inheritable_settings: list[str] :keyword enforced_settings: The list of enforced settings. :paramtype enforced_settings: list[str] """ super().__init__(**kwargs) self.caller = caller self.operations = operations self.level = level self.target_objects = target_objects self.inheritable_settings = inheritable_settings self.enforced_settings = enforced_settings class UserSet(_serialization.Model): """The detail of a user. :ivar user_type: The type of user. Known values are: "User" and "Group". :vartype user_type: str or ~azure.mgmt.authorization.v2022_04_01.models.UserType :ivar is_backup: The value indicating whether the user is a backup fallback approver. :vartype is_backup: bool :ivar id: The object id of the user. :vartype id: str :ivar description: The description of the user. :vartype description: str """ _attribute_map = { "user_type": {"key": "userType", "type": "str"}, "is_backup": {"key": "isBackup", "type": "bool"}, "id": {"key": "id", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__( self, *, user_type: Optional[Union[str, "_models.UserType"]] = None, is_backup: Optional[bool] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin description: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword user_type: The type of user. Known values are: "User" and "Group". :paramtype user_type: str or ~azure.mgmt.authorization.v2022_04_01.models.UserType :keyword is_backup: The value indicating whether the user is a backup fallback approver. :paramtype is_backup: bool :keyword id: The object id of the user. :paramtype id: str :keyword description: The description of the user. :paramtype description: str """ super().__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup self.id = id self.description = description class ValidationResponse(_serialization.Model): """Validation response. Variables are only populated by the server, and will be ignored when sending a request. :ivar is_valid: Whether or not validation succeeded. :vartype is_valid: bool :ivar error_info: Failed validation result details. :vartype error_info: ~azure.mgmt.authorization.v2022_04_01.models.ValidationResponseErrorInfo """ _validation = { "is_valid": {"readonly": True}, } _attribute_map = { "is_valid": {"key": "isValid", "type": "bool"}, "error_info": {"key": "errorInfo", "type": "ValidationResponseErrorInfo"}, } def __init__(self, *, error_info: Optional["_models.ValidationResponseErrorInfo"] = None, **kwargs: Any) -> None: """ :keyword error_info: Failed validation result details. :paramtype error_info: ~azure.mgmt.authorization.v2022_04_01.models.ValidationResponseErrorInfo """ super().__init__(**kwargs) self.is_valid = None self.error_info = error_info class ValidationResponseErrorInfo(_serialization.Model): """Failed validation result details. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: Error code indicating why validation failed. :vartype code: str :ivar message: Message indicating why validation failed. :vartype message: str """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None
0.680242
0.263404
from ._models_py3 import ApprovalSettings from ._models_py3 import ApprovalStage from ._models_py3 import DenyAssignment from ._models_py3 import DenyAssignmentFilter from ._models_py3 import DenyAssignmentListResult from ._models_py3 import DenyAssignmentPermission from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import Permission from ._models_py3 import PermissionGetResult from ._models_py3 import Principal from ._models_py3 import ProviderOperation from ._models_py3 import ProviderOperationsMetadata from ._models_py3 import ProviderOperationsMetadataListResult from ._models_py3 import ResourceType from ._models_py3 import RoleAssignment from ._models_py3 import RoleAssignmentCreateParameters from ._models_py3 import RoleAssignmentFilter from ._models_py3 import RoleAssignmentListResult from ._models_py3 import RoleDefinition from ._models_py3 import RoleDefinitionFilter from ._models_py3 import RoleDefinitionListResult from ._models_py3 import RoleManagementPolicyApprovalRule from ._models_py3 import RoleManagementPolicyAuthenticationContextRule from ._models_py3 import RoleManagementPolicyEnablementRule from ._models_py3 import RoleManagementPolicyExpirationRule from ._models_py3 import RoleManagementPolicyNotificationRule from ._models_py3 import RoleManagementPolicyRule from ._models_py3 import RoleManagementPolicyRuleTarget from ._models_py3 import UserSet from ._models_py3 import ValidationResponse from ._models_py3 import ValidationResponseErrorInfo from ._authorization_management_client_enums import ApprovalMode from ._authorization_management_client_enums import EnablementRules from ._authorization_management_client_enums import NotificationDeliveryMechanism from ._authorization_management_client_enums import NotificationLevel from ._authorization_management_client_enums import PrincipalType from ._authorization_management_client_enums import RecipientType from ._authorization_management_client_enums import RoleManagementPolicyRuleType from ._authorization_management_client_enums import UserType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "ApprovalSettings", "ApprovalStage", "DenyAssignment", "DenyAssignmentFilter", "DenyAssignmentListResult", "DenyAssignmentPermission", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "Permission", "PermissionGetResult", "Principal", "ProviderOperation", "ProviderOperationsMetadata", "ProviderOperationsMetadataListResult", "ResourceType", "RoleAssignment", "RoleAssignmentCreateParameters", "RoleAssignmentFilter", "RoleAssignmentListResult", "RoleDefinition", "RoleDefinitionFilter", "RoleDefinitionListResult", "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule", "RoleManagementPolicyRule", "RoleManagementPolicyRuleTarget", "UserSet", "ValidationResponse", "ValidationResponseErrorInfo", "ApprovalMode", "EnablementRules", "NotificationDeliveryMechanism", "NotificationLevel", "PrincipalType", "RecipientType", "RoleManagementPolicyRuleType", "UserType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_04_01/models/__init__.py
__init__.py
from ._models_py3 import ApprovalSettings from ._models_py3 import ApprovalStage from ._models_py3 import DenyAssignment from ._models_py3 import DenyAssignmentFilter from ._models_py3 import DenyAssignmentListResult from ._models_py3 import DenyAssignmentPermission from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import Permission from ._models_py3 import PermissionGetResult from ._models_py3 import Principal from ._models_py3 import ProviderOperation from ._models_py3 import ProviderOperationsMetadata from ._models_py3 import ProviderOperationsMetadataListResult from ._models_py3 import ResourceType from ._models_py3 import RoleAssignment from ._models_py3 import RoleAssignmentCreateParameters from ._models_py3 import RoleAssignmentFilter from ._models_py3 import RoleAssignmentListResult from ._models_py3 import RoleDefinition from ._models_py3 import RoleDefinitionFilter from ._models_py3 import RoleDefinitionListResult from ._models_py3 import RoleManagementPolicyApprovalRule from ._models_py3 import RoleManagementPolicyAuthenticationContextRule from ._models_py3 import RoleManagementPolicyEnablementRule from ._models_py3 import RoleManagementPolicyExpirationRule from ._models_py3 import RoleManagementPolicyNotificationRule from ._models_py3 import RoleManagementPolicyRule from ._models_py3 import RoleManagementPolicyRuleTarget from ._models_py3 import UserSet from ._models_py3 import ValidationResponse from ._models_py3 import ValidationResponseErrorInfo from ._authorization_management_client_enums import ApprovalMode from ._authorization_management_client_enums import EnablementRules from ._authorization_management_client_enums import NotificationDeliveryMechanism from ._authorization_management_client_enums import NotificationLevel from ._authorization_management_client_enums import PrincipalType from ._authorization_management_client_enums import RecipientType from ._authorization_management_client_enums import RoleManagementPolicyRuleType from ._authorization_management_client_enums import UserType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "ApprovalSettings", "ApprovalStage", "DenyAssignment", "DenyAssignmentFilter", "DenyAssignmentListResult", "DenyAssignmentPermission", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "Permission", "PermissionGetResult", "Principal", "ProviderOperation", "ProviderOperationsMetadata", "ProviderOperationsMetadataListResult", "ResourceType", "RoleAssignment", "RoleAssignmentCreateParameters", "RoleAssignmentFilter", "RoleAssignmentListResult", "RoleDefinition", "RoleDefinitionFilter", "RoleDefinitionListResult", "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule", "RoleManagementPolicyRule", "RoleManagementPolicyRuleTarget", "UserSet", "ValidationResponse", "ValidationResponseErrorInfo", "ApprovalMode", "EnablementRules", "NotificationDeliveryMechanism", "NotificationLevel", "PrincipalType", "RecipientType", "RoleManagementPolicyRuleType", "UserType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.469763
0.087994
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewHistoryDefinitionInstanceOperations, AccessReviewHistoryDefinitionInstancesOperations, AccessReviewHistoryDefinitionOperations, AccessReviewHistoryDefinitionsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, ScopeAccessReviewDefaultSettingsOperations, ScopeAccessReviewHistoryDefinitionInstanceOperations, ScopeAccessReviewHistoryDefinitionInstancesOperations, ScopeAccessReviewHistoryDefinitionOperations, ScopeAccessReviewHistoryDefinitionsOperations, ScopeAccessReviewInstanceContactedReviewersOperations, ScopeAccessReviewInstanceDecisionsOperations, ScopeAccessReviewInstanceOperations, ScopeAccessReviewInstancesOperations, ScopeAccessReviewScheduleDefinitionsOperations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_12_01_preview.operations.Operations :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations :vartype access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionsOperations :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations :vartype access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionOperations :ivar access_review_history_definition_instance: AccessReviewHistoryDefinitionInstanceOperations operations :vartype access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionInstanceOperations :ivar access_review_history_definition_instances: AccessReviewHistoryDefinitionInstancesOperations operations :vartype access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionInstancesOperations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewDefaultSettingsOperations :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations operations :vartype scope_access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionsOperations :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations operations :vartype scope_access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionOperations :ivar scope_access_review_history_definition_instance: ScopeAccessReviewHistoryDefinitionInstanceOperations operations :vartype scope_access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations :ivar scope_access_review_history_definition_instances: ScopeAccessReviewHistoryDefinitionInstancesOperations operations :vartype scope_access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations operations :vartype scope_access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewScheduleDefinitionsOperations :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations :vartype scope_access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstancesOperations :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations :vartype scope_access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceOperations :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations operations :vartype scope_access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceDecisionsOperations :ivar scope_access_review_instance_contacted_reviewers: ScopeAccessReviewInstanceContactedReviewersOperations operations :vartype scope_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceContactedReviewersOperations :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations operations :vartype scope_access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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_12_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, AccessReviewHistoryDefinitionInstanceOperations, AccessReviewHistoryDefinitionInstancesOperations, AccessReviewHistoryDefinitionOperations, AccessReviewHistoryDefinitionsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, ScopeAccessReviewDefaultSettingsOperations, ScopeAccessReviewHistoryDefinitionInstanceOperations, ScopeAccessReviewHistoryDefinitionInstancesOperations, ScopeAccessReviewHistoryDefinitionOperations, ScopeAccessReviewHistoryDefinitionsOperations, ScopeAccessReviewInstanceContactedReviewersOperations, ScopeAccessReviewInstanceDecisionsOperations, ScopeAccessReviewInstanceOperations, ScopeAccessReviewInstancesOperations, ScopeAccessReviewScheduleDefinitionsOperations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_12_01_preview.operations.Operations :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations :vartype access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionsOperations :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations :vartype access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionOperations :ivar access_review_history_definition_instance: AccessReviewHistoryDefinitionInstanceOperations operations :vartype access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionInstanceOperations :ivar access_review_history_definition_instances: AccessReviewHistoryDefinitionInstancesOperations operations :vartype access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewHistoryDefinitionInstancesOperations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewDefaultSettingsOperations :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations operations :vartype scope_access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionsOperations :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations operations :vartype scope_access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionOperations :ivar scope_access_review_history_definition_instance: ScopeAccessReviewHistoryDefinitionInstanceOperations operations :vartype scope_access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations :ivar scope_access_review_history_definition_instances: ScopeAccessReviewHistoryDefinitionInstancesOperations operations :vartype scope_access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations operations :vartype scope_access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewScheduleDefinitionsOperations :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations :vartype scope_access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstancesOperations :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations :vartype scope_access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceOperations :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations operations :vartype scope_access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceDecisionsOperations :ivar scope_access_review_instance_contacted_reviewers: ScopeAccessReviewInstanceContactedReviewersOperations operations :vartype scope_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewInstanceContactedReviewersOperations :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations operations :vartype scope_access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.operations.ScopeAccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_12_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.665845
0.063366
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.831485
0.089137
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-12-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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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_12_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-12-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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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.783864
0.089415
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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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.843348
0.086208
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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "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, 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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_12_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_12_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_12_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_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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_12_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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "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, 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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_12_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_12_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_12_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_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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.841468
0.093306
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_generate_download_uri_request( history_definition_id: str, instance_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: 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 AccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def generate_download_uri( self, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instance_operations.py
_access_review_history_definition_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_generate_download_uri_request( history_definition_id: str, instance_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: 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 AccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def generate_download_uri( self, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
0.819641
0.078184
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(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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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 ScopeAccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( 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("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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/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_12_01_preview/operations/_scope_access_review_schedule_definitions_operations.py
_scope_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(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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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 ScopeAccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( 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("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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace def stop( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
0.778733
0.078043
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_generate_download_uri_request( scope: str, history_definition_id: str, instance_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: 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 ScopeAccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def generate_download_uri( self, scope: str, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instance_operations.py
_scope_access_review_history_definition_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_generate_download_uri_request( scope: str, history_definition_id: str, instance_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"), } _url: 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 ScopeAccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def generate_download_uri( self, scope: str, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
0.825695
0.079353
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-12-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-12-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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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_12_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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_12_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-12-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-12-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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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_12_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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.824533
0.084531
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, 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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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 ScopeAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/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_12_01_preview/operations/_scope_access_review_instance_contacted_reviewers_operations.py
_scope_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(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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 ScopeAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.833833
0.076822
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( scope: str, schedule_definition_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, 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-12-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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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 ScopeAccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewInstance"]: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_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-12-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( scope=scope, schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> _models.AccessReviewInstance: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :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_12_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-12-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload def create( self, scope: str, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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( scope=scope, schedule_definition_id=schedule_definition_id, id=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": "/{scope}/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_12_01_preview/operations/_scope_access_review_instances_operations.py
_scope_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( scope: str, schedule_definition_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), } _url: 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(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, 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-12-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/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # 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 ScopeAccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewInstance"]: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_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-12-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( scope=scope, schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> _models.AccessReviewInstance: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :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_12_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-12-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload def create( self, scope: str, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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( scope=scope, schedule_definition_id=schedule_definition_id, id=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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
0.816918
0.091829
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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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.84634
0.085556
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, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 ScopeAccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, history_definition_id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, history_definition_id=history_definition_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_instances_operations.py
_scope_access_review_history_definition_instances_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, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 ScopeAccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, history_definition_id: str, **kwargs: Any ) -> Iterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, history_definition_id=history_definition_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
0.841191
0.080285
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, 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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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 ScopeAccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/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_12_01_preview/operations/_scope_access_review_instance_decisions_operations.py
_scope_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( scope: str, schedule_definition_id: str, id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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 ScopeAccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" }
0.863031
0.089933
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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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_12_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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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.861844
0.084947
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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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.812049
0.08374
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_stop_request(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_record_all_decisions_request(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_reset_decisions_request(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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 ScopeAccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @overload def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: _models.RecordAllDecisionsProperties, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.RecordAllDecisionsProperties, IO], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :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 "2021-12-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(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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, {}) record_all_decisions.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" } @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_instance_operations.py
_scope_access_review_instance_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_stop_request(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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_record_all_decisions_request(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_reset_decisions_request(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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(scope: str, schedule_definition_id: str, id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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 ScopeAccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @overload def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: _models.RecordAllDecisionsProperties, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.RecordAllDecisionsProperties, IO], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :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 "2021-12-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(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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, {}) record_all_decisions.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" } @distributed_trace def reset_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace def apply_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace def send_reminders( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" }
0.785103
0.077692
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-12-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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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_12_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-12-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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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.831759
0.086439
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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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_12_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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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 = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, "str"), "id": _SERIALIZER.url("id", id, "str"), } _url: 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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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.783988
0.085518
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(history_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 AccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, history_definition_id: str, **kwargs: Any) -> Iterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_instances_operations.py
_access_review_history_definition_instances_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(history_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 AccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, history_definition_id: str, **kwargs: Any) -> Iterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
0.837088
0.077797
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-12-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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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_12_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-12-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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, 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.867191
0.072276
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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), } _url: 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(scope: str, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 ScopeAccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions"} @distributed_trace def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definitions_operations.py
_scope_access_review_history_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_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), } _url: 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(scope: str, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 ScopeAccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions"} @distributed_trace def get_by_id(self, scope: str, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.841011
0.086093
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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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_12_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-12-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_12_01_preview.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request 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.841403
0.077518
from ._operations import Operations from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations from ._access_review_instances_operations import AccessReviewInstancesOperations from ._access_review_instance_operations import AccessReviewInstanceOperations from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations from ._scope_access_review_history_definition_instance_operations import ( ScopeAccessReviewHistoryDefinitionInstanceOperations, ) from ._scope_access_review_history_definition_instances_operations import ( ScopeAccessReviewHistoryDefinitionInstancesOperations, ) from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations from ._scope_access_review_instance_contacted_reviewers_operations import ( ScopeAccessReviewInstanceContactedReviewersOperations, ) from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, ) from ._access_review_instances_assigned_for_my_approval_operations import ( AccessReviewInstancesAssignedForMyApprovalOperations, ) from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( TenantLevelAccessReviewInstanceContactedReviewersOperations, ) from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", "AccessReviewHistoryDefinitionsOperations", "AccessReviewHistoryDefinitionOperations", "AccessReviewHistoryDefinitionInstanceOperations", "AccessReviewHistoryDefinitionInstancesOperations", "AccessReviewScheduleDefinitionsOperations", "AccessReviewInstancesOperations", "AccessReviewInstanceOperations", "AccessReviewInstanceDecisionsOperations", "AccessReviewInstanceContactedReviewersOperations", "AccessReviewDefaultSettingsOperations", "ScopeAccessReviewHistoryDefinitionsOperations", "ScopeAccessReviewHistoryDefinitionOperations", "ScopeAccessReviewHistoryDefinitionInstanceOperations", "ScopeAccessReviewHistoryDefinitionInstancesOperations", "ScopeAccessReviewScheduleDefinitionsOperations", "ScopeAccessReviewInstancesOperations", "ScopeAccessReviewInstanceOperations", "ScopeAccessReviewInstanceDecisionsOperations", "ScopeAccessReviewInstanceContactedReviewersOperations", "ScopeAccessReviewDefaultSettingsOperations", "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", "AccessReviewInstancesAssignedForMyApprovalOperations", "AccessReviewInstanceMyDecisionsOperations", "TenantLevelAccessReviewInstanceContactedReviewersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/__init__.py
__init__.py
from ._operations import Operations from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations from ._access_review_instances_operations import AccessReviewInstancesOperations from ._access_review_instance_operations import AccessReviewInstanceOperations from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations from ._scope_access_review_history_definition_instance_operations import ( ScopeAccessReviewHistoryDefinitionInstanceOperations, ) from ._scope_access_review_history_definition_instances_operations import ( ScopeAccessReviewHistoryDefinitionInstancesOperations, ) from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations from ._scope_access_review_instance_contacted_reviewers_operations import ( ScopeAccessReviewInstanceContactedReviewersOperations, ) from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, ) from ._access_review_instances_assigned_for_my_approval_operations import ( AccessReviewInstancesAssignedForMyApprovalOperations, ) from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( TenantLevelAccessReviewInstanceContactedReviewersOperations, ) from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", "AccessReviewHistoryDefinitionsOperations", "AccessReviewHistoryDefinitionOperations", "AccessReviewHistoryDefinitionInstanceOperations", "AccessReviewHistoryDefinitionInstancesOperations", "AccessReviewScheduleDefinitionsOperations", "AccessReviewInstancesOperations", "AccessReviewInstanceOperations", "AccessReviewInstanceDecisionsOperations", "AccessReviewInstanceContactedReviewersOperations", "AccessReviewDefaultSettingsOperations", "ScopeAccessReviewHistoryDefinitionsOperations", "ScopeAccessReviewHistoryDefinitionOperations", "ScopeAccessReviewHistoryDefinitionInstanceOperations", "ScopeAccessReviewHistoryDefinitionInstancesOperations", "ScopeAccessReviewScheduleDefinitionsOperations", "ScopeAccessReviewInstancesOperations", "ScopeAccessReviewInstanceOperations", "ScopeAccessReviewInstanceDecisionsOperations", "ScopeAccessReviewInstanceContactedReviewersOperations", "ScopeAccessReviewDefaultSettingsOperations", "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", "AccessReviewInstancesAssignedForMyApprovalOperations", "AccessReviewInstanceMyDecisionsOperations", "TenantLevelAccessReviewInstanceContactedReviewersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.40204
0.056835
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_create_request(history_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-12-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/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(history_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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) class AccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definition_operations.py
_access_review_history_definition_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_create_request(history_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-12-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/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(history_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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) class AccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.872171
0.083628
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, *, 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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: 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(history_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 AccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions" } @distributed_trace def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_access_review_history_definitions_operations.py
_access_review_history_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_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url: 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(history_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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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 AccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions" } @distributed_trace def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.835618
0.074366
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_create_request(scope: str, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(scope: str, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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) class ScopeAccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, scope: str, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history 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: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/operations/_scope_access_review_history_definition_operations.py
_scope_access_review_history_definition_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_create_request(scope: str, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(scope: str, history_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), "historyDefinitionId": _SERIALIZER.url("history_definition_id", history_definition_id, "str"), } _url: 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) class ScopeAccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, scope: str, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history 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: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.87982
0.062018
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(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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), } _url: 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(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-12-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/accessReviewScheduleSettings/default") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "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 ScopeAccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( scope=scope, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} @overload def put( self, scope: str, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( 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("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/{scope}/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_12_01_preview/operations/_scope_access_review_default_settings_operations.py
_scope_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(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-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str"), } _url: 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(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-12-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/accessReviewScheduleSettings/default") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "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 ScopeAccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.AuthorizationManagementClient`'s :attr:`scope_access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( scope=scope, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} @overload def put( self, scope: str, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload def put( self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def put( self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( 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("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"}
0.871078
0.079246
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( AccessReviewDefaultSettingsOperations, AccessReviewHistoryDefinitionInstanceOperations, AccessReviewHistoryDefinitionInstancesOperations, AccessReviewHistoryDefinitionOperations, AccessReviewHistoryDefinitionsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, ScopeAccessReviewDefaultSettingsOperations, ScopeAccessReviewHistoryDefinitionInstanceOperations, ScopeAccessReviewHistoryDefinitionInstancesOperations, ScopeAccessReviewHistoryDefinitionOperations, ScopeAccessReviewHistoryDefinitionsOperations, ScopeAccessReviewInstanceContactedReviewersOperations, ScopeAccessReviewInstanceDecisionsOperations, ScopeAccessReviewInstanceOperations, ScopeAccessReviewInstancesOperations, ScopeAccessReviewScheduleDefinitionsOperations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.Operations :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations :vartype access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionsOperations :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations :vartype access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionOperations :ivar access_review_history_definition_instance: AccessReviewHistoryDefinitionInstanceOperations operations :vartype access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstanceOperations :ivar access_review_history_definition_instances: AccessReviewHistoryDefinitionInstancesOperations operations :vartype access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstancesOperations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewDefaultSettingsOperations :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations operations :vartype scope_access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionsOperations :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations operations :vartype scope_access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionOperations :ivar scope_access_review_history_definition_instance: ScopeAccessReviewHistoryDefinitionInstanceOperations operations :vartype scope_access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations :ivar scope_access_review_history_definition_instances: ScopeAccessReviewHistoryDefinitionInstancesOperations operations :vartype scope_access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations operations :vartype scope_access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewScheduleDefinitionsOperations :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations :vartype scope_access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstancesOperations :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations :vartype scope_access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceOperations :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations operations :vartype scope_access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceDecisionsOperations :ivar scope_access_review_instance_contacted_reviewers: ScopeAccessReviewInstanceContactedReviewersOperations operations :vartype scope_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceContactedReviewersOperations :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations operations :vartype scope_access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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_12_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, AccessReviewHistoryDefinitionInstanceOperations, AccessReviewHistoryDefinitionInstancesOperations, AccessReviewHistoryDefinitionOperations, AccessReviewHistoryDefinitionsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, ScopeAccessReviewDefaultSettingsOperations, ScopeAccessReviewHistoryDefinitionInstanceOperations, ScopeAccessReviewHistoryDefinitionInstancesOperations, ScopeAccessReviewHistoryDefinitionOperations, ScopeAccessReviewHistoryDefinitionsOperations, ScopeAccessReviewInstanceContactedReviewersOperations, ScopeAccessReviewInstanceDecisionsOperations, ScopeAccessReviewInstanceOperations, ScopeAccessReviewInstancesOperations, ScopeAccessReviewScheduleDefinitionsOperations, TenantLevelAccessReviewInstanceContactedReviewersOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Access reviews service provides the workflow for running access reviews on different kind of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.Operations :ivar access_review_history_definitions: AccessReviewHistoryDefinitionsOperations operations :vartype access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionsOperations :ivar access_review_history_definition: AccessReviewHistoryDefinitionOperations operations :vartype access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionOperations :ivar access_review_history_definition_instance: AccessReviewHistoryDefinitionInstanceOperations operations :vartype access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstanceOperations :ivar access_review_history_definition_instances: AccessReviewHistoryDefinitionInstancesOperations operations :vartype access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstancesOperations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations :vartype access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations :vartype access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_instance_contacted_reviewers: AccessReviewInstanceContactedReviewersOperations operations :vartype access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations :vartype access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewDefaultSettingsOperations :ivar scope_access_review_history_definitions: ScopeAccessReviewHistoryDefinitionsOperations operations :vartype scope_access_review_history_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionsOperations :ivar scope_access_review_history_definition: ScopeAccessReviewHistoryDefinitionOperations operations :vartype scope_access_review_history_definition: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionOperations :ivar scope_access_review_history_definition_instance: ScopeAccessReviewHistoryDefinitionInstanceOperations operations :vartype scope_access_review_history_definition_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations :ivar scope_access_review_history_definition_instances: ScopeAccessReviewHistoryDefinitionInstancesOperations operations :vartype scope_access_review_history_definition_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations :ivar scope_access_review_schedule_definitions: ScopeAccessReviewScheduleDefinitionsOperations operations :vartype scope_access_review_schedule_definitions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewScheduleDefinitionsOperations :ivar scope_access_review_instances: ScopeAccessReviewInstancesOperations operations :vartype scope_access_review_instances: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstancesOperations :ivar scope_access_review_instance: ScopeAccessReviewInstanceOperations operations :vartype scope_access_review_instance: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceOperations :ivar scope_access_review_instance_decisions: ScopeAccessReviewInstanceDecisionsOperations operations :vartype scope_access_review_instance_decisions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceDecisionsOperations :ivar scope_access_review_instance_contacted_reviewers: ScopeAccessReviewInstanceContactedReviewersOperations operations :vartype scope_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceContactedReviewersOperations :ivar scope_access_review_default_settings: ScopeAccessReviewDefaultSettingsOperations operations :vartype scope_access_review_default_settings: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewDefaultSettingsOperations :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations :ivar tenant_level_access_review_instance_contacted_reviewers: TenantLevelAccessReviewInstanceContactedReviewersOperations operations :vartype tenant_level_access_review_instance_contacted_reviewers: azure.mgmt.authorization.v2021_12_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.operations = Operations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definitions = AccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition = AccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instance = AccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_history_definition_instances = AccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instances = AccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance = AccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_default_settings = AccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definitions = ScopeAccessReviewHistoryDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition = ScopeAccessReviewHistoryDefinitionOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instance = ScopeAccessReviewHistoryDefinitionInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_history_definition_instances = ScopeAccessReviewHistoryDefinitionInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_schedule_definitions = ScopeAccessReviewScheduleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instances = ScopeAccessReviewInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance = ScopeAccessReviewInstanceOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_decisions = ScopeAccessReviewInstanceDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_instance_contacted_reviewers = ScopeAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.scope_access_review_default_settings = ScopeAccessReviewDefaultSettingsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_schedule_definitions_assigned_for_my_approval = ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) self.tenant_level_access_review_instance_contacted_reviewers = ( TenantLevelAccessReviewInstanceContactedReviewersOperations( self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" ) ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.698227
0.065187
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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-12-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2021-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.83602
0.091463
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions" } @distributed_trace_async async def get_by_id(self, schedule_definition_id: str, **kwargs: Any) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update_by_id( self, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
0.878978
0.083329
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.856977
0.097691
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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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_12_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_12_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_12_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_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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_12_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_12_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_12_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_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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.891102
0.097048
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_history_definition_instance_operations import build_generate_download_uri_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def generate_download_uri( self, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instance_operations.py
_access_review_history_definition_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_history_definition_instance_operations import build_generate_download_uri_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def generate_download_uri( self, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( history_definition_id=history_definition_id, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
0.865948
0.092934
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._scope_access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( 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("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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/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_12_01_preview/aio/operations/_scope_access_review_schedule_definitions_operations.py
_scope_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._scope_access_review_schedule_definitions_operations import ( build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewScheduleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_schedule_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewScheduleDefinition"]: """Get access review schedule definitions. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( 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("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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Get single access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Delete access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @overload async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: _models.AccessReviewScheduleDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update_by_id( self, scope: str, schedule_definition_id: str, properties: Union[_models.AccessReviewScheduleDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewScheduleDefinition: """Create or Update access review schedule definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param properties: Access review schedule definition properties. Is either a AccessReviewScheduleDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewScheduleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleDefinitionProperties") request = build_create_or_update_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewScheduleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}" } @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, **kwargs: Any ) -> None: """Stop access review definition. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop" }
0.883638
0.097176
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_access_review_history_definition_instance_operations import ( build_generate_download_uri_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def generate_download_uri( self, scope: str, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instance_operations.py
_scope_access_review_history_definition_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._scope_access_review_history_definition_instance_operations import ( build_generate_download_uri_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def generate_download_uri( self, scope: str, history_definition_id: str, instance_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryInstance: """Generates a uri which can be used to retrieve review history data. This URI has a TTL of 1 day and can be retrieved by fetching the accessReviewHistoryDefinition object. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param instance_id: The id of the access review history definition instance to generate a URI for. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryInstance] = kwargs.pop("cls", None) request = build_generate_download_uri_request( scope=scope, history_definition_id=history_definition_id, instance_id=instance_id, api_version=api_version, template_url=self.generate_download_uri.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized generate_download_uri.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}/instances/{instanceId}/generateDownloadUri" }
0.870625
0.093306
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_my_decisions_operations import ( build_get_by_id_request, build_list_request, build_patch_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceMyDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" } @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" } @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: _models.AccessReviewDecisionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_my_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" } @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, id: str, decision_id: str, **kwargs: Any ) -> _models.AccessReviewDecision: """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) request = build_get_by_id_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" } @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: _models.AccessReviewDecisionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def patch( self, schedule_definition_id: str, id: str, decision_id: str, properties: Union[_models.AccessReviewDecisionProperties, IO], **kwargs: Any ) -> _models.AccessReviewDecision: """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param decision_id: The id of the decision record. Required. :type decision_id: str :param properties: Access review decision properties to patch. Is either a AccessReviewDecisionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDecision] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewDecisionProperties") request = build_patch_request( schedule_definition_id=schedule_definition_id, id=id, decision_id=decision_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDecision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized patch.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}" }
0.892182
0.086362
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._scope_access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/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_12_01_preview/aio/operations/_scope_access_review_instance_contacted_reviewers_operations.py
_scope_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._scope_access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.862308
0.09709
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._scope_access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewInstance"]: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_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-12-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( scope=scope, schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> _models.AccessReviewInstance: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload async def create( self, scope: str, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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( scope=scope, schedule_definition_id=schedule_definition_id, id=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": "/{scope}/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_12_01_preview/aio/operations/_scope_access_review_instances_operations.py
_scope_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._scope_access_review_instances_operations import ( build_create_request, build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewInstance"]: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_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-12-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( scope=scope, schedule_definition_id=schedule_definition_id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances" } @distributed_trace_async async def get_by_id( self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> _models.AccessReviewInstance: """Get access review instances. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewInstance] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" } @overload async def create( self, scope: str, schedule_definition_id: str, id: str, properties: _models.AccessReviewInstanceProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :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_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.AccessReviewInstanceProperties, IO], **kwargs: Any ) -> _models.AccessReviewInstance: """Update access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Access review instance properties. Is either a AccessReviewInstanceProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.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( scope=scope, schedule_definition_id=schedule_definition_id, id=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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}" }
0.873674
0.089773
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_schedule_definitions_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewScheduleDefinition"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewScheduleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewScheduleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"}
0.881532
0.101902
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._scope_access_review_history_definition_instances_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, history_definition_id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, history_definition_id=history_definition_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_instances_operations.py
_scope_access_review_history_definition_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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._scope_access_review_history_definition_instances_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, history_definition_id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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, history_definition_id=history_definition_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
0.872714
0.094177
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._scope_access_review_instance_decisions_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/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_12_01_preview/aio/operations/_scope_access_review_instance_decisions_operations.py
_scope_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._scope_access_review_instance_decisions_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstanceDecisionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, scope: str, schedule_definition_id: str, id: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewDecision"]: """Get access review instance decisions. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewDecision or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions" }
0.874023
0.105902
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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance_decisions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_01_preview.models.AccessReviewDecision] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDecisionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, 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.883343
0.103703
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantLevelAccessReviewInstanceContactedReviewersOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`tenant_level_access_review_instance_contacted_reviewers` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( self, schedule_definition_id: str, id: str, **kwargs: Any ) -> AsyncIterable["_models.AccessReviewContactedReviewer"]: """Get access review instance contacted reviewers. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewContactedReviewer or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewContactedReviewerListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers" }
0.863651
0.095181
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_access_review_instance_operations import ( build_apply_decisions_request, build_record_all_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @overload async def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: _models.RecordAllDecisionsProperties, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.RecordAllDecisionsProperties, IO], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :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 "2021-12-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(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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, {}) record_all_decisions.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" } @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_instance_operations.py
_scope_access_review_instance_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_access_review_instance_operations import ( build_apply_decisions_request, build_record_all_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @overload async def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: _models.RecordAllDecisionsProperties, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def record_all_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, properties: Union[_models.RecordAllDecisionsProperties, IO], **kwargs: Any ) -> None: """An action to approve/deny all decisions for a review with certain filters. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :param properties: Record all decisions payload. Is either a RecordAllDecisionsProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :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 "2021-12-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(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "RecordAllDecisionsProperties") request = build_record_all_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.record_all_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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, {}) record_all_decisions.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/recordAllDecisions" } @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements self, scope: str, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param scope: The scope of the resource. Required. :type scope: str :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( scope=scope, schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = 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": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" }
0.91277
0.082217
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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instances_assigned_for_my_approval` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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_12_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-12-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_12_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-12-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.89077
0.091707
from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_instance_operations import ( build_accept_recommendations_request, build_apply_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewInstanceOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) reset_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) apply_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) send_reminders.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" } @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) accept_recommendations.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_instance` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_stop_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) stop.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop" } @distributed_trace_async async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_reset_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.reset_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) reset_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions" } @distributed_trace_async async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_apply_decisions_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.apply_decisions.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) apply_decisions.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions" } @distributed_trace_async async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_send_reminders_request( schedule_definition_id=schedule_definition_id, id=id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.send_reminders.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) send_reminders.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders" } @distributed_trace_async async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, **kwargs: Any ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. Required. :type schedule_definition_id: str :param id: The id of the access review instance. Required. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_accept_recommendations_request( schedule_definition_id=schedule_definition_id, id=id, api_version=api_version, template_url=self.accept_recommendations.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) accept_recommendations.metadata = { "url": "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations" }
0.902762
0.097777
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_history_definition_instances_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, history_definition_id: str, **kwargs: Any) -> AsyncIterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_instances_operations.py
_access_review_history_definition_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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_history_definition_instances_operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, history_definition_id: str, **kwargs: Any) -> AsyncIterable["_models.AccessReviewHistoryInstance"]: """Get access review history definition instances by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_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("AccessReviewHistoryDefinitionInstanceListResult", 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/accessReviewHistoryDefinitions/{historyDefinitionId}/instances" }
0.876397
0.091829
from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._access_review_default_settings_operations import build_get_request, build_put_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" } @overload async def put( self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" } @overload async def put( self, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.put.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default" }
0.90363
0.071494
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_access_review_history_definitions_operations import ( build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions"} @distributed_trace_async async def get_by_id( self, scope: str, history_definition_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definitions_operations.py
_scope_access_review_history_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._scope_access_review_history_definitions_operations import ( build_get_by_id_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param scope: The scope of the resource. Required. :type scope: str :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions"} @distributed_trace_async async def get_by_id( self, scope: str, history_definition_id: str, **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.8946
0.08617
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/providers/Microsoft.Authorization/operations"}
0.870487
0.090937
from ._operations import Operations from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations from ._access_review_instances_operations import AccessReviewInstancesOperations from ._access_review_instance_operations import AccessReviewInstanceOperations from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations from ._scope_access_review_history_definition_instance_operations import ( ScopeAccessReviewHistoryDefinitionInstanceOperations, ) from ._scope_access_review_history_definition_instances_operations import ( ScopeAccessReviewHistoryDefinitionInstancesOperations, ) from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations from ._scope_access_review_instance_contacted_reviewers_operations import ( ScopeAccessReviewInstanceContactedReviewersOperations, ) from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, ) from ._access_review_instances_assigned_for_my_approval_operations import ( AccessReviewInstancesAssignedForMyApprovalOperations, ) from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( TenantLevelAccessReviewInstanceContactedReviewersOperations, ) from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", "AccessReviewHistoryDefinitionsOperations", "AccessReviewHistoryDefinitionOperations", "AccessReviewHistoryDefinitionInstanceOperations", "AccessReviewHistoryDefinitionInstancesOperations", "AccessReviewScheduleDefinitionsOperations", "AccessReviewInstancesOperations", "AccessReviewInstanceOperations", "AccessReviewInstanceDecisionsOperations", "AccessReviewInstanceContactedReviewersOperations", "AccessReviewDefaultSettingsOperations", "ScopeAccessReviewHistoryDefinitionsOperations", "ScopeAccessReviewHistoryDefinitionOperations", "ScopeAccessReviewHistoryDefinitionInstanceOperations", "ScopeAccessReviewHistoryDefinitionInstancesOperations", "ScopeAccessReviewScheduleDefinitionsOperations", "ScopeAccessReviewInstancesOperations", "ScopeAccessReviewInstanceOperations", "ScopeAccessReviewInstanceDecisionsOperations", "ScopeAccessReviewInstanceContactedReviewersOperations", "ScopeAccessReviewDefaultSettingsOperations", "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", "AccessReviewInstancesAssignedForMyApprovalOperations", "AccessReviewInstanceMyDecisionsOperations", "TenantLevelAccessReviewInstanceContactedReviewersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/__init__.py
__init__.py
from ._operations import Operations from ._access_review_history_definitions_operations import AccessReviewHistoryDefinitionsOperations from ._access_review_history_definition_operations import AccessReviewHistoryDefinitionOperations from ._access_review_history_definition_instance_operations import AccessReviewHistoryDefinitionInstanceOperations from ._access_review_history_definition_instances_operations import AccessReviewHistoryDefinitionInstancesOperations from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations from ._access_review_instances_operations import AccessReviewInstancesOperations from ._access_review_instance_operations import AccessReviewInstanceOperations from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations from ._scope_access_review_history_definitions_operations import ScopeAccessReviewHistoryDefinitionsOperations from ._scope_access_review_history_definition_operations import ScopeAccessReviewHistoryDefinitionOperations from ._scope_access_review_history_definition_instance_operations import ( ScopeAccessReviewHistoryDefinitionInstanceOperations, ) from ._scope_access_review_history_definition_instances_operations import ( ScopeAccessReviewHistoryDefinitionInstancesOperations, ) from ._scope_access_review_schedule_definitions_operations import ScopeAccessReviewScheduleDefinitionsOperations from ._scope_access_review_instances_operations import ScopeAccessReviewInstancesOperations from ._scope_access_review_instance_operations import ScopeAccessReviewInstanceOperations from ._scope_access_review_instance_decisions_operations import ScopeAccessReviewInstanceDecisionsOperations from ._scope_access_review_instance_contacted_reviewers_operations import ( ScopeAccessReviewInstanceContactedReviewersOperations, ) from ._scope_access_review_default_settings_operations import ScopeAccessReviewDefaultSettingsOperations from ._access_review_schedule_definitions_assigned_for_my_approval_operations import ( AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, ) from ._access_review_instances_assigned_for_my_approval_operations import ( AccessReviewInstancesAssignedForMyApprovalOperations, ) from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations from ._tenant_level_access_review_instance_contacted_reviewers_operations import ( TenantLevelAccessReviewInstanceContactedReviewersOperations, ) from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "Operations", "AccessReviewHistoryDefinitionsOperations", "AccessReviewHistoryDefinitionOperations", "AccessReviewHistoryDefinitionInstanceOperations", "AccessReviewHistoryDefinitionInstancesOperations", "AccessReviewScheduleDefinitionsOperations", "AccessReviewInstancesOperations", "AccessReviewInstanceOperations", "AccessReviewInstanceDecisionsOperations", "AccessReviewInstanceContactedReviewersOperations", "AccessReviewDefaultSettingsOperations", "ScopeAccessReviewHistoryDefinitionsOperations", "ScopeAccessReviewHistoryDefinitionOperations", "ScopeAccessReviewHistoryDefinitionInstanceOperations", "ScopeAccessReviewHistoryDefinitionInstancesOperations", "ScopeAccessReviewScheduleDefinitionsOperations", "ScopeAccessReviewInstancesOperations", "ScopeAccessReviewInstanceOperations", "ScopeAccessReviewInstanceDecisionsOperations", "ScopeAccessReviewInstanceContactedReviewersOperations", "ScopeAccessReviewDefaultSettingsOperations", "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", "AccessReviewInstancesAssignedForMyApprovalOperations", "AccessReviewInstanceMyDecisionsOperations", "TenantLevelAccessReviewInstanceContactedReviewersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.40204
0.056835
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_history_definition_operations import build_create_request, build_delete_by_id_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await 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/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definition_operations.py
_access_review_history_definition_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_history_definition_operations import build_create_request, build_delete_by_id_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await 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/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.90124
0.100392
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_history_definitions_operations import build_get_by_id_request, build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions" } @distributed_trace_async async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_access_review_history_definitions_operations.py
_access_review_history_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._access_review_history_definitions_operations import build_get_by_id_request, build_list_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AccessReviewHistoryDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`access_review_history_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") 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.AccessReviewHistoryDefinition"]: """Lists the accessReviewHistoryDefinitions available from this provider, definition instances are only available for 30 days after creation. :param filter: The filter to apply on the operation. Only standard filters on definition name and created date are supported. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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("AccessReviewHistoryDefinitionListResult", 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/accessReviewHistoryDefinitions" } @distributed_trace_async async def get_by_id(self, history_definition_id: str, **kwargs: Any) -> _models.AccessReviewHistoryDefinition: """Get access review history definition by definition Id. :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewHistoryDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( history_definition_id=history_definition_id, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.883261
0.100834
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_access_review_history_definition_operations import ( build_create_request, build_delete_by_id_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, scope: str, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history 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: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await 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": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_01_preview/aio/operations/_scope_access_review_history_definition_operations.py
_scope_access_review_history_definition_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_access_review_history_definition_operations import ( build_create_request, build_delete_by_id_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewHistoryDefinitionOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_history_definition` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, scope: str, history_definition_id: str, properties: _models.AccessReviewHistoryDefinitionProperties, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, history_definition_id: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history 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: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, history_definition_id: str, properties: Union[_models.AccessReviewHistoryDefinitionProperties, IO], **kwargs: Any ) -> _models.AccessReviewHistoryDefinition: """Create a scheduled or one-time Access Review History Definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :param properties: Access review history definition properties. Is either a AccessReviewHistoryDefinitionProperties type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionProperties or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewHistoryDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewHistoryDefinition] = 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, "AccessReviewHistoryDefinitionProperties") request = build_create_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewHistoryDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" } @distributed_trace_async async def delete_by_id( # pylint: disable=inconsistent-return-statements self, scope: str, history_definition_id: str, **kwargs: Any ) -> None: """Delete an access review history definition. :param scope: The scope of the resource. Required. :type scope: str :param history_definition_id: The id of the access review history definition. Required. :type history_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_by_id_request( scope=scope, history_definition_id=history_definition_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await 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": "/{scope}/providers/Microsoft.Authorization/accessReviewHistoryDefinitions/{historyDefinitionId}" }
0.91463
0.09899
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_access_review_default_settings_operations import build_get_request, build_put_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( scope=scope, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} @overload async def put( self, scope: str, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( 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("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/{scope}/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_12_01_preview/aio/operations/_scope_access_review_default_settings_operations.py
_scope_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._scope_access_review_default_settings_operations import build_get_request, build_put_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScopeAccessReviewDefaultSettingsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2021_12_01_preview.aio.AuthorizationManagementClient`'s :attr:`scope_access_review_default_settings` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, **kwargs: Any) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) request = build_get_request( scope=scope, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} @overload async def put( self, scope: str, properties: _models.AccessReviewScheduleSettings, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def put( self, scope: str, properties: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Required. :type properties: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def put( self, scope: str, properties: Union[_models.AccessReviewScheduleSettings, IO], **kwargs: Any ) -> _models.AccessReviewDefaultSettings: """Get access review default settings for the subscription. :param scope: The scope of the resource. Required. :type scope: str :param properties: Access review schedule settings. Is either a AccessReviewScheduleSettings type or a IO type. Required. :type properties: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleSettings or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDefaultSettings :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AccessReviewDefaultSettings] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(properties, (IOBase, bytes)): _content = properties else: _json = self._serialize.body(properties, "AccessReviewScheduleSettings") request = build_put_request( 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("AccessReviewDefaultSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized put.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"}
0.915766
0.084153
import datetime from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class AccessReviewContactedReviewer(_serialization.Model): """Access Review Contacted Reviewer. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review reviewer id. :vartype id: str :ivar name: The access review reviewer id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar user_display_name: The display name of the reviewer. :vartype user_display_name: str :ivar user_principal_name: The user principal name of the reviewer. :vartype user_principal_name: str :ivar created_date_time: Date Time when the reviewer was contacted. :vartype created_date_time: ~datetime.datetime """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "user_display_name": {"readonly": True}, "user_principal_name": {"readonly": True}, "created_date_time": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "user_display_name": {"key": "properties.userDisplayName", "type": "str"}, "user_principal_name": {"key": "properties.userPrincipalName", "type": "str"}, "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.user_display_name = None self.user_principal_name = None self.created_date_time = None class AccessReviewContactedReviewerListResult(_serialization.Model): """List of access review contacted reviewers. :ivar value: Access Review Contacted Reviewer. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewContactedReviewer]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewContactedReviewer"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Contacted Reviewer. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review decision id. :vartype id: str :ivar name: The access review decision name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar insights: This is the collection of insights for this decision item. :vartype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :ivar membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :vartype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :ivar principal_id_properties_applied_by_principal_id: The identity id. :vartype principal_id_properties_applied_by_principal_id: str :ivar principal_type_properties_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_applied_by_principal_name: The identity display name. :vartype principal_name_properties_applied_by_principal_name: str :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_applied_by_user_principal_name: str :ivar principal_id_properties_reviewed_by_principal_id: The identity id. :vartype principal_id_properties_reviewed_by_principal_id: str :ivar principal_type_properties_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. :vartype principal_name_properties_reviewed_by_principal_name: str :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_reviewed_by_user_principal_name: str :ivar type_properties_resource_type: The type of resource. "azureRole" :vartype type_properties_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType :ivar id_properties_resource_id: The id of resource associated with a decision record. :vartype id_properties_resource_id: str :ivar display_name_properties_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_properties_resource_display_name: str :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_properties_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id_properties_principal_id: The id of principal whose access was reviewed. :vartype id_properties_principal_id: str :ivar display_name_properties_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_properties_principal_display_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_properties_applied_by_principal_id": {"readonly": True}, "principal_type_properties_applied_by_principal_type": {"readonly": True}, "principal_name_properties_applied_by_principal_name": {"readonly": True}, "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, "id_properties_resource_id": {"readonly": True}, "display_name_properties_resource_display_name": {"readonly": True}, "id_properties_principal_id": {"readonly": True}, "display_name_properties_principal_display_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "recommendation": {"key": "properties.recommendation", "type": "str"}, "decision": {"key": "properties.decision", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "properties.applyResult", "type": "str"}, "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, "insights": {"key": "properties.insights", "type": "[AccessReviewDecisionInsight]"}, "membership_types": {"key": "properties.principalResourceMembership.membershipTypes", "type": "[str]"}, "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, "principal_type_properties_applied_by_principal_type": { "key": "properties.appliedBy.principalType", "type": "str", }, "principal_name_properties_applied_by_principal_name": { "key": "properties.appliedBy.principalName", "type": "str", }, "user_principal_name_properties_applied_by_user_principal_name": { "key": "properties.appliedBy.userPrincipalName", "type": "str", }, "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, "principal_type_properties_reviewed_by_principal_type": { "key": "properties.reviewedBy.principalType", "type": "str", }, "principal_name_properties_reviewed_by_principal_name": { "key": "properties.reviewedBy.principalName", "type": "str", }, "user_principal_name_properties_reviewed_by_user_principal_name": { "key": "properties.reviewedBy.userPrincipalName", "type": "str", }, "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, membership_types: Optional[ List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] ] = None, type_properties_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str :keyword insights: This is the collection of insights for this decision item. :paramtype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :keyword membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :paramtype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :keyword type_properties_resource_type: The type of resource. "azureRole" :paramtype type_properties_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.insights = insights self.membership_types = membership_types self.principal_id_properties_applied_by_principal_id = None self.principal_type_properties_applied_by_principal_type = None self.principal_name_properties_applied_by_principal_name = None self.user_principal_name_properties_applied_by_user_principal_name = None self.principal_id_properties_reviewed_by_principal_id = None self.principal_type_properties_reviewed_by_principal_type = None self.principal_name_properties_reviewed_by_principal_name = None self.user_principal_name_properties_reviewed_by_user_principal_name = None self.type_properties_resource_type = type_properties_resource_type self.id_properties_resource_id = None self.display_name_properties_resource_display_name = None self.type_properties_principal_type: Optional[str] = None self.id_properties_principal_id = None self.display_name_properties_principal_display_name = None class AccessReviewDecisionIdentity(_serialization.Model): """Target of the decision. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, } _subtype_map = { "type": { "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", "user": "AccessReviewDecisionUserIdentity", } } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.id = None self.display_name = None class AccessReviewDecisionInsight(_serialization.Model): """Access Review Decision Insight. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review insight id. :vartype id: str :ivar name: The access review insight name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar type_properties_type: The type of insight. "userSignInInsight" :vartype type_properties_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType :ivar insight_created_date_time: Date Time when the insight was created. :vartype insight_created_date_time: any """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "insight_created_date_time": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "type_properties_type": {"key": "properties.type", "type": "str"}, "insight_created_date_time": {"key": "properties.insightCreatedDateTime", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.type_properties_type: Optional[str] = None self.insight_created_date_time = None class AccessReviewDecisionInsightProperties(_serialization.Model): """Details of the Insight. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AccessReviewDecisionUserSignInInsightProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of insight. Required. "userSignInInsight" :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType :ivar insight_created_date_time: Date Time when the insight was created. :vartype insight_created_date_time: any """ _validation = { "type": {"required": True}, "insight_created_date_time": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, } _subtype_map = {"type": {"userSignInInsight": "AccessReviewDecisionUserSignInInsightProperties"}} def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.insight_created_date_time = None class AccessReviewDecisionListResult(_serialization.Model): """List of access review decisions. :ivar value: Access Review Decision list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewDecision]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewDecision"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Decision list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Approval Step. Variables are only populated by the server, and will be ignored when sending a request. :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar insights: This is the collection of insights for this decision item. :vartype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :ivar membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :vartype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :ivar principal_id_applied_by_principal_id: The identity id. :vartype principal_id_applied_by_principal_id: str :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_applied_by_principal_name: The identity display name. :vartype principal_name_applied_by_principal_name: str :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_applied_by_user_principal_name: str :ivar principal_id_reviewed_by_principal_id: The identity id. :vartype principal_id_reviewed_by_principal_id: str :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_reviewed_by_principal_name: The identity display name. :vartype principal_name_reviewed_by_principal_name: str :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_reviewed_by_user_principal_name: str :ivar type_resource_type: The type of resource. "azureRole" :vartype type_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType :ivar id_resource_id: The id of resource associated with a decision record. :vartype id_resource_id: str :ivar display_name_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_resource_display_name: str :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id_principal_id: The id of principal whose access was reviewed. :vartype id_principal_id: str :ivar display_name_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_principal_display_name: str """ _validation = { "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_applied_by_principal_id": {"readonly": True}, "principal_type_applied_by_principal_type": {"readonly": True}, "principal_name_applied_by_principal_name": {"readonly": True}, "user_principal_name_applied_by_user_principal_name": {"readonly": True}, "principal_id_reviewed_by_principal_id": {"readonly": True}, "principal_type_reviewed_by_principal_type": {"readonly": True}, "principal_name_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, "id_resource_id": {"readonly": True}, "display_name_resource_display_name": {"readonly": True}, "id_principal_id": {"readonly": True}, "display_name_principal_display_name": {"readonly": True}, } _attribute_map = { "recommendation": {"key": "recommendation", "type": "str"}, "decision": {"key": "decision", "type": "str"}, "justification": {"key": "justification", "type": "str"}, "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "applyResult", "type": "str"}, "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, "insights": {"key": "insights", "type": "[AccessReviewDecisionInsight]"}, "membership_types": {"key": "principalResourceMembership.membershipTypes", "type": "[str]"}, "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, "type_resource_type": {"key": "resource.type", "type": "str"}, "id_resource_id": {"key": "resource.id", "type": "str"}, "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, "type_principal_type": {"key": "principal.type", "type": "str"}, "id_principal_id": {"key": "principal.id", "type": "str"}, "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, membership_types: Optional[ List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] ] = None, type_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str :keyword insights: This is the collection of insights for this decision item. :paramtype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :keyword membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :paramtype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :keyword type_resource_type: The type of resource. "azureRole" :paramtype type_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType """ super().__init__(**kwargs) self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.insights = insights self.membership_types = membership_types self.principal_id_applied_by_principal_id = None self.principal_type_applied_by_principal_type = None self.principal_name_applied_by_principal_name = None self.user_principal_name_applied_by_user_principal_name = None self.principal_id_reviewed_by_principal_id = None self.principal_type_reviewed_by_principal_type = None self.principal_name_reviewed_by_principal_name = None self.user_principal_name_reviewed_by_user_principal_name = None self.type_resource_type = type_resource_type self.id_resource_id = None self.display_name_resource_display_name = None self.type_principal_type: Optional[str] = None self.id_principal_id = None self.display_name_principal_display_name = None class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): """Service Principal Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar app_id: The appId for the service principal entity being reviewed. :vartype app_id: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "app_id": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "app_id": {"key": "appId", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "servicePrincipal" self.app_id = None class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): """User Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar user_principal_name: The user principal name of the user whose access was reviewed. :vartype user_principal_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "user_principal_name": {"key": "userPrincipalName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "user" self.user_principal_name = None class AccessReviewDecisionUserSignInInsightProperties(AccessReviewDecisionInsightProperties): """User Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of insight. Required. "userSignInInsight" :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType :ivar insight_created_date_time: Date Time when the insight was created. :vartype insight_created_date_time: any :ivar last_sign_in_date_time: Date Time when the user signed into the tenant. :vartype last_sign_in_date_time: any """ _validation = { "type": {"required": True}, "insight_created_date_time": {"readonly": True}, "last_sign_in_date_time": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, "last_sign_in_date_time": {"key": "lastSignInDateTime", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "userSignInInsight" self.last_sign_in_date_time = None class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Default Settings. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review default settings id. This is only going to be default. :vartype id: str :ivar name: The access review default settings name. This is always going to be Access Review Default Settings. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "properties.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "properties.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_recurrence_range_type = type_properties_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type self.interval = interval class AccessReviewHistoryDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review History Definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review history definition id. :vartype id: str :ivar name: The access review history definition unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the history definition. :vartype display_name: str :ivar review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :vartype review_history_period_start_date_time: ~datetime.datetime :ivar review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :vartype review_history_period_end_date_time: ~datetime.datetime :ivar decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :vartype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :ivar status: This read-only field specifies the of the requested review history data. This is either requested, in-progress, done or error. Known values are: "Requested", "InProgress", "Done", and "Error". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus :ivar created_date_time: Date time when history definition was created. :vartype created_date_time: ~datetime.datetime :ivar scopes: A collection of scopes used when selecting review history data. :vartype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :ivar instances: Set of access review history instances for this history definition. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :ivar type_properties_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "review_history_period_start_date_time": {"readonly": True}, "review_history_period_end_date_time": {"readonly": True}, "status": {"readonly": True}, "created_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "review_history_period_start_date_time": { "key": "properties.reviewHistoryPeriodStartDateTime", "type": "iso-8601", }, "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, "decisions": {"key": "properties.decisions", "type": "[str]"}, "status": {"key": "properties.status", "type": "str"}, "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, "scopes": {"key": "properties.scopes", "type": "[AccessReviewScope]"}, "instances": {"key": "properties.instances", "type": "[AccessReviewHistoryInstance]"}, "type_properties_settings_range_type": {"key": "properties.settings.range.type", "type": "str"}, "number_of_occurrences": {"key": "properties.settings.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.settings.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.settings.range.endDate", "type": "iso-8601"}, "type_properties_settings_pattern_type": {"key": "properties.settings.pattern.type", "type": "str"}, "interval": {"key": "properties.settings.pattern.interval", "type": "int"}, "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, "principal_type": {"key": "properties.createdBy.principalType", "type": "str"}, "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, scopes: Optional[List["_models.AccessReviewScope"]] = None, instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, type_properties_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the history definition. :paramtype display_name: str :keyword decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :paramtype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :keyword scopes: A collection of scopes used when selecting review history data. :paramtype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :keyword instances: Set of access review history instances for this history definition. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :keyword type_properties_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.review_history_period_start_date_time = None self.review_history_period_end_date_time = None self.decisions = decisions self.status = None self.created_date_time = None self.scopes = scopes self.instances = instances self.type_properties_settings_range_type = type_properties_settings_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_settings_pattern_type = type_properties_settings_pattern_type self.interval = interval self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewHistoryDefinitionInstanceListResult(_serialization.Model): """List of Access Review History Instances. :ivar value: Access Review History Definition's Instance list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewHistoryInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewHistoryInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review History Definition's Instance list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewHistoryDefinitionListResult(_serialization.Model): """List of Access Review History Definitions. :ivar value: Access Review History Definition list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewHistoryDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewHistoryDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review History Definition list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewHistoryDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review History Instances. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the history definition. :vartype display_name: str :ivar review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :vartype review_history_period_start_date_time: ~datetime.datetime :ivar review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :vartype review_history_period_end_date_time: ~datetime.datetime :ivar decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :vartype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :ivar status: This read-only field specifies the of the requested review history data. This is either requested, in-progress, done or error. Known values are: "Requested", "InProgress", "Done", and "Error". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus :ivar created_date_time: Date time when history definition was created. :vartype created_date_time: ~datetime.datetime :ivar scopes: A collection of scopes used when selecting review history data. :vartype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :ivar instances: Set of access review history instances for this history definition. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :ivar type_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "review_history_period_start_date_time": {"readonly": True}, "review_history_period_end_date_time": {"readonly": True}, "status": {"readonly": True}, "created_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "review_history_period_start_date_time": {"key": "reviewHistoryPeriodStartDateTime", "type": "iso-8601"}, "review_history_period_end_date_time": {"key": "reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, "decisions": {"key": "decisions", "type": "[str]"}, "status": {"key": "status", "type": "str"}, "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, "scopes": {"key": "scopes", "type": "[AccessReviewScope]"}, "instances": {"key": "instances", "type": "[AccessReviewHistoryInstance]"}, "type_settings_range_type": {"key": "settings.range.type", "type": "str"}, "number_of_occurrences": {"key": "settings.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "settings.range.startDate", "type": "iso-8601"}, "end_date": {"key": "settings.range.endDate", "type": "iso-8601"}, "type_settings_pattern_type": {"key": "settings.pattern.type", "type": "str"}, "interval": {"key": "settings.pattern.interval", "type": "int"}, "principal_id": {"key": "createdBy.principalId", "type": "str"}, "principal_type": {"key": "createdBy.principalType", "type": "str"}, "principal_name": {"key": "createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, scopes: Optional[List["_models.AccessReviewScope"]] = None, instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, type_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the history definition. :paramtype display_name: str :keyword decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :paramtype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :keyword scopes: A collection of scopes used when selecting review history data. :paramtype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :keyword instances: Set of access review history instances for this history definition. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :keyword type_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.display_name = display_name self.review_history_period_start_date_time = None self.review_history_period_end_date_time = None self.decisions = decisions self.status = None self.created_date_time = None self.scopes = scopes self.instances = instances self.type_settings_range_type = type_settings_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_settings_pattern_type = type_settings_pattern_type self.interval = interval self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewHistoryInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review History Definition Instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review history definition instance id. :vartype id: str :ivar name: The access review history definition instance unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :vartype review_history_period_start_date_time: ~datetime.datetime :ivar review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :vartype review_history_period_end_date_time: ~datetime.datetime :ivar display_name: The display name for the parent history definition. :vartype display_name: str :ivar status: Status of the requested review history instance data. This is either requested, in-progress, done or error. The state transitions are as follows - Requested -> InProgress -> Done -> Expired. Known values are: "Requested", "InProgress", "Done", and "Error". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus :ivar run_date_time: Date time when the history data report is scheduled to be generated. :vartype run_date_time: ~datetime.datetime :ivar fulfilled_date_time: Date time when the history data report is scheduled to be generated. :vartype fulfilled_date_time: ~datetime.datetime :ivar download_uri: Uri which can be used to retrieve review history data. To generate this Uri, generateDownloadUri() must be called for a specific accessReviewHistoryDefinitionInstance. The link expires after a 24 hour period. Callers can see the expiration date time by looking at the 'se' parameter in the generated uri. :vartype download_uri: str :ivar expiration: Date time when history data report expires and the associated data is deleted. :vartype expiration: ~datetime.datetime """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "download_uri": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "review_history_period_start_date_time": { "key": "properties.reviewHistoryPeriodStartDateTime", "type": "iso-8601", }, "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "run_date_time": {"key": "properties.runDateTime", "type": "iso-8601"}, "fulfilled_date_time": {"key": "properties.fulfilledDateTime", "type": "iso-8601"}, "download_uri": {"key": "properties.downloadUri", "type": "str"}, "expiration": {"key": "properties.expiration", "type": "iso-8601"}, } def __init__( self, *, review_history_period_start_date_time: Optional[datetime.datetime] = None, review_history_period_end_date_time: Optional[datetime.datetime] = None, display_name: Optional[str] = None, run_date_time: Optional[datetime.datetime] = None, fulfilled_date_time: Optional[datetime.datetime] = None, expiration: Optional[datetime.datetime] = None, **kwargs: Any ) -> None: """ :keyword review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :paramtype review_history_period_start_date_time: ~datetime.datetime :keyword review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :paramtype review_history_period_end_date_time: ~datetime.datetime :keyword display_name: The display name for the parent history definition. :paramtype display_name: str :keyword run_date_time: Date time when the history data report is scheduled to be generated. :paramtype run_date_time: ~datetime.datetime :keyword fulfilled_date_time: Date time when the history data report is scheduled to be generated. :paramtype fulfilled_date_time: ~datetime.datetime :keyword expiration: Date time when history data report expires and the associated data is deleted. :paramtype expiration: ~datetime.datetime """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.review_history_period_start_date_time = review_history_period_start_date_time self.review_history_period_end_date_time = review_history_period_end_date_time self.display_name = display_name self.status = None self.run_date_time = run_date_time self.fulfilled_date_time = fulfilled_date_time self.download_uri = None self.expiration = expiration class AccessReviewInstance(_serialization.Model): """Access Review Instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review instance id. :vartype id: str :ivar name: The access review instance name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewInstanceListResult(_serialization.Model): """List of Access Review Instances. :ivar value: Access Review Instance list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Instance list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewInstanceProperties(_serialization.Model): """Access Review Instance properties. Variables are only populated by the server, and will be ignored when sending a request. :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "status": {"key": "status", "type": "str"}, "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewReviewer(_serialization.Model): """Descriptor for what needs to be reviewed. Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The id of the reviewer(user/servicePrincipal). :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewerType """ _validation = { "principal_type": {"readonly": True}, } _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "principal_type": {"key": "principalType", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: The id of the reviewer(user/servicePrincipal). :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.principal_type = None class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Schedule Definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review schedule definition id. :vartype id: str :ivar name: The access review schedule definition unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_properties_scope_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. :vartype include_inherited_access: bool :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :vartype include_access_below_resource: bool :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. :vartype exclude_resource_id: str :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :vartype exclude_role_definition_id: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_properties_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_properties_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_properties_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "properties.scope.expandNestedMemberships", "type": "bool"}, "include_inherited_access": {"key": "properties.scope.includeInheritedAccess", "type": "bool"}, "include_access_below_resource": {"key": "properties.scope.includeAccessBelowResource", "type": "bool"}, "exclude_resource_id": {"key": "properties.scope.excludeResourceId", "type": "str"}, "exclude_role_definition_id": {"key": "properties.scope.excludeRoleDefinitionId", "type": "str"}, "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": { "key": "properties.settings.justificationRequiredOnApproval", "type": "bool", }, "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": { "key": "properties.settings.recommendationLookBackDuration", "type": "duration", }, "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, "type_properties_settings_recurrence_range_type": { "key": "properties.settings.recurrence.range.type", "type": "str", }, "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_settings_recurrence_pattern_type": { "key": "properties.settings.recurrence.pattern.type", "type": "str", }, "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, "principal_type_properties_created_by_principal_type": { "key": "properties.createdBy.principalType", "type": "str", }, "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, include_inherited_access: Optional[bool] = None, include_access_below_resource: Optional[bool] = None, exclude_resource_id: Optional[str] = None, exclude_role_definition_id: Optional[str] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_settings_recurrence_range_type: Optional[ Union[str, "_models.AccessReviewRecurrenceRangeType"] ] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_settings_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or not. :paramtype include_inherited_access: bool :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :paramtype include_access_below_resource: bool :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. :paramtype exclude_resource_id: str :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :paramtype exclude_role_definition_id: str :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_properties_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.include_inherited_access = include_inherited_access self.include_access_below_resource = include_access_below_resource self.exclude_resource_id = exclude_resource_id self.exclude_role_definition_id = exclude_role_definition_id self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_properties_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleDefinitionListResult(_serialization.Model): """List of Access Review Schedule Definitions. :ivar value: Access Review Schedule Definition list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Schedule Definition list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_scope_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. :vartype include_inherited_access: bool :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :vartype include_access_below_resource: bool :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. :vartype exclude_resource_id: str :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :vartype exclude_role_definition_id: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "status": {"key": "status", "type": "str"}, "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "scope.resourceId", "type": "str"}, "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, "assignment_state": {"key": "scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "scope.expandNestedMemberships", "type": "bool"}, "include_inherited_access": {"key": "scope.includeInheritedAccess", "type": "bool"}, "include_access_below_resource": {"key": "scope.includeAccessBelowResource", "type": "bool"}, "exclude_resource_id": {"key": "scope.excludeResourceId", "type": "str"}, "exclude_role_definition_id": {"key": "scope.excludeRoleDefinitionId", "type": "str"}, "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "settings.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "createdBy.principalId", "type": "str"}, "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, "principal_name": {"key": "createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, include_inherited_access: Optional[bool] = None, include_access_below_resource: Optional[bool] = None, exclude_resource_id: Optional[str] = None, exclude_role_definition_id: Optional[str] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or not. :paramtype include_inherited_access: bool :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :paramtype include_access_below_resource: bool :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. :paramtype exclude_resource_id: str :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :paramtype exclude_role_definition_id: str :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.include_inherited_access = include_inherited_access self.include_access_below_resource = include_access_below_resource self.exclude_resource_id = exclude_resource_id self.exclude_role_definition_id = exclude_role_definition_id self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_settings_recurrence_range_type = type_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Settings of an Access Review. :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _attribute_map = { "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, "interval": {"key": "recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_recurrence_range_type = type_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_recurrence_pattern_type = type_recurrence_pattern_type self.interval = interval class AccessReviewScope(_serialization.Model): """Descriptor for what needs to be reviewed. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. :vartype include_inherited_access: bool :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :vartype include_access_below_resource: bool :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. :vartype exclude_resource_id: str :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :vartype exclude_role_definition_id: str """ _validation = { "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, } _attribute_map = { "resource_id": {"key": "resourceId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "principal_type": {"key": "principalType", "type": "str"}, "assignment_state": {"key": "assignmentState", "type": "str"}, "inactive_duration": {"key": "inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "expandNestedMemberships", "type": "bool"}, "include_inherited_access": {"key": "includeInheritedAccess", "type": "bool"}, "include_access_below_resource": {"key": "includeAccessBelowResource", "type": "bool"}, "exclude_resource_id": {"key": "excludeResourceId", "type": "str"}, "exclude_role_definition_id": {"key": "excludeRoleDefinitionId", "type": "str"}, } def __init__( self, *, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, include_inherited_access: Optional[bool] = None, include_access_below_resource: Optional[bool] = None, exclude_resource_id: Optional[str] = None, exclude_role_definition_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or not. :paramtype include_inherited_access: bool :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :paramtype include_access_below_resource: bool :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. :paramtype exclude_resource_id: str :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :paramtype exclude_role_definition_id: str """ super().__init__(**kwargs) self.resource_id = None self.role_definition_id = None self.principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.include_inherited_access = include_inherited_access self.include_access_below_resource = include_access_below_resource self.exclude_resource_id = exclude_resource_id self.exclude_role_definition_id = exclude_role_definition_id class ErrorDefinition(_serialization.Model): """Error description and code explaining why an operation failed. :ivar error: Error of the list gateway status. :vartype error: ~azure.mgmt.authorization.v2021_12_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { "error": {"key": "error", "type": "ErrorDefinitionProperties"}, } def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: """ :keyword error: Error of the list gateway status. :paramtype error: ~azure.mgmt.authorization.v2021_12_01_preview.models.ErrorDefinitionProperties """ super().__init__(**kwargs) self.error = error class ErrorDefinitionProperties(_serialization.Model): """Error description and code explaining why an operation failed. Variables are only populated by the server, and will be ignored when sending a request. :ivar message: Description of the error. :vartype message: str :ivar code: Error code of list gateway. :vartype code: str """ _validation = { "message": {"readonly": True}, } _attribute_map = { "message": {"key": "message", "type": "str"}, "code": {"key": "code", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code of list gateway. :paramtype code: str """ super().__init__(**kwargs) self.message = None self.code = code class Operation(_serialization.Model): """The definition of a Microsoft.Authorization operation. :ivar name: Name of the operation. :vartype name: str :ivar is_data_action: Indicates whether the operation is a data action. :vartype is_data_action: bool :ivar display: Display of the operation. :vartype display: ~azure.mgmt.authorization.v2021_12_01_preview.models.OperationDisplay :ivar origin: Origin of the operation. :vartype origin: str """ _attribute_map = { "name": {"key": "name", "type": "str"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, "display": {"key": "display", "type": "OperationDisplay"}, "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword name: Name of the operation. :paramtype name: str :keyword is_data_action: Indicates whether the operation is a data action. :paramtype is_data_action: bool :keyword display: Display of the operation. :paramtype display: ~azure.mgmt.authorization.v2021_12_01_preview.models.OperationDisplay :keyword origin: Origin of the operation. :paramtype origin: str """ super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.origin = origin class OperationDisplay(_serialization.Model): """The display information for a Microsoft.Authorization operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar provider: The resource provider name: Microsoft.Authorization. :vartype provider: str :ivar resource: The resource on which the operation is performed. :vartype resource: str :ivar operation: The operation that users can perform. :vartype operation: str :ivar description: The description for the operation. :vartype description: str """ _validation = { "provider": {"readonly": True}, "resource": {"readonly": True}, "operation": {"readonly": True}, "description": {"readonly": True}, } _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, "operation": {"key": "operation", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None class OperationListResult(_serialization.Model): """The result of a request to list Microsoft.Authorization operations. :ivar value: The collection value. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] :ivar next_link: The URI that can be used to request the next set of paged results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Operation]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RecordAllDecisionsProperties(_serialization.Model): """Record All Decisions payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The id of principal which needs to be approved/denied. :vartype principal_id: str :ivar resource_id: The id of resource which needs to be approved/denied. :vartype resource_id: str :ivar decision: The decision to make. Approvers can take action of Approve/Deny. Known values are: "Approve" and "Deny". :vartype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str """ _validation = { "principal_id": {"readonly": True}, "resource_id": {"readonly": True}, } _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "resource_id": {"key": "resourceId", "type": "str"}, "decision": {"key": "decision", "type": "str"}, "justification": {"key": "justification", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.RecordAllDecisionsResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision to make. Approvers can take action of Approve/Deny. Known values are: "Approve" and "Deny". :paramtype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.principal_id = None self.resource_id = None self.decision = decision self.justification = justification
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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_12_01_preview.models.AccessReviewContactedReviewer] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewContactedReviewer]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewContactedReviewer"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Contacted Reviewer. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewContactedReviewer] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecision(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review decision id. :vartype id: str :ivar name: The access review decision name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar insights: This is the collection of insights for this decision item. :vartype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :ivar membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :vartype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :ivar principal_id_properties_applied_by_principal_id: The identity id. :vartype principal_id_properties_applied_by_principal_id: str :ivar principal_type_properties_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_applied_by_principal_name: The identity display name. :vartype principal_name_properties_applied_by_principal_name: str :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_applied_by_user_principal_name: str :ivar principal_id_properties_reviewed_by_principal_id: The identity id. :vartype principal_id_properties_reviewed_by_principal_id: str :ivar principal_type_properties_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. :vartype principal_name_properties_reviewed_by_principal_name: str :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_reviewed_by_user_principal_name: str :ivar type_properties_resource_type: The type of resource. "azureRole" :vartype type_properties_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType :ivar id_properties_resource_id: The id of resource associated with a decision record. :vartype id_properties_resource_id: str :ivar display_name_properties_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_properties_resource_display_name: str :ivar type_properties_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_properties_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id_properties_principal_id: The id of principal whose access was reviewed. :vartype id_properties_principal_id: str :ivar display_name_properties_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_properties_principal_display_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_properties_applied_by_principal_id": {"readonly": True}, "principal_type_properties_applied_by_principal_type": {"readonly": True}, "principal_name_properties_applied_by_principal_name": {"readonly": True}, "user_principal_name_properties_applied_by_user_principal_name": {"readonly": True}, "principal_id_properties_reviewed_by_principal_id": {"readonly": True}, "principal_type_properties_reviewed_by_principal_type": {"readonly": True}, "principal_name_properties_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_properties_reviewed_by_user_principal_name": {"readonly": True}, "id_properties_resource_id": {"readonly": True}, "display_name_properties_resource_display_name": {"readonly": True}, "id_properties_principal_id": {"readonly": True}, "display_name_properties_principal_display_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "recommendation": {"key": "properties.recommendation", "type": "str"}, "decision": {"key": "properties.decision", "type": "str"}, "justification": {"key": "properties.justification", "type": "str"}, "reviewed_date_time": {"key": "properties.reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "properties.applyResult", "type": "str"}, "applied_date_time": {"key": "properties.appliedDateTime", "type": "iso-8601"}, "insights": {"key": "properties.insights", "type": "[AccessReviewDecisionInsight]"}, "membership_types": {"key": "properties.principalResourceMembership.membershipTypes", "type": "[str]"}, "principal_id_properties_applied_by_principal_id": {"key": "properties.appliedBy.principalId", "type": "str"}, "principal_type_properties_applied_by_principal_type": { "key": "properties.appliedBy.principalType", "type": "str", }, "principal_name_properties_applied_by_principal_name": { "key": "properties.appliedBy.principalName", "type": "str", }, "user_principal_name_properties_applied_by_user_principal_name": { "key": "properties.appliedBy.userPrincipalName", "type": "str", }, "principal_id_properties_reviewed_by_principal_id": {"key": "properties.reviewedBy.principalId", "type": "str"}, "principal_type_properties_reviewed_by_principal_type": { "key": "properties.reviewedBy.principalType", "type": "str", }, "principal_name_properties_reviewed_by_principal_name": { "key": "properties.reviewedBy.principalName", "type": "str", }, "user_principal_name_properties_reviewed_by_user_principal_name": { "key": "properties.reviewedBy.userPrincipalName", "type": "str", }, "type_properties_resource_type": {"key": "properties.resource.type", "type": "str"}, "id_properties_resource_id": {"key": "properties.resource.id", "type": "str"}, "display_name_properties_resource_display_name": {"key": "properties.resource.displayName", "type": "str"}, "type_properties_principal_type": {"key": "properties.principal.type", "type": "str"}, "id_properties_principal_id": {"key": "properties.principal.id", "type": "str"}, "display_name_properties_principal_display_name": {"key": "properties.principal.displayName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, membership_types: Optional[ List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] ] = None, type_properties_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str :keyword insights: This is the collection of insights for this decision item. :paramtype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :keyword membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :paramtype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :keyword type_properties_resource_type: The type of resource. "azureRole" :paramtype type_properties_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.insights = insights self.membership_types = membership_types self.principal_id_properties_applied_by_principal_id = None self.principal_type_properties_applied_by_principal_type = None self.principal_name_properties_applied_by_principal_name = None self.user_principal_name_properties_applied_by_user_principal_name = None self.principal_id_properties_reviewed_by_principal_id = None self.principal_type_properties_reviewed_by_principal_type = None self.principal_name_properties_reviewed_by_principal_name = None self.user_principal_name_properties_reviewed_by_user_principal_name = None self.type_properties_resource_type = type_properties_resource_type self.id_properties_resource_id = None self.display_name_properties_resource_display_name = None self.type_properties_principal_type: Optional[str] = None self.id_properties_principal_id = None self.display_name_properties_principal_display_name = None class AccessReviewDecisionIdentity(_serialization.Model): """Target of the decision. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, } _subtype_map = { "type": { "servicePrincipal": "AccessReviewDecisionServicePrincipalIdentity", "user": "AccessReviewDecisionUserIdentity", } } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.id = None self.display_name = None class AccessReviewDecisionInsight(_serialization.Model): """Access Review Decision Insight. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review insight id. :vartype id: str :ivar name: The access review insight name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar type_properties_type: The type of insight. "userSignInInsight" :vartype type_properties_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType :ivar insight_created_date_time: Date Time when the insight was created. :vartype insight_created_date_time: any """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "insight_created_date_time": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "type_properties_type": {"key": "properties.type", "type": "str"}, "insight_created_date_time": {"key": "properties.insightCreatedDateTime", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.type_properties_type: Optional[str] = None self.insight_created_date_time = None class AccessReviewDecisionInsightProperties(_serialization.Model): """Details of the Insight. You probably want to use the sub-classes and not this class directly. Known sub-classes are: AccessReviewDecisionUserSignInInsightProperties Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of insight. Required. "userSignInInsight" :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType :ivar insight_created_date_time: Date Time when the insight was created. :vartype insight_created_date_time: any """ _validation = { "type": {"required": True}, "insight_created_date_time": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, } _subtype_map = {"type": {"userSignInInsight": "AccessReviewDecisionUserSignInInsightProperties"}} def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: Optional[str] = None self.insight_created_date_time = None class AccessReviewDecisionListResult(_serialization.Model): """List of access review decisions. :ivar value: Access Review Decision list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewDecision]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewDecision"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Decision list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecision] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewDecisionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Approval Step. Variables are only populated by the server, and will be ignored when sending a request. :ivar recommendation: The feature- generated recommendation shown to the reviewer. Known values are: "Approve", "Deny", and "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessRecommendationType :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :vartype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Known values are: "New", "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", "AppliedSuccessfullyButObjectNotFound", and "ApplyNotSupported". :vartype apply_result: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewApplyResult :ivar applied_date_time: The date and time when the review decision was applied. :vartype applied_date_time: ~datetime.datetime :ivar insights: This is the collection of insights for this decision item. :vartype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :ivar membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :vartype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :ivar principal_id_applied_by_principal_id: The identity id. :vartype principal_id_applied_by_principal_id: str :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_applied_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_applied_by_principal_name: The identity display name. :vartype principal_name_applied_by_principal_name: str :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_applied_by_user_principal_name: str :ivar principal_id_reviewed_by_principal_id: The identity id. :vartype principal_id_reviewed_by_principal_id: str :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_reviewed_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name_reviewed_by_principal_name: The identity display name. :vartype principal_name_reviewed_by_principal_name: str :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_reviewed_by_user_principal_name: str :ivar type_resource_type: The type of resource. "azureRole" :vartype type_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType :ivar id_resource_id: The id of resource associated with a decision record. :vartype id_resource_id: str :ivar display_name_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_resource_display_name: str :ivar type_principal_type: The type of decision target : User/ServicePrincipal. Known values are: "user" and "servicePrincipal". :vartype type_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id_principal_id: The id of principal whose access was reviewed. :vartype id_principal_id: str :ivar display_name_principal_display_name: The display name of the user whose access was reviewed. :vartype display_name_principal_display_name: str """ _validation = { "recommendation": {"readonly": True}, "reviewed_date_time": {"readonly": True}, "apply_result": {"readonly": True}, "applied_date_time": {"readonly": True}, "principal_id_applied_by_principal_id": {"readonly": True}, "principal_type_applied_by_principal_type": {"readonly": True}, "principal_name_applied_by_principal_name": {"readonly": True}, "user_principal_name_applied_by_user_principal_name": {"readonly": True}, "principal_id_reviewed_by_principal_id": {"readonly": True}, "principal_type_reviewed_by_principal_type": {"readonly": True}, "principal_name_reviewed_by_principal_name": {"readonly": True}, "user_principal_name_reviewed_by_user_principal_name": {"readonly": True}, "id_resource_id": {"readonly": True}, "display_name_resource_display_name": {"readonly": True}, "id_principal_id": {"readonly": True}, "display_name_principal_display_name": {"readonly": True}, } _attribute_map = { "recommendation": {"key": "recommendation", "type": "str"}, "decision": {"key": "decision", "type": "str"}, "justification": {"key": "justification", "type": "str"}, "reviewed_date_time": {"key": "reviewedDateTime", "type": "iso-8601"}, "apply_result": {"key": "applyResult", "type": "str"}, "applied_date_time": {"key": "appliedDateTime", "type": "iso-8601"}, "insights": {"key": "insights", "type": "[AccessReviewDecisionInsight]"}, "membership_types": {"key": "principalResourceMembership.membershipTypes", "type": "[str]"}, "principal_id_applied_by_principal_id": {"key": "appliedBy.principalId", "type": "str"}, "principal_type_applied_by_principal_type": {"key": "appliedBy.principalType", "type": "str"}, "principal_name_applied_by_principal_name": {"key": "appliedBy.principalName", "type": "str"}, "user_principal_name_applied_by_user_principal_name": {"key": "appliedBy.userPrincipalName", "type": "str"}, "principal_id_reviewed_by_principal_id": {"key": "reviewedBy.principalId", "type": "str"}, "principal_type_reviewed_by_principal_type": {"key": "reviewedBy.principalType", "type": "str"}, "principal_name_reviewed_by_principal_name": {"key": "reviewedBy.principalName", "type": "str"}, "user_principal_name_reviewed_by_user_principal_name": {"key": "reviewedBy.userPrincipalName", "type": "str"}, "type_resource_type": {"key": "resource.type", "type": "str"}, "id_resource_id": {"key": "resource.id", "type": "str"}, "display_name_resource_display_name": {"key": "resource.displayName", "type": "str"}, "type_principal_type": {"key": "principal.type", "type": "str"}, "id_principal_id": {"key": "principal.id", "type": "str"}, "display_name_principal_display_name": {"key": "principal.displayName", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.AccessReviewResult"]] = None, justification: Optional[str] = None, insights: Optional[List["_models.AccessReviewDecisionInsight"]] = None, membership_types: Optional[ List[Union[str, "_models.AccessReviewDecisionPrincipalResourceMembershipType"]] ] = None, type_resource_type: Optional[Union[str, "_models.DecisionResourceType"]] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Known values are: "Approve", "Deny", "NotReviewed", "DontKnow", and "NotNotified". :paramtype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str :keyword insights: This is the collection of insights for this decision item. :paramtype insights: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsight] :keyword membership_types: Every decision item in an access review represents a principal's membership to a resource. This property represents details of the membership. Examples of this detail might be whether the principal has direct access or indirect access. :paramtype membership_types: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionPrincipalResourceMembershipType] :keyword type_resource_type: The type of resource. "azureRole" :paramtype type_resource_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionResourceType """ super().__init__(**kwargs) self.recommendation = None self.decision = decision self.justification = justification self.reviewed_date_time = None self.apply_result = None self.applied_date_time = None self.insights = insights self.membership_types = membership_types self.principal_id_applied_by_principal_id = None self.principal_type_applied_by_principal_type = None self.principal_name_applied_by_principal_name = None self.user_principal_name_applied_by_user_principal_name = None self.principal_id_reviewed_by_principal_id = None self.principal_type_reviewed_by_principal_type = None self.principal_name_reviewed_by_principal_name = None self.user_principal_name_reviewed_by_user_principal_name = None self.type_resource_type = type_resource_type self.id_resource_id = None self.display_name_resource_display_name = None self.type_principal_type: Optional[str] = None self.id_principal_id = None self.display_name_principal_display_name = None class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): """Service Principal Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar app_id: The appId for the service principal entity being reviewed. :vartype app_id: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "app_id": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "app_id": {"key": "appId", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "servicePrincipal" self.app_id = None class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): """User Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of decision target : User/ServicePrincipal. Required. Known values are: "user" and "servicePrincipal". :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. :vartype display_name: str :ivar user_principal_name: The user principal name of the user whose access was reviewed. :vartype user_principal_name: str """ _validation = { "type": {"required": True}, "id": {"readonly": True}, "display_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "user_principal_name": {"key": "userPrincipalName", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "user" self.user_principal_name = None class AccessReviewDecisionUserSignInInsightProperties(AccessReviewDecisionInsightProperties): """User Decision Target. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. :ivar type: The type of insight. Required. "userSignInInsight" :vartype type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewDecisionInsightType :ivar insight_created_date_time: Date Time when the insight was created. :vartype insight_created_date_time: any :ivar last_sign_in_date_time: Date Time when the user signed into the tenant. :vartype last_sign_in_date_time: any """ _validation = { "type": {"required": True}, "insight_created_date_time": {"readonly": True}, "last_sign_in_date_time": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "insight_created_date_time": {"key": "insightCreatedDateTime", "type": "object"}, "last_sign_in_date_time": {"key": "lastSignInDateTime", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type: str = "userSignInInsight" self.last_sign_in_date_time = None class AccessReviewDefaultSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Default Settings. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review default settings id. This is only going to be default. :vartype id: str :ivar name: The access review default settings name. This is always going to be Access Review Default Settings. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "mail_notifications_enabled": {"key": "properties.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "properties.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "properties.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "properties.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "properties.instanceDurationInDays", "type": "int"}, "type_properties_recurrence_range_type": {"key": "properties.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "properties.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_recurrence_pattern_type": {"key": "properties.recurrence.pattern.type", "type": "str"}, "interval": {"key": "properties.recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_recurrence_range_type = type_properties_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type self.interval = interval class AccessReviewHistoryDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review History Definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review history definition id. :vartype id: str :ivar name: The access review history definition unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the history definition. :vartype display_name: str :ivar review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :vartype review_history_period_start_date_time: ~datetime.datetime :ivar review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :vartype review_history_period_end_date_time: ~datetime.datetime :ivar decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :vartype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :ivar status: This read-only field specifies the of the requested review history data. This is either requested, in-progress, done or error. Known values are: "Requested", "InProgress", "Done", and "Error". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus :ivar created_date_time: Date time when history definition was created. :vartype created_date_time: ~datetime.datetime :ivar scopes: A collection of scopes used when selecting review history data. :vartype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :ivar instances: Set of access review history instances for this history definition. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :ivar type_properties_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "review_history_period_start_date_time": {"readonly": True}, "review_history_period_end_date_time": {"readonly": True}, "status": {"readonly": True}, "created_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "review_history_period_start_date_time": { "key": "properties.reviewHistoryPeriodStartDateTime", "type": "iso-8601", }, "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, "decisions": {"key": "properties.decisions", "type": "[str]"}, "status": {"key": "properties.status", "type": "str"}, "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, "scopes": {"key": "properties.scopes", "type": "[AccessReviewScope]"}, "instances": {"key": "properties.instances", "type": "[AccessReviewHistoryInstance]"}, "type_properties_settings_range_type": {"key": "properties.settings.range.type", "type": "str"}, "number_of_occurrences": {"key": "properties.settings.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.settings.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.settings.range.endDate", "type": "iso-8601"}, "type_properties_settings_pattern_type": {"key": "properties.settings.pattern.type", "type": "str"}, "interval": {"key": "properties.settings.pattern.interval", "type": "int"}, "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, "principal_type": {"key": "properties.createdBy.principalType", "type": "str"}, "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, scopes: Optional[List["_models.AccessReviewScope"]] = None, instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, type_properties_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the history definition. :paramtype display_name: str :keyword decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :paramtype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :keyword scopes: A collection of scopes used when selecting review history data. :paramtype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :keyword instances: Set of access review history instances for this history definition. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :keyword type_properties_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.review_history_period_start_date_time = None self.review_history_period_end_date_time = None self.decisions = decisions self.status = None self.created_date_time = None self.scopes = scopes self.instances = instances self.type_properties_settings_range_type = type_properties_settings_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_settings_pattern_type = type_properties_settings_pattern_type self.interval = interval self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewHistoryDefinitionInstanceListResult(_serialization.Model): """List of Access Review History Instances. :ivar value: Access Review History Definition's Instance list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewHistoryInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewHistoryInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review History Definition's Instance list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewHistoryDefinitionListResult(_serialization.Model): """List of Access Review History Definitions. :ivar value: Access Review History Definition list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewHistoryDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewHistoryDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review History Definition list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewHistoryDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review History Instances. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the history definition. :vartype display_name: str :ivar review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :vartype review_history_period_start_date_time: ~datetime.datetime :ivar review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :vartype review_history_period_end_date_time: ~datetime.datetime :ivar decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :vartype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :ivar status: This read-only field specifies the of the requested review history data. This is either requested, in-progress, done or error. Known values are: "Requested", "InProgress", "Done", and "Error". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus :ivar created_date_time: Date time when history definition was created. :vartype created_date_time: ~datetime.datetime :ivar scopes: A collection of scopes used when selecting review history data. :vartype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :ivar instances: Set of access review history instances for this history definition. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :ivar type_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "review_history_period_start_date_time": {"readonly": True}, "review_history_period_end_date_time": {"readonly": True}, "status": {"readonly": True}, "created_date_time": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "review_history_period_start_date_time": {"key": "reviewHistoryPeriodStartDateTime", "type": "iso-8601"}, "review_history_period_end_date_time": {"key": "reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, "decisions": {"key": "decisions", "type": "[str]"}, "status": {"key": "status", "type": "str"}, "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, "scopes": {"key": "scopes", "type": "[AccessReviewScope]"}, "instances": {"key": "instances", "type": "[AccessReviewHistoryInstance]"}, "type_settings_range_type": {"key": "settings.range.type", "type": "str"}, "number_of_occurrences": {"key": "settings.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "settings.range.startDate", "type": "iso-8601"}, "end_date": {"key": "settings.range.endDate", "type": "iso-8601"}, "type_settings_pattern_type": {"key": "settings.pattern.type", "type": "str"}, "interval": {"key": "settings.pattern.interval", "type": "int"}, "principal_id": {"key": "createdBy.principalId", "type": "str"}, "principal_type": {"key": "createdBy.principalType", "type": "str"}, "principal_name": {"key": "createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, } def __init__( self, *, display_name: Optional[str] = None, decisions: Optional[List[Union[str, "_models.AccessReviewResult"]]] = None, scopes: Optional[List["_models.AccessReviewScope"]] = None, instances: Optional[List["_models.AccessReviewHistoryInstance"]] = None, type_settings_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_settings_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the history definition. :paramtype display_name: str :keyword decisions: Collection of review decisions which the history data should be filtered on. For example if Approve and Deny are supplied the data will only contain review results in which the decision maker approved or denied a review request. :paramtype decisions: list[str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewResult] :keyword scopes: A collection of scopes used when selecting review history data. :paramtype scopes: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScope] :keyword instances: Set of access review history instances for this history definition. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryInstance] :keyword type_settings_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_settings_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_settings_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_settings_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.display_name = display_name self.review_history_period_start_date_time = None self.review_history_period_end_date_time = None self.decisions = decisions self.status = None self.created_date_time = None self.scopes = scopes self.instances = instances self.type_settings_range_type = type_settings_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_settings_pattern_type = type_settings_pattern_type self.interval = interval self.principal_id = None self.principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewHistoryInstance(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review History Definition Instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review history definition instance id. :vartype id: str :ivar name: The access review history definition instance unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :vartype review_history_period_start_date_time: ~datetime.datetime :ivar review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :vartype review_history_period_end_date_time: ~datetime.datetime :ivar display_name: The display name for the parent history definition. :vartype display_name: str :ivar status: Status of the requested review history instance data. This is either requested, in-progress, done or error. The state transitions are as follows - Requested -> InProgress -> Done -> Expired. Known values are: "Requested", "InProgress", "Done", and "Error". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewHistoryDefinitionStatus :ivar run_date_time: Date time when the history data report is scheduled to be generated. :vartype run_date_time: ~datetime.datetime :ivar fulfilled_date_time: Date time when the history data report is scheduled to be generated. :vartype fulfilled_date_time: ~datetime.datetime :ivar download_uri: Uri which can be used to retrieve review history data. To generate this Uri, generateDownloadUri() must be called for a specific accessReviewHistoryDefinitionInstance. The link expires after a 24 hour period. Callers can see the expiration date time by looking at the 'se' parameter in the generated uri. :vartype download_uri: str :ivar expiration: Date time when history data report expires and the associated data is deleted. :vartype expiration: ~datetime.datetime """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "download_uri": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "review_history_period_start_date_time": { "key": "properties.reviewHistoryPeriodStartDateTime", "type": "iso-8601", }, "review_history_period_end_date_time": {"key": "properties.reviewHistoryPeriodEndDateTime", "type": "iso-8601"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "run_date_time": {"key": "properties.runDateTime", "type": "iso-8601"}, "fulfilled_date_time": {"key": "properties.fulfilledDateTime", "type": "iso-8601"}, "download_uri": {"key": "properties.downloadUri", "type": "str"}, "expiration": {"key": "properties.expiration", "type": "iso-8601"}, } def __init__( self, *, review_history_period_start_date_time: Optional[datetime.datetime] = None, review_history_period_end_date_time: Optional[datetime.datetime] = None, display_name: Optional[str] = None, run_date_time: Optional[datetime.datetime] = None, fulfilled_date_time: Optional[datetime.datetime] = None, expiration: Optional[datetime.datetime] = None, **kwargs: Any ) -> None: """ :keyword review_history_period_start_date_time: Date time used when selecting review data, all reviews included in data start on or after this date. For use only with one-time/non-recurring reports. :paramtype review_history_period_start_date_time: ~datetime.datetime :keyword review_history_period_end_date_time: Date time used when selecting review data, all reviews included in data end on or before this date. For use only with one-time/non-recurring reports. :paramtype review_history_period_end_date_time: ~datetime.datetime :keyword display_name: The display name for the parent history definition. :paramtype display_name: str :keyword run_date_time: Date time when the history data report is scheduled to be generated. :paramtype run_date_time: ~datetime.datetime :keyword fulfilled_date_time: Date time when the history data report is scheduled to be generated. :paramtype fulfilled_date_time: ~datetime.datetime :keyword expiration: Date time when history data report expires and the associated data is deleted. :paramtype expiration: ~datetime.datetime """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.review_history_period_start_date_time = review_history_period_start_date_time self.review_history_period_end_date_time = review_history_period_end_date_time self.display_name = display_name self.status = None self.run_date_time = run_date_time self.fulfilled_date_time = fulfilled_date_time self.download_uri = None self.expiration = expiration class AccessReviewInstance(_serialization.Model): """Access Review Instance. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review instance id. :vartype id: str :ivar name: The access review instance name. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "properties.endDateTime", "type": "iso-8601"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewInstanceListResult(_serialization.Model): """List of Access Review Instances. :ivar value: Access Review Instance list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewInstance]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewInstance"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Instance list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewInstanceProperties(_serialization.Model): """Access Review Instance properties. Variables are only populated by the server, and will be ignored when sending a request. :ivar status: This read-only field specifies the status of an access review instance. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceStatus :ivar start_date_time: The DateTime when the review instance is scheduled to be start. :vartype start_date_time: ~datetime.datetime :ivar end_date_time: The DateTime when the review instance is scheduled to end. :vartype end_date_time: ~datetime.datetime :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstanceReviewersType """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, } _attribute_map = { "status": {"key": "status", "type": "str"}, "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, } def __init__( self, *, start_date_time: Optional[datetime.datetime] = None, end_date_time: Optional[datetime.datetime] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, **kwargs: Any ) -> None: """ :keyword start_date_time: The DateTime when the review instance is scheduled to be start. :paramtype start_date_time: ~datetime.datetime :keyword end_date_time: The DateTime when the review instance is scheduled to end. :paramtype end_date_time: ~datetime.datetime :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] """ super().__init__(**kwargs) self.status = None self.start_date_time = start_date_time self.end_date_time = end_date_time self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None class AccessReviewReviewer(_serialization.Model): """Descriptor for what needs to be reviewed. Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The id of the reviewer(user/servicePrincipal). :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewerType """ _validation = { "principal_type": {"readonly": True}, } _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "principal_type": {"key": "principalType", "type": "str"}, } def __init__(self, *, principal_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword principal_id: The id of the reviewer(user/servicePrincipal). :paramtype principal_id: str """ super().__init__(**kwargs) self.principal_id = principal_id self.principal_type = None class AccessReviewScheduleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review Schedule Definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The access review schedule definition id. :vartype id: str :ivar name: The access review schedule definition unique id. :vartype name: str :ivar type: The resource type. :vartype type: str :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_properties_scope_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. :vartype include_inherited_access: bool :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :vartype include_access_below_resource: bool :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. :vartype exclude_resource_id: str :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :vartype exclude_role_definition_id: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_properties_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_properties_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_properties_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_properties_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "display_name": {"key": "properties.displayName", "type": "str"}, "status": {"key": "properties.status", "type": "str"}, "description_for_admins": {"key": "properties.descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "properties.descriptionForReviewers", "type": "str"}, "reviewers": {"key": "properties.reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "properties.backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "properties.reviewersType", "type": "str"}, "instances": {"key": "properties.instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "properties.scope.resourceId", "type": "str"}, "role_definition_id": {"key": "properties.scope.roleDefinitionId", "type": "str"}, "principal_type_properties_scope_principal_type": {"key": "properties.scope.principalType", "type": "str"}, "assignment_state": {"key": "properties.scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "properties.scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "properties.scope.expandNestedMemberships", "type": "bool"}, "include_inherited_access": {"key": "properties.scope.includeInheritedAccess", "type": "bool"}, "include_access_below_resource": {"key": "properties.scope.includeAccessBelowResource", "type": "bool"}, "exclude_resource_id": {"key": "properties.scope.excludeResourceId", "type": "str"}, "exclude_role_definition_id": {"key": "properties.scope.excludeRoleDefinitionId", "type": "str"}, "mail_notifications_enabled": {"key": "properties.settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "properties.settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "properties.settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": { "key": "properties.settings.justificationRequiredOnApproval", "type": "bool", }, "default_decision": {"key": "properties.settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "properties.settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "properties.settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": { "key": "properties.settings.recommendationLookBackDuration", "type": "duration", }, "instance_duration_in_days": {"key": "properties.settings.instanceDurationInDays", "type": "int"}, "type_properties_settings_recurrence_range_type": { "key": "properties.settings.recurrence.range.type", "type": "str", }, "number_of_occurrences": {"key": "properties.settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "properties.settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "properties.settings.recurrence.range.endDate", "type": "iso-8601"}, "type_properties_settings_recurrence_pattern_type": { "key": "properties.settings.recurrence.pattern.type", "type": "str", }, "interval": {"key": "properties.settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "properties.createdBy.principalId", "type": "str"}, "principal_type_properties_created_by_principal_type": { "key": "properties.createdBy.principalType", "type": "str", }, "principal_name": {"key": "properties.createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "properties.createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, include_inherited_access: Optional[bool] = None, include_access_below_resource: Optional[bool] = None, exclude_resource_id: Optional[str] = None, exclude_role_definition_id: Optional[str] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_properties_settings_recurrence_range_type: Optional[ Union[str, "_models.AccessReviewRecurrenceRangeType"] ] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_properties_settings_recurrence_pattern_type: Optional[ Union[str, "_models.AccessReviewRecurrencePatternType"] ] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or not. :paramtype include_inherited_access: bool :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :paramtype include_access_below_resource: bool :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. :paramtype exclude_resource_id: str :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :paramtype exclude_role_definition_id: str :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_properties_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.include_inherited_access = include_inherited_access self.include_access_below_resource = include_access_below_resource self.exclude_resource_id = exclude_resource_id self.exclude_role_definition_id = exclude_role_definition_id self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_properties_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleDefinitionListResult(_serialization.Model): """List of Access Review Schedule Definitions. :ivar value: Access Review Schedule Definition list. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[AccessReviewScheduleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.AccessReviewScheduleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Access Review Schedule Definition list. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class AccessReviewScheduleDefinitionProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Access Review. Variables are only populated by the server, and will be ignored when sending a request. :ivar display_name: The display name for the schedule definition. :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Known values are: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", and "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionStatus :ivar description_for_admins: The description provided by the access review creator and visible to admins. :vartype description_for_admins: str :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :vartype description_for_reviewers: str :ivar reviewers: This is the collection of reviewers. :vartype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar backup_reviewers: This is the collection of backup reviewers. :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. Known values are: "Assigned", "Self", and "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScheduleDefinitionReviewersType :ivar instances: This is the collection of instances returned when one does an expand on it. :vartype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type_scope_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. :vartype include_inherited_access: bool :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :vartype include_access_below_resource: bool :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. :vartype exclude_resource_id: str :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :vartype exclude_role_definition_id: str :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. Known values are: "user" and "servicePrincipal". :vartype principal_type_created_by_principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewActorIdentityType :ivar principal_name: The identity display name. :vartype principal_name: str :ivar user_principal_name: The user principal name(if valid). :vartype user_principal_name: str """ _validation = { "status": {"readonly": True}, "reviewers_type": {"readonly": True}, "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type_scope_principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, "principal_id": {"readonly": True}, "principal_type_created_by_principal_type": {"readonly": True}, "principal_name": {"readonly": True}, "user_principal_name": {"readonly": True}, } _attribute_map = { "display_name": {"key": "displayName", "type": "str"}, "status": {"key": "status", "type": "str"}, "description_for_admins": {"key": "descriptionForAdmins", "type": "str"}, "description_for_reviewers": {"key": "descriptionForReviewers", "type": "str"}, "reviewers": {"key": "reviewers", "type": "[AccessReviewReviewer]"}, "backup_reviewers": {"key": "backupReviewers", "type": "[AccessReviewReviewer]"}, "reviewers_type": {"key": "reviewersType", "type": "str"}, "instances": {"key": "instances", "type": "[AccessReviewInstance]"}, "resource_id": {"key": "scope.resourceId", "type": "str"}, "role_definition_id": {"key": "scope.roleDefinitionId", "type": "str"}, "principal_type_scope_principal_type": {"key": "scope.principalType", "type": "str"}, "assignment_state": {"key": "scope.assignmentState", "type": "str"}, "inactive_duration": {"key": "scope.inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "scope.expandNestedMemberships", "type": "bool"}, "include_inherited_access": {"key": "scope.includeInheritedAccess", "type": "bool"}, "include_access_below_resource": {"key": "scope.includeAccessBelowResource", "type": "bool"}, "exclude_resource_id": {"key": "scope.excludeResourceId", "type": "str"}, "exclude_role_definition_id": {"key": "scope.excludeRoleDefinitionId", "type": "str"}, "mail_notifications_enabled": {"key": "settings.mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "settings.reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "settings.defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "settings.justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "settings.defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "settings.autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "settings.recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "settings.recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "settings.instanceDurationInDays", "type": "int"}, "type_settings_recurrence_range_type": {"key": "settings.recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "settings.recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "settings.recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "settings.recurrence.range.endDate", "type": "iso-8601"}, "type_settings_recurrence_pattern_type": {"key": "settings.recurrence.pattern.type", "type": "str"}, "interval": {"key": "settings.recurrence.pattern.interval", "type": "int"}, "principal_id": {"key": "createdBy.principalId", "type": "str"}, "principal_type_created_by_principal_type": {"key": "createdBy.principalType", "type": "str"}, "principal_name": {"key": "createdBy.principalName", "type": "str"}, "user_principal_name": {"key": "createdBy.userPrincipalName", "type": "str"}, } def __init__( # pylint: disable=too-many-locals self, *, display_name: Optional[str] = None, description_for_admins: Optional[str] = None, description_for_reviewers: Optional[str] = None, reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, backup_reviewers: Optional[List["_models.AccessReviewReviewer"]] = None, instances: Optional[List["_models.AccessReviewInstance"]] = None, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, include_inherited_access: Optional[bool] = None, include_access_below_resource: Optional[bool] = None, exclude_resource_id: Optional[str] = None, exclude_role_definition_id: Optional[str] = None, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_settings_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_settings_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword display_name: The display name for the schedule definition. :paramtype display_name: str :keyword description_for_admins: The description provided by the access review creator and visible to admins. :paramtype description_for_admins: str :keyword description_for_reviewers: The description provided by the access review creator to be shown to reviewers. :paramtype description_for_reviewers: str :keyword reviewers: This is the collection of reviewers. :paramtype reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword backup_reviewers: This is the collection of backup reviewers. :paramtype backup_reviewers: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewReviewer] :keyword instances: This is the collection of instances returned when one does an expand on it. :paramtype instances: list[~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewInstance] :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or not. :paramtype include_inherited_access: bool :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :paramtype include_access_below_resource: bool :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. :paramtype exclude_resource_id: str :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :paramtype exclude_role_definition_id: str :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.display_name = display_name self.status = None self.description_for_admins = description_for_admins self.description_for_reviewers = description_for_reviewers self.reviewers = reviewers self.backup_reviewers = backup_reviewers self.reviewers_type = None self.instances = instances self.resource_id = None self.role_definition_id = None self.principal_type_scope_principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.include_inherited_access = include_inherited_access self.include_access_below_resource = include_access_below_resource self.exclude_resource_id = exclude_resource_id self.exclude_role_definition_id = exclude_role_definition_id self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_settings_recurrence_range_type = type_settings_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type self.interval = interval self.principal_id = None self.principal_type_created_by_principal_type = None self.principal_name = None self.user_principal_name = None class AccessReviewScheduleSettings(_serialization.Model): # pylint: disable=too-many-instance-attributes """Settings of an Access Review. :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :vartype mail_notifications_enabled: bool :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :vartype reminder_notifications_enabled: bool :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :vartype default_decision_enabled: bool :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :vartype justification_required_on_approval: bool :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :vartype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :vartype auto_apply_decisions_enabled: bool :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :vartype recommendations_enabled: bool :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype recommendation_look_back_duration: ~datetime.timedelta :ivar instance_duration_in_days: The duration in days for an instance. :vartype instance_duration_in_days: int :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :ivar number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :vartype number_of_occurrences: int :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :vartype start_date: ~datetime.datetime :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :vartype end_date: ~datetime.datetime :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :vartype interval: int """ _attribute_map = { "mail_notifications_enabled": {"key": "mailNotificationsEnabled", "type": "bool"}, "reminder_notifications_enabled": {"key": "reminderNotificationsEnabled", "type": "bool"}, "default_decision_enabled": {"key": "defaultDecisionEnabled", "type": "bool"}, "justification_required_on_approval": {"key": "justificationRequiredOnApproval", "type": "bool"}, "default_decision": {"key": "defaultDecision", "type": "str"}, "auto_apply_decisions_enabled": {"key": "autoApplyDecisionsEnabled", "type": "bool"}, "recommendations_enabled": {"key": "recommendationsEnabled", "type": "bool"}, "recommendation_look_back_duration": {"key": "recommendationLookBackDuration", "type": "duration"}, "instance_duration_in_days": {"key": "instanceDurationInDays", "type": "int"}, "type_recurrence_range_type": {"key": "recurrence.range.type", "type": "str"}, "number_of_occurrences": {"key": "recurrence.range.numberOfOccurrences", "type": "int"}, "start_date": {"key": "recurrence.range.startDate", "type": "iso-8601"}, "end_date": {"key": "recurrence.range.endDate", "type": "iso-8601"}, "type_recurrence_pattern_type": {"key": "recurrence.pattern.type", "type": "str"}, "interval": {"key": "recurrence.pattern.interval", "type": "int"}, } def __init__( self, *, mail_notifications_enabled: Optional[bool] = None, reminder_notifications_enabled: Optional[bool] = None, default_decision_enabled: Optional[bool] = None, justification_required_on_approval: Optional[bool] = None, default_decision: Optional[Union[str, "_models.DefaultDecisionType"]] = None, auto_apply_decisions_enabled: Optional[bool] = None, recommendations_enabled: Optional[bool] = None, recommendation_look_back_duration: Optional[datetime.timedelta] = None, instance_duration_in_days: Optional[int] = None, type_recurrence_range_type: Optional[Union[str, "_models.AccessReviewRecurrenceRangeType"]] = None, number_of_occurrences: Optional[int] = None, start_date: Optional[datetime.datetime] = None, end_date: Optional[datetime.datetime] = None, type_recurrence_pattern_type: Optional[Union[str, "_models.AccessReviewRecurrencePatternType"]] = None, interval: Optional[int] = None, **kwargs: Any ) -> None: """ :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. :paramtype mail_notifications_enabled: bool :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. :paramtype reminder_notifications_enabled: bool :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. :paramtype default_decision_enabled: bool :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. :paramtype justification_required_on_approval: bool :keyword default_decision: This specifies the behavior for the autoReview feature when an access review completes. Known values are: "Approve", "Deny", and "Recommendation". :paramtype default_decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.DefaultDecisionType :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. :paramtype auto_apply_decisions_enabled: bool :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is enabled. :paramtype recommendations_enabled: bool :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in some scenarios, customers want to change how far back to look at and want to configure 60 days, 90 days, etc. instead. This setting allows customers to configure this duration. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype recommendation_look_back_duration: ~datetime.timedelta :keyword instance_duration_in_days: The duration in days for an instance. :paramtype instance_duration_in_days: int :keyword type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Known values are: "endDate", "noEnd", and "numbered". :paramtype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrenceRangeType :keyword number_of_occurrences: The number of times to repeat the access review. Required and must be positive if type is numbered. :paramtype number_of_occurrences: int :keyword start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. :paramtype start_date: ~datetime.datetime :keyword end_date: The DateTime when the review is scheduled to end. Required if type is endDate. :paramtype end_date: ~datetime.datetime :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Known values are: "weekly" and "absoluteMonthly". :paramtype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewRecurrencePatternType :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for type : absoluteMonthly. :paramtype interval: int """ super().__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled self.default_decision_enabled = default_decision_enabled self.justification_required_on_approval = justification_required_on_approval self.default_decision = default_decision self.auto_apply_decisions_enabled = auto_apply_decisions_enabled self.recommendations_enabled = recommendations_enabled self.recommendation_look_back_duration = recommendation_look_back_duration self.instance_duration_in_days = instance_duration_in_days self.type_recurrence_range_type = type_recurrence_range_type self.number_of_occurrences = number_of_occurrences self.start_date = start_date self.end_date = end_date self.type_recurrence_pattern_type = type_recurrence_pattern_type self.interval = interval class AccessReviewScope(_serialization.Model): """Descriptor for what needs to be reviewed. Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str :ivar role_definition_id: This is used to indicate the role being reviewed. :vartype role_definition_id: str :ivar principal_type: The identity type user/servicePrincipal to review. Known values are: "user", "guestUser", "servicePrincipal", "user,group", and "redeemedGuestUser". :vartype principal_type: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopePrincipalType :ivar assignment_state: The role assignment state eligible/active to review. Known values are: "eligible" and "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.AccessReviewScopeAssignmentState :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :vartype inactive_duration: ~datetime.timedelta :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :vartype expand_nested_memberships: bool :ivar include_inherited_access: Flag to indicate whether to expand nested memberships or not. :vartype include_inherited_access: bool :ivar include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :vartype include_access_below_resource: bool :ivar exclude_resource_id: This is used to indicate the resource id(s) to exclude. :vartype exclude_resource_id: str :ivar exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :vartype exclude_role_definition_id: str """ _validation = { "resource_id": {"readonly": True}, "role_definition_id": {"readonly": True}, "principal_type": {"readonly": True}, "assignment_state": {"readonly": True}, } _attribute_map = { "resource_id": {"key": "resourceId", "type": "str"}, "role_definition_id": {"key": "roleDefinitionId", "type": "str"}, "principal_type": {"key": "principalType", "type": "str"}, "assignment_state": {"key": "assignmentState", "type": "str"}, "inactive_duration": {"key": "inactiveDuration", "type": "duration"}, "expand_nested_memberships": {"key": "expandNestedMemberships", "type": "bool"}, "include_inherited_access": {"key": "includeInheritedAccess", "type": "bool"}, "include_access_below_resource": {"key": "includeAccessBelowResource", "type": "bool"}, "exclude_resource_id": {"key": "excludeResourceId", "type": "str"}, "exclude_role_definition_id": {"key": "excludeRoleDefinitionId", "type": "str"}, } def __init__( self, *, inactive_duration: Optional[datetime.timedelta] = None, expand_nested_memberships: Optional[bool] = None, include_inherited_access: Optional[bool] = None, include_access_below_resource: Optional[bool] = None, exclude_resource_id: Optional[str] = None, exclude_role_definition_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). :paramtype inactive_duration: ~datetime.timedelta :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. :paramtype expand_nested_memberships: bool :keyword include_inherited_access: Flag to indicate whether to expand nested memberships or not. :paramtype include_inherited_access: bool :keyword include_access_below_resource: Flag to indicate whether to expand nested memberships or not. :paramtype include_access_below_resource: bool :keyword exclude_resource_id: This is used to indicate the resource id(s) to exclude. :paramtype exclude_resource_id: str :keyword exclude_role_definition_id: This is used to indicate the role definition id(s) to exclude. :paramtype exclude_role_definition_id: str """ super().__init__(**kwargs) self.resource_id = None self.role_definition_id = None self.principal_type = None self.assignment_state = None self.inactive_duration = inactive_duration self.expand_nested_memberships = expand_nested_memberships self.include_inherited_access = include_inherited_access self.include_access_below_resource = include_access_below_resource self.exclude_resource_id = exclude_resource_id self.exclude_role_definition_id = exclude_role_definition_id class ErrorDefinition(_serialization.Model): """Error description and code explaining why an operation failed. :ivar error: Error of the list gateway status. :vartype error: ~azure.mgmt.authorization.v2021_12_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { "error": {"key": "error", "type": "ErrorDefinitionProperties"}, } def __init__(self, *, error: Optional["_models.ErrorDefinitionProperties"] = None, **kwargs: Any) -> None: """ :keyword error: Error of the list gateway status. :paramtype error: ~azure.mgmt.authorization.v2021_12_01_preview.models.ErrorDefinitionProperties """ super().__init__(**kwargs) self.error = error class ErrorDefinitionProperties(_serialization.Model): """Error description and code explaining why an operation failed. Variables are only populated by the server, and will be ignored when sending a request. :ivar message: Description of the error. :vartype message: str :ivar code: Error code of list gateway. :vartype code: str """ _validation = { "message": {"readonly": True}, } _attribute_map = { "message": {"key": "message", "type": "str"}, "code": {"key": "code", "type": "str"}, } def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code of list gateway. :paramtype code: str """ super().__init__(**kwargs) self.message = None self.code = code class Operation(_serialization.Model): """The definition of a Microsoft.Authorization operation. :ivar name: Name of the operation. :vartype name: str :ivar is_data_action: Indicates whether the operation is a data action. :vartype is_data_action: bool :ivar display: Display of the operation. :vartype display: ~azure.mgmt.authorization.v2021_12_01_preview.models.OperationDisplay :ivar origin: Origin of the operation. :vartype origin: str """ _attribute_map = { "name": {"key": "name", "type": "str"}, "is_data_action": {"key": "isDataAction", "type": "bool"}, "display": {"key": "display", "type": "OperationDisplay"}, "origin": {"key": "origin", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword name: Name of the operation. :paramtype name: str :keyword is_data_action: Indicates whether the operation is a data action. :paramtype is_data_action: bool :keyword display: Display of the operation. :paramtype display: ~azure.mgmt.authorization.v2021_12_01_preview.models.OperationDisplay :keyword origin: Origin of the operation. :paramtype origin: str """ super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.origin = origin class OperationDisplay(_serialization.Model): """The display information for a Microsoft.Authorization operation. Variables are only populated by the server, and will be ignored when sending a request. :ivar provider: The resource provider name: Microsoft.Authorization. :vartype provider: str :ivar resource: The resource on which the operation is performed. :vartype resource: str :ivar operation: The operation that users can perform. :vartype operation: str :ivar description: The description for the operation. :vartype description: str """ _validation = { "provider": {"readonly": True}, "resource": {"readonly": True}, "operation": {"readonly": True}, "description": {"readonly": True}, } _attribute_map = { "provider": {"key": "provider", "type": "str"}, "resource": {"key": "resource", "type": "str"}, "operation": {"key": "operation", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None class OperationListResult(_serialization.Model): """The result of a request to list Microsoft.Authorization operations. :ivar value: The collection value. :vartype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] :ivar next_link: The URI that can be used to request the next set of paged results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Operation]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: The collection value. :paramtype value: list[~azure.mgmt.authorization.v2021_12_01_preview.models.Operation] :keyword next_link: The URI that can be used to request the next set of paged results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RecordAllDecisionsProperties(_serialization.Model): """Record All Decisions payload. Variables are only populated by the server, and will be ignored when sending a request. :ivar principal_id: The id of principal which needs to be approved/denied. :vartype principal_id: str :ivar resource_id: The id of resource which needs to be approved/denied. :vartype resource_id: str :ivar decision: The decision to make. Approvers can take action of Approve/Deny. Known values are: "Approve" and "Deny". :vartype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsResult :ivar justification: Justification provided by approvers for their action. :vartype justification: str """ _validation = { "principal_id": {"readonly": True}, "resource_id": {"readonly": True}, } _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "resource_id": {"key": "resourceId", "type": "str"}, "decision": {"key": "decision", "type": "str"}, "justification": {"key": "justification", "type": "str"}, } def __init__( self, *, decision: Optional[Union[str, "_models.RecordAllDecisionsResult"]] = None, justification: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword decision: The decision to make. Approvers can take action of Approve/Deny. Known values are: "Approve" and "Deny". :paramtype decision: str or ~azure.mgmt.authorization.v2021_12_01_preview.models.RecordAllDecisionsResult :keyword justification: Justification provided by approvers for their action. :paramtype justification: str """ super().__init__(**kwargs) self.principal_id = None self.resource_id = None self.decision = decision self.justification = justification
0.816223
0.221761
from ._models_py3 import AccessReviewContactedReviewer from ._models_py3 import AccessReviewContactedReviewerListResult from ._models_py3 import AccessReviewDecision from ._models_py3 import AccessReviewDecisionIdentity from ._models_py3 import AccessReviewDecisionInsight from ._models_py3 import AccessReviewDecisionInsightProperties from ._models_py3 import AccessReviewDecisionListResult from ._models_py3 import AccessReviewDecisionProperties from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity from ._models_py3 import AccessReviewDecisionUserIdentity from ._models_py3 import AccessReviewDecisionUserSignInInsightProperties from ._models_py3 import AccessReviewDefaultSettings from ._models_py3 import AccessReviewHistoryDefinition from ._models_py3 import AccessReviewHistoryDefinitionInstanceListResult from ._models_py3 import AccessReviewHistoryDefinitionListResult from ._models_py3 import AccessReviewHistoryDefinitionProperties from ._models_py3 import AccessReviewHistoryInstance from ._models_py3 import AccessReviewInstance from ._models_py3 import AccessReviewInstanceListResult from ._models_py3 import AccessReviewInstanceProperties from ._models_py3 import AccessReviewReviewer from ._models_py3 import AccessReviewScheduleDefinition from ._models_py3 import AccessReviewScheduleDefinitionListResult from ._models_py3 import AccessReviewScheduleDefinitionProperties from ._models_py3 import AccessReviewScheduleSettings from ._models_py3 import AccessReviewScope from ._models_py3 import ErrorDefinition from ._models_py3 import ErrorDefinitionProperties from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._models_py3 import RecordAllDecisionsProperties from ._authorization_management_client_enums import AccessRecommendationType from ._authorization_management_client_enums import AccessReviewActorIdentityType from ._authorization_management_client_enums import AccessReviewApplyResult from ._authorization_management_client_enums import AccessReviewDecisionInsightType from ._authorization_management_client_enums import AccessReviewDecisionPrincipalResourceMembershipType from ._authorization_management_client_enums import AccessReviewHistoryDefinitionStatus from ._authorization_management_client_enums import AccessReviewInstanceReviewersType from ._authorization_management_client_enums import AccessReviewInstanceStatus from ._authorization_management_client_enums import AccessReviewRecurrencePatternType from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType from ._authorization_management_client_enums import AccessReviewResult from ._authorization_management_client_enums import AccessReviewReviewerType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus from ._authorization_management_client_enums import AccessReviewScopeAssignmentState from ._authorization_management_client_enums import AccessReviewScopePrincipalType from ._authorization_management_client_enums import DecisionResourceType from ._authorization_management_client_enums import DecisionTargetType from ._authorization_management_client_enums import DefaultDecisionType from ._authorization_management_client_enums import RecordAllDecisionsResult from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AccessReviewContactedReviewer", "AccessReviewContactedReviewerListResult", "AccessReviewDecision", "AccessReviewDecisionIdentity", "AccessReviewDecisionInsight", "AccessReviewDecisionInsightProperties", "AccessReviewDecisionListResult", "AccessReviewDecisionProperties", "AccessReviewDecisionServicePrincipalIdentity", "AccessReviewDecisionUserIdentity", "AccessReviewDecisionUserSignInInsightProperties", "AccessReviewDefaultSettings", "AccessReviewHistoryDefinition", "AccessReviewHistoryDefinitionInstanceListResult", "AccessReviewHistoryDefinitionListResult", "AccessReviewHistoryDefinitionProperties", "AccessReviewHistoryInstance", "AccessReviewInstance", "AccessReviewInstanceListResult", "AccessReviewInstanceProperties", "AccessReviewReviewer", "AccessReviewScheduleDefinition", "AccessReviewScheduleDefinitionListResult", "AccessReviewScheduleDefinitionProperties", "AccessReviewScheduleSettings", "AccessReviewScope", "ErrorDefinition", "ErrorDefinitionProperties", "Operation", "OperationDisplay", "OperationListResult", "RecordAllDecisionsProperties", "AccessRecommendationType", "AccessReviewActorIdentityType", "AccessReviewApplyResult", "AccessReviewDecisionInsightType", "AccessReviewDecisionPrincipalResourceMembershipType", "AccessReviewHistoryDefinitionStatus", "AccessReviewInstanceReviewersType", "AccessReviewInstanceStatus", "AccessReviewRecurrencePatternType", "AccessReviewRecurrenceRangeType", "AccessReviewResult", "AccessReviewReviewerType", "AccessReviewScheduleDefinitionReviewersType", "AccessReviewScheduleDefinitionStatus", "AccessReviewScopeAssignmentState", "AccessReviewScopePrincipalType", "DecisionResourceType", "DecisionTargetType", "DefaultDecisionType", "RecordAllDecisionsResult", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2021_12_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 AccessReviewDecisionInsight from ._models_py3 import AccessReviewDecisionInsightProperties from ._models_py3 import AccessReviewDecisionListResult from ._models_py3 import AccessReviewDecisionProperties from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity from ._models_py3 import AccessReviewDecisionUserIdentity from ._models_py3 import AccessReviewDecisionUserSignInInsightProperties from ._models_py3 import AccessReviewDefaultSettings from ._models_py3 import AccessReviewHistoryDefinition from ._models_py3 import AccessReviewHistoryDefinitionInstanceListResult from ._models_py3 import AccessReviewHistoryDefinitionListResult from ._models_py3 import AccessReviewHistoryDefinitionProperties from ._models_py3 import AccessReviewHistoryInstance from ._models_py3 import AccessReviewInstance from ._models_py3 import AccessReviewInstanceListResult from ._models_py3 import AccessReviewInstanceProperties from ._models_py3 import AccessReviewReviewer from ._models_py3 import AccessReviewScheduleDefinition from ._models_py3 import AccessReviewScheduleDefinitionListResult from ._models_py3 import AccessReviewScheduleDefinitionProperties from ._models_py3 import AccessReviewScheduleSettings from ._models_py3 import AccessReviewScope from ._models_py3 import ErrorDefinition from ._models_py3 import ErrorDefinitionProperties from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult from ._models_py3 import RecordAllDecisionsProperties from ._authorization_management_client_enums import AccessRecommendationType from ._authorization_management_client_enums import AccessReviewActorIdentityType from ._authorization_management_client_enums import AccessReviewApplyResult from ._authorization_management_client_enums import AccessReviewDecisionInsightType from ._authorization_management_client_enums import AccessReviewDecisionPrincipalResourceMembershipType from ._authorization_management_client_enums import AccessReviewHistoryDefinitionStatus from ._authorization_management_client_enums import AccessReviewInstanceReviewersType from ._authorization_management_client_enums import AccessReviewInstanceStatus from ._authorization_management_client_enums import AccessReviewRecurrencePatternType from ._authorization_management_client_enums import AccessReviewRecurrenceRangeType from ._authorization_management_client_enums import AccessReviewResult from ._authorization_management_client_enums import AccessReviewReviewerType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionReviewersType from ._authorization_management_client_enums import AccessReviewScheduleDefinitionStatus from ._authorization_management_client_enums import AccessReviewScopeAssignmentState from ._authorization_management_client_enums import AccessReviewScopePrincipalType from ._authorization_management_client_enums import DecisionResourceType from ._authorization_management_client_enums import DecisionTargetType from ._authorization_management_client_enums import DefaultDecisionType from ._authorization_management_client_enums import RecordAllDecisionsResult from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AccessReviewContactedReviewer", "AccessReviewContactedReviewerListResult", "AccessReviewDecision", "AccessReviewDecisionIdentity", "AccessReviewDecisionInsight", "AccessReviewDecisionInsightProperties", "AccessReviewDecisionListResult", "AccessReviewDecisionProperties", "AccessReviewDecisionServicePrincipalIdentity", "AccessReviewDecisionUserIdentity", "AccessReviewDecisionUserSignInInsightProperties", "AccessReviewDefaultSettings", "AccessReviewHistoryDefinition", "AccessReviewHistoryDefinitionInstanceListResult", "AccessReviewHistoryDefinitionListResult", "AccessReviewHistoryDefinitionProperties", "AccessReviewHistoryInstance", "AccessReviewInstance", "AccessReviewInstanceListResult", "AccessReviewInstanceProperties", "AccessReviewReviewer", "AccessReviewScheduleDefinition", "AccessReviewScheduleDefinitionListResult", "AccessReviewScheduleDefinitionProperties", "AccessReviewScheduleSettings", "AccessReviewScope", "ErrorDefinition", "ErrorDefinitionProperties", "Operation", "OperationDisplay", "OperationListResult", "RecordAllDecisionsProperties", "AccessRecommendationType", "AccessReviewActorIdentityType", "AccessReviewApplyResult", "AccessReviewDecisionInsightType", "AccessReviewDecisionPrincipalResourceMembershipType", "AccessReviewHistoryDefinitionStatus", "AccessReviewInstanceReviewersType", "AccessReviewInstanceStatus", "AccessReviewRecurrencePatternType", "AccessReviewRecurrenceRangeType", "AccessReviewResult", "AccessReviewReviewerType", "AccessReviewScheduleDefinitionReviewersType", "AccessReviewScheduleDefinitionStatus", "AccessReviewScopeAssignmentState", "AccessReviewScopePrincipalType", "DecisionResourceType", "DecisionTargetType", "DefaultDecisionType", "RecordAllDecisionsResult", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.363421
0.075448
from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): def __init__(self, *args, **kwargs): """This is a fake class to support current implemetation of MultiApiClientMixin." Will be removed in final version of multiapi azure-core based client """ pass class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. This ready contains multiple API versions, to help you deal with all of the Azure clouds (Azure Stack, Azure Government, Azure China, etc.). By default, it uses the latest API version available on public Azure. For production, you should stick to a particular api-version and/or profile. The profile sets a mapping between an operation group and its API version. The api-version parameter sets the default API version if the operation group is not described in the profile. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str :param base_url: Service URL :type base_url: str :param profile: A profile definition, from KnownProfiles to dict. :type profile: azure.profiles.KnownProfiles :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ DEFAULT_API_VERSION = '2022-04-01' _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, 'access_review_default_settings': '2021-12-01-preview', 'access_review_history_definition': '2021-12-01-preview', 'access_review_history_definition_instance': '2021-12-01-preview', 'access_review_history_definition_instances': '2021-12-01-preview', 'access_review_history_definitions': '2021-12-01-preview', 'access_review_instance': '2021-12-01-preview', 'access_review_instance_contacted_reviewers': '2021-12-01-preview', 'access_review_instance_decisions': '2021-12-01-preview', 'access_review_instance_my_decisions': '2021-12-01-preview', 'access_review_instances': '2021-12-01-preview', 'access_review_instances_assigned_for_my_approval': '2021-12-01-preview', 'access_review_schedule_definitions': '2021-12-01-preview', 'access_review_schedule_definitions_assigned_for_my_approval': '2021-12-01-preview', 'classic_administrators': '2015-07-01', 'eligible_child_resources': '2020-10-01', 'global_administrator': '2015-07-01', 'operations': '2021-12-01-preview', 'role_assignment_approval': '2021-01-01-preview', 'role_assignment_approval_step': '2021-01-01-preview', 'role_assignment_approval_steps': '2021-01-01-preview', 'role_assignment_metrics': '2019-08-01-preview', 'role_assignment_schedule_instances': '2020-10-01', 'role_assignment_schedule_requests': '2020-10-01', 'role_assignment_schedules': '2020-10-01', 'role_eligibility_schedule_instances': '2020-10-01', 'role_eligibility_schedule_requests': '2020-10-01', 'role_eligibility_schedules': '2020-10-01', 'role_management_policies': '2020-10-01', 'role_management_policy_assignments': '2020-10-01', 'scope_access_review_default_settings': '2021-12-01-preview', 'scope_access_review_history_definition': '2021-12-01-preview', 'scope_access_review_history_definition_instance': '2021-12-01-preview', 'scope_access_review_history_definition_instances': '2021-12-01-preview', 'scope_access_review_history_definitions': '2021-12-01-preview', 'scope_access_review_instance': '2021-12-01-preview', 'scope_access_review_instance_contacted_reviewers': '2021-12-01-preview', 'scope_access_review_instance_decisions': '2021-12-01-preview', 'scope_access_review_instances': '2021-12-01-preview', 'scope_access_review_schedule_definitions': '2021-12-01-preview', 'scope_role_assignment_approval': '2021-01-01-preview', 'scope_role_assignment_approval_step': '2021-01-01-preview', 'scope_role_assignment_approval_steps': '2021-01-01-preview', 'tenant_level_access_review_instance_contacted_reviewers': '2021-12-01-preview', }}, _PROFILE_TAG + " latest" ) def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: if api_version: kwargs.setdefault('api_version', api_version) self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, profile=profile ) @classmethod def _models_dict(cls, api_version): return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} @classmethod def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-06-01: :mod:`v2015_06_01.models<azure.mgmt.authorization.v2015_06_01.models>` * 2015-07-01: :mod:`v2015_07_01.models<azure.mgmt.authorization.v2015_07_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.authorization.v2018_01_01_preview.models>` * 2018-05-01-preview: :mod:`v2018_05_01_preview.models<azure.mgmt.authorization.v2018_05_01_preview.models>` * 2018-07-01-preview: :mod:`v2018_07_01_preview.models<azure.mgmt.authorization.v2018_07_01_preview.models>` * 2018-09-01-preview: :mod:`v2018_09_01_preview.models<azure.mgmt.authorization.v2018_09_01_preview.models>` * 2019-08-01-preview: :mod:`v2019_08_01_preview.models<azure.mgmt.authorization.v2019_08_01_preview.models>` * 2020-04-01-preview: :mod:`v2020_04_01_preview.models<azure.mgmt.authorization.v2020_04_01_preview.models>` * 2020-10-01: :mod:`v2020_10_01.models<azure.mgmt.authorization.v2020_10_01.models>` * 2020-10-01-preview: :mod:`v2020_10_01_preview.models<azure.mgmt.authorization.v2020_10_01_preview.models>` * 2021-01-01-preview: :mod:`v2021_01_01_preview.models<azure.mgmt.authorization.v2021_01_01_preview.models>` * 2021-03-01-preview: :mod:`v2021_03_01_preview.models<azure.mgmt.authorization.v2021_03_01_preview.models>` * 2021-07-01-preview: :mod:`v2021_07_01_preview.models<azure.mgmt.authorization.v2021_07_01_preview.models>` * 2021-12-01-preview: :mod:`v2021_12_01_preview.models<azure.mgmt.authorization.v2021_12_01_preview.models>` * 2022-04-01: :mod:`v2022_04_01.models<azure.mgmt.authorization.v2022_04_01.models>` * 2022-04-01-preview: :mod:`v2022_04_01_preview.models<azure.mgmt.authorization.v2022_04_01_preview.models>` * 2022-05-01-preview: :mod:`v2022_05_01_preview.models<azure.mgmt.authorization.v2022_05_01_preview.models>` * 2022-08-01-preview: :mod:`v2022_08_01_preview.models<azure.mgmt.authorization.v2022_08_01_preview.models>` """ if api_version == '2015-06-01': from ..v2015_06_01 import models return models elif api_version == '2015-07-01': from ..v2015_07_01 import models return models elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview import models return models elif api_version == '2018-05-01-preview': from ..v2018_05_01_preview import models return models elif api_version == '2018-07-01-preview': from ..v2018_07_01_preview import models return models elif api_version == '2018-09-01-preview': from ..v2018_09_01_preview import models return models elif api_version == '2019-08-01-preview': from ..v2019_08_01_preview import models return models elif api_version == '2020-04-01-preview': from ..v2020_04_01_preview import models return models elif api_version == '2020-10-01': from ..v2020_10_01 import models return models elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview import models return models elif api_version == '2021-01-01-preview': from ..v2021_01_01_preview import models return models elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview import models return models elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview import models return models elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview import models return models elif api_version == '2022-04-01': from ..v2022_04_01 import models return models elif api_version == '2022-04-01-preview': from ..v2022_04_01_preview import models return models elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview import models return models elif api_version == '2022-08-01-preview': from ..v2022_08_01_preview import models return models raise ValueError("API version {} is not available".format(api_version)) @property def access_review_default_settings(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` * 2021-07-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` * 2021-12-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` """ api_version = self._get_api_version('access_review_default_settings') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_default_settings'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definition(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionOperations>` """ api_version = self._get_api_version('access_review_history_definition') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definition'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definition_instance(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstanceOperations>` """ api_version = self._get_api_version('access_review_history_definition_instance') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definition_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definition_instances(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstancesOperations>` """ api_version = self._get_api_version('access_review_history_definition_instances') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definition_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definitions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionsOperations>` """ api_version = self._get_api_version('access_review_history_definitions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceOperations>` * 2021-03-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceOperations>` * 2021-07-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceOperations>` """ api_version = self._get_api_version('access_review_instance') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance_contacted_reviewers(self): """Instance depends on the API version: * 2021-07-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations>` """ api_version = self._get_api_version('access_review_instance_contacted_reviewers') if api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_contacted_reviewers'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance_decisions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` * 2021-03-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` * 2021-07-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` """ api_version = self._get_api_version('access_review_instance_decisions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_decisions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance_my_decisions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` * 2021-03-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` * 2021-07-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` """ api_version = self._get_api_version('access_review_instance_my_decisions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_my_decisions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instances(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesOperations>` * 2021-03-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesOperations>` * 2021-07-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesOperations>` * 2021-12-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesOperations>` """ api_version = self._get_api_version('access_review_instances') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instances_assigned_for_my_approval(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` * 2021-03-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` * 2021-07-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` * 2021-12-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` """ api_version = self._get_api_version('access_review_instances_assigned_for_my_approval') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances_assigned_for_my_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_schedule_definitions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` """ api_version = self._get_api_version('access_review_schedule_definitions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_schedule_definitions_assigned_for_my_approval(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` """ api_version = self._get_api_version('access_review_schedule_definitions_assigned_for_my_approval') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions_assigned_for_my_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_configurations(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertConfigurationsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertConfigurationsOperations>` """ api_version = self._get_api_version('alert_configurations') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_configurations'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_definitions(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertDefinitionsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertDefinitionsOperations>` """ api_version = self._get_api_version('alert_definitions') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_incidents(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertIncidentsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertIncidentsOperations>` """ api_version = self._get_api_version('alert_incidents') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertIncidentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_incidents'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_operation(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertOperationOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertOperationOperations>` """ api_version = self._get_api_version('alert_operation') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertOperationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_operation'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alerts(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertsOperations>` """ api_version = self._get_api_version('alerts') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def classic_administrators(self): """Instance depends on the API version: * 2015-06-01: :class:`ClassicAdministratorsOperations<azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations>` * 2015-07-01: :class:`ClassicAdministratorsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.ClassicAdministratorsOperations>` """ api_version = self._get_api_version('classic_administrators') if api_version == '2015-06-01': from ..v2015_06_01.aio.operations import ClassicAdministratorsOperations as OperationClass elif api_version == '2015-07-01': from ..v2015_07_01.aio.operations import ClassicAdministratorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'classic_administrators'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def deny_assignments(self): """Instance depends on the API version: * 2018-07-01-preview: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations>` * 2022-04-01: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.DenyAssignmentsOperations>` """ api_version = self._get_api_version('deny_assignments') if api_version == '2018-07-01-preview': from ..v2018_07_01_preview.aio.operations import DenyAssignmentsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import DenyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deny_assignments'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def eligible_child_resources(self): """Instance depends on the API version: * 2020-10-01: :class:`EligibleChildResourcesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.EligibleChildResourcesOperations>` * 2020-10-01-preview: :class:`EligibleChildResourcesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.EligibleChildResourcesOperations>` """ api_version = self._get_api_version('eligible_child_resources') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import EligibleChildResourcesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import EligibleChildResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'eligible_child_resources'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def global_administrator(self): """Instance depends on the API version: * 2015-07-01: :class:`GlobalAdministratorOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.GlobalAdministratorOperations>` """ api_version = self._get_api_version('global_administrator') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import GlobalAdministratorOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'global_administrator'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`Operations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.Operations>` * 2021-01-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.Operations>` * 2021-03-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.Operations>` * 2021-07-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.Operations>` * 2021-12-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.Operations>` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def permissions(self): """Instance depends on the API version: * 2015-07-01: :class:`PermissionsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.PermissionsOperations>` * 2018-01-01-preview: :class:`PermissionsOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.PermissionsOperations>` * 2022-04-01: :class:`PermissionsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.PermissionsOperations>` * 2022-05-01-preview: :class:`PermissionsOperations<azure.mgmt.authorization.v2022_05_01_preview.aio.operations.PermissionsOperations>` """ api_version = self._get_api_version('permissions') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import PermissionsOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import PermissionsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import PermissionsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import PermissionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'permissions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def provider_operations_metadata(self): """Instance depends on the API version: * 2015-07-01: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.ProviderOperationsMetadataOperations>` * 2018-01-01-preview: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.ProviderOperationsMetadataOperations>` * 2022-04-01: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.ProviderOperationsMetadataOperations>` """ api_version = self._get_api_version('provider_operations_metadata') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import ProviderOperationsMetadataOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import ProviderOperationsMetadataOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import ProviderOperationsMetadataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'provider_operations_metadata'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_approval(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`RoleAssignmentApprovalOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalOperations>` """ api_version = self._get_api_version('role_assignment_approval') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_approval_step(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepOperations>` """ api_version = self._get_api_version('role_assignment_approval_step') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalStepOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_approval_step'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_approval_steps(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepsOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepsOperations>` """ api_version = self._get_api_version('role_assignment_approval_steps') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalStepsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_approval_steps'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_metrics(self): """Instance depends on the API version: * 2019-08-01-preview: :class:`RoleAssignmentMetricsOperations<azure.mgmt.authorization.v2019_08_01_preview.aio.operations.RoleAssignmentMetricsOperations>` """ api_version = self._get_api_version('role_assignment_metrics') if api_version == '2019-08-01-preview': from ..v2019_08_01_preview.aio.operations import RoleAssignmentMetricsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_metrics'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_schedule_instances(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleAssignmentScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleInstancesOperations>` * 2020-10-01-preview: :class:`RoleAssignmentScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleInstancesOperations>` """ api_version = self._get_api_version('role_assignment_schedule_instances') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_schedule_requests(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleRequestsOperations>` * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations>` * 2022-04-01-preview: :class:`RoleAssignmentScheduleRequestsOperations<azure.mgmt.authorization.v2022_04_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations>` """ api_version = self._get_api_version('role_assignment_schedule_requests') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass elif api_version == '2022-04-01-preview': from ..v2022_04_01_preview.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_schedules(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleAssignmentSchedulesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentSchedulesOperations>` * 2020-10-01-preview: :class:`RoleAssignmentSchedulesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentSchedulesOperations>` """ api_version = self._get_api_version('role_assignment_schedules') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleAssignmentSchedulesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentSchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedules'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignments(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.RoleAssignmentsOperations>` * 2018-01-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleAssignmentsOperations>` * 2018-09-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations>` * 2020-04-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations>` * 2020-10-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentsOperations>` * 2022-04-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.RoleAssignmentsOperations>` """ api_version = self._get_api_version('role_assignments') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-09-01-preview': from ..v2018_09_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2020-04-01-preview': from ..v2020_04_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import RoleAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignments'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_definitions(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.RoleDefinitionsOperations>` * 2018-01-01-preview: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleDefinitionsOperations>` * 2022-04-01: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.RoleDefinitionsOperations>` * 2022-05-01-preview: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2022_05_01_preview.aio.operations.RoleDefinitionsOperations>` """ api_version = self._get_api_version('role_definitions') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import RoleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_eligibility_schedule_instances(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleEligibilityScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleInstancesOperations>` * 2020-10-01-preview: :class:`RoleEligibilityScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleInstancesOperations>` """ api_version = self._get_api_version('role_eligibility_schedule_instances') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_eligibility_schedule_requests(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleRequestsOperations>` * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations>` * 2022-04-01-preview: :class:`RoleEligibilityScheduleRequestsOperations<azure.mgmt.authorization.v2022_04_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations>` """ api_version = self._get_api_version('role_eligibility_schedule_requests') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass elif api_version == '2022-04-01-preview': from ..v2022_04_01_preview.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_eligibility_schedules(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleEligibilitySchedulesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilitySchedulesOperations>` * 2020-10-01-preview: :class:`RoleEligibilitySchedulesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilitySchedulesOperations>` """ api_version = self._get_api_version('role_eligibility_schedules') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleEligibilitySchedulesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilitySchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedules'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_management_policies(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleManagementPoliciesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPoliciesOperations>` * 2020-10-01-preview: :class:`RoleManagementPoliciesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPoliciesOperations>` """ api_version = self._get_api_version('role_management_policies') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleManagementPoliciesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policies'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_management_policy_assignments(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleManagementPolicyAssignmentsOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPolicyAssignmentsOperations>` * 2020-10-01-preview: :class:`RoleManagementPolicyAssignmentsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPolicyAssignmentsOperations>` """ api_version = self._get_api_version('role_management_policy_assignments') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policy_assignments'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_default_settings(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewDefaultSettingsOperations>` """ api_version = self._get_api_version('scope_access_review_default_settings') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewDefaultSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_default_settings'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definition(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionOperations>` """ api_version = self._get_api_version('scope_access_review_history_definition') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definition_instance(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations>` """ api_version = self._get_api_version('scope_access_review_history_definition_instance') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definition_instances(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations>` """ api_version = self._get_api_version('scope_access_review_history_definition_instances') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definitions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionsOperations>` """ api_version = self._get_api_version('scope_access_review_history_definitions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instance(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceOperations>` """ api_version = self._get_api_version('scope_access_review_instance') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instance_contacted_reviewers(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceContactedReviewersOperations>` """ api_version = self._get_api_version('scope_access_review_instance_contacted_reviewers') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceContactedReviewersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instance_contacted_reviewers'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instance_decisions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceDecisionsOperations>` """ api_version = self._get_api_version('scope_access_review_instance_decisions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instance_decisions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instances(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstancesOperations>` """ api_version = self._get_api_version('scope_access_review_instances') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_schedule_definitions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewScheduleDefinitionsOperations>` """ api_version = self._get_api_version('scope_access_review_schedule_definitions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewScheduleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_schedule_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_role_assignment_approval(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalOperations>` """ api_version = self._get_api_version('scope_role_assignment_approval') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_role_assignment_approval_step(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepOperations>` """ api_version = self._get_api_version('scope_role_assignment_approval_step') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalStepOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_step'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_role_assignment_approval_steps(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepsOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepsOperations>` """ api_version = self._get_api_version('scope_role_assignment_approval_steps') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalStepsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def tenant_level_access_review_instance_contacted_reviewers(self): """Instance depends on the API version: * 2021-07-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations>` * 2021-12-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations>` """ api_version = self._get_api_version('tenant_level_access_review_instance_contacted_reviewers') if api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tenant_level_access_review_instance_contacted_reviewers'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) async def close(self): await self._client.close() async def __aenter__(self): await self._client.__aenter__() return self async def __aexit__(self, *exc_details): 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/aio/_authorization_management_client.py
_authorization_management_client.py
from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): def __init__(self, *args, **kwargs): """This is a fake class to support current implemetation of MultiApiClientMixin." Will be removed in final version of multiapi azure-core based client """ pass class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. This ready contains multiple API versions, to help you deal with all of the Azure clouds (Azure Stack, Azure Government, Azure China, etc.). By default, it uses the latest API version available on public Azure. For production, you should stick to a particular api-version and/or profile. The profile sets a mapping between an operation group and its API version. The api-version parameter sets the default API version if the operation group is not described in the profile. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str :param base_url: Service URL :type base_url: str :param profile: A profile definition, from KnownProfiles to dict. :type profile: azure.profiles.KnownProfiles :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ DEFAULT_API_VERSION = '2022-04-01' _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, 'access_review_default_settings': '2021-12-01-preview', 'access_review_history_definition': '2021-12-01-preview', 'access_review_history_definition_instance': '2021-12-01-preview', 'access_review_history_definition_instances': '2021-12-01-preview', 'access_review_history_definitions': '2021-12-01-preview', 'access_review_instance': '2021-12-01-preview', 'access_review_instance_contacted_reviewers': '2021-12-01-preview', 'access_review_instance_decisions': '2021-12-01-preview', 'access_review_instance_my_decisions': '2021-12-01-preview', 'access_review_instances': '2021-12-01-preview', 'access_review_instances_assigned_for_my_approval': '2021-12-01-preview', 'access_review_schedule_definitions': '2021-12-01-preview', 'access_review_schedule_definitions_assigned_for_my_approval': '2021-12-01-preview', 'classic_administrators': '2015-07-01', 'eligible_child_resources': '2020-10-01', 'global_administrator': '2015-07-01', 'operations': '2021-12-01-preview', 'role_assignment_approval': '2021-01-01-preview', 'role_assignment_approval_step': '2021-01-01-preview', 'role_assignment_approval_steps': '2021-01-01-preview', 'role_assignment_metrics': '2019-08-01-preview', 'role_assignment_schedule_instances': '2020-10-01', 'role_assignment_schedule_requests': '2020-10-01', 'role_assignment_schedules': '2020-10-01', 'role_eligibility_schedule_instances': '2020-10-01', 'role_eligibility_schedule_requests': '2020-10-01', 'role_eligibility_schedules': '2020-10-01', 'role_management_policies': '2020-10-01', 'role_management_policy_assignments': '2020-10-01', 'scope_access_review_default_settings': '2021-12-01-preview', 'scope_access_review_history_definition': '2021-12-01-preview', 'scope_access_review_history_definition_instance': '2021-12-01-preview', 'scope_access_review_history_definition_instances': '2021-12-01-preview', 'scope_access_review_history_definitions': '2021-12-01-preview', 'scope_access_review_instance': '2021-12-01-preview', 'scope_access_review_instance_contacted_reviewers': '2021-12-01-preview', 'scope_access_review_instance_decisions': '2021-12-01-preview', 'scope_access_review_instances': '2021-12-01-preview', 'scope_access_review_schedule_definitions': '2021-12-01-preview', 'scope_role_assignment_approval': '2021-01-01-preview', 'scope_role_assignment_approval_step': '2021-01-01-preview', 'scope_role_assignment_approval_steps': '2021-01-01-preview', 'tenant_level_access_review_instance_contacted_reviewers': '2021-12-01-preview', }}, _PROFILE_TAG + " latest" ) def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: if api_version: kwargs.setdefault('api_version', api_version) self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, profile=profile ) @classmethod def _models_dict(cls, api_version): return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)} @classmethod def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: * 2015-06-01: :mod:`v2015_06_01.models<azure.mgmt.authorization.v2015_06_01.models>` * 2015-07-01: :mod:`v2015_07_01.models<azure.mgmt.authorization.v2015_07_01.models>` * 2018-01-01-preview: :mod:`v2018_01_01_preview.models<azure.mgmt.authorization.v2018_01_01_preview.models>` * 2018-05-01-preview: :mod:`v2018_05_01_preview.models<azure.mgmt.authorization.v2018_05_01_preview.models>` * 2018-07-01-preview: :mod:`v2018_07_01_preview.models<azure.mgmt.authorization.v2018_07_01_preview.models>` * 2018-09-01-preview: :mod:`v2018_09_01_preview.models<azure.mgmt.authorization.v2018_09_01_preview.models>` * 2019-08-01-preview: :mod:`v2019_08_01_preview.models<azure.mgmt.authorization.v2019_08_01_preview.models>` * 2020-04-01-preview: :mod:`v2020_04_01_preview.models<azure.mgmt.authorization.v2020_04_01_preview.models>` * 2020-10-01: :mod:`v2020_10_01.models<azure.mgmt.authorization.v2020_10_01.models>` * 2020-10-01-preview: :mod:`v2020_10_01_preview.models<azure.mgmt.authorization.v2020_10_01_preview.models>` * 2021-01-01-preview: :mod:`v2021_01_01_preview.models<azure.mgmt.authorization.v2021_01_01_preview.models>` * 2021-03-01-preview: :mod:`v2021_03_01_preview.models<azure.mgmt.authorization.v2021_03_01_preview.models>` * 2021-07-01-preview: :mod:`v2021_07_01_preview.models<azure.mgmt.authorization.v2021_07_01_preview.models>` * 2021-12-01-preview: :mod:`v2021_12_01_preview.models<azure.mgmt.authorization.v2021_12_01_preview.models>` * 2022-04-01: :mod:`v2022_04_01.models<azure.mgmt.authorization.v2022_04_01.models>` * 2022-04-01-preview: :mod:`v2022_04_01_preview.models<azure.mgmt.authorization.v2022_04_01_preview.models>` * 2022-05-01-preview: :mod:`v2022_05_01_preview.models<azure.mgmt.authorization.v2022_05_01_preview.models>` * 2022-08-01-preview: :mod:`v2022_08_01_preview.models<azure.mgmt.authorization.v2022_08_01_preview.models>` """ if api_version == '2015-06-01': from ..v2015_06_01 import models return models elif api_version == '2015-07-01': from ..v2015_07_01 import models return models elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview import models return models elif api_version == '2018-05-01-preview': from ..v2018_05_01_preview import models return models elif api_version == '2018-07-01-preview': from ..v2018_07_01_preview import models return models elif api_version == '2018-09-01-preview': from ..v2018_09_01_preview import models return models elif api_version == '2019-08-01-preview': from ..v2019_08_01_preview import models return models elif api_version == '2020-04-01-preview': from ..v2020_04_01_preview import models return models elif api_version == '2020-10-01': from ..v2020_10_01 import models return models elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview import models return models elif api_version == '2021-01-01-preview': from ..v2021_01_01_preview import models return models elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview import models return models elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview import models return models elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview import models return models elif api_version == '2022-04-01': from ..v2022_04_01 import models return models elif api_version == '2022-04-01-preview': from ..v2022_04_01_preview import models return models elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview import models return models elif api_version == '2022-08-01-preview': from ..v2022_08_01_preview import models return models raise ValueError("API version {} is not available".format(api_version)) @property def access_review_default_settings(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` * 2021-07-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` * 2021-12-01-preview: :class:`AccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewDefaultSettingsOperations>` """ api_version = self._get_api_version('access_review_default_settings') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_default_settings'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definition(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionOperations>` """ api_version = self._get_api_version('access_review_history_definition') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definition'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definition_instance(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstanceOperations>` """ api_version = self._get_api_version('access_review_history_definition_instance') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definition_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definition_instances(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionInstancesOperations>` """ api_version = self._get_api_version('access_review_history_definition_instances') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definition_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_history_definitions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`AccessReviewHistoryDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewHistoryDefinitionsOperations>` """ api_version = self._get_api_version('access_review_history_definitions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewHistoryDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_history_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceOperations>` * 2021-03-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceOperations>` * 2021-07-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceOperations>` """ api_version = self._get_api_version('access_review_instance') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance_contacted_reviewers(self): """Instance depends on the API version: * 2021-07-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations>` """ api_version = self._get_api_version('access_review_instance_contacted_reviewers') if api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_contacted_reviewers'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance_decisions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` * 2021-03-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` * 2021-07-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations>` """ api_version = self._get_api_version('access_review_instance_decisions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_decisions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instance_my_decisions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` * 2021-03-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` * 2021-07-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` * 2021-12-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations>` """ api_version = self._get_api_version('access_review_instance_my_decisions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_my_decisions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instances(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesOperations>` * 2021-03-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesOperations>` * 2021-07-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesOperations>` * 2021-12-01-preview: :class:`AccessReviewInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesOperations>` """ api_version = self._get_api_version('access_review_instances') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_instances_assigned_for_my_approval(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` * 2021-03-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` * 2021-07-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` * 2021-12-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations>` """ api_version = self._get_api_version('access_review_instances_assigned_for_my_approval') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances_assigned_for_my_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_schedule_definitions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations>` """ api_version = self._get_api_version('access_review_schedule_definitions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def access_review_schedule_definitions_assigned_for_my_approval(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` * 2021-12-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations>` """ api_version = self._get_api_version('access_review_schedule_definitions_assigned_for_my_approval') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions_assigned_for_my_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_configurations(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertConfigurationsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertConfigurationsOperations>` """ api_version = self._get_api_version('alert_configurations') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertConfigurationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_configurations'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_definitions(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertDefinitionsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertDefinitionsOperations>` """ api_version = self._get_api_version('alert_definitions') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_incidents(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertIncidentsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertIncidentsOperations>` """ api_version = self._get_api_version('alert_incidents') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertIncidentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_incidents'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alert_operation(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertOperationOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertOperationOperations>` """ api_version = self._get_api_version('alert_operation') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertOperationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alert_operation'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alerts(self): """Instance depends on the API version: * 2022-08-01-preview: :class:`AlertsOperations<azure.mgmt.authorization.v2022_08_01_preview.aio.operations.AlertsOperations>` """ api_version = self._get_api_version('alerts') if api_version == '2022-08-01-preview': from ..v2022_08_01_preview.aio.operations import AlertsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def classic_administrators(self): """Instance depends on the API version: * 2015-06-01: :class:`ClassicAdministratorsOperations<azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations>` * 2015-07-01: :class:`ClassicAdministratorsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.ClassicAdministratorsOperations>` """ api_version = self._get_api_version('classic_administrators') if api_version == '2015-06-01': from ..v2015_06_01.aio.operations import ClassicAdministratorsOperations as OperationClass elif api_version == '2015-07-01': from ..v2015_07_01.aio.operations import ClassicAdministratorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'classic_administrators'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def deny_assignments(self): """Instance depends on the API version: * 2018-07-01-preview: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations>` * 2022-04-01: :class:`DenyAssignmentsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.DenyAssignmentsOperations>` """ api_version = self._get_api_version('deny_assignments') if api_version == '2018-07-01-preview': from ..v2018_07_01_preview.aio.operations import DenyAssignmentsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import DenyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deny_assignments'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def eligible_child_resources(self): """Instance depends on the API version: * 2020-10-01: :class:`EligibleChildResourcesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.EligibleChildResourcesOperations>` * 2020-10-01-preview: :class:`EligibleChildResourcesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.EligibleChildResourcesOperations>` """ api_version = self._get_api_version('eligible_child_resources') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import EligibleChildResourcesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import EligibleChildResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'eligible_child_resources'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def global_administrator(self): """Instance depends on the API version: * 2015-07-01: :class:`GlobalAdministratorOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.GlobalAdministratorOperations>` """ api_version = self._get_api_version('global_administrator') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import GlobalAdministratorOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'global_administrator'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`Operations<azure.mgmt.authorization.v2018_05_01_preview.aio.operations.Operations>` * 2021-01-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.Operations>` * 2021-03-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_03_01_preview.aio.operations.Operations>` * 2021-07-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.Operations>` * 2021-12-01-preview: :class:`Operations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.Operations>` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def permissions(self): """Instance depends on the API version: * 2015-07-01: :class:`PermissionsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.PermissionsOperations>` * 2018-01-01-preview: :class:`PermissionsOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.PermissionsOperations>` * 2022-04-01: :class:`PermissionsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.PermissionsOperations>` * 2022-05-01-preview: :class:`PermissionsOperations<azure.mgmt.authorization.v2022_05_01_preview.aio.operations.PermissionsOperations>` """ api_version = self._get_api_version('permissions') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import PermissionsOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import PermissionsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import PermissionsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import PermissionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'permissions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def provider_operations_metadata(self): """Instance depends on the API version: * 2015-07-01: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.ProviderOperationsMetadataOperations>` * 2018-01-01-preview: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.ProviderOperationsMetadataOperations>` * 2022-04-01: :class:`ProviderOperationsMetadataOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.ProviderOperationsMetadataOperations>` """ api_version = self._get_api_version('provider_operations_metadata') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import ProviderOperationsMetadataOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import ProviderOperationsMetadataOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import ProviderOperationsMetadataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'provider_operations_metadata'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_approval(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`RoleAssignmentApprovalOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalOperations>` """ api_version = self._get_api_version('role_assignment_approval') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_approval_step(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepOperations>` """ api_version = self._get_api_version('role_assignment_approval_step') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalStepOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_approval_step'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_approval_steps(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`RoleAssignmentApprovalStepsOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepsOperations>` """ api_version = self._get_api_version('role_assignment_approval_steps') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import RoleAssignmentApprovalStepsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_approval_steps'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_metrics(self): """Instance depends on the API version: * 2019-08-01-preview: :class:`RoleAssignmentMetricsOperations<azure.mgmt.authorization.v2019_08_01_preview.aio.operations.RoleAssignmentMetricsOperations>` """ api_version = self._get_api_version('role_assignment_metrics') if api_version == '2019-08-01-preview': from ..v2019_08_01_preview.aio.operations import RoleAssignmentMetricsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_metrics'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_schedule_instances(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleAssignmentScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleInstancesOperations>` * 2020-10-01-preview: :class:`RoleAssignmentScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleInstancesOperations>` """ api_version = self._get_api_version('role_assignment_schedule_instances') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_schedule_requests(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleRequestsOperations>` * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations>` * 2022-04-01-preview: :class:`RoleAssignmentScheduleRequestsOperations<azure.mgmt.authorization.v2022_04_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations>` """ api_version = self._get_api_version('role_assignment_schedule_requests') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass elif api_version == '2022-04-01-preview': from ..v2022_04_01_preview.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignment_schedules(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleAssignmentSchedulesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentSchedulesOperations>` * 2020-10-01-preview: :class:`RoleAssignmentSchedulesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentSchedulesOperations>` """ api_version = self._get_api_version('role_assignment_schedules') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleAssignmentSchedulesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentSchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedules'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_assignments(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.RoleAssignmentsOperations>` * 2018-01-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleAssignmentsOperations>` * 2018-09-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations>` * 2020-04-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations>` * 2020-10-01-preview: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentsOperations>` * 2022-04-01: :class:`RoleAssignmentsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.RoleAssignmentsOperations>` """ api_version = self._get_api_version('role_assignments') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2018-09-01-preview': from ..v2018_09_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2020-04-01-preview': from ..v2020_04_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import RoleAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignments'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_definitions(self): """Instance depends on the API version: * 2015-07-01: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2015_07_01.aio.operations.RoleDefinitionsOperations>` * 2018-01-01-preview: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleDefinitionsOperations>` * 2022-04-01: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2022_04_01.aio.operations.RoleDefinitionsOperations>` * 2022-05-01-preview: :class:`RoleDefinitionsOperations<azure.mgmt.authorization.v2022_05_01_preview.aio.operations.RoleDefinitionsOperations>` """ api_version = self._get_api_version('role_definitions') if api_version == '2015-07-01': from ..v2015_07_01.aio.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2018-01-01-preview': from ..v2018_01_01_preview.aio.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2022-04-01': from ..v2022_04_01.aio.operations import RoleDefinitionsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import RoleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_eligibility_schedule_instances(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleEligibilityScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleInstancesOperations>` * 2020-10-01-preview: :class:`RoleEligibilityScheduleInstancesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleInstancesOperations>` """ api_version = self._get_api_version('role_eligibility_schedule_instances') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_eligibility_schedule_requests(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleRequestsOperations>` * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations>` * 2022-04-01-preview: :class:`RoleEligibilityScheduleRequestsOperations<azure.mgmt.authorization.v2022_04_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations>` """ api_version = self._get_api_version('role_eligibility_schedule_requests') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass elif api_version == '2022-04-01-preview': from ..v2022_04_01_preview.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_eligibility_schedules(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleEligibilitySchedulesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilitySchedulesOperations>` * 2020-10-01-preview: :class:`RoleEligibilitySchedulesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilitySchedulesOperations>` """ api_version = self._get_api_version('role_eligibility_schedules') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleEligibilitySchedulesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilitySchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedules'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_management_policies(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleManagementPoliciesOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPoliciesOperations>` * 2020-10-01-preview: :class:`RoleManagementPoliciesOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPoliciesOperations>` """ api_version = self._get_api_version('role_management_policies') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleManagementPoliciesOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policies'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def role_management_policy_assignments(self): """Instance depends on the API version: * 2020-10-01: :class:`RoleManagementPolicyAssignmentsOperations<azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPolicyAssignmentsOperations>` * 2020-10-01-preview: :class:`RoleManagementPolicyAssignmentsOperations<azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPolicyAssignmentsOperations>` """ api_version = self._get_api_version('role_management_policy_assignments') if api_version == '2020-10-01': from ..v2020_10_01.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policy_assignments'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_default_settings(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewDefaultSettingsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewDefaultSettingsOperations>` """ api_version = self._get_api_version('scope_access_review_default_settings') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewDefaultSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_default_settings'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definition(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionOperations>` """ api_version = self._get_api_version('scope_access_review_history_definition') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definition_instance(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstanceOperations>` """ api_version = self._get_api_version('scope_access_review_history_definition_instance') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definition_instances(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionInstancesOperations>` """ api_version = self._get_api_version('scope_access_review_history_definition_instances') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definition_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_history_definitions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewHistoryDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewHistoryDefinitionsOperations>` """ api_version = self._get_api_version('scope_access_review_history_definitions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewHistoryDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_history_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instance(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceOperations>` """ api_version = self._get_api_version('scope_access_review_instance') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instance'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instance_contacted_reviewers(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceContactedReviewersOperations>` """ api_version = self._get_api_version('scope_access_review_instance_contacted_reviewers') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceContactedReviewersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instance_contacted_reviewers'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instance_decisions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstanceDecisionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstanceDecisionsOperations>` """ api_version = self._get_api_version('scope_access_review_instance_decisions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstanceDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instance_decisions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_instances(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewInstancesOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewInstancesOperations>` """ api_version = self._get_api_version('scope_access_review_instances') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_instances'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_access_review_schedule_definitions(self): """Instance depends on the API version: * 2021-12-01-preview: :class:`ScopeAccessReviewScheduleDefinitionsOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.ScopeAccessReviewScheduleDefinitionsOperations>` """ api_version = self._get_api_version('scope_access_review_schedule_definitions') if api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import ScopeAccessReviewScheduleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_access_review_schedule_definitions'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_role_assignment_approval(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalOperations>` """ api_version = self._get_api_version('scope_role_assignment_approval') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_role_assignment_approval_step(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepOperations>` """ api_version = self._get_api_version('scope_role_assignment_approval_step') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalStepOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_step'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def scope_role_assignment_approval_steps(self): """Instance depends on the API version: * 2021-01-01-preview: :class:`ScopeRoleAssignmentApprovalStepsOperations<azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepsOperations>` """ api_version = self._get_api_version('scope_role_assignment_approval_steps') if api_version == '2021-01-01-preview': from ..v2021_01_01_preview.aio.operations import ScopeRoleAssignmentApprovalStepsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def tenant_level_access_review_instance_contacted_reviewers(self): """Instance depends on the API version: * 2021-07-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_07_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations>` * 2021-12-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations<azure.mgmt.authorization.v2021_12_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations>` """ api_version = self._get_api_version('tenant_level_access_review_instance_contacted_reviewers') if api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass elif api_version == '2021-12-01-preview': from ..v2021_12_01_preview.aio.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tenant_level_access_review_instance_contacted_reviewers'".format(api_version)) self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) async def close(self): await self._client.close() async def __aenter__(self): await self._client.__aenter__() return self async def __aexit__(self, *exc_details): await self._client.__aexit__(*exc_details)
0.852445
0.138374
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) self._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/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): """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 """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) self._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.820541
0.082033
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import PermissionsOperations, RoleDefinitionsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations allow you to manage role definitions. A role definition describes the set of actions that can be performed on resources. :ivar permissions: PermissionsOperations operations :vartype permissions: azure.mgmt.authorization.v2022_05_01_preview.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations :vartype role_definitions: azure.mgmt.authorization.v2022_05_01_preview.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.permissions = PermissionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) self.role_definitions = RoleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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_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 PermissionsOperations, RoleDefinitionsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations allow you to manage role definitions. A role definition describes the set of actions that can be performed on resources. :ivar permissions: PermissionsOperations operations :vartype permissions: azure.mgmt.authorization.v2022_05_01_preview.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations :vartype role_definitions: azure.mgmt.authorization.v2022_05_01_preview.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.permissions = PermissionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) self.role_definitions = RoleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.838415
0.126704
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_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 "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.832271
0.091504
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.AuthorizationManagementClient`'s :attr:`role_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: """Get role definition by ID (GUID). :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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @overload def create_or_update( self, scope: str, role_definition_id: str, role_definition: _models.RoleDefinition, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( self, scope: str, role_definition_id: str, role_definition: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update( self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or a IO type. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(role_definition, (IOBase, bytes)): _content = role_definition else: _json = self._serialize.body(role_definition, "RoleDefinition") request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the 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 atScopeAndBelow filter to search below the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. :param role_id: The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_05_01_preview/operations/_role_definitions_operations.py
_role_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_delete_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request(scope: str, role_definition_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-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", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.AuthorizationManagementClient`'s :attr:`role_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: """Get role definition by ID (GUID). :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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @overload def create_or_update( self, scope: str, role_definition_id: str, role_definition: _models.RoleDefinition, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( self, scope: str, role_definition_id: str, role_definition: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_or_update( self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or a IO type. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(role_definition, (IOBase, bytes)): _content = role_definition else: _json = self._serialize.body(role_definition, "RoleDefinition") request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RoleDefinition"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the 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 atScopeAndBelow filter to search below the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} @distributed_trace def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. :param role_id: The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"}
0.795022
0.083217
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", pattern=r".+"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class PermissionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.AuthorizationManagementClient`'s :attr:`permissions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Permission"]: """Gets all permissions the caller has for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, **kwargs: Any ) -> Iterable["_models.Permission"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_05_01_preview/operations/_permissions_operations.py
_permissions_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_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", pattern=r".+"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class PermissionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.AuthorizationManagementClient`'s :attr:`permissions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Permission"]: """Gets all permissions the caller has for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, **kwargs: Any ) -> Iterable["_models.Permission"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" }
0.827306
0.073997
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import PermissionsOperations, RoleDefinitionsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations allow you to manage role definitions. A role definition describes the set of actions that can be performed on resources. :ivar permissions: PermissionsOperations operations :vartype permissions: azure.mgmt.authorization.v2022_05_01_preview.aio.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations :vartype role_definitions: azure.mgmt.authorization.v2022_05_01_preview.aio.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.permissions = PermissionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) self.role_definitions = RoleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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_05_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 PermissionsOperations, RoleDefinitionsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations allow you to manage role definitions. A role definition describes the set of actions that can be performed on resources. :ivar permissions: PermissionsOperations operations :vartype permissions: azure.mgmt.authorization.v2022_05_01_preview.aio.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations :vartype role_definitions: azure.mgmt.authorization.v2022_05_01_preview.aio.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.permissions = PermissionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) self.role_definitions = RoleDefinitionsOperations( self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.827584
0.132262
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_05_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 "2022-05-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2022-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.836888
0.093802
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_definitions_operations import ( build_create_or_update_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace_async async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: """Get role definition by ID (GUID). :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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @overload async def create_or_update( self, scope: str, role_definition_id: str, role_definition: _models.RoleDefinition, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update( self, scope: str, role_definition_id: str, role_definition: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update( self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or a IO type. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(role_definition, (IOBase, bytes)): _content = role_definition else: _json = self._serialize.body(role_definition, "RoleDefinition") request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the 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 atScopeAndBelow filter to search below the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. :param role_id: The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_role_definitions_operations.py
_role_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._role_definitions_operations import ( build_create_or_update_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleDefinitionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_definitions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def delete(self, scope: str, role_definition_id: str, **kwargs: Any) -> Optional[_models.RoleDefinition]: """Deletes a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition to delete. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[Optional[_models.RoleDefinition]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace_async async def get(self, scope: str, role_definition_id: str, **kwargs: Any) -> _models.RoleDefinition: """Get role definition by ID (GUID). :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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @overload async def create_or_update( self, scope: str, role_definition_id: str, role_definition: _models.RoleDefinition, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_or_update( self, scope: str, role_definition_id: str, role_definition: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Required. :type role_definition: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_or_update( self, scope: str, role_definition_id: str, role_definition: Union[_models.RoleDefinition, IO], **kwargs: Any ) -> _models.RoleDefinition: """Creates or updates a role definition. :param scope: The scope of the 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_definition_id: The ID of the role definition. Required. :type role_definition_id: str :param role_definition: The values for the role definition. Is either a RoleDefinition type or a IO type. Required. :type role_definition: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(role_definition, (IOBase, bytes)): _content = role_definition else: _json = self._serialize.body(role_definition, "RoleDefinition") request = build_create_or_update_request( scope=scope, role_definition_id=role_definition_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} @distributed_trace def list(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.RoleDefinition"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the 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 atScopeAndBelow filter to search below the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleDefinition or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinitionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} @distributed_trace_async async def get_by_id(self, role_id: str, **kwargs: Any) -> _models.RoleDefinition: """Gets a role definition by ID. :param role_id: The fully qualified role definition ID. Use the format, /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant level role definitions. Required. :type role_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleDefinition or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.RoleDefinition] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleDefinition", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"}
0.878269
0.086131
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PermissionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.aio.AuthorizationManagementClient`'s :attr:`permissions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Permission"]: """Gets all permissions the caller has for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.Permission"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_05_01_preview/aio/operations/_permissions_operations.py
_permissions_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._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PermissionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2022_05_01_preview.aio.AuthorizationManagementClient`'s :attr:`permissions` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Permission"]: """Gets all permissions the caller has for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.Permission"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get the permissions for. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Permission or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") ) cls: ClsType[_models.PermissionGetResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions" }
0.867289
0.093182
from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ApprovalSettings(_serialization.Model): """The approval settings. :ivar is_approval_required: Determines whether approval is required or not. :vartype is_approval_required: bool :ivar is_approval_required_for_extension: Determines whether approval is required for assignment extension. :vartype is_approval_required_for_extension: bool :ivar is_requestor_justification_required: Determine whether requestor justification is required. :vartype is_requestor_justification_required: bool :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :vartype approval_mode: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalMode :ivar approval_stages: The approval stages of the request. :vartype approval_stages: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalStage] """ _attribute_map = { "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, "approval_mode": {"key": "approvalMode", "type": "str"}, "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, } def __init__( self, *, is_approval_required: Optional[bool] = None, is_approval_required_for_extension: Optional[bool] = None, is_requestor_justification_required: Optional[bool] = None, approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, approval_stages: Optional[List["_models.ApprovalStage"]] = None, **kwargs: Any ) -> None: """ :keyword is_approval_required: Determines whether approval is required or not. :paramtype is_approval_required: bool :keyword is_approval_required_for_extension: Determines whether approval is required for assignment extension. :paramtype is_approval_required_for_extension: bool :keyword is_requestor_justification_required: Determine whether requestor justification is required. :paramtype is_requestor_justification_required: bool :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :paramtype approval_mode: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalMode :keyword approval_stages: The approval stages of the request. :paramtype approval_stages: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalStage] """ super().__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension self.is_requestor_justification_required = is_requestor_justification_required self.approval_mode = approval_mode self.approval_stages = approval_stages class ApprovalStage(_serialization.Model): """The approval stage. :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. :vartype approval_stage_time_out_in_days: int :ivar is_approver_justification_required: Determines whether approver need to provide justification for his decision. :vartype is_approver_justification_required: bool :ivar escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :vartype escalation_time_in_minutes: int :ivar primary_approvers: The primary approver of the request. :vartype primary_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. :vartype is_escalation_enabled: bool :ivar escalation_approvers: The escalation approver of the request. :vartype escalation_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] """ _attribute_map = { "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, } def __init__( self, *, approval_stage_time_out_in_days: Optional[int] = None, is_approver_justification_required: Optional[bool] = None, escalation_time_in_minutes: Optional[int] = None, primary_approvers: Optional[List["_models.UserSet"]] = None, is_escalation_enabled: Optional[bool] = None, escalation_approvers: Optional[List["_models.UserSet"]] = None, **kwargs: Any ) -> None: """ :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed out. :paramtype approval_stage_time_out_in_days: int :keyword is_approver_justification_required: Determines whether approver need to provide justification for his decision. :paramtype is_approver_justification_required: bool :keyword escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :paramtype escalation_time_in_minutes: int :keyword primary_approvers: The primary approver of the request. :paramtype primary_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. :paramtype is_escalation_enabled: bool :keyword escalation_approvers: The escalation approver of the request. :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] """ super().__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required self.escalation_time_in_minutes = escalation_time_in_minutes self.primary_approvers = primary_approvers self.is_escalation_enabled = is_escalation_enabled self.escalation_approvers = escalation_approvers class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class Permission(_serialization.Model): """Role definition permissions. Variables are only populated by the server, and will be ignored when sending a request. :ivar actions: Allowed actions. :vartype actions: list[str] :ivar not_actions: Denied actions. :vartype not_actions: list[str] :ivar data_actions: Allowed Data actions. :vartype data_actions: list[str] :ivar not_data_actions: Denied Data actions. :vartype not_data_actions: list[str] :ivar condition: The conditions on the role definition. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. :vartype condition_version: str """ _validation = { "condition": {"readonly": True}, "condition_version": {"readonly": True}, } _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, "condition": {"key": "condition", "type": "str"}, "condition_version": {"key": "conditionVersion", "type": "str"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Allowed actions. :paramtype actions: list[str] :keyword not_actions: Denied actions. :paramtype not_actions: list[str] :keyword data_actions: Allowed Data actions. :paramtype data_actions: list[str] :keyword not_data_actions: Denied Data actions. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions self.condition = None self.condition_version = None class PermissionGetResult(_serialization.Model): """Permissions information. :ivar value: An array of permissions. :vartype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Permission]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: An array of permissions. :paramtype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email class RoleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role definition ID. :vartype id: str :ivar name: The role definition name. :vartype name: str :ivar type: The role definition type. :vartype type: str :ivar role_name: The role name. :vartype role_name: str :ivar description: The role definition description. :vartype description: str :ivar role_type: The role type. :vartype role_type: str :ivar permissions: Role definition permissions. :vartype permissions: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :ivar assignable_scopes: Role definition assignable scopes. :vartype assignable_scopes: list[str] :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "role_name": {"key": "properties.roleName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "role_type": {"key": "properties.type", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[Permission]"}, "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, } def __init__( self, *, role_name: Optional[str] = None, description: Optional[str] = None, role_type: Optional[str] = None, permissions: Optional[List["_models.Permission"]] = None, assignable_scopes: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword role_name: The role name. :paramtype role_name: str :keyword description: The role definition description. :paramtype description: str :keyword role_type: The role type. :paramtype role_type: str :keyword permissions: Role definition permissions. :paramtype permissions: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :keyword assignable_scopes: Role definition assignable scopes. :paramtype assignable_scopes: list[str] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.role_name = role_name self.description = description self.role_type = role_type self.permissions = permissions self.assignable_scopes = assignable_scopes self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None class RoleDefinitionFilter(_serialization.Model): """Role Definitions filter. :ivar role_name: Returns role definition with the specific name. :vartype role_name: str :ivar type: Returns role definition with the specific type. :vartype type: str """ _attribute_map = { "role_name": {"key": "roleName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: """ :keyword role_name: Returns role definition with the specific name. :paramtype role_name: str :keyword type: Returns role definition with the specific type. :paramtype type: str """ super().__init__(**kwargs) self.role_name = role_name self.type = type class RoleDefinitionListResult(_serialization.Model): """Role definition list operation result. :ivar value: Role definition list. :vartype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role definition list. :paramtype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyRule(_serialization.Model): """The role management policy rule. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, } _subtype_map = { "rule_type": { "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", } } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget """ super().__init__(**kwargs) self.id = id self.rule_type: Optional[str] = None self.target = target class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar setting: The approval setting. :vartype setting: ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalSettings """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "setting": {"key": "setting", "type": "ApprovalSettings"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, setting: Optional["_models.ApprovalSettings"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword setting: The approval setting. :paramtype setting: ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalSettings """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyApprovalRule" self.setting = setting class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): """The role management policy authentication context rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_enabled: The value indicating if rule is enabled. :vartype is_enabled: bool :ivar claim_value: The claim value. :vartype claim_value: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "claim_value": {"key": "claimValue", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_enabled: Optional[bool] = None, claim_value: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_enabled: The value indicating if rule is enabled. :paramtype is_enabled: bool :keyword claim_value: The claim value. :paramtype claim_value: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" self.is_enabled = is_enabled self.claim_value = claim_value class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy enablement rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar enabled_rules: The list of enabled rules. :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_05_01_preview.models.EnablementRules] """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "enabled_rules": {"key": "enabledRules", "type": "[str]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword enabled_rules: The list of enabled rules. :paramtype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_05_01_preview.models.EnablementRules] """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyEnablementRule" self.enabled_rules = enabled_rules class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_expiration_required: The value indicating whether expiration is required. :vartype is_expiration_required: bool :ivar maximum_duration: The maximum duration of expiration in timespan. :vartype maximum_duration: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, "maximum_duration": {"key": "maximumDuration", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_expiration_required: Optional[bool] = None, maximum_duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_expiration_required: The value indicating whether expiration is required. :paramtype is_expiration_required: bool :keyword maximum_duration: The maximum duration of expiration in timespan. :paramtype maximum_duration: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyExpirationRule" self.is_expiration_required = is_expiration_required self.maximum_duration = maximum_duration class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar notification_type: The type of notification. "Email" :vartype notification_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationDeliveryMechanism :ivar notification_level: The notification level. Known values are: "None", "Critical", and "All". :vartype notification_level: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationLevel :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :vartype recipient_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RecipientType :ivar notification_recipients: The list of notification recipients. :vartype notification_recipients: list[str] :ivar is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :vartype is_default_recipients_enabled: bool """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "notification_type": {"key": "notificationType", "type": "str"}, "notification_level": {"key": "notificationLevel", "type": "str"}, "recipient_type": {"key": "recipientType", "type": "str"}, "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, notification_recipients: Optional[List[str]] = None, is_default_recipients_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword notification_type: The type of notification. "Email" :paramtype notification_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationDeliveryMechanism :keyword notification_level: The notification level. Known values are: "None", "Critical", and "All". :paramtype notification_level: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationLevel :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :paramtype recipient_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RecipientType :keyword notification_recipients: The list of notification recipients. :paramtype notification_recipients: list[str] :keyword is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :paramtype is_default_recipients_enabled: bool """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyNotificationRule" self.notification_type = notification_type self.notification_level = notification_level self.recipient_type = recipient_type self.notification_recipients = notification_recipients self.is_default_recipients_enabled = is_default_recipients_enabled class RoleManagementPolicyRuleTarget(_serialization.Model): """The role management policy rule target. :ivar caller: The caller of the setting. :vartype caller: str :ivar operations: The type of operation. :vartype operations: list[str] :ivar level: The assignment level to which rule is applied. :vartype level: str :ivar target_objects: The list of target objects. :vartype target_objects: list[str] :ivar inheritable_settings: The list of inheritable settings. :vartype inheritable_settings: list[str] :ivar enforced_settings: The list of enforced settings. :vartype enforced_settings: list[str] """ _attribute_map = { "caller": {"key": "caller", "type": "str"}, "operations": {"key": "operations", "type": "[str]"}, "level": {"key": "level", "type": "str"}, "target_objects": {"key": "targetObjects", "type": "[str]"}, "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, } def __init__( self, *, caller: Optional[str] = None, operations: Optional[List[str]] = None, level: Optional[str] = None, target_objects: Optional[List[str]] = None, inheritable_settings: Optional[List[str]] = None, enforced_settings: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword caller: The caller of the setting. :paramtype caller: str :keyword operations: The type of operation. :paramtype operations: list[str] :keyword level: The assignment level to which rule is applied. :paramtype level: str :keyword target_objects: The list of target objects. :paramtype target_objects: list[str] :keyword inheritable_settings: The list of inheritable settings. :paramtype inheritable_settings: list[str] :keyword enforced_settings: The list of enforced settings. :paramtype enforced_settings: list[str] """ super().__init__(**kwargs) self.caller = caller self.operations = operations self.level = level self.target_objects = target_objects self.inheritable_settings = inheritable_settings self.enforced_settings = enforced_settings class UserSet(_serialization.Model): """The detail of a user. :ivar user_type: The type of user. Known values are: "User" and "Group". :vartype user_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.UserType :ivar is_backup: The value indicating whether the user is a backup fallback approver. :vartype is_backup: bool :ivar id: The object id of the user. :vartype id: str :ivar description: The description of the user. :vartype description: str """ _attribute_map = { "user_type": {"key": "userType", "type": "str"}, "is_backup": {"key": "isBackup", "type": "bool"}, "id": {"key": "id", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__( self, *, user_type: Optional[Union[str, "_models.UserType"]] = None, is_backup: Optional[bool] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin description: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword user_type: The type of user. Known values are: "User" and "Group". :paramtype user_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.UserType :keyword is_backup: The value indicating whether the user is a backup fallback approver. :paramtype is_backup: bool :keyword id: The object id of the user. :paramtype id: str :keyword description: The description of the user. :paramtype description: str """ super().__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup self.id = id self.description = description
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_05_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 ApprovalSettings(_serialization.Model): """The approval settings. :ivar is_approval_required: Determines whether approval is required or not. :vartype is_approval_required: bool :ivar is_approval_required_for_extension: Determines whether approval is required for assignment extension. :vartype is_approval_required_for_extension: bool :ivar is_requestor_justification_required: Determine whether requestor justification is required. :vartype is_requestor_justification_required: bool :ivar approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :vartype approval_mode: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalMode :ivar approval_stages: The approval stages of the request. :vartype approval_stages: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalStage] """ _attribute_map = { "is_approval_required": {"key": "isApprovalRequired", "type": "bool"}, "is_approval_required_for_extension": {"key": "isApprovalRequiredForExtension", "type": "bool"}, "is_requestor_justification_required": {"key": "isRequestorJustificationRequired", "type": "bool"}, "approval_mode": {"key": "approvalMode", "type": "str"}, "approval_stages": {"key": "approvalStages", "type": "[ApprovalStage]"}, } def __init__( self, *, is_approval_required: Optional[bool] = None, is_approval_required_for_extension: Optional[bool] = None, is_requestor_justification_required: Optional[bool] = None, approval_mode: Optional[Union[str, "_models.ApprovalMode"]] = None, approval_stages: Optional[List["_models.ApprovalStage"]] = None, **kwargs: Any ) -> None: """ :keyword is_approval_required: Determines whether approval is required or not. :paramtype is_approval_required: bool :keyword is_approval_required_for_extension: Determines whether approval is required for assignment extension. :paramtype is_approval_required_for_extension: bool :keyword is_requestor_justification_required: Determine whether requestor justification is required. :paramtype is_requestor_justification_required: bool :keyword approval_mode: The type of rule. Known values are: "SingleStage", "Serial", "Parallel", and "NoApproval". :paramtype approval_mode: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalMode :keyword approval_stages: The approval stages of the request. :paramtype approval_stages: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalStage] """ super().__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension self.is_requestor_justification_required = is_requestor_justification_required self.approval_mode = approval_mode self.approval_stages = approval_stages class ApprovalStage(_serialization.Model): """The approval stage. :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. :vartype approval_stage_time_out_in_days: int :ivar is_approver_justification_required: Determines whether approver need to provide justification for his decision. :vartype is_approver_justification_required: bool :ivar escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :vartype escalation_time_in_minutes: int :ivar primary_approvers: The primary approver of the request. :vartype primary_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. :vartype is_escalation_enabled: bool :ivar escalation_approvers: The escalation approver of the request. :vartype escalation_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] """ _attribute_map = { "approval_stage_time_out_in_days": {"key": "approvalStageTimeOutInDays", "type": "int"}, "is_approver_justification_required": {"key": "isApproverJustificationRequired", "type": "bool"}, "escalation_time_in_minutes": {"key": "escalationTimeInMinutes", "type": "int"}, "primary_approvers": {"key": "primaryApprovers", "type": "[UserSet]"}, "is_escalation_enabled": {"key": "isEscalationEnabled", "type": "bool"}, "escalation_approvers": {"key": "escalationApprovers", "type": "[UserSet]"}, } def __init__( self, *, approval_stage_time_out_in_days: Optional[int] = None, is_approver_justification_required: Optional[bool] = None, escalation_time_in_minutes: Optional[int] = None, primary_approvers: Optional[List["_models.UserSet"]] = None, is_escalation_enabled: Optional[bool] = None, escalation_approvers: Optional[List["_models.UserSet"]] = None, **kwargs: Any ) -> None: """ :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed out. :paramtype approval_stage_time_out_in_days: int :keyword is_approver_justification_required: Determines whether approver need to provide justification for his decision. :paramtype is_approver_justification_required: bool :keyword escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approve. :paramtype escalation_time_in_minutes: int :keyword primary_approvers: The primary approver of the request. :paramtype primary_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. :paramtype is_escalation_enabled: bool :keyword escalation_approvers: The escalation approver of the request. :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2022_05_01_preview.models.UserSet] """ super().__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required self.escalation_time_in_minutes = escalation_time_in_minutes self.primary_approvers = primary_approvers self.is_escalation_enabled = is_escalation_enabled self.escalation_approvers = escalation_approvers class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2022_05_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class Permission(_serialization.Model): """Role definition permissions. Variables are only populated by the server, and will be ignored when sending a request. :ivar actions: Allowed actions. :vartype actions: list[str] :ivar not_actions: Denied actions. :vartype not_actions: list[str] :ivar data_actions: Allowed Data actions. :vartype data_actions: list[str] :ivar not_data_actions: Denied Data actions. :vartype not_data_actions: list[str] :ivar condition: The conditions on the role definition. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently the only accepted value is '2.0'. :vartype condition_version: str """ _validation = { "condition": {"readonly": True}, "condition_version": {"readonly": True}, } _attribute_map = { "actions": {"key": "actions", "type": "[str]"}, "not_actions": {"key": "notActions", "type": "[str]"}, "data_actions": {"key": "dataActions", "type": "[str]"}, "not_data_actions": {"key": "notDataActions", "type": "[str]"}, "condition": {"key": "condition", "type": "str"}, "condition_version": {"key": "conditionVersion", "type": "str"}, } def __init__( self, *, actions: Optional[List[str]] = None, not_actions: Optional[List[str]] = None, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword actions: Allowed actions. :paramtype actions: list[str] :keyword not_actions: Denied actions. :paramtype not_actions: list[str] :keyword data_actions: Allowed Data actions. :paramtype data_actions: list[str] :keyword not_data_actions: Denied Data actions. :paramtype not_data_actions: list[str] """ super().__init__(**kwargs) self.actions = actions self.not_actions = not_actions self.data_actions = data_actions self.not_data_actions = not_data_actions self.condition = None self.condition_version = None class PermissionGetResult(_serialization.Model): """Permissions information. :ivar value: An array of permissions. :vartype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[Permission]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.Permission"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: An array of permissions. :paramtype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class Principal(_serialization.Model): """The name of the entity last modified it. :ivar id: The id of the principal made changes. :vartype id: str :ivar display_name: The name of the principal made changes. :vartype display_name: str :ivar type: Type of principal such as user , group etc. :vartype type: str :ivar email: Email of principal. :vartype email: str """ _attribute_map = { "id": {"key": "id", "type": "str"}, "display_name": {"key": "displayName", "type": "str"}, "type": {"key": "type", "type": "str"}, "email": {"key": "email", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin display_name: Optional[str] = None, type: Optional[str] = None, email: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the principal made changes. :paramtype id: str :keyword display_name: The name of the principal made changes. :paramtype display_name: str :keyword type: Type of principal such as user , group etc. :paramtype type: str :keyword email: Email of principal. :paramtype email: str """ super().__init__(**kwargs) self.id = id self.display_name = display_name self.type = type self.email = email class RoleDefinition(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role definition. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role definition ID. :vartype id: str :ivar name: The role definition name. :vartype name: str :ivar type: The role definition type. :vartype type: str :ivar role_name: The role name. :vartype role_name: str :ivar description: The role definition description. :vartype description: str :ivar role_type: The role type. :vartype role_type: str :ivar permissions: Role definition permissions. :vartype permissions: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :ivar assignable_scopes: Role definition assignable scopes. :vartype assignable_scopes: list[str] :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, "created_on": {"readonly": True}, "updated_on": {"readonly": True}, "created_by": {"readonly": True}, "updated_by": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "role_name": {"key": "properties.roleName", "type": "str"}, "description": {"key": "properties.description", "type": "str"}, "role_type": {"key": "properties.type", "type": "str"}, "permissions": {"key": "properties.permissions", "type": "[Permission]"}, "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, } def __init__( self, *, role_name: Optional[str] = None, description: Optional[str] = None, role_type: Optional[str] = None, permissions: Optional[List["_models.Permission"]] = None, assignable_scopes: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword role_name: The role name. :paramtype role_name: str :keyword description: The role definition description. :paramtype description: str :keyword role_type: The role type. :paramtype role_type: str :keyword permissions: Role definition permissions. :paramtype permissions: list[~azure.mgmt.authorization.v2022_05_01_preview.models.Permission] :keyword assignable_scopes: Role definition assignable scopes. :paramtype assignable_scopes: list[str] """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.role_name = role_name self.description = description self.role_type = role_type self.permissions = permissions self.assignable_scopes = assignable_scopes self.created_on = None self.updated_on = None self.created_by = None self.updated_by = None class RoleDefinitionFilter(_serialization.Model): """Role Definitions filter. :ivar role_name: Returns role definition with the specific name. :vartype role_name: str :ivar type: Returns role definition with the specific type. :vartype type: str """ _attribute_map = { "role_name": {"key": "roleName", "type": "str"}, "type": {"key": "type", "type": "str"}, } def __init__(self, *, role_name: Optional[str] = None, type: Optional[str] = None, **kwargs: Any) -> None: """ :keyword role_name: Returns role definition with the specific name. :paramtype role_name: str :keyword type: Returns role definition with the specific type. :paramtype type: str """ super().__init__(**kwargs) self.role_name = role_name self.type = type class RoleDefinitionListResult(_serialization.Model): """Role definition list operation result. :ivar value: Role definition list. :vartype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleDefinition]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleDefinition"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role definition list. :paramtype value: list[~azure.mgmt.authorization.v2022_05_01_preview.models.RoleDefinition] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link class RoleManagementPolicyRule(_serialization.Model): """The role management policy rule. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, } _subtype_map = { "rule_type": { "RoleManagementPolicyApprovalRule": "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule": "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule": "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule": "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule": "RoleManagementPolicyNotificationRule", } } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget """ super().__init__(**kwargs) self.id = id self.rule_type: Optional[str] = None self.target = target class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): """The role management policy approval rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar setting: The approval setting. :vartype setting: ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalSettings """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "setting": {"key": "setting", "type": "ApprovalSettings"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, setting: Optional["_models.ApprovalSettings"] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword setting: The approval setting. :paramtype setting: ~azure.mgmt.authorization.v2022_05_01_preview.models.ApprovalSettings """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyApprovalRule" self.setting = setting class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): """The role management policy authentication context rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_enabled: The value indicating if rule is enabled. :vartype is_enabled: bool :ivar claim_value: The claim value. :vartype claim_value: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_enabled": {"key": "isEnabled", "type": "bool"}, "claim_value": {"key": "claimValue", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_enabled: Optional[bool] = None, claim_value: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_enabled: The value indicating if rule is enabled. :paramtype is_enabled: bool :keyword claim_value: The claim value. :paramtype claim_value: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyAuthenticationContextRule" self.is_enabled = is_enabled self.claim_value = claim_value class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): """The role management policy enablement rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar enabled_rules: The list of enabled rules. :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_05_01_preview.models.EnablementRules] """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "enabled_rules": {"key": "enabledRules", "type": "[str]"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, enabled_rules: Optional[List[Union[str, "_models.EnablementRules"]]] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword enabled_rules: The list of enabled rules. :paramtype enabled_rules: list[str or ~azure.mgmt.authorization.v2022_05_01_preview.models.EnablementRules] """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyEnablementRule" self.enabled_rules = enabled_rules class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): """The role management policy expiration rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar is_expiration_required: The value indicating whether expiration is required. :vartype is_expiration_required: bool :ivar maximum_duration: The maximum duration of expiration in timespan. :vartype maximum_duration: str """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "is_expiration_required": {"key": "isExpirationRequired", "type": "bool"}, "maximum_duration": {"key": "maximumDuration", "type": "str"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, is_expiration_required: Optional[bool] = None, maximum_duration: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword is_expiration_required: The value indicating whether expiration is required. :paramtype is_expiration_required: bool :keyword maximum_duration: The maximum duration of expiration in timespan. :paramtype maximum_duration: str """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyExpirationRule" self.is_expiration_required = is_expiration_required self.maximum_duration = maximum_duration class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): """The role management policy notification rule. All required parameters must be populated in order to send to Azure. :ivar id: The id of the rule. :vartype id: str :ivar rule_type: The type of rule. Required. Known values are: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", and "RoleManagementPolicyNotificationRule". :vartype rule_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleType :ivar target: The target of the current rule. :vartype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :ivar notification_type: The type of notification. "Email" :vartype notification_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationDeliveryMechanism :ivar notification_level: The notification level. Known values are: "None", "Critical", and "All". :vartype notification_level: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationLevel :ivar recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :vartype recipient_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RecipientType :ivar notification_recipients: The list of notification recipients. :vartype notification_recipients: list[str] :ivar is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :vartype is_default_recipients_enabled: bool """ _validation = { "rule_type": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "rule_type": {"key": "ruleType", "type": "str"}, "target": {"key": "target", "type": "RoleManagementPolicyRuleTarget"}, "notification_type": {"key": "notificationType", "type": "str"}, "notification_level": {"key": "notificationLevel", "type": "str"}, "recipient_type": {"key": "recipientType", "type": "str"}, "notification_recipients": {"key": "notificationRecipients", "type": "[str]"}, "is_default_recipients_enabled": {"key": "isDefaultRecipientsEnabled", "type": "bool"}, } def __init__( self, *, id: Optional[str] = None, # pylint: disable=redefined-builtin target: Optional["_models.RoleManagementPolicyRuleTarget"] = None, notification_type: Optional[Union[str, "_models.NotificationDeliveryMechanism"]] = None, notification_level: Optional[Union[str, "_models.NotificationLevel"]] = None, recipient_type: Optional[Union[str, "_models.RecipientType"]] = None, notification_recipients: Optional[List[str]] = None, is_default_recipients_enabled: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword id: The id of the rule. :paramtype id: str :keyword target: The target of the current rule. :paramtype target: ~azure.mgmt.authorization.v2022_05_01_preview.models.RoleManagementPolicyRuleTarget :keyword notification_type: The type of notification. "Email" :paramtype notification_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationDeliveryMechanism :keyword notification_level: The notification level. Known values are: "None", "Critical", and "All". :paramtype notification_level: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.NotificationLevel :keyword recipient_type: The recipient type. Known values are: "Requestor", "Approver", and "Admin". :paramtype recipient_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.RecipientType :keyword notification_recipients: The list of notification recipients. :paramtype notification_recipients: list[str] :keyword is_default_recipients_enabled: Determines if the notification will be sent to the recipient type specified in the policy rule. :paramtype is_default_recipients_enabled: bool """ super().__init__(id=id, target=target, **kwargs) self.rule_type: str = "RoleManagementPolicyNotificationRule" self.notification_type = notification_type self.notification_level = notification_level self.recipient_type = recipient_type self.notification_recipients = notification_recipients self.is_default_recipients_enabled = is_default_recipients_enabled class RoleManagementPolicyRuleTarget(_serialization.Model): """The role management policy rule target. :ivar caller: The caller of the setting. :vartype caller: str :ivar operations: The type of operation. :vartype operations: list[str] :ivar level: The assignment level to which rule is applied. :vartype level: str :ivar target_objects: The list of target objects. :vartype target_objects: list[str] :ivar inheritable_settings: The list of inheritable settings. :vartype inheritable_settings: list[str] :ivar enforced_settings: The list of enforced settings. :vartype enforced_settings: list[str] """ _attribute_map = { "caller": {"key": "caller", "type": "str"}, "operations": {"key": "operations", "type": "[str]"}, "level": {"key": "level", "type": "str"}, "target_objects": {"key": "targetObjects", "type": "[str]"}, "inheritable_settings": {"key": "inheritableSettings", "type": "[str]"}, "enforced_settings": {"key": "enforcedSettings", "type": "[str]"}, } def __init__( self, *, caller: Optional[str] = None, operations: Optional[List[str]] = None, level: Optional[str] = None, target_objects: Optional[List[str]] = None, inheritable_settings: Optional[List[str]] = None, enforced_settings: Optional[List[str]] = None, **kwargs: Any ) -> None: """ :keyword caller: The caller of the setting. :paramtype caller: str :keyword operations: The type of operation. :paramtype operations: list[str] :keyword level: The assignment level to which rule is applied. :paramtype level: str :keyword target_objects: The list of target objects. :paramtype target_objects: list[str] :keyword inheritable_settings: The list of inheritable settings. :paramtype inheritable_settings: list[str] :keyword enforced_settings: The list of enforced settings. :paramtype enforced_settings: list[str] """ super().__init__(**kwargs) self.caller = caller self.operations = operations self.level = level self.target_objects = target_objects self.inheritable_settings = inheritable_settings self.enforced_settings = enforced_settings class UserSet(_serialization.Model): """The detail of a user. :ivar user_type: The type of user. Known values are: "User" and "Group". :vartype user_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.UserType :ivar is_backup: The value indicating whether the user is a backup fallback approver. :vartype is_backup: bool :ivar id: The object id of the user. :vartype id: str :ivar description: The description of the user. :vartype description: str """ _attribute_map = { "user_type": {"key": "userType", "type": "str"}, "is_backup": {"key": "isBackup", "type": "bool"}, "id": {"key": "id", "type": "str"}, "description": {"key": "description", "type": "str"}, } def __init__( self, *, user_type: Optional[Union[str, "_models.UserType"]] = None, is_backup: Optional[bool] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin description: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword user_type: The type of user. Known values are: "User" and "Group". :paramtype user_type: str or ~azure.mgmt.authorization.v2022_05_01_preview.models.UserType :keyword is_backup: The value indicating whether the user is a backup fallback approver. :paramtype is_backup: bool :keyword id: The object id of the user. :paramtype id: str :keyword description: The description of the user. :paramtype description: str """ super().__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup self.id = id self.description = description
0.889748
0.27136
from ._models_py3 import ApprovalSettings from ._models_py3 import ApprovalStage from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import Permission from ._models_py3 import PermissionGetResult from ._models_py3 import Principal from ._models_py3 import RoleDefinition from ._models_py3 import RoleDefinitionFilter from ._models_py3 import RoleDefinitionListResult from ._models_py3 import RoleManagementPolicyApprovalRule from ._models_py3 import RoleManagementPolicyAuthenticationContextRule from ._models_py3 import RoleManagementPolicyEnablementRule from ._models_py3 import RoleManagementPolicyExpirationRule from ._models_py3 import RoleManagementPolicyNotificationRule from ._models_py3 import RoleManagementPolicyRule from ._models_py3 import RoleManagementPolicyRuleTarget from ._models_py3 import UserSet from ._authorization_management_client_enums import ApprovalMode from ._authorization_management_client_enums import EnablementRules from ._authorization_management_client_enums import NotificationDeliveryMechanism from ._authorization_management_client_enums import NotificationLevel from ._authorization_management_client_enums import RecipientType from ._authorization_management_client_enums import RoleManagementPolicyRuleType from ._authorization_management_client_enums import UserType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "ApprovalSettings", "ApprovalStage", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "Permission", "PermissionGetResult", "Principal", "RoleDefinition", "RoleDefinitionFilter", "RoleDefinitionListResult", "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule", "RoleManagementPolicyRule", "RoleManagementPolicyRuleTarget", "UserSet", "ApprovalMode", "EnablementRules", "NotificationDeliveryMechanism", "NotificationLevel", "RecipientType", "RoleManagementPolicyRuleType", "UserType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2022_05_01_preview/models/__init__.py
__init__.py
from ._models_py3 import ApprovalSettings from ._models_py3 import ApprovalStage from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import Permission from ._models_py3 import PermissionGetResult from ._models_py3 import Principal from ._models_py3 import RoleDefinition from ._models_py3 import RoleDefinitionFilter from ._models_py3 import RoleDefinitionListResult from ._models_py3 import RoleManagementPolicyApprovalRule from ._models_py3 import RoleManagementPolicyAuthenticationContextRule from ._models_py3 import RoleManagementPolicyEnablementRule from ._models_py3 import RoleManagementPolicyExpirationRule from ._models_py3 import RoleManagementPolicyNotificationRule from ._models_py3 import RoleManagementPolicyRule from ._models_py3 import RoleManagementPolicyRuleTarget from ._models_py3 import UserSet from ._authorization_management_client_enums import ApprovalMode from ._authorization_management_client_enums import EnablementRules from ._authorization_management_client_enums import NotificationDeliveryMechanism from ._authorization_management_client_enums import NotificationLevel from ._authorization_management_client_enums import RecipientType from ._authorization_management_client_enums import RoleManagementPolicyRuleType from ._authorization_management_client_enums import UserType from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "ApprovalSettings", "ApprovalStage", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "Permission", "PermissionGetResult", "Principal", "RoleDefinition", "RoleDefinitionFilter", "RoleDefinitionListResult", "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule", "RoleManagementPolicyRule", "RoleManagementPolicyRuleTarget", "UserSet", "ApprovalMode", "EnablementRules", "NotificationDeliveryMechanism", "NotificationLevel", "RecipientType", "RoleManagementPolicyRuleType", "UserType", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk()
0.443118
0.058723
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2020_04_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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/v2020_04_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.v2020_04_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.843927
0.09795
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_04_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 "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.83363
0.087252
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request( scope: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_04_01_preview.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def delete_by_id( self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_04_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, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, "str", skip_quote=True), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_create_by_id_request(role_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleId}") path_format_arguments = { "roleId": _SERIALIZER.url("role_id", role_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request( scope: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_04_01_preview.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def delete_by_id( self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
0.765506
0.076167
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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/v2020_04_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.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-04-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.831349
0.10316
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_04_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 "2020-04-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-04-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.835416
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.v2020_04_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def delete_by_id( self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload async def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace_async async def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_04_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.v2020_04_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param parent_resource_path: The parent resource identity. Required. :type parent_resource_path: str :param resource_type: The resource type of the resource. Required. :type resource_type: str :param resource_name: The name of the resource to get role assignments for. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, parent_resource_path=parent_resource_path, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """List role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace_async async def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param scope: The scope of the role assignment to delete. Required. :type scope: str :param role_assignment_name: The name of the role assignment to delete. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload async def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get the specified role assignment. :param scope: The scope of the role assignment. Required. :type scope: str :param role_assignment_name: The name of the role assignment to get. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace_async async def delete_by_id( self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment. :param role_id: The ID of the role assignment to delete. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.delete_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleId}"} @overload async def create_by_id( self, role_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create_by_id( self, role_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create_by_id( self, role_id: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. Required. :type role_id: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_by_id_request( role_id=role_id, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create_by_id.metadata = {"url": "/{roleId}"} @distributed_trace_async async def get_by_id(self, role_id: str, tenant_id: Optional[str] = None, **kwargs: Any) -> _models.RoleAssignment: """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. Required. :type role_id: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_by_id_request( role_id=role_id, tenant_id=tenant_id, api_version=api_version, template_url=self.get_by_id.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleId}"} @distributed_trace def list( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignment"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-04-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"}
0.868102
0.092606
import datetime from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, updated_on: Optional[datetime.datetime] = None, created_by: Optional[str] = None, updated_by: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: Time it was created. :paramtype created_on: ~datetime.datetime :keyword updated_on: Time it was updated. :paramtype updated_on: ~datetime.datetime :keyword created_by: Id of the user who created the assignment. :paramtype created_by: str :keyword updated_by: Id of the user who updated the assignment. :paramtype updated_by: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate self.description = description self.condition = condition self.condition_version = condition_version self.created_on = created_on self.updated_on = updated_on self.created_by = created_by self.updated_by = updated_by self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. All required parameters must be populated in order to send to Azure. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :ivar can_delegate: The delegation flag used for creating a role assignment. :vartype can_delegate: bool :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "role_definition_id": {"required": True}, "principal_id": {"required": True}, } _attribute_map = { "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID used in the role assignment. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :keyword can_delegate: The delegation flag used for creating a role assignment. :paramtype can_delegate: bool :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate self.description = description self.condition = condition self.condition_version = condition_version self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "can_delegate": {"key": "canDelegate", "type": "bool"}, } def __init__( self, *, principal_id: Optional[str] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_04_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 ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. :vartype info: JSON """ _validation = { "type": {"readonly": True}, "info": {"readonly": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, "info": {"key": "info", "type": "object"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None self.info = None class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: The error code. :vartype code: str :ivar message: The error message. :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: The error details. :vartype details: list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorAdditionalInfo] """ _validation = { "code": {"readonly": True}, "message": {"readonly": True}, "target": {"readonly": True}, "details": {"readonly": True}, "additional_info": {"readonly": True}, } _attribute_map = { "code": {"key": "code", "type": "str"}, "message": {"key": "message", "type": "str"}, "target": {"key": "target", "type": "str"}, "details": {"key": "details", "type": "[ErrorDetail]"}, "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None self.message = None self.target = None self.details = None self.additional_info = None class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. :vartype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail """ _attribute_map = { "error": {"key": "error", "type": "ErrorDetail"}, } def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail """ super().__init__(**kwargs) self.error = error class RoleAssignment(_serialization.Model): # pylint: disable=too-many-instance-attributes """Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The role assignment ID. :vartype id: str :ivar name: The role assignment name. :vartype name: str :ivar type: The role assignment type. :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str :ivar role_definition_id: The role definition ID. :vartype role_definition_id: str :ivar principal_id: The principal ID. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. :vartype updated_on: ~datetime.datetime :ivar created_by: Id of the user who created the assignment. :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "scope": {"key": "properties.scope", "type": "str"}, "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, "updated_on": {"key": "properties.updatedOn", "type": "iso-8601"}, "created_by": {"key": "properties.createdBy", "type": "str"}, "updated_by": {"key": "properties.updatedBy", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, scope: Optional[str] = None, role_definition_id: Optional[str] = None, principal_id: Optional[str] = None, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, created_on: Optional[datetime.datetime] = None, updated_on: Optional[datetime.datetime] = None, created_by: Optional[str] = None, updated_by: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword scope: The role assignment scope. :paramtype scope: str :keyword role_definition_id: The role definition ID. :paramtype role_definition_id: str :keyword principal_id: The principal ID. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword created_on: Time it was created. :paramtype created_on: ~datetime.datetime :keyword updated_on: Time it was updated. :paramtype updated_on: ~datetime.datetime :keyword created_by: Id of the user who created the assignment. :paramtype created_by: str :keyword updated_by: Id of the user who updated the assignment. :paramtype updated_by: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.scope = scope self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate self.description = description self.condition = condition self.condition_version = condition_version self.created_on = created_on self.updated_on = updated_on self.created_by = created_by self.updated_by = updated_by self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentCreateParameters(_serialization.Model): """Role assignment create parameters. All required parameters must be populated in order to send to Azure. :ivar role_definition_id: The role definition ID used in the role assignment. Required. :vartype role_definition_id: str :ivar principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :ivar can_delegate: The delegation flag used for creating a role assignment. :vartype can_delegate: bool :ivar description: Description of role assignment. :vartype description: str :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :vartype condition: str :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. :vartype condition_version: str :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :vartype delegated_managed_identity_resource_id: str """ _validation = { "role_definition_id": {"required": True}, "principal_id": {"required": True}, } _attribute_map = { "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, "principal_id": {"key": "properties.principalId", "type": "str"}, "principal_type": {"key": "properties.principalType", "type": "str"}, "can_delegate": {"key": "properties.canDelegate", "type": "bool"}, "description": {"key": "properties.description", "type": "str"}, "condition": {"key": "properties.condition", "type": "str"}, "condition_version": {"key": "properties.conditionVersion", "type": "str"}, "delegated_managed_identity_resource_id": { "key": "properties.delegatedManagedIdentityResourceId", "type": "str", }, } def __init__( self, *, role_definition_id: str, principal_id: str, principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, can_delegate: Optional[bool] = None, description: Optional[str] = None, condition: Optional[str] = None, condition_version: Optional[str] = None, delegated_managed_identity_resource_id: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword role_definition_id: The role definition ID used in the role assignment. Required. :paramtype role_definition_id: str :keyword principal_id: The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group. Required. :paramtype principal_id: str :keyword principal_type: The principal type of the assigned principal ID. Known values are: "User", "Group", "ServicePrincipal", and "ForeignGroup". :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType :keyword can_delegate: The delegation flag used for creating a role assignment. :paramtype can_delegate: bool :keyword description: Description of role assignment. :paramtype description: str :keyword condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. :paramtype condition: str :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. :paramtype condition_version: str :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. :paramtype delegated_managed_identity_resource_id: str """ super().__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id self.principal_type = principal_type self.can_delegate = can_delegate self.description = description self.condition = condition self.condition_version = condition_version self.delegated_managed_identity_resource_id = delegated_managed_identity_resource_id class RoleAssignmentFilter(_serialization.Model): """Role Assignments filter. :ivar principal_id: Returns role assignment of the specific principal. :vartype principal_id: str :ivar can_delegate: The Delegation flag for the role assignment. :vartype can_delegate: bool """ _attribute_map = { "principal_id": {"key": "principalId", "type": "str"}, "can_delegate": {"key": "canDelegate", "type": "bool"}, } def __init__( self, *, principal_id: Optional[str] = None, can_delegate: Optional[bool] = None, **kwargs: Any ) -> None: """ :keyword principal_id: Returns role assignment of the specific principal. :paramtype principal_id: str :keyword can_delegate: The Delegation flag for the role assignment. :paramtype can_delegate: bool """ super().__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate class RoleAssignmentListResult(_serialization.Model): """Role assignment list operation result. :ivar value: Role assignment list. :vartype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ _attribute_map = { "value": {"key": "value", "type": "[RoleAssignment]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, value: Optional[List["_models.RoleAssignment"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: Role assignment list. :paramtype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] :keyword next_link: The URL to use for getting the next set of results. :paramtype next_link: str """ super().__init__(**kwargs) self.value = value self.next_link = next_link
0.867864
0.280308
from copy import deepcopy from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleAssignmentsOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentsOperations :ivar eligible_child_resources: EligibleChildResourcesOperations operations :vartype eligible_child_resources: azure.mgmt.authorization.v2020_10_01_preview.operations.EligibleChildResourcesOperations :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations :vartype role_assignment_schedules: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentSchedulesOperations :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations :vartype role_assignment_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleInstancesOperations :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations :vartype role_assignment_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleRequestsOperations :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations :vartype role_eligibility_schedules: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilitySchedulesOperations :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations operations :vartype role_eligibility_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleInstancesOperations :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations :vartype role_eligibility_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleRequestsOperations :ivar role_management_policies: RoleManagementPoliciesOperations operations :vartype role_management_policies: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPoliciesOperations :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations :vartype role_management_policy_assignments: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.eligible_child_resources = EligibleChildResourcesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedules = RoleAssignmentSchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policies = RoleManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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/v2020_10_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 ( EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleAssignmentsOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentsOperations :ivar eligible_child_resources: EligibleChildResourcesOperations operations :vartype eligible_child_resources: azure.mgmt.authorization.v2020_10_01_preview.operations.EligibleChildResourcesOperations :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations :vartype role_assignment_schedules: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentSchedulesOperations :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations :vartype role_assignment_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleInstancesOperations :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations :vartype role_assignment_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleRequestsOperations :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations :vartype role_eligibility_schedules: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilitySchedulesOperations :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations operations :vartype role_eligibility_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleInstancesOperations :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations :vartype role_eligibility_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleRequestsOperations :ivar role_management_policies: RoleManagementPoliciesOperations operations :vartype role_management_policies: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPoliciesOperations :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations :vartype role_management_policy_assignments: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.eligible_child_resources = EligibleChildResourcesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedules = RoleAssignmentSchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policies = RoleManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.829665
0.089933
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_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 "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.833223
0.086516
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleName": _SERIALIZER.url( "role_eligibility_schedule_name", role_eligibility_schedule_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleEligibilitySchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_eligibility_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> _models.RoleEligibilitySchedule: """Get the specified role eligibility schedule for a resource scope. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleEligibilitySchedule"]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedules at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py
_role_eligibility_schedules_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, role_eligibility_schedule_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleName": _SERIALIZER.url( "role_eligibility_schedule_name", role_eligibility_schedule_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleEligibilitySchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_eligibility_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any) -> _models.RoleEligibilitySchedule: """Get the specified role eligibility schedule for a resource scope. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleEligibilitySchedule"]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedules at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"}
0.853134
0.083778
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleManagementPoliciesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_management_policies` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: """Get the specified role management policy for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @overload def update( self, scope: str, role_management_policy_name: str, parameters: _models.RoleManagementPolicy, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, scope: str, role_management_policy_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def update( self, scope: str, role_management_policy_name: str, parameters: Union[_models.RoleManagementPolicy, IO], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicy") request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized update.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_name: str, **kwargs: Any ) -> None: """Delete a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicy"]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py
_role_management_policies_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, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request(scope: str, role_management_policy_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, "str"), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleManagementPoliciesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_management_policies` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: """Get the specified role management policy for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @overload def update( self, scope: str, role_management_policy_name: str, parameters: _models.RoleManagementPolicy, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, scope: str, role_management_policy_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def update( self, scope: str, role_management_policy_name: str, parameters: Union[_models.RoleManagementPolicy, IO], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicy") request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized update.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_name: str, **kwargs: Any ) -> None: """Delete a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicy"]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"}
0.802556
0.08163
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleManagementPolicyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_management_policy_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Get the specified role management policy assignment for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @overload def create( self, scope: str, role_management_policy_assignment_name: str, parameters: _models.RoleManagementPolicyAssignment, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_management_policy_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_management_policy_assignment_name: str, parameters: Union[_models.RoleManagementPolicyAssignment, IO], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a RoleManagementPolicyAssignment type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> None: """Delete a role management policy assignment. :param scope: The scope of the role management policy assignment to delete. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicyAssignment"]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py
_role_management_policy_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_get_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request(scope: str, role_management_policy_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleManagementPolicyAssignmentName": _SERIALIZER.url( "role_management_policy_assignment_name", role_management_policy_assignment_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleManagementPolicyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_management_policy_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Get the specified role management policy assignment for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @overload def create( self, scope: str, role_management_policy_assignment_name: str, parameters: _models.RoleManagementPolicyAssignment, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_management_policy_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_management_policy_assignment_name: str, parameters: Union[_models.RoleManagementPolicyAssignment, IO], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a RoleManagementPolicyAssignment type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> None: """Delete a role management policy assignment. :param scope: The scope of the role management policy assignment to delete. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> Iterable["_models.RoleManagementPolicyAssignment"]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"}
0.814975
0.067209
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleInstanceName": _SERIALIZER.url( "role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentScheduleInstance"]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule instances created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} @distributed_trace def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleInstance: """Gets the specified role assignment schedule instance. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py
_role_assignment_schedule_instances_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_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleInstanceName": _SERIALIZER.url( "role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentScheduleInstance"]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule instances created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} @distributed_trace def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleInstance: """Gets the specified role assignment schedule instance. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" }
0.843541
0.091585
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleName": _SERIALIZER.url( "role_assignment_schedule_name", role_assignment_schedule_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentSchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> _models.RoleAssignmentSchedule: """Get the specified role assignment schedule for a resource scope. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentSchedule"]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py
_role_assignment_schedules_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, role_assignment_schedule_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleName": _SERIALIZER.url( "role_assignment_schedule_name", role_assignment_schedule_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentSchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, role_assignment_schedule_name: str, **kwargs: Any) -> _models.RoleAssignmentSchedule: """Get the specified role assignment schedule for a resource scope. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentSchedule"]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"}
0.858985
0.091261
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_get_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/eligibleChildResources") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class EligibleChildResourcesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`eligible_child_resources` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.EligibleChildResource"]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only resource of type = 'Subscription'. Use $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EligibleChildResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_get_request( scope=scope, filter=filter, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"}
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py
_eligible_child_resources_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, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/eligibleChildResources") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class EligibleChildResourcesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`eligible_child_resources` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scope: str, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.EligibleChildResource"]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only resource of type = 'Subscription'. Use $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EligibleChildResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_get_request( scope=scope, filter=filter, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"}
0.856302
0.08061
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_create_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class RoleEligibilityScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: _models.RoleEligibilityScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: Union[_models.RoleEligibilityScheduleRequest, IO], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a RoleEligibilityScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace def get( self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Get the specified role eligibility schedule request. :param scope: The scope of the role eligibility schedule request. Required. :type scope: str :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleEligibilityScheduleRequest"]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role eligibility schedule request. :param scope: The scope of the role eligibility request to cancel. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py
_role_eligibility_schedule_requests_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_create_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_cancel_request(scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleRequestName": _SERIALIZER.url( "role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class RoleEligibilityScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: _models.RoleEligibilityScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: Union[_models.RoleEligibilityScheduleRequest, IO], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a RoleEligibilityScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace def get( self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Get the specified role eligibility schedule request. :param scope: The scope of the role eligibility schedule request. Required. :type scope: str :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleEligibilityScheduleRequest"]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role eligibility schedule request. :param scope: The scope of the role eligibility request to cancel. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" }
0.78691
0.080213
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_create_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: _models.RoleAssignmentScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: Union[_models.RoleAssignmentScheduleRequest, IO], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a RoleAssignmentScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace def get( self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Get the specified role assignment schedule request. :param scope: The scope of the role assignment schedule request. Required. :type scope: str :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentScheduleRequest"]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role assignment schedule requests created for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role assignment schedule request. :param scope: The scope of the role assignment request to cancel. Required. :type scope: str :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py
_role_assignment_schedule_requests_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_create_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_cancel_request(scope: str, role_assignment_schedule_request_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentScheduleRequestName": _SERIALIZER.url( "role_assignment_schedule_request_name", role_assignment_schedule_request_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: _models.RoleAssignmentScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_schedule_request_name: str, parameters: Union[_models.RoleAssignmentScheduleRequest, IO], **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The name must be unique and different for each role assignment. Required. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. Is either a RoleAssignmentScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentScheduleRequest") request = build_create_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace def get( self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleRequest: """Get the specified role assignment schedule request. :param scope: The scope of the role assignment schedule request. Required. :type scope: str :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule request to get. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignmentScheduleRequest"]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role assignment schedule requests created for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleRequest or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} @distributed_trace def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role assignment schedule request. :param scope: The scope of the role assignment request to cancel. Required. :type scope: str :param role_assignment_schedule_request_name: The name of the role assignment request to cancel. Required. :type role_assignment_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_assignment_schedule_request_name=role_assignment_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel" }
0.821474
0.074265
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleInstanceName": _SERIALIZER.url( "role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleEligibilityScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleEligibilityScheduleInstance"]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} @distributed_trace def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleInstance: """Gets the specified role eligibility schedule instance. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" }
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py
_role_eligibility_schedule_instances_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_scope_request(scope: str, *, filter: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request(scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}", ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleEligibilityScheduleInstanceName": _SERIALIZER.url( "role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, "str" ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) class RoleEligibilityScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleEligibilityScheduleInstance"]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} @distributed_trace def get( self, scope: str, role_eligibility_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleInstance: """Gets the specified role eligibility schedule instance. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}" }
0.861145
0.073397
from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False def build_list_for_subscription_request( subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request( scope: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_assignment_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request( role_assignment_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}/validate") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). Required. :type resource_type: str :param resource_name: The resource name. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def validate( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload def validate( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def validate( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_validate_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ValidationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized validate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload def create_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 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 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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create_by_id.metadata = {"url": "/{roleAssignmentId}"} @distributed_trace def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload def validate_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 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 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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_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/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_subscription_request( subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_group_request( resource_group_name: str, subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_resource_request( resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, subscription_id: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), "resourceGroupName": _SERIALIZER.url( "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 ), "resourceProviderNamespace": _SERIALIZER.url( "resource_provider_namespace", resource_provider_namespace, "str", skip_quote=True ), "resourceType": _SERIALIZER.url("resource_type", resource_type, "str", skip_quote=True), "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( scope: str, role_assignment_name: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_request(scope: str, role_assignment_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" ) # pylint: disable=line-too-long path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_for_scope_request( scope: str, *, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: _params["$filter"] = _SERIALIZER.query("filter", filter, "str", skip_quote=True) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_id_request(role_assignment_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_by_id_request( role_assignment_id: str, *, tenant_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if tenant_id is not None: _params["tenantId"] = _SERIALIZER.query("tenant_id", tenant_id, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_validate_by_id_request(role_assignment_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/{roleAssignmentId}/validate") path_format_arguments = { "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, "str", skip_quote=True), } _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class RoleAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.AuthorizationManagementClient`'s :attr:`role_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_subscription.metadata = { "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource_group( self, resource_group_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource_group.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def list_for_resource( self, resource_group_name: str, resource_provider_namespace: str, resource_type: str, resource_name: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param resource_provider_namespace: The namespace of the resource provider. Required. :type resource_provider_namespace: str :param resource_type: The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). Required. :type resource_type: str :param resource_name: The resource name. Required. :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_resource_request( resource_group_name=resource_group_name, resource_provider_namespace=resource_provider_namespace, resource_type=resource_type, resource_name=resource_name, subscription_id=self._config.subscription_id, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_resource.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments" } @distributed_trace def get( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def create( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def create( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_create_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @distributed_trace def delete( self, scope: str, role_assignment_name: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment or None or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment or None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[Optional[_models.RoleAssignment]] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_assignment_name=role_assignment_name, tenant_id=tenant_id, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} @overload def validate( self, scope: str, role_assignment_name: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload def validate( self, scope: str, role_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace def validate( self, scope: str, role_assignment_name: str, parameters: Union[_models.RoleAssignmentCreateParameters, IO], **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. Required. :type role_assignment_name: str :param parameters: Parameters for the role assignment. Is either a RoleAssignmentCreateParameters type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ValidationResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleAssignmentCreateParameters") request = build_validate_request( scope=scope, role_assignment_name=role_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.validate.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ValidationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized validate.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.RoleAssignment"]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, tenant_id=tenant_id, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignments"} @distributed_trace def get_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> _models.RoleAssignment: """Get a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload def create_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleAssignment: """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 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 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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if response.status_code == 201: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore create_by_id.metadata = {"url": "/{roleAssignmentId}"} @distributed_trace def delete_by_id( self, role_assignment_id: str, tenant_id: Optional[str] = None, **kwargs: Any ) -> Optional[_models.RoleAssignment]: """Delete a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: deserialized = self._deserialize("RoleAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized delete_by_id.metadata = {"url": "/{roleAssignmentId}"} @overload def validate_by_id( self, role_assignment_id: str, parameters: _models.RoleAssignmentCreateParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidationResponse: """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, resource name, and resource type. Format: /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:`<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 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 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 = self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_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.802826
0.076822
from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration from .operations import ( EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleAssignmentsOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentsOperations :ivar eligible_child_resources: EligibleChildResourcesOperations operations :vartype eligible_child_resources: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.EligibleChildResourcesOperations :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations :vartype role_assignment_schedules: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentSchedulesOperations :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations :vartype role_assignment_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleInstancesOperations :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations :vartype role_assignment_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations :vartype role_eligibility_schedules: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilitySchedulesOperations :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations operations :vartype role_eligibility_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleInstancesOperations :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations :vartype role_eligibility_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations :ivar role_management_policies: RoleManagementPoliciesOperations operations :vartype role_management_policies: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPoliciesOperations :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations :vartype role_management_policy_assignments: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.eligible_child_resources = EligibleChildResourcesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedules = RoleAssignmentSchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policies = RoleManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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/v2020_10_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 ( EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleAssignmentsOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations, ) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations :vartype role_assignments: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentsOperations :ivar eligible_child_resources: EligibleChildResourcesOperations operations :vartype eligible_child_resources: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.EligibleChildResourcesOperations :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations :vartype role_assignment_schedules: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentSchedulesOperations :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations :vartype role_assignment_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleInstancesOperations :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations :vartype role_assignment_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations :vartype role_eligibility_schedules: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilitySchedulesOperations :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations operations :vartype role_eligibility_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleInstancesOperations :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations :vartype role_eligibility_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations :ivar role_management_policies: RoleManagementPoliciesOperations operations :vartype role_management_policies: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPoliciesOperations :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations :vartype role_management_policy_assignments: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: self._config = AuthorizationManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.role_assignments = RoleAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.eligible_child_resources = EligibleChildResourcesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedules = RoleAssignmentSchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policies = RoleManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( self._client, self._config, self._serialize, self._deserialize, "2020-10-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <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.802594
0.083367
from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
azure-mgmt-authorization
/azure-mgmt-authorization-4.0.0.zip/azure-mgmt-authorization-4.0.0/azure/mgmt/authorization/v2020_10_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 "2020-10-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2020-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential self.subscription_id = subscription_id self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-authorization/{}".format(VERSION)) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( self.credential, *self.credential_scopes, **kwargs )
0.835013
0.088505
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_eligibility_schedules_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleEligibilitySchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any ) -> _models.RoleEligibilitySchedule: """Get the specified role eligibility schedule for a resource scope. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleEligibilitySchedule"]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedules at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"}
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_schedules_operations.py
_role_eligibility_schedules_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_schedules_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleEligibilitySchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_name: str, **kwargs: Any ) -> _models.RoleEligibilitySchedule: """Get the specified role eligibility schedule for a resource scope. :param scope: The scope of the role eligibility schedule. Required. :type scope: str :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. Required. :type role_eligibility_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilitySchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_name=role_eligibility_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilitySchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleEligibilitySchedule"]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedules at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilitySchedule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"}
0.895819
0.095476
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_management_policies_operations import ( build_delete_request, build_get_request, build_list_for_scope_request, build_update_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleManagementPoliciesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_management_policies` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: """Get the specified role management policy for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @overload async def update( self, scope: str, role_management_policy_name: str, parameters: _models.RoleManagementPolicy, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( self, scope: str, role_management_policy_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def update( self, scope: str, role_management_policy_name: str, parameters: Union[_models.RoleManagementPolicy, IO], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicy") request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized update.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_name: str, **kwargs: Any ) -> None: """Delete a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicy"]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"}
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_management_policies_operations.py
_role_management_policies_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_management_policies_operations import ( build_delete_request, build_get_request, build_list_for_scope_request, build_update_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleManagementPoliciesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_management_policies` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scope: str, role_management_policy_name: str, **kwargs: Any) -> _models.RoleManagementPolicy: """Get the specified role management policy for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to get. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @overload async def update( self, scope: str, role_management_policy_name: str, parameters: _models.RoleManagementPolicy, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( self, scope: str, role_management_policy_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def update( self, scope: str, role_management_policy_name: str, parameters: Union[_models.RoleManagementPolicy, IO], **kwargs: Any ) -> _models.RoleManagementPolicy: """Update a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :param parameters: Parameters for the role management policy. Is either a RoleManagementPolicy type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicy") request = build_update_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized update.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_name: str, **kwargs: Any ) -> None: """Delete a role management policy. :param scope: The scope of the role management policy to upsert. Required. :type scope: str :param role_management_policy_name: The name (guid) of the role management policy to upsert. Required. :type role_management_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_name=role_management_policy_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicy"]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"}
0.91504
0.079496
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_management_policy_assignments_operations import ( build_create_request, build_delete_request, build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleManagementPolicyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_management_policy_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Get the specified role management policy assignment for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @overload async def create( self, scope: str, role_management_policy_assignment_name: str, parameters: _models.RoleManagementPolicyAssignment, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_management_policy_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_management_policy_assignment_name: str, parameters: Union[_models.RoleManagementPolicyAssignment, IO], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a RoleManagementPolicyAssignment type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> None: """Delete a role management policy assignment. :param scope: The scope of the role management policy assignment to delete. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicyAssignment"]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"}
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_management_policy_assignments_operations.py
_role_management_policy_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_management_policy_assignments_operations import ( build_create_request, build_delete_request, build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleManagementPolicyAssignmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_management_policy_assignments` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Get the specified role management policy assignment for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to get. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @overload async def create( self, scope: str, role_management_policy_assignment_name: str, parameters: _models.RoleManagementPolicyAssignment, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_management_policy_assignment_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_management_policy_assignment_name: str, parameters: Union[_models.RoleManagementPolicyAssignment, IO], **kwargs: Any ) -> _models.RoleManagementPolicyAssignment: """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to upsert. Required. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. Is either a RoleManagementPolicyAssignment type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleManagementPolicyAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleManagementPolicyAssignment") request = build_create_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleManagementPolicyAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_assignment_name: str, **kwargs: Any ) -> None: """Delete a role management policy assignment. :param scope: The scope of the role management policy assignment to delete. Required. :type scope: str :param role_management_policy_assignment_name: The name of format {guid_guid} the role management policy assignment to delete. Required. :type role_management_policy_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( scope=scope, role_management_policy_assignment_name=role_management_policy_assignment_name, api_version=api_version, template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}" } @distributed_trace def list_for_scope(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.RoleManagementPolicyAssignment"]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleManagementPolicyAssignment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleManagementPolicyAssignmentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"}
0.906398
0.095139
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentScheduleInstance"]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule instances created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleInstance: """Gets the specified role assignment schedule instance. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" }
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_instances_operations.py
_role_assignment_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_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentScheduleInstancesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedule_instances` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentScheduleInstance"]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule instances created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstanceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_instance_name: str, **kwargs: Any ) -> _models.RoleAssignmentScheduleInstance: """Gets the specified role assignment schedule instance. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the role assignment schedule to get. Required. :type role_assignment_schedule_instance_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleInstance or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleInstance] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentScheduleInstance", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}" }
0.899281
0.113457
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_assignment_schedules_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentSchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_name: str, **kwargs: Any ) -> _models.RoleAssignmentSchedule: """Get the specified role assignment schedule for a resource scope. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentSchedule"]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"}
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_schedules_operations.py
_role_assignment_schedules_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_schedules_operations import build_get_request, build_list_for_scope_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleAssignmentSchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_assignment_schedules` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( self, scope: str, role_assignment_schedule_name: str, **kwargs: Any ) -> _models.RoleAssignmentSchedule: """Get the specified role assignment schedule for a resource scope. :param scope: The scope of the role assignment schedule. Required. :type scope: str :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. Required. :type role_assignment_schedule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentSchedule] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_assignment_schedule_name=role_assignment_schedule_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleAssignmentSchedule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleAssignmentSchedule"]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules created for the current user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleAssignmentSchedule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleAssignmentScheduleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"}
0.899224
0.111604
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._eligible_child_resources_operations import build_get_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EligibleChildResourcesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`eligible_child_resources` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.EligibleChildResource"]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only resource of type = 'Subscription'. Use $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EligibleChildResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_get_request( scope=scope, filter=filter, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"}
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/_eligible_child_resources_operations.py
_eligible_child_resources_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._eligible_child_resources_operations import build_get_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EligibleChildResourcesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`eligible_child_resources` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.EligibleChildResource"]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only resource of type = 'Subscription'. Use $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EligibleChildResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.EligibleChildResourcesListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_get_request( scope=scope, filter=filter, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) get.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"}
0.887741
0.091585
from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error, ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._role_eligibility_schedule_requests_operations import ( build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleEligibilityScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: _models.RoleEligibilityScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: Union[_models.RoleEligibilityScheduleRequest, IO], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a RoleEligibilityScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Get the specified role eligibility schedule request. :param scope: The scope of the role eligibility schedule request. Required. :type scope: str :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleEligibilityScheduleRequest"]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role eligibility schedule request. :param scope: The scope of the role eligibility request to cancel. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" }
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_requests_operations.py
_role_eligibility_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_eligibility_schedule_requests_operations import ( build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request, ) T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RoleEligibilityScheduleRequestsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.authorization.v2020_10_01_preview.aio.AuthorizationManagementClient`'s :attr:`role_eligibility_schedule_requests` attribute. """ models = _models def __init__(self, *args, **kwargs) -> None: input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: _models.RoleEligibilityScheduleRequest, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( self, scope: str, role_eligibility_schedule_request_name: str, parameters: Union[_models.RoleEligibilityScheduleRequest, IO], **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be any REST resource instance. For example, use '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/' for a subscription, '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a resource group, and '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It can be any valid GUID. Required. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. Is either a RoleEligibilityScheduleRequest type or a IO type. Required. :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RoleEligibilityScheduleRequest") request = build_create_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, content_type=content_type, json=_json, content=_content, template_url=self.create.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized create.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace_async async def get( self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> _models.RoleEligibilityScheduleRequest: """Get the specified role eligibility schedule request. :param scope: The scope of the role eligibility schedule request. Required. :type scope: str :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule request to get. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequest] = kwargs.pop("cls", None) request = build_get_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.get.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RoleEligibilityScheduleRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized get.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}" } @distributed_trace def list_for_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.RoleEligibilityScheduleRequest"]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. Required. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RoleEligibilityScheduleRequest or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[_models.RoleEligibilityScheduleRequestListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_for_scope_request( scope=scope, filter=filter, api_version=api_version, template_url=self.list_for_scope.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._config.api_version request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) request.url = self._client.format_url(request.url) request.method = "GET" return request async def extract_data(pipeline_response): deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) list_for_scope.metadata = {"url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} @distributed_trace_async async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, **kwargs: Any ) -> None: """Cancels a pending role eligibility schedule request. :param scope: The scope of the role eligibility request to cancel. Required. :type scope: str :param role_eligibility_schedule_request_name: The name of the role eligibility request to cancel. Required. :type role_eligibility_schedule_request_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop( "api_version", _params.pop("api-version", self._api_version or "2020-10-01-preview") ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_cancel_request( scope=scope, role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, api_version=api_version, template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) request.url = self._client.format_url(request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) cancel.metadata = { "url": "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel" }
0.88513
0.063135