Skip to content

Commit efab85a

Browse files
author
Hubot
committed
Sync changes from upstream repository
1 parent 3b82842 commit efab85a

3 files changed

Lines changed: 148 additions & 2 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
kind: change
3+
title: Accepting organization invitations from the API
4+
created_at: 2014-08-28
5+
author_name: jakeboxer
6+
---
7+
8+
The upcoming [Team Memberships API][team-memberships-api] gives you the power to [invite][org-invitations] new GitHub users to your organization via the API. We're expanding the API to also allow users to view their organization membership statuses and accept any invitations they've received.
9+
10+
### The new Organization Memberships API
11+
12+
When someone [invites][org-invitations] you to an organization, your membership with that organization begins in the "pending" state. The new [list organization memberships][list-org-memberships] endpoint allows you to find your pending memberships. You can then change them to "active" (accepting the invitation in the process) by using the [edit organization membership][edit-org-membership] endpoint.
13+
14+
### New Team Membership API response attribute
15+
16+
Previously, responses from the [add team membership][add-team-membership] and [get team membership][get-team-membership] endpoints included a "status" attribute, which could either be "active" or "pending". We've renamed this attribute from "status" to "state" for better consistency with our other API calls.
17+
18+
To give you time to update your apps, we'll keep the legacy "status" attribute around alongside the new "state" attribute until **September 4th, 2014**.
19+
20+
### Preview period
21+
22+
The new Organization Memberships API is available for developers to preview alongside the [Team Memberships API][team-memberships-api]. During this period, we may change aspects of these endpoints. If we do, we will announce the changes on the developer blog, but we will not provide any advance notice.
23+
24+
While these new APIs are in their preview period, you'll need to provide the following custom media type in the `Accept` header:
25+
26+
application/vnd.github.the-wasp-preview+json
27+
28+
We expect the preview period to last 30-60 days. At the end of the preview period, the Team and Organization Memberships APIs will become official components of GitHub API v3.
29+
30+
If you have any questions or feedback, please [get in touch with us][contact]!
31+
32+
[contact]: https://github.com/contact?form[subject]=Team+Memberships+API
33+
[team-memberships-api]: /changes/2014-08-05-team-memberships-api/
34+
[org-invitations]: https://help.github.com/articles/adding-or-inviting-members-to-a-team-in-an-organization
35+
[list-org-memberships]: /v3/orgs/members/#list-your-organization-memberships
36+
[edit-org-membership]: /v3/orgs/members/#edit-your-organization-membership
37+
[add-team-membership]: /v3/orgs/teams/#add-team-membership
38+
[get-team-membership]: /v3/orgs/teams/#get-team-membership

content/v3/orgs/members.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,95 @@ The user can publicize their own membership.
115115
### Response
116116

117117
<%= headers 204 %>
118+
119+
## List your organization memberships
120+
121+
<div class="alert">
122+
<p>
123+
The Organization Memberships API is currently available for developers to preview.
124+
During the preview period, the API may change without notice.
125+
Please see the <a href="/changes/2014-08-28-accepting-organization-invitations-from-the-api/">blog post</a> for full details.
126+
</p>
127+
128+
<p>
129+
To access the API during the preview period, you must provide a custom <a href="/v3/media">media type</a> in the <code>Accept</code> header:
130+
<pre>application/vnd.github.the-wasp-preview+json</pre>
131+
</p>
132+
</div>
133+
134+
An optional `state` can be passed to request only pending or active memberships.
135+
136+
GET /user/memberships/orgs
137+
GET /user/memberships/orgs?state=active
138+
GET /user/memberships/orgs?state=pending
139+
140+
### Response when no state is specified
141+
142+
<%= headers 200, :pagination => default_pagination_rels %>
143+
<%= json(:org_memberships) %>
144+
145+
### Response when a "pending" state is specified
146+
147+
<%= headers 200, :pagination => default_pagination_rels %>
148+
<%= json(:pending_org_memberships) %>
149+
150+
### Response when an "active" state is specified
151+
152+
<%= headers 200, :pagination => default_pagination_rels %>
153+
<%= json(:active_org_memberships) %>
154+
155+
## Get your organization membership
156+
157+
<div class="alert">
158+
<p>
159+
The Organization Memberships API is currently available for developers to preview.
160+
During the preview period, the API may change without notice.
161+
Please see the <a href="/changes/2014-08-28-accepting-organization-invitations-from-the-api/">blog post</a> for full details.
162+
</p>
163+
164+
<p>
165+
To access the API during the preview period, you must provide a custom <a href="/v3/media">media type</a> in the <code>Accept</code> header:
166+
<pre>application/vnd.github.the-wasp-preview+json</pre>
167+
</p>
168+
</div>
169+
170+
GET /user/memberships/orgs/:org
171+
172+
### Response
173+
174+
<%= headers 200 %>
175+
<%= json(:pending_org_membership) %>
176+
177+
## Edit your organization membership
178+
179+
<div class="alert">
180+
<p>
181+
The Organization Memberships API is currently available for developers to preview.
182+
During the preview period, the API may change without notice.
183+
Please see the <a href="/changes/2014-08-28-accepting-organization-invitations-from-the-api/">blog post</a> for full details.
184+
</p>
185+
186+
<p>
187+
To access the API during the preview period, you must provide a custom <a href="/v3/media">media type</a> in the <code>Accept</code> header:
188+
<pre>application/vnd.github.the-wasp-preview+json</pre>
189+
</p>
190+
</div>
191+
192+
PATCH /user/memberships/orgs/:org
193+
194+
### Input
195+
196+
Name | Type | Description
197+
-----|------|--------------
198+
`state`|`string`| **Required**. The state that the membership should be in. Only `"active"` will be accepted.
199+
200+
### Example
201+
202+
<%= json \
203+
:state => "active"
204+
%>
205+
206+
### Response
207+
208+
<%= headers 200 %>
209+
<%= json(:active_org_membership) %>

lib/resources.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,29 @@ def fetch_content(key)
717717
}
718718

719719
ACTIVE_TEAM_MEMBERSHIP ||= TEAM_MEMBERSHIP.merge(
720-
"status" => "active"
720+
"state" => "active"
721721
)
722722

723723
PENDING_TEAM_MEMBERSHIP ||= TEAM_MEMBERSHIP.merge(
724-
"status" => "pending"
724+
"state" => "pending"
725725
)
726726

727+
ACTIVE_ORG_MEMBERSHIP ||= {
728+
"url" => "https://api.github.com/user/memberships/orgs/octocat",
729+
"state" => "active",
730+
"organization_url" => "https://api.github.com/orgs/octocat"
731+
}
732+
733+
PENDING_ORG_MEMBERSHIP ||= {
734+
"url" => "https://api.github.com/user/memberships/orgs/invitocat",
735+
"state" => "pending",
736+
"organization_url" => "https://api.github.com/orgs/invitocat"
737+
}
738+
739+
ORG_MEMBERSHIPS ||= [ACTIVE_ORG_MEMBERSHIP, PENDING_ORG_MEMBERSHIP]
740+
ACTIVE_ORG_MEMBERSHIPS ||= [ACTIVE_ORG_MEMBERSHIP]
741+
PENDING_ORG_MEMBERSHIPS ||= [PENDING_ORG_MEMBERSHIP]
742+
727743
LABEL ||= {
728744
"url" => "https://api.github.com/repos/octocat/Hello-World/labels/bug",
729745
"name" => "bug",

0 commit comments

Comments
 (0)