diff --git a/github/github-accessors.go b/github/github-accessors.go index 68de9bb17c0..dcb50adc393 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9844,6 +9844,30 @@ func (p *Pages) GetHTMLURL() string { return *p.HTMLURL } +// GetHTTPSCertificate returns the HTTPSCertificate field. +func (p *Pages) GetHTTPSCertificate() *PagesHTTPSCertificate { + if p == nil { + return nil + } + return p.HTTPSCertificate +} + +// GetHTTPSEnforced returns the HTTPSEnforced field if it's non-nil, zero value otherwise. +func (p *Pages) GetHTTPSEnforced() bool { + if p == nil || p.HTTPSEnforced == nil { + return false + } + return *p.HTTPSEnforced +} + +// GetPublic returns the Public field if it's non-nil, zero value otherwise. +func (p *Pages) GetPublic() bool { + if p == nil || p.Public == nil { + return false + } + return *p.Public +} + // GetSource returns the Source field. func (p *Pages) GetSource() *PagesSource { if p == nil { @@ -9940,6 +9964,30 @@ func (p *PagesError) GetMessage() string { return *p.Message } +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (p *PagesHTTPSCertificate) GetDescription() string { + if p == nil || p.Description == nil { + return "" + } + return *p.Description +} + +// GetExpiresAt returns the ExpiresAt field if it's non-nil, zero value otherwise. +func (p *PagesHTTPSCertificate) GetExpiresAt() string { + if p == nil || p.ExpiresAt == nil { + return "" + } + return *p.ExpiresAt +} + +// GetState returns the State field if it's non-nil, zero value otherwise. +func (p *PagesHTTPSCertificate) GetState() string { + if p == nil || p.State == nil { + return "" + } + return *p.State +} + // GetBranch returns the Branch field if it's non-nil, zero value otherwise. func (p *PagesSource) GetBranch() string { if p == nil || p.Branch == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index aa9bd566825..a216ad85943 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -11550,6 +11550,33 @@ func TestPages_GetHTMLURL(tt *testing.T) { p.GetHTMLURL() } +func TestPages_GetHTTPSCertificate(tt *testing.T) { + p := &Pages{} + p.GetHTTPSCertificate() + p = nil + p.GetHTTPSCertificate() +} + +func TestPages_GetHTTPSEnforced(tt *testing.T) { + var zeroValue bool + p := &Pages{HTTPSEnforced: &zeroValue} + p.GetHTTPSEnforced() + p = &Pages{} + p.GetHTTPSEnforced() + p = nil + p.GetHTTPSEnforced() +} + +func TestPages_GetPublic(tt *testing.T) { + var zeroValue bool + p := &Pages{Public: &zeroValue} + p.GetPublic() + p = &Pages{} + p.GetPublic() + p = nil + p.GetPublic() +} + func TestPages_GetSource(tt *testing.T) { p := &Pages{} p.GetSource() @@ -11661,6 +11688,36 @@ func TestPagesError_GetMessage(tt *testing.T) { p.GetMessage() } +func TestPagesHTTPSCertificate_GetDescription(tt *testing.T) { + var zeroValue string + p := &PagesHTTPSCertificate{Description: &zeroValue} + p.GetDescription() + p = &PagesHTTPSCertificate{} + p.GetDescription() + p = nil + p.GetDescription() +} + +func TestPagesHTTPSCertificate_GetExpiresAt(tt *testing.T) { + var zeroValue string + p := &PagesHTTPSCertificate{ExpiresAt: &zeroValue} + p.GetExpiresAt() + p = &PagesHTTPSCertificate{} + p.GetExpiresAt() + p = nil + p.GetExpiresAt() +} + +func TestPagesHTTPSCertificate_GetState(tt *testing.T) { + var zeroValue string + p := &PagesHTTPSCertificate{State: &zeroValue} + p.GetState() + p = &PagesHTTPSCertificate{} + p.GetState() + p = nil + p.GetState() +} + func TestPagesSource_GetBranch(tt *testing.T) { var zeroValue string p := &PagesSource{Branch: &zeroValue} diff --git a/github/repos_pages.go b/github/repos_pages.go index a954e70584b..04825baea1e 100644 --- a/github/repos_pages.go +++ b/github/repos_pages.go @@ -12,12 +12,15 @@ import ( // Pages represents a GitHub Pages site configuration. type Pages struct { - URL *string `json:"url,omitempty"` - Status *string `json:"status,omitempty"` - CNAME *string `json:"cname,omitempty"` - Custom404 *bool `json:"custom_404,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - Source *PagesSource `json:"source,omitempty"` + URL *string `json:"url,omitempty"` + Status *string `json:"status,omitempty"` + CNAME *string `json:"cname,omitempty"` + Custom404 *bool `json:"custom_404,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + Source *PagesSource `json:"source,omitempty"` + Public *bool `json:"public,omitempty"` + HTTPSCertificate *PagesHTTPSCertificate `json:"https_certificate,omitempty"` + HTTPSEnforced *bool `json:"https_enforced,omitempty"` } // PagesSource represents a GitHub page's source. @@ -43,6 +46,15 @@ type PagesBuild struct { UpdatedAt *Timestamp `json:"updated_at,omitempty"` } +// PagesHTTPSCertificate represents the HTTPS Certificate information for a GitHub Pages site. +type PagesHTTPSCertificate struct { + State *string `json:"state,omitempty"` + Description *string `json:"description,omitempty"` + Domains []string `json:"domains,omitempty"` + // GitHub's API doesn't return a standard Timestamp, rather it returns a YYYY-MM-DD string. + ExpiresAt *string `json:"expires_at,omitempty"` +} + // createPagesRequest is a subset of Pages and is used internally // by EnablePages to pass only the known fields for the endpoint. type createPagesRequest struct { diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index 85069f946c5..46bffcff591 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -170,7 +170,7 @@ func TestRepositoriesService_GetPagesInfo(t *testing.T) { mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"url":"u","status":"s","cname":"c","custom_404":false,"html_url":"h"}`) + fmt.Fprint(w, `{"url":"u","status":"s","cname":"c","custom_404":false,"html_url":"h","public":true, "https_certificate": {"state":"approved","description": "Certificate is approved","domains": ["developer.github.com"],"expires_at": "2021-05-22"},"https_enforced": true}`) }) ctx := context.Background() @@ -179,7 +179,7 @@ func TestRepositoriesService_GetPagesInfo(t *testing.T) { t.Errorf("Repositories.GetPagesInfo returned error: %v", err) } - want := &Pages{URL: String("u"), Status: String("s"), CNAME: String("c"), Custom404: Bool(false), HTMLURL: String("h")} + want := &Pages{URL: String("u"), Status: String("s"), CNAME: String("c"), Custom404: Bool(false), HTMLURL: String("h"), Public: Bool(true), HTTPSCertificate: &PagesHTTPSCertificate{State: String("approved"), Description: String("Certificate is approved"), Domains: []string{"developer.github.com"}, ExpiresAt: String("2021-05-22")}, HTTPSEnforced: Bool(true)} if !cmp.Equal(page, want) { t.Errorf("Repositories.GetPagesInfo returned %+v, want %+v", page, want) }