File size: 1,613 Bytes
56d74b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# coding=utf-8

from .base import BitbucketServerBase
from .projects import Projects
from .globalPermissions import Groups, Users


class Server(BitbucketServerBase):
    """
    Class implementing parts of the REST API described in
    https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html
    """

    def __init__(self, url, *args, **kwargs):
        kwargs["cloud"] = False
        kwargs["api_root"] = "rest/api"
        kwargs["api_version"] = "1.0"
        url = url.strip("/") + "/{}/{}".format(kwargs["api_root"], kwargs["api_version"])
        super(Server, self).__init__(url, *args, **kwargs)
        self.__projects = Projects(self._sub_url("projects"), **self._new_session_args)
        self.__groups = Groups(self._sub_url("admin/permissions/groups"), **self._new_session_args)
        self.__users = Users(self._sub_url("admin/permissions/users"), **self._new_session_args)

    @property
    def groups(self):
        """
        Property to access the global groups
        Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp62
        """
        return self.__groups

    @property
    def users(self):
        """
        Property to access the global users
        Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp68
        """
        return self.__users

    @property
    def projects(self):
        """
        Property to access the projects
        Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp147
        """
        return self.__projects