-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Add manage_ghes endpoints introduced in 3.15 #3433
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b0d92eb
Adding manage_ghes endpoints introduced in 3.15
s4mur4i b0f90be
Fix year in Copyright
s4mur4i e75c400
Fix generate & lint
s4mur4i 9a0776c
Fix double-space in comment
s4mur4i c024efa
Fix omitempty and types
s4mur4i 65cea53
Fix ghes_ssh Modified field
s4mur4i 519df01
Fix broken test
s4mur4i cdb712e
Add missing testNewRequestAndDoFailure
s4mur4i 9775d73
Run generate
s4mur4i af473da
Run generate
s4mur4i f9aac39
Run generate with go 1.22.0
s4mur4i dfc158a
Add #3436 patch and generate
s4mur4i 8eea7bb
Fix APIs
s4mur4i 885cafc
Fix plural of method in doc
s4mur4i d18f95d
Fix from review to enterprise_manage_ghes.go
s4mur4i f3d10fd
Fix ClusterSSHKey
s4mur4i c4121e9
Fix enterprise_manage_ghes_config
s4mur4i b38b74f
Fix ClusterStatusNodeServiceItem and ConnectionServiceItem
s4mur4i a469388
Merge branch 'master' into master
gmlewis 957be90
Fix for review findings in config
s4mur4i 9be9a4c
Revert int64 changes for non ID fields
s4mur4i b07fc10
Fix for review findings
s4mur4i File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
// Copyright 2025 The go-github AUTHORS. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package github | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// NodeQueryOptions specifies the optional parameters to the EnterpriseService | ||
// Node management APIs. | ||
type NodeQueryOptions struct { | ||
// UUID filters issues based on the node UUID. | ||
UUID *string `url:"uuid,omitempty"` | ||
|
||
// ClusterRoles filters the cluster roles from the cluster configuration file. | ||
ClusterRoles *string `url:"cluster_roles,omitempty"` | ||
} | ||
|
||
// ClusterStatus represents a response from the ClusterStatus and ReplicationStatus methods. | ||
type ClusterStatus struct { | ||
Status *string `json:"status,omitempty"` | ||
Nodes []*ClusterStatusNode `json:"nodes"` | ||
} | ||
|
||
// ClusterStatusNode represents the status of a cluster node. | ||
type ClusterStatusNode struct { | ||
Hostname *string `json:"hostname,omitempty"` | ||
Status *string `json:"status,omitempty"` | ||
Services []*ClusterStatusNodeServiceItem `json:"services"` | ||
} | ||
|
||
// ClusterStatusNodeServiceItem represents the status of a service running on a cluster node. | ||
type ClusterStatusNodeServiceItem struct { | ||
Status *string `json:"status,omitempty"` | ||
Name *string `json:"name,omitempty"` | ||
Details *string `json:"details,omitempty"` | ||
} | ||
|
||
// SystemRequirements represents a response from the CheckSystemRequirements method. | ||
type SystemRequirements struct { | ||
Status *string `json:"status,omitempty"` | ||
Nodes []*SystemRequirementsNode `json:"nodes"` | ||
} | ||
|
||
// SystemRequirementsNode represents the status of a system node. | ||
type SystemRequirementsNode struct { | ||
Hostname *string `json:"hostname,omitempty"` | ||
Status *string `json:"status,omitempty"` | ||
RolesStatus []*SystemRequirementsNodeRoleStatus `json:"roles_status"` | ||
} | ||
|
||
// SystemRequirementsNodeRoleStatus represents the status of a role on a system node. | ||
type SystemRequirementsNodeRoleStatus struct { | ||
Status *string `json:"status,omitempty"` | ||
Role *string `json:"role,omitempty"` | ||
} | ||
|
||
// NodeReleaseVersion represents a response from the GetNodeReleaseVersions method. | ||
type NodeReleaseVersion struct { | ||
Hostname *string `json:"hostname,omitempty"` | ||
Version *ReleaseVersion `json:"version"` | ||
} | ||
|
||
// ReleaseVersion holds the release version information of the node. | ||
type ReleaseVersion struct { | ||
Version *string `json:"version,omitempty"` | ||
Platform *string `json:"platform,omitempty"` | ||
BuildID *string `json:"build_id,omitempty"` | ||
BuildDate *string `json:"build_date,omitempty"` | ||
} | ||
|
||
// CheckSystemRequirements checks if GHES system nodes meet the system requirements. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#get-the-system-requirement-check-results-for-configured-cluster-nodes | ||
// | ||
//meta:operation GET /manage/v1/checks/system-requirements | ||
func (s *EnterpriseService) CheckSystemRequirements(ctx context.Context) (*SystemRequirements, *Response, error) { | ||
u := "manage/v1/checks/system-requirements" | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
systemRequirements := new(SystemRequirements) | ||
resp, err := s.client.Do(ctx, req, systemRequirements) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return systemRequirements, resp, nil | ||
} | ||
|
||
// ClusterStatus gets the status of all services running on each cluster node. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#get-the-status-of-services-running-on-all-cluster-nodes | ||
// | ||
//meta:operation GET /manage/v1/cluster/status | ||
func (s *EnterpriseService) ClusterStatus(ctx context.Context) (*ClusterStatus, *Response, error) { | ||
u := "manage/v1/cluster/status" | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
clusterStatus := new(ClusterStatus) | ||
resp, err := s.client.Do(ctx, req, clusterStatus) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return clusterStatus, resp, nil | ||
} | ||
|
||
// ReplicationStatus gets the status of all services running on each replica node. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#get-the-status-of-services-running-on-all-replica-nodes | ||
// | ||
//meta:operation GET /manage/v1/replication/status | ||
func (s *EnterpriseService) ReplicationStatus(ctx context.Context, opts *NodeQueryOptions) (*ClusterStatus, *Response, error) { | ||
u, err := addOptions("manage/v1/replication/status", opts) | ||
if err != nil { | ||
return nil, nil, err | ||
s4mur4i marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
status := new(ClusterStatus) | ||
resp, err := s.client.Do(ctx, req, status) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return status, resp, nil | ||
} | ||
|
||
// GetNodeReleaseVersions gets the version information deployed to each node. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#get-all-ghes-release-versions-for-all-nodes | ||
// | ||
//meta:operation GET /manage/v1/version | ||
func (s *EnterpriseService) GetNodeReleaseVersions(ctx context.Context, opts *NodeQueryOptions) ([]*NodeReleaseVersion, *Response, error) { | ||
u, err := addOptions("manage/v1/version", opts) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
var releaseVersions []*NodeReleaseVersion | ||
resp, err := s.client.Do(ctx, req, &releaseVersions) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return releaseVersions, resp, nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.