-
Notifications
You must be signed in to change notification settings - Fork 4
/
billingAccounts.clj
276 lines (240 loc) · 7.82 KB
/
billingAccounts.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
(ns happygapi.cloudbilling.billingAccounts
"Cloud Billing API: billingAccounts.
Allows developers to manage billing for their Google Cloud Platform projects
programmatically.
See: https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn list$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/list
Required parameters: none
Optional parameters: pageToken, pageSize, filter
Lists the billing accounts that the current authenticated user has
permission to
[view](https://cloud.google.com/billing/docs/how-to/billing-access)."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/get
(util/get-url
"https://cloudbilling.googleapis.com/"
"v1/billingAccounts"
#{}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn setIamPolicy$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/setIamPolicy
Required parameters: resource
Optional parameters: none
Body:
{:updateMask string,
:policy {:auditConfigs [AuditConfig],
:bindings [Binding],
:etag string,
:version integer}}
Sets the access control policy for a billing account. Replaces any existing
policy.
The caller must have the `billing.accounts.setIamPolicy` permission on the
account, which is often given to billing account
[administrators](https://cloud.google.com/billing/docs/how-to/billing-access)."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args body]
{:pre [(util/has-keys? args #{:resource})]}
(util/get-response
(http/post
(util/get-url
"https://cloudbilling.googleapis.com/"
"v1/{+resource}:setIamPolicy"
#{:resource}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn create$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/create
Required parameters: none
Optional parameters: none
Body:
{:name string,
:open boolean,
:displayName string,
:masterBillingAccount string}
Creates a billing account.
This method can only be used to create
[billing subaccounts](https://cloud.google.com/billing/docs/concepts)
by GCP resellers.
When creating a subaccount, the current authenticated user must have the
`billing.accounts.update` IAM permission on the master account, which is
typically given to billing account
[administrators](https://cloud.google.com/billing/docs/how-to/billing-access).
This method will return an error if the master account has not been
provisioned as a reseller account."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://cloudbilling.googleapis.com/"
"v1/billingAccounts"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn getIamPolicy$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/getIamPolicy
Required parameters: resource
Optional parameters: options.requestedPolicyVersion
Gets the access control policy for a billing account.
The caller must have the `billing.accounts.getIamPolicy` permission on the
account, which is often given to billing account
[viewers](https://cloud.google.com/billing/docs/how-to/billing-access)."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:resource})]}
(util/get-response
(http/get
(util/get-url
"https://cloudbilling.googleapis.com/"
"v1/{+resource}:getIamPolicy"
#{:resource}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn patch$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/patch
Required parameters: name
Optional parameters: updateMask
Body:
{:name string,
:open boolean,
:displayName string,
:masterBillingAccount string}
Updates a billing account's fields.
Currently the only field that can be edited is `display_name`.
The current authenticated user must have the `billing.accounts.update`
IAM permission, which is typically given to the
[administrator](https://cloud.google.com/billing/docs/how-to/billing-access)
of the billing account."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args body]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/patch
(util/get-url
"https://cloudbilling.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 get$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/get
Required parameters: name
Optional parameters: none
Gets information about a billing account. The current authenticated user
must be a [viewer of the billing
account](https://cloud.google.com/billing/docs/how-to/billing-access)."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/get
(util/get-url
"https://cloudbilling.googleapis.com/"
"v1/{+name}"
#{:name}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn testIamPermissions$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/testIamPermissions
Required parameters: resource
Optional parameters: none
Body:
{:permissions [string]}
Tests the access control policy for a billing account. This method takes
the resource and a set of permissions as input and returns the subset of
the input permissions that the caller is allowed for that resource."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args body]
{:pre [(util/has-keys? args #{:resource})]}
(util/get-response
(http/post
(util/get-url
"https://cloudbilling.googleapis.com/"
"v1/{+resource}:testIamPermissions"
#{:resource}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn projects-list$
"https://cloud.google.com/billing/api/reference/rest/v1/billingAccounts/projects/list
Required parameters: name
Optional parameters: pageToken, pageSize
Lists the projects associated with a billing account. The current
authenticated user must have the `billing.resourceAssociations.list` IAM
permission, which is often given to billing account
[viewers](https://cloud.google.com/billing/docs/how-to/billing-access)."
{:scopes ["https://www.googleapis.com/auth/cloud-platform"]}
[auth args]
{:pre [(util/has-keys? args #{:name})]}
(util/get-response
(http/get
(util/get-url
"https://cloudbilling.googleapis.com/"
"v1/{+name}/projects"
#{:name}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))