Ejemplo n.º 1
0
    def grants(self):
        """
        Returns grants for the current user
        """
        from linode_api4.objects.account import UserGrants
        resp = self._client.get('/profile/grants') # use special endpoint for restricted users

        grants = None
        if resp is not None:
            # if resp is None, we're unrestricted and do not have grants
            grants = UserGrants(self._client, self.username, resp)

        return grants
Ejemplo n.º 2
0
    def grants(self):
        """
        Retrieves the grants for this user.  If the user is unrestricted, this
        will result in an ApiError.  This is smart, and will only fetch from the
        api once unless the object is invalidated.

        :returns: The grants for this user.
        :rtype: linode.objects.account.UserGrants
        """
        from linode_api4.objects.account import UserGrants  # pylint: disable-all
        if not hasattr(self, '_grants'):
            resp = self._client.get(
                UserGrants.api_endpoint.format(username=self.username))

            grants = UserGrants(self._client, self.username, resp)
            self._set('_grants', grants)

        return self._grants