-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Add support for network-configurations endpoints #3497
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 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
054e65b
feat(network-configurations): Add support for network-configurations …
jndz2 aef2391
feat(network-configurations): Add support for network-configurations …
jndz2 442161c
feat(network-configurations): Add support for network-configurations …
jndz2 41226b8
feat(network-configurations): Add support for network-configurations …
jndz2 d9f8734
feat(network-configurations): Refactoring struct type and simplify fu…
jndz2 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,170 @@ | ||
// 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" | ||
"fmt" | ||
) | ||
|
||
// ComputeService represents a hosted compute service the network configuration supports. | ||
type ComputeService string | ||
|
||
const ( | ||
ComputeServiceNone ComputeService = "none" | ||
ComputeServiceActions ComputeService = "actions" | ||
) | ||
|
||
// EnterpriseNetworkConfiguration represents a hosted compute network configuration. | ||
type EnterpriseNetworkConfiguration struct { | ||
ID *string `json:"id,omitempty"` | ||
Name *string `json:"name,omitempty"` | ||
ComputeService *ComputeService `json:"compute_service,omitempty"` | ||
NetworkSettingsIDs []string `json:"network_settings_ids,omitempty"` | ||
CreatedOn *Timestamp `json:"created_on,omitempty"` | ||
} | ||
|
||
// EnterpriseNetworkConfigurations represents a hosted compute network configurations. | ||
type EnterpriseNetworkConfigurations struct { | ||
TotalCount *int64 `json:"total_count,omitempty"` | ||
NetworkConfigurations []*EnterpriseNetworkConfiguration `json:"network_configurations,omitempty"` | ||
} | ||
|
||
// EnterpriseNetworkSettingsResource represents a hosted compute network settings resource. | ||
type EnterpriseNetworkSettingsResource struct { | ||
ID *string `json:"id,omitempty"` | ||
Name *string `json:"name,omitempty"` | ||
NetworkConfigurationID *string `json:"network_configuration_id,omitempty"` | ||
SubnetID *string `json:"subnet_id,omitempty"` | ||
Region *string `json:"region,omitempty"` | ||
} | ||
|
||
// EnterpriseNetworkConfigurationRequest represents a request to create or update a network configuration for an enterprise. | ||
type EnterpriseNetworkConfigurationRequest struct { | ||
Name *string `json:"name,omitempty"` | ||
ComputeService *ComputeService `json:"compute_service,omitempty"` | ||
NetworkSettingsIDs *[]string `json:"network_settings_ids,omitempty"` | ||
} | ||
|
||
// ListEnterpriseNetworkConfigurations lists all hosted compute network configurations configured in an enterprise. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/network-configurations#list-hosted-compute-network-configurations-for-an-enterprise | ||
// | ||
//meta:operation GET /enterprises/{enterprise}/network-configurations | ||
func (s *EnterpriseService) ListEnterpriseNetworkConfigurations(ctx context.Context, enterprise string, opts *ListOptions) (*EnterpriseNetworkConfigurations, *Response, error) { | ||
u := fmt.Sprintf("enterprises/%v/network-configurations", enterprise) | ||
u, err := addOptions(u, opts) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
networks := &EnterpriseNetworkConfigurations{} | ||
resp, err := s.client.Do(ctx, req, networks) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
return networks, resp, nil | ||
} | ||
|
||
// CreateEnterpriseNetworkConfiguration creates a hosted compute network configuration for an enterprise. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/network-configurations#create-a-hosted-compute-network-configuration-for-an-enterprise | ||
// | ||
//meta:operation POST /enterprises/{enterprise}/network-configurations | ||
func (s *EnterpriseService) CreateEnterpriseNetworkConfiguration(ctx context.Context, enterprise string, createReq EnterpriseNetworkConfigurationRequest) (*EnterpriseNetworkConfiguration, *Response, error) { | ||
u := fmt.Sprintf("enterprises/%v/network-configurations", enterprise) | ||
req, err := s.client.NewRequest("POST", u, createReq) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
network := &EnterpriseNetworkConfiguration{} | ||
resp, err := s.client.Do(ctx, req, network) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
|
||
return network, resp, nil | ||
} | ||
|
||
// GetEnterpriseNetworkConfiguration gets a hosted compute network configuration configured in an enterprise. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/network-configurations#get-a-hosted-compute-network-configuration-for-an-enterprise | ||
// | ||
//meta:operation GET /enterprises/{enterprise}/network-configurations/{network_configuration_id} | ||
func (s *EnterpriseService) GetEnterpriseNetworkConfiguration(ctx context.Context, enterprise string, networkID string) (*EnterpriseNetworkConfiguration, *Response, error) { | ||
gmlewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
u := fmt.Sprintf("enterprises/%v/network-configurations/%v", enterprise, networkID) | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
network := &EnterpriseNetworkConfiguration{} | ||
resp, err := s.client.Do(ctx, req, network) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
return network, resp, nil | ||
} | ||
|
||
// UpdateEnterpriseNetworkConfiguration updates a hosted compute network configuration for an enterprise. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/network-configurations#update-a-hosted-compute-network-configuration-for-an-enterprise | ||
// | ||
//meta:operation PATCH /enterprises/{enterprise}/network-configurations/{network_configuration_id} | ||
func (s *EnterpriseService) UpdateEnterpriseNetworkConfiguration(ctx context.Context, enterprise string, networkID string, updateReq EnterpriseNetworkConfigurationRequest) (*EnterpriseNetworkConfiguration, *Response, error) { | ||
gmlewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
u := fmt.Sprintf("enterprises/%v/network-configurations/%v", enterprise, networkID) | ||
req, err := s.client.NewRequest("PATCH", u, updateReq) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
network := &EnterpriseNetworkConfiguration{} | ||
resp, err := s.client.Do(ctx, req, network) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
return network, resp, nil | ||
} | ||
|
||
// DeleteEnterpriseNetworkConfiguration deletes a hosted compute network configuration from an enterprise. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/network-configurations#delete-a-hosted-compute-network-configuration-from-an-enterprise | ||
// | ||
//meta:operation DELETE /enterprises/{enterprise}/network-configurations/{network_configuration_id} | ||
func (s *EnterpriseService) DeleteEnterpriseNetworkConfiguration(ctx context.Context, enterprise string, networkID string) (*Response, error) { | ||
gmlewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
u := fmt.Sprintf("enterprises/%v/network-configurations/%v", enterprise, networkID) | ||
req, err := s.client.NewRequest("DELETE", u, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return s.client.Do(ctx, req, nil) | ||
} | ||
|
||
// GetEnterpriseNetworkSettingsResource gets a hosted compute network settings resource configured for an enterprise. | ||
// | ||
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/network-configurations#get-a-hosted-compute-network-settings-resource-for-an-enterprise | ||
// | ||
//meta:operation GET /enterprises/{enterprise}/network-settings/{network_settings_id} | ||
func (s *EnterpriseService) GetEnterpriseNetworkSettingsResource(ctx context.Context, enterprise string, networkID string) (*EnterpriseNetworkSettingsResource, *Response, error) { | ||
gmlewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
u := fmt.Sprintf("enterprises/%v/network-settings/%v", enterprise, networkID) | ||
req, err := s.client.NewRequest("GET", u, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
resource := &EnterpriseNetworkSettingsResource{} | ||
resp, err := s.client.Do(ctx, req, resource) | ||
if err != nil { | ||
return nil, resp, err | ||
} | ||
return resource, resp, err | ||
} |
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.