Skip to content

Request parent team when endpoints return a team #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 22, 2017

Conversation

elliott-beach
Copy link
Contributor

Re-submit of #718.

This PR address part of #714 by

  1. Adding a parent field to the Team struct.
  2. Requesting this field to be populated from each endpoint that returns a team, by adding the API preview header to the request.

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Sep 22, 2017
@elliott-beach elliott-beach changed the title Request parent team Request parent team when endpoints return a team Sep 22, 2017
@elliott-beach
Copy link
Contributor Author

As @shurcooL mentioned, another side effect of this PR is stated in the docs:

Endpoints that return team hashes will now include the parent field representing the parent team. Additionally, the members_count and repositories_count will include all members and repositories according to the nested structure.

Those fields are a part of the Team struct. The endpoints that have the application/vnd.github.hellcat-preview+json header set will return different numbers than other endpoints where application/vnd.github.hellcat-preview+json isn't yet set.

@dmitshur
Copy link
Member

dmitshur commented Sep 22, 2017

@e-beach, this PR is currently targeting master branch in this repo. Was that a mistake? Can you update it to target NestedTeamsPreview instead?

@elliott-beach elliott-beach changed the base branch from master to NestedTeamsPreview September 22, 2017 18:23
@elliott-beach
Copy link
Contributor Author

@shurcooL Fixed.

Copy link
Member

@dmitshur dmitshur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@dmitshur dmitshur merged commit ad2ff3f into google:NestedTeamsPreview Sep 22, 2017
elliott-beach added a commit to elliott-beach/go-github that referenced this pull request Sep 26, 2017
Create mediaTypeNestedTeamsPreview const for
https://developer.github.com/changes/2017-08-30-preview-nested-teams/.

Add parent field to the Team struct.

Set preview API media type in endpoints that return a team, so that
the new parent field gets populated.

Helps google#714.
dmitshur pushed a commit that referenced this pull request Oct 16, 2017
Create mediaTypeNestedTeamsPreview const for
https://developer.github.com/changes/2017-08-30-preview-nested-teams/.

Add parent field to the Team struct.

Set preview API media type in endpoints that return a team, so that
the new parent field gets populated.

Helps #714.
gmlewis added a commit that referenced this pull request Oct 31, 2017
* Add support for fetching parent team (for nested teams). (#723)

Create mediaTypeNestedTeamsPreview const for
https://developer.github.com/changes/2017-08-30-preview-nested-teams/.

Add parent field to the Team struct.

Set preview API media type in endpoints that return a team, so that
the new parent field gets populated.

Helps #714.

* Add NewTeam struct. (#724)

This replaces Team with NewTeam in function that accept a team for
creating or editing a team. The NewTeam struct is similar to the
existing NewPullRequest for creating pull requests.

We need a new struct because the set of parameters for creating or
editing a team contains some parameters that are not in the parameter
for teams, and most properties of teams cannot be used for editing.

The specific change is that Teams are returned with a parent field,
but are created/edited with a parent_id field.

Helps #714.

* Add NestedTeamsPreview header to remaining endpoints

Fixes #714.

* Change ParentTeamID field to int (from string). (#748)

Using the code as written in the `NestedTeamsPreview` branch produces
an error when talking to the GitHub API:

	panic: PATCH https://github.com/api/teams/2514825: 422 Invalid request.

	For 'properties/parent_team_id', "2514824" is not a number or null. []

The documentation at https://developer.github.com/v3/orgs/teams/#create-team
states that this parameter is an id type which appears to mean an integer, not a string.
Also, id is an integer in the sample responses for Get team endpoint, etc.

* Bump libraryVersion

* NestedTeamsPreview: Add the ListChildTeams endpoint (#758)
nbareil pushed a commit to nbareil/go-github that referenced this pull request May 1, 2018
* Add support for fetching parent team (for nested teams). (google#723)

Create mediaTypeNestedTeamsPreview const for
https://developer.github.com/changes/2017-08-30-preview-nested-teams/.

Add parent field to the Team struct.

Set preview API media type in endpoints that return a team, so that
the new parent field gets populated.

Helps google#714.

* Add NewTeam struct. (google#724)

This replaces Team with NewTeam in function that accept a team for
creating or editing a team. The NewTeam struct is similar to the
existing NewPullRequest for creating pull requests.

We need a new struct because the set of parameters for creating or
editing a team contains some parameters that are not in the parameter
for teams, and most properties of teams cannot be used for editing.

The specific change is that Teams are returned with a parent field,
but are created/edited with a parent_id field.

Helps google#714.

* Add NestedTeamsPreview header to remaining endpoints

Fixes google#714.

* Change ParentTeamID field to int (from string). (google#748)

Using the code as written in the `NestedTeamsPreview` branch produces
an error when talking to the GitHub API:

	panic: PATCH https://github.com/api/teams/2514825: 422 Invalid request.

	For 'properties/parent_team_id', "2514824" is not a number or null. []

The documentation at https://developer.github.com/v3/orgs/teams/#create-team
states that this parameter is an id type which appears to mean an integer, not a string.
Also, id is an integer in the sample responses for Get team endpoint, etc.

* Bump libraryVersion

* NestedTeamsPreview: Add the ListChildTeams endpoint (google#758)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants