Skip to content

create_resource

create_resource(
    organization_id: OrganizationId,
    name: ResourceName,
    type: ResourceType,
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    description: Optional[ResourceDescription] = None,
    hidden_from_global_address_list: Optional[Boolean] = None,
) -> CreateResourceResponse

Creates a new WorkMail resource.

Parameters:

  • organization_id (OrganizationId) –

    The identifier associated with the organization for which the resource is created.

  • name (ResourceName) –

    The name of the new resource.

  • type (ResourceType) –

    The type of the new resource. The available types are equipment and room.

  • description (Optional[ResourceDescription], default: None ) –

    Resource description.

  • hidden_from_global_address_list (Optional[Boolean], default: None ) –

    If this parameter is enabled, the resource will be hidden from the address book.

Raises:

Source code in docs_src/capo_workmail/_services/work_mail.py
def create_resource(
    self,
    organization_id: "capo_workmail.types.organization_id.OrganizationId",
    name: "capo_workmail.types.resource_name.ResourceName",
    type: "capo_workmail.types.resource_type.ResourceType",
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    description: Optional[
        "capo_workmail.types.resource_description.ResourceDescription"
    ] = None,
    hidden_from_global_address_list: Optional[
        "capo_workmail.types.boolean.Boolean"
    ] = None,
) -> "capo_workmail.types.create_resource_response.CreateResourceResponse":
    """<p>Creates a new WorkMail resource.</p>

    Args:
        organization_id: <p>The identifier associated with the organization for which the resource is created.</p>
        name: <p>The name of the new resource.</p>
        type: <p>The type of the new resource. The available types are <code>equipment</code> and <code>room</code>.</p>
        description: <p>Resource description.</p>
        hidden_from_global_address_list: <p>If this parameter is enabled, the resource will be hidden from the address book.</p>

    Raises:
        capo_workmail.errors.directory_service_authentication_failed_exception.DirectoryServiceAuthenticationFailedException: <p>The directory service doesn't recognize the credentials supplied by WorkMail.</p>
        capo_workmail.errors.directory_unavailable_exception.DirectoryUnavailableException: <p>The directory is unavailable. It might be located in another Region or deleted.</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.name_availability_exception.NameAvailabilityException: <p>The user, group, or resource name isn't unique in WorkMail.</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.reserved_name_exception.ReservedNameException: <p>This user, group, or resource name is not allowed in WorkMail.</p>
        capo_workmail.errors.unsupported_operation_exception.UnsupportedOperationException: <p>You can't perform a write operation against a read-only directory.</p>
        capo_workmail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_workmail.types.create_resource_request.CreateResourceRequest]",
    ) -> OperationResponse[
        "capo_workmail.types.create_resource_response.CreateResourceResponse"
    ]:
        import capo_workmail._operations.work_mail_service.create_resource

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

    def _redact_input(
        input_: "capo_workmail.types.create_resource_request.CreateResourceRequest",
    ) -> dict[str, Any]:
        import capo_workmail.types.create_resource_request

        return capo_workmail.types.create_resource_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateResource", redact_input=_redact_input),
    )
    input_: capo_workmail.types.create_resource_request.CreateResourceRequest = {
        "organization_id": organization_id,
        "name": name,
        "type": type,
    }
    if description is not None:
        input_["description"] = description
    if hidden_from_global_address_list is not None:
        input_["hidden_from_global_address_list"] = hidden_from_global_address_list

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