Sheeprider / BitBucket-api

Python library to interact with BitBucket REST API
ISC License
75 stars 65 forks source link

Get private repositories for team #14

Open facconi opened 9 years ago

facconi commented 9 years ago

I have browsed the documentation and played a lot with the library but I haven't found how to deal with the following issue: I need to browser all private repositories for my team. Thanks

robwilkerson commented 9 years ago

If I read it right, the source code would indicate that it's not possible. It seems to be explicitly retrieving the repos the authenticated user owns. The docs hint at this as well, but I was hoping the implementation was more permissive.

robwilkerson commented 9 years ago

@facconi I've made a few adjustments in repository.py that seem to fix the problem. The lack of activity (including a long outstanding pull request) on this project doesn't fill me with hope, but I'll try to get my changes in a pull request and see if I can get them merged.

In the meantime, if you update your copy of repository.py, replacing the existing all() function with the one below, it seems to be working for me.

def all(self, owner=None):
    """ Return all repositories for a given owner """
    owner = owner or self.bitbucket.username
    url = self.bitbucket.url('GET_USER', username=owner)
    response = self.bitbucket.dispatch('GET', url, auth=self.bitbucket.auth)
    try:
        return (response[0], response[1]['repositories'])
    except TypeError:
        pass
    return response

Then call bb.repository.all(owner='team-name'). This seems to be working for me so far.

facconi commented 9 years ago

Thank you @robwilkerson Your code works very well. I hope the repo will pull your fix. Thanks again.

robwilkerson commented 9 years ago

@facconi - glad it worked for you. I'm working on updated the other methods similarly (there are several others that only operate against the user's repo. Will update my fork and send a pull request today or tomorrow.