Skip to content
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

Update GitHub Pages API to add new response parameters #2109

Merged
merged 10 commits into from
Dec 3, 2021
48 changes: 48 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions github/repos_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
gmlewis marked this conversation as resolved.
Show resolved Hide resolved
HttpsEnforced *bool `json:"https_enforced,omitempty"`
gmlewis marked this conversation as resolved.
Show resolved Hide resolved
}

// PagesSource represents a GitHub page's source.
Expand All @@ -43,6 +46,14 @@ type PagesBuild struct {
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
}

// PagesBuild represents the HTTPS Certificate information for a GitHub Pages site.
rreichel3 marked this conversation as resolved.
Show resolved Hide resolved
type PagesHttpsCertificate struct {
gmlewis marked this conversation as resolved.
Show resolved Hide resolved
State *string `json:"state,omitempty"`
Description *string `json:"description,omitempty"`
Domains *[]*string `json:"domains,omitempty"`
gmlewis marked this conversation as resolved.
Show resolved Hide resolved
ExpiresAt *string `json:"expires_at,omitempty"`
gmlewis marked this conversation as resolved.
Show resolved Hide resolved
}

// createPagesRequest is a subset of Pages and is used internally
// by EnablePages to pass only the known fields for the endpoint.
type createPagesRequest struct {
Expand Down
4 changes: 2 additions & 2 deletions github/repos_pages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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{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)
}
Expand Down