-
Notifications
You must be signed in to change notification settings - Fork 4
/
services.clj
311 lines (266 loc) · 9.6 KB
/
services.clj
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
(ns happygapi.servicenetworking.services
"Service Networking API: services.
Provides automatic management of network configurations necessary for certain services.
See: https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn validate$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/validate
Required parameters: parent
Optional parameters: none
Body:
{:validateNetwork boolean,
:consumerProject {:projectNum string},
:consumerNetwork string,
:rangeReservation {:secondaryRangeIpPrefixLengths [integer],
:ipPrefixLength integer}}
Service producers use this method to validate if the consumer provided
network, project and the requested range is valid. This allows them to use
a fail-fast mechanism for consumer requests, and not have to wait for
AddSubnetwork operation completion to determine if user request is invalid."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args body]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/post
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+parent}:validate"
#{:parent}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn disableVpcServiceControls$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/disableVpcServiceControls
Required parameters: parent
Optional parameters: none
Body:
{:consumerNetwork string}
Disables VPC service controls for a connection."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args body]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/patch
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+parent}:disableVpcServiceControls"
#{:parent}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn addSubnetwork$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/addSubnetwork
Required parameters: parent
Optional parameters: none
Body:
{:description string,
:consumer string,
:consumerNetwork string,
:privateIpv6GoogleAccess string,
:subnetworkUsers [string],
:requestedAddress string,
:region string,
:ipPrefixLength integer,
:subnetwork string}
For service producers, provisions a new subnet in a
peered service's shared VPC network in the requested region and with the
requested size that's expressed as a CIDR range (number of leading bits of
ipV4 network mask). The method checks against the assigned allocated ranges
to find a non-conflicting IP address range. The method will reuse a subnet
if subsequent calls contain the same subnet name, region, and prefix
length. This method will make producer's tenant project to be a shared VPC
service project as needed. The response from the `get` operation will be of
type `Subnetwork` if the operation successfully completes."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args body]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/post
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+parent}:addSubnetwork"
#{:parent}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn searchRange$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/searchRange
Required parameters: parent
Optional parameters: none
Body:
{:ipPrefixLength integer, :network string}
Service producers can use this method to find a currently unused range
within consumer allocated ranges. This returned range is not reserved,
and not guaranteed to remain unused.
It will validate previously provided allocated ranges, find
non-conflicting sub-range of requested size (expressed in
number of leading bits of ipv4 network mask, as in CIDR range
notation).
Operation<response: Range>"
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args body]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/post
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+parent}:searchRange"
#{:parent}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn enableVpcServiceControls$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/enableVpcServiceControls
Required parameters: parent
Optional parameters: none
Body:
{:consumerNetwork string}
Enables VPC service controls for a connection."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args body]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/patch
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+parent}:enableVpcServiceControls"
#{:parent}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn connections-list$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/connections/list
Required parameters: parent
Optional parameters: network
List the private connections that are configured in a service consumer's
VPC network."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/get
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+parent}/connections"
#{:parent}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn connections-patch$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/connections/patch
Required parameters: name
Optional parameters: updateMask, force
Body:
{:network string,
:peering string,
:reservedPeeringRanges [string],
:service string}
Updates the allocated ranges that are assigned to a connection.
The response from the `get` operation will be of type `Connection` if the
operation successfully completes."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args body]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/patch
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+name}"
#{:name}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn connections-create$
"https://cloud.google.com/service-infrastructure/docs/service-networking/getting-startedapi/reference/rest/v1/services/connections/create
Required parameters: parent
Optional parameters: none
Body:
{:network string,
:peering string,
:reservedPeeringRanges [string],
:service string}
Creates a private connection that establishes a VPC Network Peering
connection to a VPC network in the service producer's organization.
The administrator of the service consumer's VPC network invokes this
method. The administrator must assign one or more allocated IP ranges for
provisioning subnetworks in the service producer's VPC network. This
connection is used for all supported services in the service producer's
organization, so it only needs to be invoked once. The response from the
`get` operation will be of type `Connection` if the operation successfully
completes."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/service.management"]}
[auth args body]
{:pre [(util/has-keys? args #{:parent})]}
(util/get-response
(http/post
(util/get-url
"https://servicenetworking.googleapis.com/"
"v1/{+parent}/connections"
#{:parent}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))