Exemplo n.º 1
0
 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"]
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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"]
Exemplo n.º 5
0
    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()
Exemplo n.º 6
0
 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"]
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
 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"]
Exemplo n.º 9
0
 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()
Exemplo n.º 10
0
    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()
Exemplo n.º 11
0
    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()
Exemplo n.º 12
0
 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()
Exemplo n.º 13
0
            "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
Exemplo n.º 14
0
        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
Exemplo n.º 15
0
 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()
Exemplo n.º 16
0
 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()