How to use the stashy.permissions.Permissions function in stashy

To help you get started, we’ve selected a few stashy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cosmin / stashy / stashy / repos.py View on Github external
The commits may be identified by hash, branch or tag name.

        since: the changeset id or ref (exclusively) to restrieve changesets after
        until: the changeset id or ref (inclusively) to retrieve changesets before.
        path: an optional path to filter changesets by.

        Support for withCounts is not implement.
        """
        params = dict(until=until, withCounts=False)
        if since is not None:
            params['since'] = since
        if path is not None:
            params['path'] = path
        return self.paginate('/commits', params=params)

    permissions = Nested(Permissions)
    repo_permissions = Nested(RepositoryPermissions,
                              relative_path="/permissions")

    pull_requests = Nested(PullRequests, relative_path="/pull-requests")
    settings = Nested(Settings)
    webhooks = Nested(Webhooks)
    branch_permissions = Nested(BranchPermissions, relative_path=None)
       
    @response_or_error
    def _get_public(self):
        """
        Args:
            N/A
        Returns:
            (bool): True if repo is public, False if it is not public
        """
github cosmin / stashy / stashy / permissions.py View on Github external
return self._client.put(self.url(), params=dict(name=user, permission=permission))

    @ok_or_error
    def revoke(self, user):
        """
        Revoke all permissions for a user.
        """
        return self._client.delete(self.url(), params=dict(name=user))


class Permissions(ResourceBase):
    groups = Nested(Groups)
    users = Nested(Users)


class ProjectPermissions(Permissions):
    def _url_for(self, permission):
        return self.url().rstrip("/") + "/" + permission + "/all"

    def _url_for_users(self):
        return self.url().rstrip("/") + "/users"

    def _url_for_groups(self):
        return self.url().rstrip("/") + "/groups"

    @ok_or_error
    def grant(self, permission):
        """
        Grant or revoke a project permission to all users, i.e. set the default permission.

        project permissions:
            * PROJECT_READ
github cosmin / stashy / stashy / permissions.py View on Github external
* PROJECT_ADMIN

        """
        return self._client.put(self._url_for_groups(), params=dict(name=group,
                                                                        permission=permission))

    @ok_or_error
    def revoke_from_group(self, group):
        """
        Revoke all project permissions from a group.

        """
        return self._client.delete(self._url_for_groups(), params=dict(name=group))


class RepositoryPermissions(Permissions):
    def _url_for(self):
        return self.url().rstrip("/") + "/users"

    def _url_for_users(self):
        return self.url().rstrip("/") + "/users"

    def _url_for_groups(self):
        return self.url().rstrip("/") + "/groups"

    @ok_or_error
    def grant(self, user, permission):
        """
        Grant or revoke a repository permission to all users, i.e. set the
        default permission.

        repository permissions: