-
Notifications
You must be signed in to change notification settings - Fork 592
/
asset_service.query_assets.js
121 lines (111 loc) · 4.58 KB
/
asset_service.query_assets.js
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
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(parent) {
// [START cloudasset_v1_generated_AssetService_QueryAssets_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The relative name of the root asset. This can only be an
* organization number (such as "organizations/123"), a project ID (such as
* "projects/my-project-id"), or a project number (such as "projects/12345"),
* or a folder number (such as "folders/123").
* Only assets belonging to the `parent` will be returned.
*/
// const parent = 'abc123'
/**
* Optional. A SQL statement that's compatible with BigQuery Standard
* SQL (http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql).
*/
// const statement = 'abc123'
/**
* Optional. Reference to the query job, which is from the `QueryAssetsResponse` of
* previous `QueryAssets` call.
*/
// const jobReference = 'abc123'
/**
* Optional. The maximum number of rows to return in the results. Responses are limited
* to 10 MB and 1000 rows.
* By default, the maximum row count is 1000. When the byte or row count limit
* is reached, the rest of the query results will be paginated.
* The field will be ignored when output_config is specified.
*/
// const pageSize = 1234
/**
* Optional. A page token received from previous `QueryAssets`.
* The field will be ignored when output_config is specified.
*/
// const pageToken = 'abc123'
/**
* Optional. Specifies the maximum amount of time that the client is willing to wait
* for the query to complete. By default, this limit is 5 min for the first
* query, and 1 minute for the following queries. If the query is complete,
* the `done` field in the `QueryAssetsResponse` is true, otherwise false.
* Like BigQuery jobs.query
* API (https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query#queryrequest)
* The call is not guaranteed to wait for the specified timeout; it typically
* returns after around 200 seconds (200,000 milliseconds), even if the query
* is not complete.
* The field will be ignored when output_config is specified.
*/
// const timeout = {}
/**
* Optional. start_time is required. start_time must be less than end_time
* Defaults end_time to now if start_time is set and end_time isn't.
* Maximum permitted time range is 7 days.
*/
// const readTimeWindow = {}
/**
* Optional. Queries cloud assets as they appeared at the specified point in time.
*/
// const readTime = {}
/**
* Optional. Destination where the query results will be saved.
* When this field is specified, the query results won't be saved in the
* QueryAssetsResponse.query_result. Instead
* QueryAssetsResponse.output_config will be set.
* Meanwhile, QueryAssetsResponse.job_reference will be set and can be used
* to check the status of the query job when passed to a following
* QueryAssets API call.
*/
// const outputConfig = {}
// Imports the Asset library
const {AssetServiceClient} = require('@google-cloud/asset').v1;
// Instantiates a client
const assetClient = new AssetServiceClient();
async function callQueryAssets() {
// Construct request
const request = {
parent,
};
// Run request
const response = await assetClient.queryAssets(request);
console.log(response);
}
callQueryAssets();
// [END cloudasset_v1_generated_AssetService_QueryAssets_async]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));