Skip to content

create_snapshot

create_snapshot(
    directory_id: DirectoryId,
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    name: Optional[SnapshotName] = None,
) -> CreateSnapshotResult

Creates a snapshot of a Simple AD or Microsoft AD directory in the Amazon Web Services cloud.

You cannot take snapshots of AD Connector directories.

Parameters:

  • directory_id (DirectoryId) –

    The identifier of the directory of which to take a snapshot.

  • name (Optional[SnapshotName], default: None ) –

    The descriptive name to apply to the snapshot.

Raises:

Examples:

To create a snapshot of a directory The following example creates a snapshot of a Simple AD or Microsoft AD directory in the AWS cloud.

>>> client.create_snapshot(directory_id='d-92654abfed', name='ad.example.com')
Source code in docs_src/capo_directory_service/_services/directory_service.py
def create_snapshot(
    self,
    directory_id: "capo_directory_service.types.directory_id.DirectoryId",
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    name: Optional[
        "capo_directory_service.types.snapshot_name.SnapshotName"
    ] = None,
) -> "capo_directory_service.types.create_snapshot_result.CreateSnapshotResult":
    """<p>Creates a snapshot of a Simple AD or Microsoft AD directory in the Amazon Web Services cloud.</p> <note> <p>You cannot take snapshots of AD Connector directories.</p> </note>

    Args:
        directory_id: <p>The identifier of the directory of which to take a snapshot.</p>
        name: <p>The descriptive name to apply to the snapshot.</p>

    Raises:
        capo_directory_service.errors.client_exception.ClientException: <p>A client exception has occurred.</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.snapshot_limit_exceeded_exception.SnapshotLimitExceededException: <p>The maximum number of manual snapshots for the directory has been reached. You can use the <a>GetSnapshotLimits</a> operation to determine the snapshot limits for a directory.</p>
        capo_directory_service.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a snapshot of a directory
        The following example creates a snapshot of a Simple AD or Microsoft AD directory in the AWS cloud.

        >>> client.create_snapshot(directory_id='d-92654abfed', name='ad.example.com')
    """

    def _handler(
        req: "OperationRequest[capo_directory_service.types.create_snapshot_request.CreateSnapshotRequest]",
    ) -> OperationResponse[
        "capo_directory_service.types.create_snapshot_result.CreateSnapshotResult"
    ]:
        import capo_directory_service._operations.directory_service_20150416.create_snapshot

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSnapshot")
    )
    input_: capo_directory_service.types.create_snapshot_request.CreateSnapshotRequest = {
        "directory_id": directory_id
    }
    if name is not None:
        input_["name"] = name

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