Google Cloud Storage C++ Client  1.42.0
A C++ Client Library for Google Cloud Storage
Public Member Functions | List of all members
google::cloud::storage::ObjectRewriter Class Reference

Complete long running object rewrite operations. More...

#include <google/cloud/storage/object_rewriter.h>

Public Member Functions

 ObjectRewriter (std::shared_ptr< internal::RawClient > client, internal::RewriteObjectRequest request)
 
StatusOr< RewriteProgressIterate ()
 Perform one iteration in the rewrite. More...
 
StatusOr< RewriteProgressCurrentProgress () const
 The current progress on the rewrite operation. More...
 
StatusOr< ObjectMetadataResult ()
 Iterate until the operation completes using a callback to report progress. More...
 
template<typename Functor , typename std::enable_if< google::cloud::internal::is_invocable< Functor, StatusOr< RewriteProgress >>::value, int >::type = 0>
StatusOr< ObjectMetadataResultWithProgressCallback (Functor cb)
 Iterate until the operation completes using a callback to report progress. More...
 
std::string const & token () const
 The current rewrite token. More...
 

Detailed Description

Complete long running object rewrite operations.

The Client::RewriteObject() operation allows applications to copy objects across location boundaries, and to rewrite objects with different encryption keys. In some circumstances it may take multiple calls to the service to complete a rewrite, this class encapsulates the state of a partial copy.

Definition at line 49 of file object_rewriter.h.

Constructor & Destructor Documentation

◆ ObjectRewriter()

google::cloud::storage::ObjectRewriter::ObjectRewriter ( std::shared_ptr< internal::RawClient >  client,
internal::RewriteObjectRequest  request 
)

Member Function Documentation

◆ CurrentProgress()

StatusOr<RewriteProgress> google::cloud::storage::ObjectRewriter::CurrentProgress ( ) const
inline

The current progress on the rewrite operation.

Definition at line 64 of file object_rewriter.h.

◆ Iterate()

StatusOr<RewriteProgress> google::cloud::storage::ObjectRewriter::Iterate ( )

Perform one iteration in the rewrite.

Returns
The progress after the iteration. If the rewrite has completed the application can use Result() to examine the metadata for the newly created object.

◆ Result()

StatusOr<ObjectMetadata> google::cloud::storage::ObjectRewriter::Result ( )
inline

Iterate until the operation completes using a callback to report progress.

Note
This operation blocks until the copy is finished. For very large objects that could take substantial time. Applications may need to persist the rewrite operation. Some applications may want to wrap this call with std::async, and run the copy on a separate thread.
Returns
the object metadata once the copy completes.

Definition at line 81 of file object_rewriter.h.

◆ ResultWithProgressCallback()

template<typename Functor , typename std::enable_if< google::cloud::internal::is_invocable< Functor, StatusOr< RewriteProgress >>::value, int >::type = 0>
StatusOr<ObjectMetadata> google::cloud::storage::ObjectRewriter::ResultWithProgressCallback ( Functor  cb)
inline

Iterate until the operation completes using a callback to report progress.

Note
This operation blocks until the copy is finished. For very large objects that could take substantial time. Applications may need to persist the rewrite operation. Some applications may want to wrap this call with std::async, and run the copy on a separate thread.
Parameters
cbthe callback object.
Template Parameters
Functorthe type of the callback object. It must satisfy: std:is_invocable<Functor, StatusOr<RewriteProgress>>:: value == true.
Returns
the object metadata once the copy completes.

Definition at line 105 of file object_rewriter.h.

◆ token()

std::string const& google::cloud::storage::ObjectRewriter::token ( ) const
inline

The current rewrite token.

Applications can save the token of partially completed rewrites, and restart those operations using Client::CopyObjectRestart, even if the application has terminated. It is up to the application to preserve all the other information for the request, including source and destination buckets, encryption keys, and any preconditions affecting the request.

Note
For rewrites that have not started the token is an empty string. For rewrites that have completed the token is also an empty string. The application should preserve other information (such as the RewriteProgress) to avoid repeating a rewrite.

Definition at line 129 of file object_rewriter.h.