Exemple #1
0
    def get_projects(self, include_archived=False):
        projects = []
        url = make_url(_BITBUCKET_API_URL, "repositories", self._user)
        while url is not None:
            r = self._do_request_raw("get", url)
            projects_obj = r.json()
            projects.extend(
                map(lambda o: _make_project(self, o), projects_obj["values"]))
            url = projects_obj.get("next")

        return projects
Exemple #2
0
 def create_project(self, project_name, is_private=True):
     visibility = "private" if is_private else "public"
     url = make_url(_GITLAB_API_URL,
                    "projects",
                    private_token=self._api_token)
     r = requests.post(url,
                       data={
                           "name": project_name,
                           "visibility": visibility
                       })
     r.raise_for_status()
Exemple #3
0
    def archive_project(self, project, confirmation_token=False):
        if not confirmation_token:
            raise RuntimeError("Dangerous operation disallowed")

        if self != project.provider:
            raise RuntimeError("Project does not belong to this provider")

        url = make_url(_GITLAB_API_URL, "projects",
                       self._encode_project_name(project.name), "archive")
        r = requests.post(url, data={"private_token": self._api_token})
        r.raise_for_status()
Exemple #4
0
    def get_projects(self, include_archived=False):
        projects = []

        url = make_url(_GITHUB_API_URL, "users", self._user, "repos")
        while True:
            r = self._do_request_raw("get", url)
            projects.extend(map(lambda o: _make_project(self, o), r.json()))
            next_link = r.links.get("next")
            if next_link is None: break
            url = next_link["url"]

        return projects
Exemple #5
0
 def _do_request(self, method, *args, **kwargs):
     url = make_url(*[_BITBUCKET_API_URL] + list(args), **kwargs)
     return self._do_request_raw(method, url)
Exemple #6
0
 def _delete(self, *args, **kwargs):
     url = make_url(*args, **kwargs)
     self._do_oauth_dance()
     r = self._client.delete(url)
     r.raise_for_status()