def get_global_changes(self, db): r = requests.get("{}/{}/_changes".format(self.admin_url, db)) log_request(r) log_response(r) r.raise_for_status() resp_data = r.json() return resp_data["results"]
def get_active_tasks(self): r = requests.get("{}/_active_tasks".format(self.admin_url)) log_request(r) log_response(r) r.raise_for_status() resp_data = r.json() return resp_data
def get_num_docs(self, db): r = requests.get("{}/{}/_all_docs".format(self.url, db)) log_request(r) log_response(r) r.raise_for_status() resp_data = r.json() return resp_data["total_rows"]
def stop_pull_replication(self, source_url, source_db, target_db, continuous=True, use_remote_target=False, use_admin_url=False): sg_url = self.url if use_admin_url: sg_url = self.admin.admin_url data = { "source": "{}/{}".format(source_url, source_db), "cancel": True, "continuous": continuous } if use_remote_target: data["target"] = "{}/{}".format(sg_url, target_db) else: data["target"] = "{}".format(target_db) r = requests.post("{}/_replicate".format(sg_url), headers=self._headers, data=json.dumps(data)) log_request(r) log_response(r) r.raise_for_status() return r.json()
def add_design_doc(self, doc_id, content): data = json.dumps(content) r = self._session.put("{0}/{1}/_design/{2}".format( self.target.url, self.db, doc_id), data=data) log_request(r) log_response(r) r.raise_for_status()
def stop_replication_by_id(self, replication_id, use_admin_url=False): sg_url = self.url if use_admin_url: sg_url = self.admin.admin_url data = { "replication_id": "{}".format(replication_id), "cancel": True, } r = requests.post("{}/_replicate".format(sg_url), headers=self._headers, data=json.dumps(data)) log_request(r) log_response(r) r.raise_for_status()
def delete_db(self, name): r = requests.delete("{}/{}".format(self.admin_url, name)) log_request(r) log_response(r) r.raise_for_status() return r.json()
"continuous": continuous } if use_remote_source: data["source"] = "{}/{}".format(sg_url, source_db) else: data["source"] = "{}".format(source_db) if len(channels) > 0: data["filter"] = "sync_gateway/bychannel" data["query_params"] = channels if async is True: data["async"] = True r = requests.post("{}/_replicate".format(sg_url), headers=self._headers, data=json.dumps(data)) log_request(r) log_response(r) r.raise_for_status() return r.json() def stop_push_replication(self, target, source_db, target_db, continuous=True, use_remote_source=False, use_admin_url=False): sg_url = self.url if use_admin_url: sg_url = self.admin.admin_url
if use_remote_source: data["source"] = "{}/{}".format(sg_url, source_db) else: data["source"] = "{}".format(source_db) if len(channels) > 0: data["filter"] = "sync_gateway/bychannel" data["query_params"] = channels if async is True: data["async"] = True r = requests.post("{}/_replicate".format(sg_url), headers=self._headers, data=json.dumps(data)) log_request(r) log_response(r) r.raise_for_status() return r.json() def stop_push_replication(self, target, source_db, target_db, continuous=True, use_remote_source=False, use_admin_url=False): sg_url = self.url if use_admin_url: sg_url = self.admin.admin_url
def add_design_doc(self, doc_id, content): data = json.dumps(content) r = self._session.put("{0}/{1}/_design/{2}".format(self.target.url, self.db, doc_id), data=data) log_request(r) log_response(r) r.raise_for_status()