Creates a snapshot of an existing Amazon FSx for OpenZFS volume. With snapshots, you can easily undo file changes and compare file versions by restoring the volume to a previous version.
If a snapshot with the specified client request token exists, and the parameters match, this operation returns the description of the existing snapshot. If a snapshot with the specified client request token exists, and the parameters don't match, this operation returns IncompatibleParameterError. If a snapshot with the specified client request token doesn't exist, CreateSnapshot does the following:
-
Creates a new OpenZFS snapshot with an assigned ID, and an initial lifecycle state of CREATING.
-
Returns the description of the snapshot.
By using the idempotent operation, you can retry a CreateSnapshot operation without the risk of creating an extra snapshot. This approach can be useful when an initial call fails in a way that makes it unclear whether a snapshot was created. If you use the same client request token and the initial call created a snapshot, the operation returns a successful result because all the parameters are the same.
The CreateSnapshot operation returns while the snapshot's lifecycle state is still CREATING. You can check the snapshot creation status by calling the DescribeSnapshots operation, which returns the snapshot state along with other information.
Parameters:
Raises:
-
BadRequest
–
A generic error indicating a failure with a client request.
-
InternalServerError
–
A generic error indicating a server-side failure.
-
ServiceLimitExceeded
–
An error indicating that a particular service limit was exceeded. You can increase some service limits by contacting Amazon Web Services Support.
-
VolumeNotFound
–
No Amazon FSx volumes were found based upon the supplied parameters.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_fsx/_services/async_f_sx.py
| async def create_snapshot(
self,
*,
config_overrides: Optional[AsyncFSxClientConfig] = None,
client_request_token: Optional[
"capo_fsx.types.client_request_token.ClientRequestToken"
] = None,
name: Optional["capo_fsx.types.snapshot_name.SnapshotName"] = None,
volume_id: Optional["capo_fsx.types.volume_id.VolumeId"] = None,
tags: Optional["capo_fsx.types.tags.Tags"] = None,
) -> "capo_fsx.types.create_snapshot_response.CreateSnapshotResponse":
"""<p>Creates a snapshot of an existing Amazon FSx for OpenZFS volume. With snapshots, you can easily undo file changes and compare file versions by restoring the volume to a previous version.</p> <p>If a snapshot with the specified client request token exists, and the parameters match, this operation returns the description of the existing snapshot. If a snapshot with the specified client request token exists, and the parameters don't match, this operation returns <code>IncompatibleParameterError</code>. If a snapshot with the specified client request token doesn't exist, <code>CreateSnapshot</code> does the following:</p> <ul> <li> <p>Creates a new OpenZFS snapshot with an assigned ID, and an initial lifecycle state of <code>CREATING</code>.</p> </li> <li> <p>Returns the description of the snapshot.</p> </li> </ul> <p>By using the idempotent operation, you can retry a <code>CreateSnapshot</code> operation without the risk of creating an extra snapshot. This approach can be useful when an initial call fails in a way that makes it unclear whether a snapshot was created. If you use the same client request token and the initial call created a snapshot, the operation returns a successful result because all the parameters are the same.</p> <p>The <code>CreateSnapshot</code> operation returns while the snapshot's lifecycle state is still <code>CREATING</code>. You can check the snapshot creation status by calling the <a href="https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeSnapshots.html">DescribeSnapshots</a> operation, which returns the snapshot state along with other information.</p>
Args:
name: <p>The name of the snapshot. </p>
volume_id: <p>The ID of the volume that you are taking a snapshot of.</p>
Raises:
capo_fsx.errors.bad_request.BadRequest: <p>A generic error indicating a failure with a client request.</p>
capo_fsx.errors.internal_server_error.InternalServerError: <p>A generic error indicating a server-side failure.</p>
capo_fsx.errors.service_limit_exceeded.ServiceLimitExceeded: <p>An error indicating that a particular service limit was exceeded. You can increase some service limits by contacting Amazon Web Services Support.</p>
capo_fsx.errors.volume_not_found.VolumeNotFound: <p>No Amazon FSx volumes were found based upon the supplied parameters.</p>
capo_fsx.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_fsx.types.create_snapshot_request.CreateSnapshotRequest]",
) -> AsyncOperationResponse[
"capo_fsx.types.create_snapshot_response.CreateSnapshotResponse"
]:
import capo_fsx._operations.aws_simba_api_service_v20180301.create_snapshot
(
output,
http_response,
) = await capo_fsx._operations.aws_simba_api_service_v20180301.create_snapshot.async_create_snapshot(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
def _redact_output(
output: "capo_fsx.types.create_snapshot_response.CreateSnapshotResponse",
) -> dict[str, Any]:
import capo_fsx.types.create_snapshot_response
return capo_fsx.types.create_snapshot_response.redact_sensitive(output)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("CreateSnapshot", redact_output=_redact_output),
)
input_: capo_fsx.types.create_snapshot_request.CreateSnapshotRequest = {}
if client_request_token is None:
client_request_token = str(uuid.uuid4())
input_["client_request_token"] = client_request_token
if name is not None:
input_["name"] = name
if volume_id is not None:
input_["volume_id"] = volume_id
if tags is not None:
input_["tags"] = tags
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|