Skip to content

restore_from_snapshot async

restore_from_snapshot(
    snapshot_id: SnapshotId,
    *,
    config_overrides: Optional[AsyncDirectoryServiceClientConfig] = None,
) -> RestoreFromSnapshotResult

Restores a directory using an existing directory snapshot.

When you restore a directory from a snapshot, any changes made to the directory after the snapshot date are overwritten.

This action returns as soon as the restore operation is initiated. You can monitor the progress of the restore operation by calling the DescribeDirectories operation with the directory identifier. When the DirectoryDescription.Stage value changes to Active, the restore operation is complete.

Parameters:

  • snapshot_id (SnapshotId) –

    The identifier of the snapshot to restore from.

Raises:

Examples:

To restore a snapshot The following example restores a directory using an existing directory snapshot.

>>> await client.restore_from_snapshot(snapshot_id='s-9267f6da4e')
Source code in docs_src/capo_directory_service/_services/async_directory_service.py
async def restore_from_snapshot(
    self,
    snapshot_id: "capo_directory_service.types.snapshot_id.SnapshotId",
    *,
    config_overrides: Optional[AsyncDirectoryServiceClientConfig] = None,
) -> "capo_directory_service.types.restore_from_snapshot_result.RestoreFromSnapshotResult":
    """<p>Restores a directory using an existing directory snapshot.</p> <p>When you restore a directory from a snapshot, any changes made to the directory after the snapshot date are overwritten.</p> <p>This action returns as soon as the restore operation is initiated. You can monitor the progress of the restore operation by calling the <a>DescribeDirectories</a> operation with the directory identifier. When the <b>DirectoryDescription.Stage</b> value changes to <code>Active</code>, the restore operation is complete.</p>

    Args:
        snapshot_id: <p>The identifier of the snapshot to restore from.</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.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To restore a snapshot
        The following example restores a directory using an existing directory snapshot.

        >>> await client.restore_from_snapshot(snapshot_id='s-9267f6da4e')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_directory_service.types.restore_from_snapshot_request.RestoreFromSnapshotRequest]",
    ) -> AsyncOperationResponse[
        "capo_directory_service.types.restore_from_snapshot_result.RestoreFromSnapshotResult"
    ]:
        import capo_directory_service._operations.directory_service_20150416.restore_from_snapshot

        (
            output,
            http_response,
        ) = await capo_directory_service._operations.directory_service_20150416.restore_from_snapshot.async_restore_from_snapshot(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("RestoreFromSnapshot")
    )
    input_: capo_directory_service.types.restore_from_snapshot_request.RestoreFromSnapshotRequest = {
        "snapshot_id": snapshot_id
    }

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