Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions github/enterprise_manage_ghes_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ type LicenseStatus struct {
ReferenceNumber *string `json:"referenceNumber,omitempty"`
Seats *int `json:"seats,omitempty"`
SSHAllowed *bool `json:"sshAllowed,omitempty"`
SupportKey *string `json:"supportKey,omitempty"`
UnlimitedSeating *bool `json:"unlimitedSeating,omitempty"`
// SupportKey is documented as a string, but the actual response is a bool.
// TODO: Remove this note once GitHub corrects the schema documentation.
SupportKey *bool `json:"supportKey,omitempty"`
UnlimitedSeating *bool `json:"unlimitedSeating,omitempty"`
}

// UploadLicenseOptions is a struct to hold the options for the UploadLicense API.
Expand Down Expand Up @@ -351,17 +353,21 @@ func (s *EnterpriseService) InitialConfig(ctx context.Context, license, password

// License gets the current license information for the GitHub Enterprise instance.
//
// NOTE: The GitHub documentation incorrectly shows the return type as a list ([{...}]),
// but the actual response is a single object ({...}).
// TODO: Remove this note once GitHub corrects the schema documentation.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.21/rest/enterprise-admin/manage-ghes#get-the-enterprise-license-information
//
//meta:operation GET /manage/v1/config/license
func (s *EnterpriseService) License(ctx context.Context) ([]*LicenseStatus, *Response, error) {
func (s *EnterpriseService) License(ctx context.Context) (*LicenseStatus, *Response, error) {
Comment thread
s4mur4i marked this conversation as resolved.
u := "manage/v1/config/license"
req, err := s.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}

var licenseStatus []*LicenseStatus
var licenseStatus *LicenseStatus
resp, err := s.client.Do(req, &licenseStatus)
if err != nil {
return nil, resp, err
Expand Down
12 changes: 6 additions & 6 deletions github/enterprise_manage_ghes_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func TestEnterpriseService_License(t *testing.T) {

mux.HandleFunc("/manage/v1/config/license", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{
fmt.Fprint(w, `{
"advancedSecurityEnabled": true,
"advancedSecuritySeats": 0,
"clusterSupport": false,
Expand All @@ -424,9 +424,9 @@ func TestEnterpriseService_License(t *testing.T) {
"referenceNumber": "32a145",
"seats": 0,
"sshAllowed": true,
"supportKey": "",
"supportKey": true,
"unlimitedSeating": true
}]`)
}`)
})

ctx := t.Context()
Expand All @@ -435,7 +435,7 @@ func TestEnterpriseService_License(t *testing.T) {
t.Errorf("Enterprise.License returned error: %v", err)
}

want := []*LicenseStatus{{
want := &LicenseStatus{
AdvancedSecurityEnabled: Ptr(true),
AdvancedSecuritySeats: Ptr(0),
ClusterSupport: Ptr(false),
Expand All @@ -452,9 +452,9 @@ func TestEnterpriseService_License(t *testing.T) {
ReferenceNumber: Ptr("32a145"),
Seats: Ptr(0),
SSHAllowed: Ptr(true),
SupportKey: Ptr(""),
SupportKey: Ptr(true),
UnlimitedSeating: Ptr(true),
}}
}
if diff := cmp.Diff(want, license); diff != "" {
t.Errorf("diff mismatch (-want +got):\n%v", diff)
}
Expand Down
4 changes: 2 additions & 2 deletions github/github-accessors.go

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

2 changes: 1 addition & 1 deletion github/github-accessors_test.go

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

Loading