@maxim_mazurok/gapi.client.orgpolicy-v2 0.0.20220809

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.orgpolicy-v2",
3
+ "version": "0.0.20220809",
4
+ "description": "TypeScript typings for Organization Policy API v2",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "maxim@mazurok.com",
8
+ "name": "Maxim Mazurok",
9
+ "url": "https://maxim.mazurok.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,68 @@
1
+ # TypeScript typings for Organization Policy API v2
2
+
3
+ The Org Policy API allows users to configure governance rules on their GCP resources across the Cloud Resource Hierarchy.
4
+ For detailed description please check [documentation](https://cloud.google.com/orgpolicy/docs/reference/rest/index.html).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Organization Policy API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.orgpolicy-v2 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load('https://orgpolicy.googleapis.com/$discovery/rest?version=v2', () => {
29
+ // now we can use:
30
+ // gapi.client.orgpolicy
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
36
+ gapi.client.load('orgpolicy', 'v2', () => {
37
+ // now we can use:
38
+ // gapi.client.orgpolicy
39
+ });
40
+ ```
41
+
42
+ Don't forget to authenticate your client before sending any request to resources:
43
+
44
+ ```typescript
45
+ // declare client_id registered in Google Developers Console
46
+ var client_id = '',
47
+ scope = [
48
+ // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
49
+ 'https://www.googleapis.com/auth/cloud-platform',
50
+ ],
51
+ immediate = true;
52
+ // ...
53
+
54
+ gapi.auth.authorize(
55
+ { client_id: client_id, scope: scope, immediate: immediate },
56
+ authResult => {
57
+ if (authResult && !authResult.error) {
58
+ /* handle successful authorization */
59
+ } else {
60
+ /* handle authorization error */
61
+ }
62
+ });
63
+ ```
64
+
65
+ After that you can use Organization Policy API resources: <!-- TODO: make this work for multiple namespaces -->
66
+
67
+ ```typescript
68
+ ```
package/tests.ts ADDED
@@ -0,0 +1,519 @@
1
+ /* This is stub file for gapi.client.orgpolicy-v2 definition tests */
2
+ // IMPORTANT
3
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
4
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
5
+
6
+ // Revision: 20220809
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://orgpolicy.googleapis.com/$discovery/rest?version=v2');
12
+ /** now we can use gapi.client.orgpolicy */
13
+
14
+ /** don't forget to authenticate your client before sending any request to resources: */
15
+ /** declare client_id registered in Google Developers Console */
16
+ const client_id = '<<PUT YOUR CLIENT ID HERE>>';
17
+ const scope = [
18
+ /** See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account. */
19
+ 'https://www.googleapis.com/auth/cloud-platform',
20
+ ];
21
+ const immediate = false;
22
+ gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
23
+ if (authResult && !authResult.error) {
24
+ /** handle successful authorization */
25
+ run();
26
+ } else {
27
+ /** handle authorization error */
28
+ }
29
+ });
30
+
31
+ async function run() {
32
+ /** Lists `Constraints` that could be applied on the specified resource. */
33
+ await gapi.client.orgpolicy.folders.constraints.list({
34
+ pageSize: 42,
35
+ pageToken: "Test string",
36
+ parent: "Test string",
37
+ });
38
+ /**
39
+ * Creates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if
40
+ * the policy already exists on the given Cloud resource.
41
+ */
42
+ await gapi.client.orgpolicy.folders.policies.create({
43
+ parent: "Test string",
44
+ }, {
45
+ alternate: {
46
+ launch: "Test string",
47
+ spec: {
48
+ etag: "Test string",
49
+ inheritFromParent: true,
50
+ reset: true,
51
+ rules: [
52
+ {
53
+ allowAll: true,
54
+ condition: {
55
+ description: "Test string",
56
+ expression: "Test string",
57
+ location: "Test string",
58
+ title: "Test string",
59
+ },
60
+ denyAll: true,
61
+ enforce: true,
62
+ values: {
63
+ allowedValues: [
64
+ "Test string"
65
+ ],
66
+ deniedValues: [
67
+ "Test string"
68
+ ],
69
+ },
70
+ }
71
+ ],
72
+ updateTime: "Test string",
73
+ },
74
+ },
75
+ name: "Test string",
76
+ spec: {
77
+ etag: "Test string",
78
+ inheritFromParent: true,
79
+ reset: true,
80
+ rules: [
81
+ {
82
+ allowAll: true,
83
+ condition: {
84
+ description: "Test string",
85
+ expression: "Test string",
86
+ location: "Test string",
87
+ title: "Test string",
88
+ },
89
+ denyAll: true,
90
+ enforce: true,
91
+ values: {
92
+ allowedValues: [
93
+ "Test string"
94
+ ],
95
+ deniedValues: [
96
+ "Test string"
97
+ ],
98
+ },
99
+ }
100
+ ],
101
+ updateTime: "Test string",
102
+ },
103
+ });
104
+ /** Deletes a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org Policy does not exist. */
105
+ await gapi.client.orgpolicy.folders.policies.delete({
106
+ name: "Test string",
107
+ });
108
+ /**
109
+ * Gets a `Policy` on a resource. If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used with `UpdatePolicy()` to update a `Policy` during
110
+ * read-modify-write.
111
+ */
112
+ await gapi.client.orgpolicy.folders.policies.get({
113
+ name: "Test string",
114
+ });
115
+ /**
116
+ * Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or
117
+ * `condition` set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
118
+ */
119
+ await gapi.client.orgpolicy.folders.policies.getEffectivePolicy({
120
+ name: "Test string",
121
+ });
122
+ /** Retrieves all of the `Policies` that exist on a particular resource. */
123
+ await gapi.client.orgpolicy.folders.policies.list({
124
+ pageSize: 42,
125
+ pageToken: "Test string",
126
+ parent: "Test string",
127
+ });
128
+ /**
129
+ * Updates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the policy do not exist. Returns a `google.rpc.Status` with
130
+ * `google.rpc.Code.ABORTED` if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.
131
+ */
132
+ await gapi.client.orgpolicy.folders.policies.patch({
133
+ name: "Test string",
134
+ }, {
135
+ alternate: {
136
+ launch: "Test string",
137
+ spec: {
138
+ etag: "Test string",
139
+ inheritFromParent: true,
140
+ reset: true,
141
+ rules: [
142
+ {
143
+ allowAll: true,
144
+ condition: {
145
+ description: "Test string",
146
+ expression: "Test string",
147
+ location: "Test string",
148
+ title: "Test string",
149
+ },
150
+ denyAll: true,
151
+ enforce: true,
152
+ values: {
153
+ allowedValues: [
154
+ "Test string"
155
+ ],
156
+ deniedValues: [
157
+ "Test string"
158
+ ],
159
+ },
160
+ }
161
+ ],
162
+ updateTime: "Test string",
163
+ },
164
+ },
165
+ name: "Test string",
166
+ spec: {
167
+ etag: "Test string",
168
+ inheritFromParent: true,
169
+ reset: true,
170
+ rules: [
171
+ {
172
+ allowAll: true,
173
+ condition: {
174
+ description: "Test string",
175
+ expression: "Test string",
176
+ location: "Test string",
177
+ title: "Test string",
178
+ },
179
+ denyAll: true,
180
+ enforce: true,
181
+ values: {
182
+ allowedValues: [
183
+ "Test string"
184
+ ],
185
+ deniedValues: [
186
+ "Test string"
187
+ ],
188
+ },
189
+ }
190
+ ],
191
+ updateTime: "Test string",
192
+ },
193
+ });
194
+ /** Lists `Constraints` that could be applied on the specified resource. */
195
+ await gapi.client.orgpolicy.organizations.constraints.list({
196
+ pageSize: 42,
197
+ pageToken: "Test string",
198
+ parent: "Test string",
199
+ });
200
+ /**
201
+ * Creates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if
202
+ * the policy already exists on the given Cloud resource.
203
+ */
204
+ await gapi.client.orgpolicy.organizations.policies.create({
205
+ parent: "Test string",
206
+ }, {
207
+ alternate: {
208
+ launch: "Test string",
209
+ spec: {
210
+ etag: "Test string",
211
+ inheritFromParent: true,
212
+ reset: true,
213
+ rules: [
214
+ {
215
+ allowAll: true,
216
+ condition: {
217
+ description: "Test string",
218
+ expression: "Test string",
219
+ location: "Test string",
220
+ title: "Test string",
221
+ },
222
+ denyAll: true,
223
+ enforce: true,
224
+ values: {
225
+ allowedValues: [
226
+ "Test string"
227
+ ],
228
+ deniedValues: [
229
+ "Test string"
230
+ ],
231
+ },
232
+ }
233
+ ],
234
+ updateTime: "Test string",
235
+ },
236
+ },
237
+ name: "Test string",
238
+ spec: {
239
+ etag: "Test string",
240
+ inheritFromParent: true,
241
+ reset: true,
242
+ rules: [
243
+ {
244
+ allowAll: true,
245
+ condition: {
246
+ description: "Test string",
247
+ expression: "Test string",
248
+ location: "Test string",
249
+ title: "Test string",
250
+ },
251
+ denyAll: true,
252
+ enforce: true,
253
+ values: {
254
+ allowedValues: [
255
+ "Test string"
256
+ ],
257
+ deniedValues: [
258
+ "Test string"
259
+ ],
260
+ },
261
+ }
262
+ ],
263
+ updateTime: "Test string",
264
+ },
265
+ });
266
+ /** Deletes a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org Policy does not exist. */
267
+ await gapi.client.orgpolicy.organizations.policies.delete({
268
+ name: "Test string",
269
+ });
270
+ /**
271
+ * Gets a `Policy` on a resource. If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used with `UpdatePolicy()` to update a `Policy` during
272
+ * read-modify-write.
273
+ */
274
+ await gapi.client.orgpolicy.organizations.policies.get({
275
+ name: "Test string",
276
+ });
277
+ /**
278
+ * Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or
279
+ * `condition` set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
280
+ */
281
+ await gapi.client.orgpolicy.organizations.policies.getEffectivePolicy({
282
+ name: "Test string",
283
+ });
284
+ /** Retrieves all of the `Policies` that exist on a particular resource. */
285
+ await gapi.client.orgpolicy.organizations.policies.list({
286
+ pageSize: 42,
287
+ pageToken: "Test string",
288
+ parent: "Test string",
289
+ });
290
+ /**
291
+ * Updates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the policy do not exist. Returns a `google.rpc.Status` with
292
+ * `google.rpc.Code.ABORTED` if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.
293
+ */
294
+ await gapi.client.orgpolicy.organizations.policies.patch({
295
+ name: "Test string",
296
+ }, {
297
+ alternate: {
298
+ launch: "Test string",
299
+ spec: {
300
+ etag: "Test string",
301
+ inheritFromParent: true,
302
+ reset: true,
303
+ rules: [
304
+ {
305
+ allowAll: true,
306
+ condition: {
307
+ description: "Test string",
308
+ expression: "Test string",
309
+ location: "Test string",
310
+ title: "Test string",
311
+ },
312
+ denyAll: true,
313
+ enforce: true,
314
+ values: {
315
+ allowedValues: [
316
+ "Test string"
317
+ ],
318
+ deniedValues: [
319
+ "Test string"
320
+ ],
321
+ },
322
+ }
323
+ ],
324
+ updateTime: "Test string",
325
+ },
326
+ },
327
+ name: "Test string",
328
+ spec: {
329
+ etag: "Test string",
330
+ inheritFromParent: true,
331
+ reset: true,
332
+ rules: [
333
+ {
334
+ allowAll: true,
335
+ condition: {
336
+ description: "Test string",
337
+ expression: "Test string",
338
+ location: "Test string",
339
+ title: "Test string",
340
+ },
341
+ denyAll: true,
342
+ enforce: true,
343
+ values: {
344
+ allowedValues: [
345
+ "Test string"
346
+ ],
347
+ deniedValues: [
348
+ "Test string"
349
+ ],
350
+ },
351
+ }
352
+ ],
353
+ updateTime: "Test string",
354
+ },
355
+ });
356
+ /** Lists `Constraints` that could be applied on the specified resource. */
357
+ await gapi.client.orgpolicy.projects.constraints.list({
358
+ pageSize: 42,
359
+ pageToken: "Test string",
360
+ parent: "Test string",
361
+ });
362
+ /**
363
+ * Creates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if
364
+ * the policy already exists on the given Cloud resource.
365
+ */
366
+ await gapi.client.orgpolicy.projects.policies.create({
367
+ parent: "Test string",
368
+ }, {
369
+ alternate: {
370
+ launch: "Test string",
371
+ spec: {
372
+ etag: "Test string",
373
+ inheritFromParent: true,
374
+ reset: true,
375
+ rules: [
376
+ {
377
+ allowAll: true,
378
+ condition: {
379
+ description: "Test string",
380
+ expression: "Test string",
381
+ location: "Test string",
382
+ title: "Test string",
383
+ },
384
+ denyAll: true,
385
+ enforce: true,
386
+ values: {
387
+ allowedValues: [
388
+ "Test string"
389
+ ],
390
+ deniedValues: [
391
+ "Test string"
392
+ ],
393
+ },
394
+ }
395
+ ],
396
+ updateTime: "Test string",
397
+ },
398
+ },
399
+ name: "Test string",
400
+ spec: {
401
+ etag: "Test string",
402
+ inheritFromParent: true,
403
+ reset: true,
404
+ rules: [
405
+ {
406
+ allowAll: true,
407
+ condition: {
408
+ description: "Test string",
409
+ expression: "Test string",
410
+ location: "Test string",
411
+ title: "Test string",
412
+ },
413
+ denyAll: true,
414
+ enforce: true,
415
+ values: {
416
+ allowedValues: [
417
+ "Test string"
418
+ ],
419
+ deniedValues: [
420
+ "Test string"
421
+ ],
422
+ },
423
+ }
424
+ ],
425
+ updateTime: "Test string",
426
+ },
427
+ });
428
+ /** Deletes a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org Policy does not exist. */
429
+ await gapi.client.orgpolicy.projects.policies.delete({
430
+ name: "Test string",
431
+ });
432
+ /**
433
+ * Gets a `Policy` on a resource. If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used with `UpdatePolicy()` to update a `Policy` during
434
+ * read-modify-write.
435
+ */
436
+ await gapi.client.orgpolicy.projects.policies.get({
437
+ name: "Test string",
438
+ });
439
+ /**
440
+ * Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or
441
+ * `condition` set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
442
+ */
443
+ await gapi.client.orgpolicy.projects.policies.getEffectivePolicy({
444
+ name: "Test string",
445
+ });
446
+ /** Retrieves all of the `Policies` that exist on a particular resource. */
447
+ await gapi.client.orgpolicy.projects.policies.list({
448
+ pageSize: 42,
449
+ pageToken: "Test string",
450
+ parent: "Test string",
451
+ });
452
+ /**
453
+ * Updates a Policy. Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the policy do not exist. Returns a `google.rpc.Status` with
454
+ * `google.rpc.Code.ABORTED` if the etag supplied in the request does not match the persisted etag of the policy Note: the supplied policy will perform a full overwrite of all fields.
455
+ */
456
+ await gapi.client.orgpolicy.projects.policies.patch({
457
+ name: "Test string",
458
+ }, {
459
+ alternate: {
460
+ launch: "Test string",
461
+ spec: {
462
+ etag: "Test string",
463
+ inheritFromParent: true,
464
+ reset: true,
465
+ rules: [
466
+ {
467
+ allowAll: true,
468
+ condition: {
469
+ description: "Test string",
470
+ expression: "Test string",
471
+ location: "Test string",
472
+ title: "Test string",
473
+ },
474
+ denyAll: true,
475
+ enforce: true,
476
+ values: {
477
+ allowedValues: [
478
+ "Test string"
479
+ ],
480
+ deniedValues: [
481
+ "Test string"
482
+ ],
483
+ },
484
+ }
485
+ ],
486
+ updateTime: "Test string",
487
+ },
488
+ },
489
+ name: "Test string",
490
+ spec: {
491
+ etag: "Test string",
492
+ inheritFromParent: true,
493
+ reset: true,
494
+ rules: [
495
+ {
496
+ allowAll: true,
497
+ condition: {
498
+ description: "Test string",
499
+ expression: "Test string",
500
+ location: "Test string",
501
+ title: "Test string",
502
+ },
503
+ denyAll: true,
504
+ enforce: true,
505
+ values: {
506
+ allowedValues: [
507
+ "Test string"
508
+ ],
509
+ deniedValues: [
510
+ "Test string"
511
+ ],
512
+ },
513
+ }
514
+ ],
515
+ updateTime: "Test string",
516
+ },
517
+ });
518
+ }
519
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "lib": ["es6", "dom"],
5
+ "noImplicitAny": true,
6
+ "noImplicitThis": true,
7
+ "strictNullChecks": true,
8
+ "baseUrl": "../",
9
+ "typeRoots": [
10
+ "../"
11
+ ],
12
+ "types": [],
13
+ "noEmit": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "strictFunctionTypes": true
16
+ },
17
+ "files": ["index.d.ts", "tests.ts"]
18
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }