Repository: google/go-github
Pull request #1805 (2021-02-17 22:56:44)

Add MembersCanCreate* to Organization
#### What type of PR is this?

Update Organization

#### What this PR does / why we need it

Bring Organization inline with the latest API changes  (see https://docs.github.com/en/rest/reference/orgs#get-an-organization)



codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1805?src=pr&el=h1) Report
> Merging [#1805](https://codecov.io/gh/google/go-github/pull/1805?src=pr&el=desc) (11d6465) into [master](https://codecov.io/gh/google/go-github/commit/dfc45d98d3e8531077738876df88127148a4bcc9?el=desc) (dfc45d9) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1805/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0)](https://codecov.io/gh/google/go-github/pull/1805?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1805   +/-   ##
=======================================
  Coverage   97.55%   97.55%           
=======================================
  Files          99       99           
  Lines        6426     6426           
=======================================
  Hits         6269     6269           
  Misses         85       85           
  Partials       72       72           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1805?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/orgs.go](https://codecov.io/gh/google/go-github/pull/1805/diff?src=pr&el=tree#diff-Z2l0aHViL29yZ3MuZ28=) | `97.14% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1805?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1805?src=pr&el=footer). Last update [dfc45d9...11d6465](https://codecov.io/gh/google/go-github/pull/1805?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 5794c076..0ec41280 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -7220,6 +7220,22 @@ func (o *Organization) GetMembersCanCreateInternalRepos() bool {
 	return *o.MembersCanCreateInternalRepos
 }
 
