-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathenterprise_network_configurations.go
More file actions
139 lines (122 loc) · 5.58 KB
/
enterprise_network_configurations.go
File metadata and controls
139 lines (122 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// 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"
)
// 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) (*NetworkConfigurations, *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 := &NetworkConfigurations{}
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 NetworkConfigurationRequest) (*NetworkConfiguration, *Response, error) {
if err := validateNetworkConfigurationRequest(createReq); err != nil {
return nil, nil, fmt.Errorf("validation failed: %w", err)
}
u := fmt.Sprintf("enterprises/%v/network-configurations", enterprise)
req, err := s.client.NewRequest("POST", u, createReq)
if err != nil {
return nil, nil, err
}
network := &NetworkConfiguration{}
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, networkID string) (*NetworkConfiguration, *Response, error) {
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 := &NetworkConfiguration{}
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, networkID string, updateReq NetworkConfigurationRequest) (*NetworkConfiguration, *Response, error) {
if err := validateNetworkConfigurationRequest(updateReq); err != nil {
return nil, nil, fmt.Errorf("validation failed: %w", err)
}
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 := &NetworkConfiguration{}
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, networkID string) (*Response, error) {
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, networkID string) (*NetworkSettingsResource, *Response, error) {
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 := &NetworkSettingsResource{}
resp, err := s.client.Do(ctx, req, resource)
if err != nil {
return nil, resp, err
}
return resource, resp, err
}