(ctx context.Context)
| 56 | } |
| 57 | |
| 58 | func (c *Client) ListAllTeams(ctx context.Context) ([]Team, error) { |
| 59 | page := cloudquery_api.Page(1) |
| 60 | perPage := cloudquery_api.PerPage(100) |
| 61 | teams := make([]Team, 0) |
| 62 | for { |
| 63 | resp, err := c.api.ListTeamsWithResponse(ctx, &cloudquery_api.ListTeamsParams{ |
| 64 | PerPage: &perPage, |
| 65 | Page: &page, |
| 66 | }) |
| 67 | if err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | if resp.StatusCode() != http.StatusOK || resp.JSON200 == nil { |
| 71 | return nil, hub.ErrorFromHTTPResponse(resp.HTTPResponse, resp) |
| 72 | } |
| 73 | teams = append(teams, resp.JSON200.Items...) |
| 74 | if resp.JSON200.Metadata.LastPage == nil || *resp.JSON200.Metadata.LastPage <= int(page) { |
| 75 | break |
| 76 | } |
| 77 | page++ |
| 78 | } |
| 79 | return teams, nil |
| 80 | } |
| 81 | |
| 82 | func (c *Client) ListAllTeamNames(ctx context.Context) ([]string, error) { |
| 83 | teams, err := c.ListAllTeams(ctx) |
no outgoing calls
no test coverage detected