Skip to content

create_computer

create_computer(
    directory_id: DirectoryId,
    computer_name: ComputerName,
    password: ComputerPassword,
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    organizational_unit_distinguished_name: Optional[OrganizationalUnitDN] = None,
    computer_attributes: Optional[Attributes] = None,
) -> CreateComputerResult

Creates an Active Directory computer object in the specified directory.

Parameters:

  • directory_id (DirectoryId) –

    The identifier of the directory in which to create the computer account.

  • computer_name (ComputerName) –

    The name of the computer account.

  • password (ComputerPassword) –

    A one-time password that is used to join the computer to the directory. You should generate a random, strong password to use for this parameter.

  • organizational_unit_distinguished_name (Optional[OrganizationalUnitDN], default: None ) –

    The fully-qualified distinguished name of the organizational unit to place the computer account in.

  • computer_attributes (Optional[Attributes], default: None ) –

    An array of Attribute objects that contain any LDAP attributes to apply to the computer account.

Raises:

Examples:

To create a computer account The following example creates a computer account in the specified directory, and joins the computer to the directory.

>>> client.create_computer(directory_id='d-92654abfed', computer_name='labcomputer', password='Str0ngP@ssw0rd', organizational_unit_distinguished_name='OU=Computers,OU=example,DC=corp,DC=example,DC=com', computer_attributes=[{'Name': 'ip', 'Value': '192.168.101.100'}])
Source code in docs_src/capo_directory_service/_services/directory_service.py
def create_computer(
    self,
    directory_id: "capo_directory_service.types.directory_id.DirectoryId",
    computer_name: "capo_directory_service.types.computer_name.ComputerName",
    password: "capo_directory_service.types.computer_password.ComputerPassword",
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    organizational_unit_distinguished_name: Optional[
        "capo_directory_service.types.organizational_unit_dn.OrganizationalUnitDN"
    ] = None,
    computer_attributes: Optional[
        "capo_directory_service.types.attributes.Attributes"
    ] = None,
) -> "capo_directory_service.types.create_computer_result.CreateComputerResult":
    """<p>Creates an Active Directory computer object in the specified directory.</p>

    Args:
        directory_id: <p>The identifier of the directory in which to create the computer account.</p>
        computer_name: <p>The name of the computer account.</p>
        password: <p>A one-time password that is used to join the computer to the directory. You should generate a random, strong password to use for this parameter.</p>
        organizational_unit_distinguished_name: <p>The fully-qualified distinguished name of the organizational unit to place the computer account in.</p>
        computer_attributes: <p>An array of <a>Attribute</a> objects that contain any LDAP attributes to apply to the computer account.</p>

    Raises:
        capo_directory_service.errors.authentication_failed_exception.AuthenticationFailedException: <p>An authentication error occurred.</p>
        capo_directory_service.errors.client_exception.ClientException: <p>A client exception has occurred.</p>
        capo_directory_service.errors.directory_unavailable_exception.DirectoryUnavailableException: <p>The specified directory is unavailable.</p>
        capo_directory_service.errors.entity_already_exists_exception.EntityAlreadyExistsException: <p>The specified entity already exists.</p>
        capo_directory_service.errors.entity_does_not_exist_exception.EntityDoesNotExistException: <p>The specified entity could not be found.</p>
        capo_directory_service.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more parameters are not valid.</p>
        capo_directory_service.errors.service_exception.ServiceException: <p>An exception has occurred in Directory Service.</p>
        capo_directory_service.errors.unsupported_operation_exception.UnsupportedOperationException: <p>The operation is not supported.</p>
        capo_directory_service.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a computer account
        The following example creates a computer account in the specified directory, and joins the computer to the directory.

        >>> client.create_computer(directory_id='d-92654abfed', computer_name='labcomputer', password='Str0ngP@ssw0rd', organizational_unit_distinguished_name='OU=Computers,OU=example,DC=corp,DC=example,DC=com', computer_attributes=[{'Name': 'ip', 'Value': '192.168.101.100'}])
    """

    def _handler(
        req: "OperationRequest[capo_directory_service.types.create_computer_request.CreateComputerRequest]",
    ) -> OperationResponse[
        "capo_directory_service.types.create_computer_result.CreateComputerResult"
    ]:
        import capo_directory_service._operations.directory_service_20150416.create_computer

        output, http_response = (
            capo_directory_service._operations.directory_service_20150416.create_computer.create_computer(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_directory_service.types.create_computer_request.CreateComputerRequest",
    ) -> dict[str, Any]:
        import capo_directory_service.types.create_computer_request

        return (
            capo_directory_service.types.create_computer_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateComputer", redact_input=_redact_input),
    )
    input_: capo_directory_service.types.create_computer_request.CreateComputerRequest = {
        "directory_id": directory_id,
        "computer_name": computer_name,
        "password": password,
    }
    if organizational_unit_distinguished_name is not None:
        input_["organizational_unit_distinguished_name"] = (
            organizational_unit_distinguished_name
        )
    if computer_attributes is not None:
        input_["computer_attributes"] = computer_attributes

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