Skip to content

workspaces

Workspace

Bases: BitbucketCloudBase

Source code in server/vendor/atlassian/bitbucket/cloud/workspaces/__init__.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
class Workspace(BitbucketCloudBase):
    def __init__(self, data, *args, **kwargs):
        super(Workspace, self).__init__(None, *args, data=data, expected_type="workspace", **kwargs)
        self.__permissions = Permissions(self.url_joiner(self.url, "permissions"), **self._new_session_args)
        self.__projects = Projects(self.get_link("projects"), **self._new_session_args)
        self.__repositories = WorkspaceRepositories(self.get_link("repositories"), **self._new_session_args)
        self.__members = WorkspaceMembers(self.get_link("members"), **self._new_session_args)

    @property
    def name(self):
        """The workspace name"""
        return self.get_data("name")

    @property
    def slug(self):
        """The workspace slug"""
        return self.get_data("slug")

    @property
    def uuid(self):
        """The workspace uuid"""
        return self.get_data("uuid")

    @property
    def is_private(self):
        """The workspace private flag"""
        return self.get_data("is_private")

    @property
    def created_on(self):
        """The workspace creation time"""
        return self.get_data("created_on")

    @property
    def updated_on(self):
        """The workspace last update time"""
        return self.get_data("updated_on", "never updated")

    def get_avatar(self):
        """The project avatar"""
        return self.get(self.get_link("avatar"), absolute=True)

    @property
    def permissions(self):
        """The workspace permissions repositories"""
        return self.__permissions

    @property
    def projects(self):
        """The workspace projects"""
        return self.__projects

    @property
    def repositories(self):
        """The workspace repositories"""
        return self.__repositories

    @property
    def members(self):
        """The workspace members"""
        return self.__members

created_on property

The workspace creation time

is_private property

The workspace private flag

members property

The workspace members

name property

The workspace name

permissions property

The workspace permissions repositories

projects property

The workspace projects

repositories property

The workspace repositories

slug property

The workspace slug

updated_on property

The workspace last update time

uuid property

The workspace uuid

get_avatar()

The project avatar

Source code in server/vendor/atlassian/bitbucket/cloud/workspaces/__init__.py
124
125
126
def get_avatar(self):
    """The project avatar"""
    return self.get(self.get_link("avatar"), absolute=True)

Workspaces

Bases: BitbucketCloudBase

Source code in server/vendor/atlassian/bitbucket/cloud/workspaces/__init__.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class Workspaces(BitbucketCloudBase):
    def __init__(self, url, *args, **kwargs):
        super(Workspaces, self).__init__(url, *args, **kwargs)

    def __get_object(self, data):
        return Workspace(data, **self._new_session_args)

    def each(self, role=None, q=None, sort=None):
        """
        Get all workspaces matching the criteria.

        :param role: string (default is None):
                    Filters the workspaces based on the authenticated user's role on each workspace.
                    * member: returns a list of all the workspaces which the caller is a member of
                                at least one workspace group or repository
                    * collaborator: returns a list of workspaces which the caller has written access
                            to at least one repository in the workspace
                    * owner: returns a list of workspaces which the caller has administrator access
        :param q: string (default is None):
                        Query string to narrow down the response.
                        See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
        :param sort: string (default is None):
                        Name of a response property to sort results.
                        See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.

        :return: A generator for the Workspace objects

        API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces#get.
        """
        params = {}
        if role is not None:
            params["role"] = role
        if q is not None:
            params["q"] = q
        if sort is not None:
            params["sort"] = sort
        for workspace in self._get_paged(None, params):
            yield self.__get_object(workspace)

        return

    def get(self, workspace):
        """
        Returns the requested workspace

        :param workspace: string: This can either be the workspace ID (slug) or the workspace UUID
                                  surrounded by curly-braces, for example: {workspace UUID}.

        :return: The requested Workspace objects

        API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D#get
        """
        return self.__get_object(super(Workspaces, self).get(workspace))

    def exists(self, workspace):
        """
        Check if workspace exist.

        :param workspace: string: The requested workspace.

        :return: True if the workspace exists

        API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D#get
        """
        exists = False
        try:
            self.get(workspace)
            exists = True
        except HTTPError as e:
            if e.response.status_code in (401, 404):
                pass
        return exists

each(role=None, q=None, sort=None)

Get all workspaces matching the criteria.

:param role: string (default is None): Filters the workspaces based on the authenticated user's role on each workspace. * member: returns a list of all the workspaces which the caller is a member of at least one workspace group or repository * collaborator: returns a list of workspaces which the caller has written access to at least one repository in the workspace * owner: returns a list of workspaces which the caller has administrator access :param q: string (default is None): Query string to narrow down the response. See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details. :param sort: string (default is None): Name of a response property to sort results. See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.

:return: A generator for the Workspace objects

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces#get.

Source code in server/vendor/atlassian/bitbucket/cloud/workspaces/__init__.py
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
48
49
50
51
def each(self, role=None, q=None, sort=None):
    """
    Get all workspaces matching the criteria.

    :param role: string (default is None):
                Filters the workspaces based on the authenticated user's role on each workspace.
                * member: returns a list of all the workspaces which the caller is a member of
                            at least one workspace group or repository
                * collaborator: returns a list of workspaces which the caller has written access
                        to at least one repository in the workspace
                * owner: returns a list of workspaces which the caller has administrator access
    :param q: string (default is None):
                    Query string to narrow down the response.
                    See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.
    :param sort: string (default is None):
                    Name of a response property to sort results.
                    See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details.

    :return: A generator for the Workspace objects

    API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces#get.
    """
    params = {}
    if role is not None:
        params["role"] = role
    if q is not None:
        params["q"] = q
    if sort is not None:
        params["sort"] = sort
    for workspace in self._get_paged(None, params):
        yield self.__get_object(workspace)

    return

exists(workspace)

Check if workspace exist.

:param workspace: string: The requested workspace.

:return: True if the workspace exists

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D#get

Source code in server/vendor/atlassian/bitbucket/cloud/workspaces/__init__.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def exists(self, workspace):
    """
    Check if workspace exist.

    :param workspace: string: The requested workspace.

    :return: True if the workspace exists

    API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D#get
    """
    exists = False
    try:
        self.get(workspace)
        exists = True
    except HTTPError as e:
        if e.response.status_code in (401, 404):
            pass
    return exists

get(workspace)

Returns the requested workspace

:param workspace: string: This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: {workspace UUID}.

:return: The requested Workspace objects

API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D#get

Source code in server/vendor/atlassian/bitbucket/cloud/workspaces/__init__.py
53
54
55
56
57
58
59
60
61
62
63
64
def get(self, workspace):
    """
    Returns the requested workspace

    :param workspace: string: This can either be the workspace ID (slug) or the workspace UUID
                              surrounded by curly-braces, for example: {workspace UUID}.

    :return: The requested Workspace objects

    API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D#get
    """
    return self.__get_object(super(Workspaces, self).get(workspace))