replicator¶
API module/class for handling database replications
-
class
cloudant.replicator.
Replicator
(client)¶ Bases:
object
Provides a database replication API. A Replicator object is instantiated with a reference to a client/session. It retrieves the
_replicator
database for the specified client and uses that database object to manage replications.Parameters: client – Client instance used by the database. Can either be a CouchDB
orCloudant
client instance.-
create_replication
(source_db=None, target_db=None, repl_id=None, **kwargs)¶ Creates a new replication task.
Parameters: - source_db – Database object to replicate from. Can be either a
CouchDatabase
orCloudantDatabase
instance. - target_db – Database object to replicate to. Can be either a
CouchDatabase
orCloudantDatabase
instance. - repl_id (str) – Optional replication id. Generated internally if not explicitly set.
- user_ctx (dict) – Optional user to act as. Composed internally if not explicitly set.
- create_target (bool) – Specifies whether or not to create the target, if it does not already exist.
- continuous (bool) – If set to True then the replication will be continuous.
Returns: Replication document as a Document instance
- source_db – Database object to replicate from. Can be either a
-
follow_replication
(repl_id)¶ Blocks and streams status of a given replication.
For example:
for doc in replicator.follow_replication(repl_doc_id): # Process replication information as it comes in
Parameters: repl_id (str) – Replication id used to identify the replication to inspect. Returns: Iterable stream of copies of the replication Document and replication state as a str
for the specified replication id
-
list_replications
()¶ Retrieves all replication documents from the replication database.
Returns: List containing replication Document objects
-
replication_state
(repl_id)¶ Retrieves the state for the given replication. Possible values are
triggered
,completed
,error
, andNone
(meaning not yet triggered).Parameters: repl_id (str) – Replication id used to identify the replication to inspect. Returns: Replication state as a str
-
stop_replication
(repl_id)¶ Stops a replication based on the provided replication id by deleting the replication document from the replication database. The replication can only be stopped if it has not yet completed. If it has already completed then the replication document is still deleted from replication database.
Parameters: repl_id (str) – Replication id used to identify the replication to stop.
-