Skip to content

put_access_control_rule

put_access_control_rule(
    name: AccessControlRuleName,
    effect: AccessControlRuleEffect,
    description: AccessControlRuleDescription,
    organization_id: OrganizationId,
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    ip_ranges: Optional[IpRangeList] = None,
    not_ip_ranges: Optional[IpRangeList] = None,
    actions: Optional[ActionsList] = None,
    not_actions: Optional[ActionsList] = None,
    user_ids: Optional[UserIdList] = None,
    not_user_ids: Optional[UserIdList] = None,
    impersonation_role_ids: Optional[ImpersonationRoleIdList] = None,
    not_impersonation_role_ids: Optional[ImpersonationRoleIdList] = None,
) -> PutAccessControlRuleResponse

Adds a new access control rule for the specified organization. The rule allows or denies access to the organization for the specified IPv4 addresses, access protocol actions, user IDs and impersonation IDs. Adding a new rule with the same name as an existing rule replaces the older rule.

Parameters:

Raises:

Source code in docs_src/capo_workmail/_services/work_mail.py
def put_access_control_rule(
    self,
    name: "capo_workmail.types.access_control_rule_name.AccessControlRuleName",
    effect: "capo_workmail.types.access_control_rule_effect.AccessControlRuleEffect",
    description: "capo_workmail.types.access_control_rule_description.AccessControlRuleDescription",
    organization_id: "capo_workmail.types.organization_id.OrganizationId",
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    ip_ranges: Optional["capo_workmail.types.ip_range_list.IpRangeList"] = None,
    not_ip_ranges: Optional["capo_workmail.types.ip_range_list.IpRangeList"] = None,
    actions: Optional["capo_workmail.types.actions_list.ActionsList"] = None,
    not_actions: Optional["capo_workmail.types.actions_list.ActionsList"] = None,
    user_ids: Optional["capo_workmail.types.user_id_list.UserIdList"] = None,
    not_user_ids: Optional["capo_workmail.types.user_id_list.UserIdList"] = None,
    impersonation_role_ids: Optional[
        "capo_workmail.types.impersonation_role_id_list.ImpersonationRoleIdList"
    ] = None,
    not_impersonation_role_ids: Optional[
        "capo_workmail.types.impersonation_role_id_list.ImpersonationRoleIdList"
    ] = None,
) -> "capo_workmail.types.put_access_control_rule_response.PutAccessControlRuleResponse":
    """<p>Adds a new access control rule for the specified organization. The rule allows or denies access to the organization for the specified IPv4 addresses, access protocol actions, user IDs and impersonation IDs. Adding a new rule with the same name as an existing rule replaces the older rule.</p>

    Args:
        name: <p>The rule name.</p>
        effect: <p>The rule effect.</p>
        description: <p>The rule description.</p>
        ip_ranges: <p>IPv4 CIDR ranges to include in the rule.</p>
        not_ip_ranges: <p>IPv4 CIDR ranges to exclude from the rule.</p>
        actions: <p>Access protocol actions to include in the rule. Valid values include <code>ActiveSync</code>, <code>AutoDiscover</code>, <code>EWS</code>, <code>IMAP</code>, <code>SMTP</code>, <code>WindowsOutlook</code>, and <code>WebMail</code>.</p>
        not_actions: <p>Access protocol actions to exclude from the rule. Valid values include <code>ActiveSync</code>, <code>AutoDiscover</code>, <code>EWS</code>, <code>IMAP</code>, <code>SMTP</code>, <code>WindowsOutlook</code>, and <code>WebMail</code>.</p>
        user_ids: <p>User IDs to include in the rule.</p>
        not_user_ids: <p>User IDs to exclude from the rule.</p>
        organization_id: <p>The identifier of the organization.</p>
        impersonation_role_ids: <p>Impersonation role IDs to include in the rule.</p>
        not_impersonation_role_ids: <p>Impersonation role IDs to exclude from the rule.</p>

    Raises:
        capo_workmail.errors.entity_not_found_exception.EntityNotFoundException: <p>The identifier supplied for the user, group, or resource does not exist in your organization.</p>
        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.resource_not_found_exception.ResourceNotFoundException: <p>The resource cannot be found.</p>
        capo_workmail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_workmail.types.put_access_control_rule_request.PutAccessControlRuleRequest]",
    ) -> OperationResponse[
        "capo_workmail.types.put_access_control_rule_response.PutAccessControlRuleResponse"
    ]:
        import capo_workmail._operations.work_mail_service.put_access_control_rule

        output, http_response = (
            capo_workmail._operations.work_mail_service.put_access_control_rule.put_access_control_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutAccessControlRule")
    )
    input_: capo_workmail.types.put_access_control_rule_request.PutAccessControlRuleRequest = {
        "name": name,
        "effect": effect,
        "description": description,
        "organization_id": organization_id,
    }
    if ip_ranges is not None:
        input_["ip_ranges"] = ip_ranges
    if not_ip_ranges is not None:
        input_["not_ip_ranges"] = not_ip_ranges
    if actions is not None:
        input_["actions"] = actions
    if not_actions is not None:
        input_["not_actions"] = not_actions
    if user_ids is not None:
        input_["user_ids"] = user_ids
    if not_user_ids is not None:
        input_["not_user_ids"] = not_user_ids
    if impersonation_role_ids is not None:
        input_["impersonation_role_ids"] = impersonation_role_ids
    if not_impersonation_role_ids is not None:
        input_["not_impersonation_role_ids"] = not_impersonation_role_ids

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output