@maxim_mazurok/gapi.client.cloudasset-v1 0.0.20220805

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.cloudasset-v1",
3
+ "version": "0.0.20220805",
4
+ "description": "TypeScript typings for Cloud Asset API v1",
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,168 @@
1
+ # TypeScript typings for Cloud Asset API v1
2
+
3
+ The cloud asset API manages the history and inventory of cloud resources.
4
+ For detailed description please check [documentation](https://cloud.google.com/asset-inventory/docs/quickstart).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Cloud Asset API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.cloudasset-v1 --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://cloudasset.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.cloudasset
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('cloudasset', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.cloudasset
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 Cloud Asset API resources: <!-- TODO: make this work for multiple namespaces -->
66
+
67
+ ```typescript
68
+
69
+ /*
70
+ Lists assets with time and resource types and returns paged results in response.
71
+ */
72
+ await gapi.client.cloudasset.assets.list({ parent: "parent", });
73
+
74
+ /*
75
+ Gets effective IAM policies for a batch of resources.
76
+ */
77
+ await gapi.client.cloudasset.effectiveIamPolicies.batchGet({ scope: "scope", });
78
+
79
+ /*
80
+ Creates a feed in a parent project/folder/organization to listen to its asset updates.
81
+ */
82
+ await gapi.client.cloudasset.feeds.create({ parent: "parent", });
83
+
84
+ /*
85
+ Deletes an asset feed.
86
+ */
87
+ await gapi.client.cloudasset.feeds.delete({ name: "name", });
88
+
89
+ /*
90
+ Gets details about an asset feed.
91
+ */
92
+ await gapi.client.cloudasset.feeds.get({ name: "name", });
93
+
94
+ /*
95
+ Lists all asset feeds in a parent project/folder/organization.
96
+ */
97
+ await gapi.client.cloudasset.feeds.list({ parent: "parent", });
98
+
99
+ /*
100
+ Updates an asset feed configuration.
101
+ */
102
+ await gapi.client.cloudasset.feeds.patch({ name: "name", });
103
+
104
+ /*
105
+ Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
106
+ */
107
+ await gapi.client.cloudasset.operations.get({ name: "name", });
108
+
109
+ /*
110
+ Creates a saved query in a parent project/folder/organization.
111
+ */
112
+ await gapi.client.cloudasset.savedQueries.create({ parent: "parent", });
113
+
114
+ /*
115
+ Deletes a saved query.
116
+ */
117
+ await gapi.client.cloudasset.savedQueries.delete({ name: "name", });
118
+
119
+ /*
120
+ Gets details about a saved query.
121
+ */
122
+ await gapi.client.cloudasset.savedQueries.get({ name: "name", });
123
+
124
+ /*
125
+ Lists all saved queries in a parent project/folder/organization.
126
+ */
127
+ await gapi.client.cloudasset.savedQueries.list({ parent: "parent", });
128
+
129
+ /*
130
+ Updates a saved query.
131
+ */
132
+ await gapi.client.cloudasset.savedQueries.patch({ name: "name", });
133
+
134
+ /*
135
+ Analyzes IAM policies to answer which identities have what accesses on which resources.
136
+ */
137
+ await gapi.client.cloudasset.analyzeIamPolicy({ scope: "scope", });
138
+
139
+ /*
140
+ Analyzes IAM policies asynchronously to answer which identities have what accesses on which resources, and writes the analysis results to a Google Cloud Storage or a BigQuery destination. For Cloud Storage destination, the output format is the JSON format that represents a AnalyzeIamPolicyResponse. This method implements the google.longrunning.Operation, which allows you to track the operation status. We recommend intervals of at least 2 seconds with exponential backoff retry to poll the operation result. The metadata contains the metadata for the long-running operation.
141
+ */
142
+ await gapi.client.cloudasset.analyzeIamPolicyLongrunning({ scope: "scope", });
143
+
144
+ /*
145
+ Analyze moving a resource to a specified destination without kicking off the actual move. The analysis is best effort depending on the user's permissions of viewing different hierarchical policies and configurations. The policies and configuration are subject to change before the actual resource migration takes place.
146
+ */
147
+ await gapi.client.cloudasset.analyzeMove({ resource: "resource", });
148
+
149
+ /*
150
+ Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create gaps in the output history. Otherwise, this API outputs history with asset in both non-delete or deleted status. If a specified asset does not exist, this API returns an INVALID_ARGUMENT error.
151
+ */
152
+ await gapi.client.cloudasset.batchGetAssetsHistory({ parent: "parent", });
153
+
154
+ /*
155
+ Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line represents a google.cloud.asset.v1.Asset in the JSON format; for BigQuery table destinations, the output table stores the fields in asset Protobuf as columns. This API implements the google.longrunning.Operation API, which allows you to keep track of the export. We recommend intervals of at least 2 seconds with exponential retry to poll the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes.
156
+ */
157
+ await gapi.client.cloudasset.exportAssets({ parent: "parent", });
158
+
159
+ /*
160
+ Searches all IAM policies within the specified scope, such as a project, folder, or organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` permission on the desired scope, otherwise the request will be rejected.
161
+ */
162
+ await gapi.client.cloudasset.searchAllIamPolicies({ scope: "scope", });
163
+
164
+ /*
165
+ Searches all Cloud resources within the specified scope, such as a project, folder, or organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission on the desired scope, otherwise the request will be rejected.
166
+ */
167
+ await gapi.client.cloudasset.searchAllResources({ scope: "scope", });
168
+ ```
package/tests.ts ADDED
@@ -0,0 +1,376 @@
1
+ /* This is stub file for gapi.client.cloudasset-v1 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: 20220805
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://cloudasset.googleapis.com/$discovery/rest?version=v1');
12
+ /** now we can use gapi.client.cloudasset */
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 assets with time and resource types and returns paged results in response. */
33
+ await gapi.client.cloudasset.assets.list({
34
+ assetTypes: "Test string",
35
+ contentType: "Test string",
36
+ pageSize: 42,
37
+ pageToken: "Test string",
38
+ parent: "Test string",
39
+ readTime: "Test string",
40
+ relationshipTypes: "Test string",
41
+ });
42
+ /** Gets effective IAM policies for a batch of resources. */
43
+ await gapi.client.cloudasset.effectiveIamPolicies.batchGet({
44
+ names: "Test string",
45
+ scope: "Test string",
46
+ });
47
+ /** Creates a feed in a parent project/folder/organization to listen to its asset updates. */
48
+ await gapi.client.cloudasset.feeds.create({
49
+ parent: "Test string",
50
+ }, {
51
+ feed: {
52
+ assetNames: [
53
+ "Test string"
54
+ ],
55
+ assetTypes: [
56
+ "Test string"
57
+ ],
58
+ condition: {
59
+ description: "Test string",
60
+ expression: "Test string",
61
+ location: "Test string",
62
+ title: "Test string",
63
+ },
64
+ contentType: "Test string",
65
+ feedOutputConfig: {
66
+ pubsubDestination: {
67
+ topic: "Test string",
68
+ },
69
+ },
70
+ name: "Test string",
71
+ relationshipTypes: [
72
+ "Test string"
73
+ ],
74
+ },
75
+ feedId: "Test string",
76
+ });
77
+ /** Deletes an asset feed. */
78
+ await gapi.client.cloudasset.feeds.delete({
79
+ name: "Test string",
80
+ });
81
+ /** Gets details about an asset feed. */
82
+ await gapi.client.cloudasset.feeds.get({
83
+ name: "Test string",
84
+ });
85
+ /** Lists all asset feeds in a parent project/folder/organization. */
86
+ await gapi.client.cloudasset.feeds.list({
87
+ parent: "Test string",
88
+ });
89
+ /** Updates an asset feed configuration. */
90
+ await gapi.client.cloudasset.feeds.patch({
91
+ name: "Test string",
92
+ }, {
93
+ feed: {
94
+ assetNames: [
95
+ "Test string"
96
+ ],
97
+ assetTypes: [
98
+ "Test string"
99
+ ],
100
+ condition: {
101
+ description: "Test string",
102
+ expression: "Test string",
103
+ location: "Test string",
104
+ title: "Test string",
105
+ },
106
+ contentType: "Test string",
107
+ feedOutputConfig: {
108
+ pubsubDestination: {
109
+ topic: "Test string",
110
+ },
111
+ },
112
+ name: "Test string",
113
+ relationshipTypes: [
114
+ "Test string"
115
+ ],
116
+ },
117
+ updateMask: "Test string",
118
+ });
119
+ /** Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service. */
120
+ await gapi.client.cloudasset.operations.get({
121
+ name: "Test string",
122
+ });
123
+ /** Creates a saved query in a parent project/folder/organization. */
124
+ await gapi.client.cloudasset.savedQueries.create({
125
+ parent: "Test string",
126
+ savedQueryId: "Test string",
127
+ }, {
128
+ content: {
129
+ iamPolicyAnalysisQuery: {
130
+ accessSelector: {
131
+ permissions: [
132
+ "Test string"
133
+ ],
134
+ roles: [
135
+ "Test string"
136
+ ],
137
+ },
138
+ conditionContext: {
139
+ accessTime: "Test string",
140
+ },
141
+ identitySelector: {
142
+ identity: "Test string",
143
+ },
144
+ options: {
145
+ analyzeServiceAccountImpersonation: true,
146
+ expandGroups: true,
147
+ expandResources: true,
148
+ expandRoles: true,
149
+ outputGroupEdges: true,
150
+ outputResourceEdges: true,
151
+ },
152
+ resourceSelector: {
153
+ fullResourceName: "Test string",
154
+ },
155
+ scope: "Test string",
156
+ },
157
+ },
158
+ createTime: "Test string",
159
+ creator: "Test string",
160
+ description: "Test string",
161
+ labels: {
162
+ A: "Test string"
163
+ },
164
+ lastUpdater: "Test string",
165
+ lastUpdateTime: "Test string",
166
+ name: "Test string",
167
+ });
168
+ /** Deletes a saved query. */
169
+ await gapi.client.cloudasset.savedQueries.delete({
170
+ name: "Test string",
171
+ });
172
+ /** Gets details about a saved query. */
173
+ await gapi.client.cloudasset.savedQueries.get({
174
+ name: "Test string",
175
+ });
176
+ /** Lists all saved queries in a parent project/folder/organization. */
177
+ await gapi.client.cloudasset.savedQueries.list({
178
+ filter: "Test string",
179
+ pageSize: 42,
180
+ pageToken: "Test string",
181
+ parent: "Test string",
182
+ });
183
+ /** Updates a saved query. */
184
+ await gapi.client.cloudasset.savedQueries.patch({
185
+ name: "Test string",
186
+ updateMask: "Test string",
187
+ }, {
188
+ content: {
189
+ iamPolicyAnalysisQuery: {
190
+ accessSelector: {
191
+ permissions: [
192
+ "Test string"
193
+ ],
194
+ roles: [
195
+ "Test string"
196
+ ],
197
+ },
198
+ conditionContext: {
199
+ accessTime: "Test string",
200
+ },
201
+ identitySelector: {
202
+ identity: "Test string",
203
+ },
204
+ options: {
205
+ analyzeServiceAccountImpersonation: true,
206
+ expandGroups: true,
207
+ expandResources: true,
208
+ expandRoles: true,
209
+ outputGroupEdges: true,
210
+ outputResourceEdges: true,
211
+ },
212
+ resourceSelector: {
213
+ fullResourceName: "Test string",
214
+ },
215
+ scope: "Test string",
216
+ },
217
+ },
218
+ createTime: "Test string",
219
+ creator: "Test string",
220
+ description: "Test string",
221
+ labels: {
222
+ A: "Test string"
223
+ },
224
+ lastUpdater: "Test string",
225
+ lastUpdateTime: "Test string",
226
+ name: "Test string",
227
+ });
228
+ /** Analyzes IAM policies to answer which identities have what accesses on which resources. */
229
+ await gapi.client.cloudasset.v1.analyzeIamPolicy({
230
+ "analysisQuery.accessSelector.permissions": "Test string",
231
+ "analysisQuery.accessSelector.roles": "Test string",
232
+ "analysisQuery.conditionContext.accessTime": "Test string",
233
+ "analysisQuery.identitySelector.identity": "Test string",
234
+ "analysisQuery.options.analyzeServiceAccountImpersonation": true,
235
+ "analysisQuery.options.expandGroups": true,
236
+ "analysisQuery.options.expandResources": true,
237
+ "analysisQuery.options.expandRoles": true,
238
+ "analysisQuery.options.outputGroupEdges": true,
239
+ "analysisQuery.options.outputResourceEdges": true,
240
+ "analysisQuery.resourceSelector.fullResourceName": "Test string",
241
+ executionTimeout: "Test string",
242
+ savedAnalysisQuery: "Test string",
243
+ scope: "Test string",
244
+ });
245
+ /**
246
+ * Analyzes IAM policies asynchronously to answer which identities have what accesses on which resources, and writes the analysis results to a Google Cloud Storage or a BigQuery
247
+ * destination. For Cloud Storage destination, the output format is the JSON format that represents a AnalyzeIamPolicyResponse. This method implements the google.longrunning.Operation,
248
+ * which allows you to track the operation status. We recommend intervals of at least 2 seconds with exponential backoff retry to poll the operation result. The metadata contains the
249
+ * metadata for the long-running operation.
250
+ */
251
+ await gapi.client.cloudasset.v1.analyzeIamPolicyLongrunning({
252
+ scope: "Test string",
253
+ }, {
254
+ analysisQuery: {
255
+ accessSelector: {
256
+ permissions: [
257
+ "Test string"
258
+ ],
259
+ roles: [
260
+ "Test string"
261
+ ],
262
+ },
263
+ conditionContext: {
264
+ accessTime: "Test string",
265
+ },
266
+ identitySelector: {
267
+ identity: "Test string",
268
+ },
269
+ options: {
270
+ analyzeServiceAccountImpersonation: true,
271
+ expandGroups: true,
272
+ expandResources: true,
273
+ expandRoles: true,
274
+ outputGroupEdges: true,
275
+ outputResourceEdges: true,
276
+ },
277
+ resourceSelector: {
278
+ fullResourceName: "Test string",
279
+ },
280
+ scope: "Test string",
281
+ },
282
+ outputConfig: {
283
+ bigqueryDestination: {
284
+ dataset: "Test string",
285
+ partitionKey: "Test string",
286
+ tablePrefix: "Test string",
287
+ writeDisposition: "Test string",
288
+ },
289
+ gcsDestination: {
290
+ uri: "Test string",
291
+ },
292
+ },
293
+ savedAnalysisQuery: "Test string",
294
+ });
295
+ /**
296
+ * Analyze moving a resource to a specified destination without kicking off the actual move. The analysis is best effort depending on the user's permissions of viewing different
297
+ * hierarchical policies and configurations. The policies and configuration are subject to change before the actual resource migration takes place.
298
+ */
299
+ await gapi.client.cloudasset.v1.analyzeMove({
300
+ destinationParent: "Test string",
301
+ resource: "Test string",
302
+ view: "Test string",
303
+ });
304
+ /**
305
+ * Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can
306
+ * create gaps in the output history. Otherwise, this API outputs history with asset in both non-delete or deleted status. If a specified asset does not exist, this API returns an
307
+ * INVALID_ARGUMENT error.
308
+ */
309
+ await gapi.client.cloudasset.v1.batchGetAssetsHistory({
310
+ assetNames: "Test string",
311
+ contentType: "Test string",
312
+ parent: "Test string",
313
+ "readTimeWindow.endTime": "Test string",
314
+ "readTimeWindow.startTime": "Test string",
315
+ relationshipTypes: "Test string",
316
+ });
317
+ /**
318
+ * Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. For Cloud Storage location destinations, the output format is newline-delimited JSON. Each
319
+ * line represents a google.cloud.asset.v1.Asset in the JSON format; for BigQuery table destinations, the output table stores the fields in asset Protobuf as columns. This API implements
320
+ * the google.longrunning.Operation API, which allows you to keep track of the export. We recommend intervals of at least 2 seconds with exponential retry to poll the export operation
321
+ * result. For regular-size resource parent, the export operation usually finishes within 5 minutes.
322
+ */
323
+ await gapi.client.cloudasset.v1.exportAssets({
324
+ parent: "Test string",
325
+ }, {
326
+ assetTypes: [
327
+ "Test string"
328
+ ],
329
+ contentType: "Test string",
330
+ outputConfig: {
331
+ bigqueryDestination: {
332
+ dataset: "Test string",
333
+ force: true,
334
+ partitionSpec: {
335
+ partitionKey: "Test string",
336
+ },
337
+ separateTablesPerAssetType: true,
338
+ table: "Test string",
339
+ },
340
+ gcsDestination: {
341
+ uri: "Test string",
342
+ uriPrefix: "Test string",
343
+ },
344
+ },
345
+ readTime: "Test string",
346
+ relationshipTypes: [
347
+ "Test string"
348
+ ],
349
+ });
350
+ /**
351
+ * Searches all IAM policies within the specified scope, such as a project, folder, or organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` permission on
352
+ * the desired scope, otherwise the request will be rejected.
353
+ */
354
+ await gapi.client.cloudasset.v1.searchAllIamPolicies({
355
+ assetTypes: "Test string",
356
+ orderBy: "Test string",
357
+ pageSize: 42,
358
+ pageToken: "Test string",
359
+ query: "Test string",
360
+ scope: "Test string",
361
+ });
362
+ /**
363
+ * Searches all Cloud resources within the specified scope, such as a project, folder, or organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission on
364
+ * the desired scope, otherwise the request will be rejected.
365
+ */
366
+ await gapi.client.cloudasset.v1.searchAllResources({
367
+ assetTypes: "Test string",
368
+ orderBy: "Test string",
369
+ pageSize: 42,
370
+ pageToken: "Test string",
371
+ query: "Test string",
372
+ readMask: "Test string",
373
+ scope: "Test string",
374
+ });
375
+ }
376
+ });
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
+ }