Skip to content

Commit

Permalink
ListProject function for Repositories (#281)
Browse files Browse the repository at this point in the history
* add function to return all repos for project

fix url

remove ssh

add ssh

* update interface
  • Loading branch information
travisnburton committed Apr 16, 2024
1 parent ca089ec commit 81bfa62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type repository interface {
type repositories interface {
ListForAccount(opt RepositoriesOptions) (interface{}, error)
ListForTeam(opt RepositoriesOptions) (interface{}, error)
ListProject(opt RepositoriesOptions) (interface{}, error)
ListPublic() (interface{}, error)
}

Expand Down Expand Up @@ -140,6 +141,7 @@ type pipelines interface {

type RepositoriesOptions struct {
Owner string `json:"owner"`
Project string `json:"project"`
Role string `json:"role"` // role=[owner|admin|contributor|member]
Page *int `json:"page"`
Keyword *string `json:"keyword"`
Expand Down
11 changes: 11 additions & 0 deletions repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ func (r *Repositories) ListForTeam(ro *RepositoriesOptions) (*RepositoriesRes, e
return r.ListForAccount(ro)
}

// Return all repositories that belong to a project
func (r *Repositories) ListProject(ro *RepositoriesOptions) (*RepositoriesRes, error) {
urlPath := r.c.requestUrl("/repositories")
urlPath += fmt.Sprintf("/%s/?q=project.key=\"%s\"", ro.Owner, ro.Project)
repos, err := r.c.executePaginated("GET", urlPath, "", nil)
if err != nil {
return nil, err
}
return decodeRepositories(repos)
}

func (r *Repositories) ListPublic() (*RepositoriesRes, error) {
urlStr := r.c.requestUrl("/repositories/")
repos, err := r.c.executePaginated("GET", urlStr, "", nil)
Expand Down

0 comments on commit 81bfa62

Please sign in to comment.