Skip to content

create_mobile_device_access_rule async

create_mobile_device_access_rule(
    organization_id: OrganizationId,
    name: MobileDeviceAccessRuleName,
    effect: MobileDeviceAccessRuleEffect,
    *,
    config_overrides: Optional[AsyncWorkMailClientConfig] = None,
    client_token: Optional[IdempotencyClientToken] = None,
    description: Optional[MobileDeviceAccessRuleDescription] = None,
    device_types: Optional[DeviceTypeList] = None,
    not_device_types: Optional[DeviceTypeList] = None,
    device_models: Optional[DeviceModelList] = None,
    not_device_models: Optional[DeviceModelList] = None,
    device_operating_systems: Optional[DeviceOperatingSystemList] = None,
    not_device_operating_systems: Optional[DeviceOperatingSystemList] = None,
    device_user_agents: Optional[DeviceUserAgentList] = None,
    not_device_user_agents: Optional[DeviceUserAgentList] = None,
) -> CreateMobileDeviceAccessRuleResponse

Creates a new mobile device access rule for the specified WorkMail organization.

Parameters:

Raises:

Source code in docs_src/capo_workmail/_services/async_work_mail.py
async def create_mobile_device_access_rule(
    self,
    organization_id: "capo_workmail.types.organization_id.OrganizationId",
    name: "capo_workmail.types.mobile_device_access_rule_name.MobileDeviceAccessRuleName",
    effect: "capo_workmail.types.mobile_device_access_rule_effect.MobileDeviceAccessRuleEffect",
    *,
    config_overrides: Optional[AsyncWorkMailClientConfig] = None,
    client_token: Optional[
        "capo_workmail.types.idempotency_client_token.IdempotencyClientToken"
    ] = None,
    description: Optional[
        "capo_workmail.types.mobile_device_access_rule_description.MobileDeviceAccessRuleDescription"
    ] = None,
    device_types: Optional[
        "capo_workmail.types.device_type_list.DeviceTypeList"
    ] = None,
    not_device_types: Optional[
        "capo_workmail.types.device_type_list.DeviceTypeList"
    ] = None,
    device_models: Optional[
        "capo_workmail.types.device_model_list.DeviceModelList"
    ] = None,
    not_device_models: Optional[
        "capo_workmail.types.device_model_list.DeviceModelList"
    ] = None,
    device_operating_systems: Optional[
        "capo_workmail.types.device_operating_system_list.DeviceOperatingSystemList"
    ] = None,
    not_device_operating_systems: Optional[
        "capo_workmail.types.device_operating_system_list.DeviceOperatingSystemList"
    ] = None,
    device_user_agents: Optional[
        "capo_workmail.types.device_user_agent_list.DeviceUserAgentList"
    ] = None,
    not_device_user_agents: Optional[
        "capo_workmail.types.device_user_agent_list.DeviceUserAgentList"
    ] = None,
) -> "capo_workmail.types.create_mobile_device_access_rule_response.CreateMobileDeviceAccessRuleResponse":
    """<p>Creates a new mobile device access rule for the specified WorkMail organization.</p>

    Args:
        organization_id: <p>The WorkMail organization under which the rule will be created.</p>
        client_token: <p>The idempotency token for the client request.</p>
        name: <p>The rule name.</p>
        description: <p>The rule description.</p>
        effect: <p>The effect of the rule when it matches. Allowed values are <code>ALLOW</code> or <code>DENY</code>.</p>
        device_types: <p>Device types that the rule will match.</p>
        not_device_types: <p>Device types that the rule <b>will not</b> match. All other device types will match.</p>
        device_models: <p>Device models that the rule will match.</p>
        not_device_models: <p>Device models that the rule <b>will not</b> match. All other device models will match.</p>
        device_operating_systems: <p>Device operating systems that the rule will match.</p>
        not_device_operating_systems: <p>Device operating systems that the rule <b>will not</b> match. All other device operating systems will match.</p>
        device_user_agents: <p>Device user agents that the rule will match.</p>
        not_device_user_agents: <p>Device user agents that the rule <b>will not</b> match. All other device user agents will match.</p>

    Raises:
        capo_workmail.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more of the input parameters don't match the service's restrictions.</p>
        capo_workmail.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeds the limit of the resource.</p>
        capo_workmail.errors.organization_not_found_exception.OrganizationNotFoundException: <p>An operation received a valid organization identifier that either doesn't belong or exist in the system.</p>
        capo_workmail.errors.organization_state_exception.OrganizationStateException: <p>The organization must have a valid state to perform certain operations on the organization or its members.</p>
        capo_workmail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_workmail.types.create_mobile_device_access_rule_request.CreateMobileDeviceAccessRuleRequest]",
    ) -> AsyncOperationResponse[
        "capo_workmail.types.create_mobile_device_access_rule_response.CreateMobileDeviceAccessRuleResponse"
    ]:
        import capo_workmail._operations.work_mail_service.create_mobile_device_access_rule

        (
            output,
            http_response,
        ) = await capo_workmail._operations.work_mail_service.create_mobile_device_access_rule.async_create_mobile_device_access_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateMobileDeviceAccessRule")
    )
    input_: capo_workmail.types.create_mobile_device_access_rule_request.CreateMobileDeviceAccessRuleRequest = {
        "organization_id": organization_id,
        "name": name,
        "effect": effect,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if device_types is not None:
        input_["device_types"] = device_types
    if not_device_types is not None:
        input_["not_device_types"] = not_device_types
    if device_models is not None:
        input_["device_models"] = device_models
    if not_device_models is not None:
        input_["not_device_models"] = not_device_models
    if device_operating_systems is not None:
        input_["device_operating_systems"] = device_operating_systems
    if not_device_operating_systems is not None:
        input_["not_device_operating_systems"] = not_device_operating_systems
    if device_user_agents is not None:
        input_["device_user_agents"] = device_user_agents
    if not_device_user_agents is not None:
        input_["not_device_user_agents"] = not_device_user_agents

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output