Skip to content

Commit 8fc256d

Browse files
docs(samples): add auto-generated samples for Node with api short name in region tag (#562)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 399287285 Source-Link: googleapis/googleapis@1575986 Source-Link: googleapis/googleapis-gen@b27fff6 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjI3ZmZmNjIzYTVkOGQ1ODZiNzAzYjVlNDkxOTg1NmFiZTdjMmViMyJ9
1 parent 6577ce1 commit 8fc256d

27 files changed

+1838
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(analysisQuery) {
18+
// [START cloudasset_v1_generated_AssetService_AnalyzeIamPolicy_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The request query.
24+
*/
25+
// const analysisQuery = ''
26+
/**
27+
* Optional. Amount of time executable has to complete. See JSON representation of
28+
* [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json).
29+
* If this field is set with a value less than the RPC deadline, and the
30+
* execution of your query hasn't finished in the specified
31+
* execution timeout, you will get a response with partial result.
32+
* Otherwise, your query's execution will continue until the RPC deadline.
33+
* If it's not finished until then, you will get a DEADLINE_EXCEEDED error.
34+
* Default is empty.
35+
*/
36+
// const executionTimeout = ''
37+
38+
// Imports the Asset library
39+
const {AssetServiceClient} = require('@google-cloud/asset').v1;
40+
41+
// Instantiates a client
42+
const assetClient = new AssetServiceClient();
43+
44+
async function analyzeIamPolicy() {
45+
// Construct request
46+
const request = {
47+
analysisQuery,
48+
};
49+
50+
// Run request
51+
const response = await assetClient.analyzeIamPolicy(request);
52+
console.log(response);
53+
}
54+
55+
analyzeIamPolicy();
56+
// [END cloudasset_v1_generated_AssetService_AnalyzeIamPolicy_async]
57+
}
58+
59+
process.on('unhandledRejection', err => {
60+
console.error(err.message);
61+
process.exitCode = 1;
62+
});
63+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(analysisQuery, outputConfig) {
18+
// [START cloudasset_v1_generated_AssetService_AnalyzeIamPolicyLongrunning_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The request query.
24+
*/
25+
// const analysisQuery = ''
26+
/**
27+
* Required. Output configuration indicating where the results will be output to.
28+
*/
29+
// const outputConfig = ''
30+
31+
// Imports the Asset library
32+
const {AssetServiceClient} = require('@google-cloud/asset').v1;
33+
34+
// Instantiates a client
35+
const assetClient = new AssetServiceClient();
36+
37+
async function analyzeIamPolicyLongrunning() {
38+
// Construct request
39+
const request = {
40+
analysisQuery,
41+
outputConfig,
42+
};
43+
44+
// Run request
45+
const [operation] = await assetClient.analyzeIamPolicyLongrunning(request);
46+
const [response] = await operation.promise();
47+
console.log(response);
48+
}
49+
50+
analyzeIamPolicyLongrunning();
51+
// [END cloudasset_v1_generated_AssetService_AnalyzeIamPolicyLongrunning_async]
52+
}
53+
54+
process.on('unhandledRejection', err => {
55+
console.error(err.message);
56+
process.exitCode = 1;
57+
});
58+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(resource, destinationParent) {
18+
// [START cloudasset_v1_generated_AssetService_AnalyzeMove_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. Name of the resource to perform the analysis against.
24+
* Only GCP Project are supported as of today. Hence, this can only be Project
25+
* ID (such as "projects/my-project-id") or a Project Number (such as
26+
* "projects/12345").
27+
*/
28+
// const resource = 'abc123'
29+
/**
30+
* Required. Name of the GCP Folder or Organization to reparent the target
31+
* resource. The analysis will be performed against hypothetically moving the
32+
* resource to this specified desitination parent. This can only be a Folder
33+
* number (such as "folders/123") or an Organization number (such as
34+
* "organizations/123").
35+
*/
36+
// const destinationParent = 'abc123'
37+
/**
38+
* Analysis view indicating what information should be included in the
39+
* analysis response. If unspecified, the default view is FULL.
40+
*/
41+
// const view = ''
42+
43+
// Imports the Asset library
44+
const {AssetServiceClient} = require('@google-cloud/asset').v1;
45+
46+
// Instantiates a client
47+
const assetClient = new AssetServiceClient();
48+
49+
async function analyzeMove() {
50+
// Construct request
51+
const request = {
52+
resource,
53+
destinationParent,
54+
};
55+
56+
// Run request
57+
const response = await assetClient.analyzeMove(request);
58+
console.log(response);
59+
}
60+
61+
analyzeMove();
62+
// [END cloudasset_v1_generated_AssetService_AnalyzeMove_async]
63+
}
64+
65+
process.on('unhandledRejection', err => {
66+
console.error(err.message);
67+
process.exitCode = 1;
68+
});
69+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent) {
18+
// [START cloudasset_v1_generated_AssetService_BatchGetAssetsHistory_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The relative name of the root asset. It can only be an
24+
* organization number (such as "organizations/123"), a project ID (such as
25+
* "projects/my-project-id")", or a project number (such as "projects/12345").
26+
*/
27+
// const parent = 'abc123'
28+
/**
29+
* A list of the full names of the assets.
30+
* See: https://cloud.google.com/asset-inventory/docs/resource-name-format
31+
* Example:
32+
* `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`.
33+
* The request becomes a no-op if the asset name list is empty, and the max
34+
* size of the asset name list is 100 in one request.
35+
*/
36+
// const assetNames = 'abc123'
37+
/**
38+
* Optional. The content type.
39+
*/
40+
// const contentType = ''
41+
/**
42+
* Optional. The time window for the asset history. Both start_time and
43+
* end_time are optional and if set, it must be after the current time minus
44+
* 35 days. If end_time is not set, it is default to current timestamp.
45+
* If start_time is not set, the snapshot of the assets at end_time will be
46+
* returned. The returned results contain all temporal assets whose time
47+
* window overlap with read_time_window.
48+
*/
49+
// const readTimeWindow = ''
50+
/**
51+
* Optional. A list of relationship types to output, for example:
52+
* `INSTANCE_TO_INSTANCEGROUP`. This field should only be specified if
53+
* content_type=RELATIONSHIP.
54+
* * If specified:
55+
* it outputs specified relationships' history on the [asset_names]. It
56+
* returns an error if any of the [relationship_types] doesn't belong to the
57+
* supported relationship types of the [asset_names] or if any of the
58+
* [asset_names]'s types doesn't belong to the source types of the
59+
* [relationship_types].
60+
* * Otherwise:
61+
* it outputs the supported relationships' history on the [asset_names] or
62+
* returns an error if any of the [asset_names]'s types has no relationship
63+
* support.
64+
* See [Introduction to Cloud Asset
65+
* Inventory](https://cloud.google.com/asset-inventory/docs/overview) for all
66+
* supported asset types and relationship types.
67+
*/
68+
// const relationshipTypes = 'abc123'
69+
70+
// Imports the Asset library
71+
const {AssetServiceClient} = require('@google-cloud/asset').v1;
72+
73+
// Instantiates a client
74+
const assetClient = new AssetServiceClient();
75+
76+
async function batchGetAssetsHistory() {
77+
// Construct request
78+
const request = {
79+
parent,
80+
};
81+
82+
// Run request
83+
const response = await assetClient.batchGetAssetsHistory(request);
84+
console.log(response);
85+
}
86+
87+
batchGetAssetsHistory();
88+
// [END cloudasset_v1_generated_AssetService_BatchGetAssetsHistory_async]
89+
}
90+
91+
process.on('unhandledRejection', err => {
92+
console.error(err.message);
93+
process.exitCode = 1;
94+
});
95+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, feedId, feed) {
18+
// [START cloudasset_v1_generated_AssetService_CreateFeed_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The name of the project/folder/organization where this feed
24+
* should be created in. It can only be an organization number (such as
25+
* "organizations/123"), a folder number (such as "folders/123"), a project ID
26+
* (such as "projects/my-project-id")", or a project number (such as
27+
* "projects/12345").
28+
*/
29+
// const parent = 'abc123'
30+
/**
31+
* Required. This is the client-assigned asset feed identifier and it needs to
32+
* be unique under a specific parent project/folder/organization.
33+
*/
34+
// const feedId = 'abc123'
35+
/**
36+
* Required. The feed details. The field `name` must be empty and it will be generated
37+
* in the format of:
38+
* projects/project_number/feeds/feed_id
39+
* folders/folder_number/feeds/feed_id
40+
* organizations/organization_number/feeds/feed_id
41+
*/
42+
// const feed = ''
43+
44+
// Imports the Asset library
45+
const {AssetServiceClient} = require('@google-cloud/asset').v1;
46+
47+
// Instantiates a client
48+
const assetClient = new AssetServiceClient();
49+
50+
async function createFeed() {
51+
// Construct request
52+
const request = {
53+
parent,
54+
feedId,
55+
feed,
56+
};
57+
58+
// Run request
59+
const response = await assetClient.createFeed(request);
60+
console.log(response);
61+
}
62+
63+
createFeed();
64+
// [END cloudasset_v1_generated_AssetService_CreateFeed_async]
65+
}
66+
67+
process.on('unhandledRejection', err => {
68+
console.error(err.message);
69+
process.exitCode = 1;
70+
});
71+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)