+// GetMembersCanCreatePages returns the MembersCanCreatePages field if it's non-nil, zero value otherwise.
+func (o *Organization) GetMembersCanCreatePages() bool {
+	if o == nil || o.MembersCanCreatePages == nil {
+		return false
+	}
+	return *o.MembersCanCreatePages
+}
+
+// GetMembersCanCreatePrivatePages returns the MembersCanCreatePrivatePages field if it's non-nil, zero value otherwise.
+func (o *Organization) GetMembersCanCreatePrivatePages() bool {
+	if o == nil || o.MembersCanCreatePrivatePages == nil {
+		return false
+	}
+	return *o.MembersCanCreatePrivatePages
+}
+
 // GetMembersCanCreatePrivateRepos returns the MembersCanCreatePrivateRepos field if it's non-nil, zero value otherwise.
 func (o *Organization) GetMembersCanCreatePrivateRepos() bool {
 	if o == nil || o.MembersCanCreatePrivateRepos == nil {
@@ -7228,6 +7244,14 @@ func (o *Organization) GetMembersCanCreatePrivateRepos() bool {
 	return *o.MembersCanCreatePrivateRepos
 }
 
+// GetMembersCanCreatePublicPages returns the MembersCanCreatePublicPages field if it's non-nil, zero value otherwise.
+func (o *Organization) GetMembersCanCreatePublicPages() bool {
+	if o == nil || o.MembersCanCreatePublicPages == nil {
+		return false
+	}
+	return *o.MembersCanCreatePublicPages
+}
+
 // GetMembersCanCreatePublicRepos returns the MembersCanCreatePublicRepos field if it's non-nil, zero value otherwise.
 func (o *Organization) GetMembersCanCreatePublicRepos() bool {
 	if o == nil || o.MembersCanCreatePublicRepos == nil {
diff --git a/github/orgs.go b/github/orgs.go
index beb71fff..62f6ed24 100644
--- a/github/orgs.go
+++ b/github/orgs.go
@@ -73,6 +73,13 @@ type Organization struct {
 	// operation and does not consider 'internal' repositories during 'get' operation
 	MembersAllowedRepositoryCreationType *string `json:"members_allowed_repository_creation_type,omitempty"`
 
+	// MembersCanCreatePages toggles whether organization members can create GitHub Pages sites.
+	MembersCanCreatePages *bool `json:"members_can_create_pages,omitempty"`
+	// MembersCanCreatePublicPages toggles whether organization members can create public GitHub Pages sites.
+	MembersCanCreatePublicPages *bool `json:"members_can_create_public_pages,omitempty"`
+	// MembersCanCreatePrivatePages toggles whether organization members can create private GitHub Pages sites.
+	MembersCanCreatePrivatePages *bool `json:"members_can_create_private_pages,omitempty"`
+
 	// API URLs
 	URL              *string `json:"url,omitempty"`
 	EventsURL        *string `json:"events_url,omitempty"`


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index f06fa5cc..28ffcc6a 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -8462,6 +8462,26 @@ func TestOrganization_GetMembersCanCreateInternalRepos(tt *testing.T) {
 	o.GetMembersCanCreateInternalRepos()
 }
 
+func TestOrganization_GetMembersCanCreatePages(tt *testing.T) {
+	var zeroValue bool
+	o := &Organization{MembersCanCreatePages: &zeroValue}
+	o.GetMembersCanCreatePages()
+	o = &Organization{}
+	o.GetMembersCanCreatePages()
+	o = nil
+	o.GetMembersCanCreatePages()
+}
+
+func TestOrganization_GetMembersCanCreatePrivatePages(tt *testing.T) {
+	var zeroValue bool
+	o := &Organization{MembersCanCreatePrivatePages: &zeroValue}
+	o.GetMembersCanCreatePrivatePages()
+	o = &Organization{}
+	o.GetMembersCanCreatePrivatePages()
+	o = nil
+	o.GetMembersCanCreatePrivatePages()
+}
+
 func TestOrganization_GetMembersCanCreatePrivateRepos(tt *testing.T) {
 	var zeroValue bool
 	o := &Organization{MembersCanCreatePrivateRepos: &zeroValue}
@@ -8472,6 +8492,16 @@ func TestOrganization_GetMembersCanCreatePrivateRepos(tt *testing.T) {
 	o.GetMembersCanCreatePrivateRepos()
 }
 
+func TestOrganization_GetMembersCanCreatePublicPages(tt *testing.T) {
+	var zeroValue bool
+	o := &Organization{MembersCanCreatePublicPages: &zeroValue}
+	o.GetMembersCanCreatePublicPages()
+	o = &Organization{}
+	o.GetMembersCanCreatePublicPages()
+	o = nil
+	o.GetMembersCanCreatePublicPages()
+}
+
 func TestOrganization_GetMembersCanCreatePublicRepos(tt *testing.T) {
 	var zeroValue bool
 	o := &Organization{MembersCanCreatePublicRepos: &zeroValue}
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index ced52849..d77747d8 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -890,6 +890,9 @@ func TestOrganization_String(t *testing.T) {
 		MembersCanCreatePrivateRepos:         Bool(false),
 		MembersCanCreateInternalRepos:        Bool(false),
 		MembersAllowedRepositoryCreationType: String(""),
+		MembersCanCreatePages:                Bool(false),
+		MembersCanCreatePublicPages:          Bool(false),
+		MembersCanCreatePrivatePages:         Bool(false),
 		URL:                                  String(""),
 		EventsURL:                            String(""),
 		HooksURL:                             String(""),
@@ -898,7 +901,7 @@ func TestOrganization_String(t *testing.T) {
 		PublicMembersURL:                     String(""),
 		ReposURL:                             String(""),
 	}
-	want := `github.Organization{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", Name:"", Company:"", Blog:"", Location:"", Email:"", TwitterUsername:"", Description:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, BillingEmail:"", Type:"", Plan:github.Plan{}, TwoFactorRequirementEnabled:false, IsVerified:false, HasOrganizationProjects:false, HasRepositoryProjects:false, DefaultRepoPermission:"", DefaultRepoSettings:"", MembersCanCreateRepos:false, MembersCanCreatePublicRepos:false, MembersCanCreatePrivateRepos:false, MembersCanCreateInternalRepos:false, MembersAllowedRepositoryCreationType:"", URL:"", EventsURL:"", HooksURL:"", IssuesURL:"", MembersURL:"", PublicMembersURL:"", ReposURL:""}`
+	want := `github.Organization{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", Name:"", Company:"", Blog:"", Location:"", Email:"", TwitterUsername:"", Description:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, BillingEmail:"", Type:"", Plan:github.Plan{}, TwoFactorRequirementEnabled:false, IsVerified:false, HasOrganizationProjects:false, HasRepositoryProjects:false, DefaultRepoPermission:"", DefaultRepoSettings:"", MembersCanCreateRepos:false, MembersCanCreatePublicRepos:false, MembersCanCreatePrivateRepos:false, MembersCanCreateInternalRepos:false, MembersAllowedRepositoryCreationType:"", MembersCanCreatePages:false, MembersCanCreatePublicPages:false, MembersCanCreatePrivatePages:false, URL:"", EventsURL:"", HooksURL:"", IssuesURL:"", MembersURL:"", PublicMembersURL:"", ReposURL:""}`
 	if got := v.String(); got != want {
 		t.Errorf("Organization.String = %v, want %v", got, want)
 	}
diff --git a/github/orgs_test.go b/github/orgs_test.go
index dc467877..18a017d7 100644
--- a/github/orgs_test.go
+++ b/github/orgs_test.go
@@ -35,6 +35,9 @@ func TestOrganization_marshal(t *testing.T) {
 		MembersCanCreatePrivateRepos:         Bool(true),
 		MembersCanCreatePublicRepos:          Bool(false),
 		MembersAllowedRepositoryCreationType: String("all"),
+		MembersCanCreatePages:                Bool(true),
+		MembersCanCreatePublicPages:          Bool(false),
+		MembersCanCreatePrivatePages:         Bool(true),
 	}
 	want := `
 		{
@@ -54,7 +57,10 @@ func TestOrganization_marshal(t *testing.T) {
 			"members_can_create_public_repositories": false,
 			"members_can_create_private_repositories": true,
 			"members_can_create_internal_repositories": true,
-			"members_allowed_repository_creation_type": "all"
+			"members_allowed_repository_creation_type": "all",
+			"members_can_create_pages": true,
+			"members_can_create_public_pages": false,
+			"members_can_create_private_pages": true
 		}
 	`
 	testJSONMarshal(t, o, want)