Skip to content

Commit 1bab17e

Browse files
davidji99gmlewis
authored andcommitted
Add repository creation permissions field (#1213)
1 parent 60c47f3 commit 1bab17e

File tree

6 files changed

+57
-36
lines changed

6 files changed

+57
-36
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Dave Du Cros <davidducros@gmail.com>
7070
Dave Henderson <dhenderson@gmail.com>
7171
David Deng <daviddengcn@gmail.com>
7272
David Jannotta <djannotta@gmail.com>
73+
David Ji <github.com/davidji99>
7374
Davide Zipeto <dawez1@gmail.com>
7475
Dennis Webb <dennis@bluesentryit.com>
7576
Dhi Aurrahman <diorahman@rockybars.com>

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-stringify_test.go

Lines changed: 37 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ const (
150150

151151
// https://developer.github.com/changes/2019-06-12-team-sync/
152152
mediaTypeTeamSyncPreview = "application/vnd.github.team-sync-preview+json"
153+
154+
// https://developer.github.com/v3/previews/#repository-creation-permissions
155+
mediaTypeMemberAllowedRepoCreationTypePreview = "application/vnd.github.surtur-preview+json"
153156
)
154157

155158
// A Client manages communication with the GitHub API.

github/orgs.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ type Organization struct {
5656
// MembersCanCreateRepos default value is true and is only used in Organizations.Edit.
5757
MembersCanCreateRepos *bool `json:"members_can_create_repositories,omitempty"`
5858

59+
// MembersAllowedRepositoryCreationType denotes if organization members can create repositories
60+
// and the type of repositories they can create. Possible values are: "all", "private", or "none".
61+
MembersAllowedRepositoryCreationType *string `json:"members_allowed_repository_creation_type,omitempty"`
62+
5963
// API URLs
6064
URL *string `json:"url,omitempty"`
6165
EventsURL *string `json:"events_url,omitempty"`
@@ -160,6 +164,9 @@ func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organizati
160164
return nil, nil, err
161165
}
162166

167+
// TODO: remove custom Accept header when this API fully launches.
168+
req.Header.Set("Accept", mediaTypeMemberAllowedRepoCreationTypePreview)
169+
163170
organization := new(Organization)
164171
resp, err := s.client.Do(ctx, req, organization)
165172
if err != nil {

github/orgs_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func TestOrganizationsService_Get(t *testing.T) {
9393

9494
mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
9595
testMethod(t, r, "GET")
96+
testHeader(t, r, "Accept", mediaTypeMemberAllowedRepoCreationTypePreview)
9697
fmt.Fprint(w, `{"id":1, "login":"l", "url":"u", "avatar_url": "a", "location":"l"}`)
9798
})
9899

0 commit comments

Comments
 (0)