-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(samples): add auto-generated samples for Node with api short nam…
…e 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
- Loading branch information
1 parent
522981e
commit acad1b6
Showing
27 changed files
with
1,838 additions
and
13 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
packages/google-cloud-asset/samples/generated/v1/asset_service.analyze_iam_policy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2021 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 | ||
// | ||
// http://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. | ||
|
||
'use strict'; | ||
|
||
function main(analysisQuery) { | ||
// [START cloudasset_v1_generated_AssetService_AnalyzeIamPolicy_async] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
/** | ||
* Required. The request query. | ||
*/ | ||
// const analysisQuery = '' | ||
/** | ||
* Optional. Amount of time executable has to complete. See JSON representation of | ||
* [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json). | ||
* If this field is set with a value less than the RPC deadline, and the | ||
* execution of your query hasn't finished in the specified | ||
* execution timeout, you will get a response with partial result. | ||
* Otherwise, your query's execution will continue until the RPC deadline. | ||
* If it's not finished until then, you will get a DEADLINE_EXCEEDED error. | ||
* Default is empty. | ||
*/ | ||
// const executionTimeout = '' | ||
|
||
// Imports the Asset library | ||
const {AssetServiceClient} = require('@google-cloud/asset').v1; | ||
|
||
// Instantiates a client | ||
const assetClient = new AssetServiceClient(); | ||
|
||
async function analyzeIamPolicy() { | ||
// Construct request | ||
const request = { | ||
analysisQuery, | ||
}; | ||
|
||
// Run request | ||
const response = await assetClient.analyzeIamPolicy(request); | ||
console.log(response); | ||
} | ||
|
||
analyzeIamPolicy(); | ||
// [END cloudasset_v1_generated_AssetService_AnalyzeIamPolicy_async] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
58 changes: 58 additions & 0 deletions
58
...s/google-cloud-asset/samples/generated/v1/asset_service.analyze_iam_policy_longrunning.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2021 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 | ||
// | ||
// http://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. | ||
|
||
'use strict'; | ||
|
||
function main(analysisQuery, outputConfig) { | ||
// [START cloudasset_v1_generated_AssetService_AnalyzeIamPolicyLongrunning_async] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
/** | ||
* Required. The request query. | ||
*/ | ||
// const analysisQuery = '' | ||
/** | ||
* Required. Output configuration indicating where the results will be output to. | ||
*/ | ||
// const outputConfig = '' | ||
|
||
// Imports the Asset library | ||
const {AssetServiceClient} = require('@google-cloud/asset').v1; | ||
|
||
// Instantiates a client | ||
const assetClient = new AssetServiceClient(); | ||
|
||
async function analyzeIamPolicyLongrunning() { | ||
// Construct request | ||
const request = { | ||
analysisQuery, | ||
outputConfig, | ||
}; | ||
|
||
// Run request | ||
const [operation] = await assetClient.analyzeIamPolicyLongrunning(request); | ||
const [response] = await operation.promise(); | ||
console.log(response); | ||
} | ||
|
||
analyzeIamPolicyLongrunning(); | ||
// [END cloudasset_v1_generated_AssetService_AnalyzeIamPolicyLongrunning_async] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
69 changes: 69 additions & 0 deletions
69
packages/google-cloud-asset/samples/generated/v1/asset_service.analyze_move.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2021 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 | ||
// | ||
// http://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. | ||
|
||
'use strict'; | ||
|
||
function main(resource, destinationParent) { | ||
// [START cloudasset_v1_generated_AssetService_AnalyzeMove_async] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
/** | ||
* Required. Name of the resource to perform the analysis against. | ||
* Only GCP Project are supported as of today. Hence, this can only be Project | ||
* ID (such as "projects/my-project-id") or a Project Number (such as | ||
* "projects/12345"). | ||
*/ | ||
// const resource = 'abc123' | ||
/** | ||
* Required. Name of the GCP Folder or Organization to reparent the target | ||
* resource. The analysis will be performed against hypothetically moving the | ||
* resource to this specified desitination parent. This can only be a Folder | ||
* number (such as "folders/123") or an Organization number (such as | ||
* "organizations/123"). | ||
*/ | ||
// const destinationParent = 'abc123' | ||
/** | ||
* Analysis view indicating what information should be included in the | ||
* analysis response. If unspecified, the default view is FULL. | ||
*/ | ||
// const view = '' | ||
|
||
// Imports the Asset library | ||
const {AssetServiceClient} = require('@google-cloud/asset').v1; | ||
|
||
// Instantiates a client | ||
const assetClient = new AssetServiceClient(); | ||
|
||
async function analyzeMove() { | ||
// Construct request | ||
const request = { | ||
resource, | ||
destinationParent, | ||
}; | ||
|
||
// Run request | ||
const response = await assetClient.analyzeMove(request); | ||
console.log(response); | ||
} | ||
|
||
analyzeMove(); | ||
// [END cloudasset_v1_generated_AssetService_AnalyzeMove_async] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
95 changes: 95 additions & 0 deletions
95
packages/google-cloud-asset/samples/generated/v1/asset_service.batch_get_assets_history.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright 2021 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 | ||
// | ||
// http://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. | ||
|
||
'use strict'; | ||
|
||
function main(parent) { | ||
// [START cloudasset_v1_generated_AssetService_BatchGetAssetsHistory_async] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
/** | ||
* Required. The relative name of the root asset. It 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"). | ||
*/ | ||
// const parent = 'abc123' | ||
/** | ||
* A list of the full names of the assets. | ||
* See: https://cloud.google.com/asset-inventory/docs/resource-name-format | ||
* Example: | ||
* `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`. | ||
* The request becomes a no-op if the asset name list is empty, and the max | ||
* size of the asset name list is 100 in one request. | ||
*/ | ||
// const assetNames = 'abc123' | ||
/** | ||
* Optional. The content type. | ||
*/ | ||
// const contentType = '' | ||
/** | ||
* Optional. The time window for the asset history. Both start_time and | ||
* end_time are optional and if set, it must be after the current time minus | ||
* 35 days. If end_time is not set, it is default to current timestamp. | ||
* If start_time is not set, the snapshot of the assets at end_time will be | ||
* returned. The returned results contain all temporal assets whose time | ||
* window overlap with read_time_window. | ||
*/ | ||
// const readTimeWindow = '' | ||
/** | ||
* Optional. A list of relationship types to output, for example: | ||
* `INSTANCE_TO_INSTANCEGROUP`. This field should only be specified if | ||
* content_type=RELATIONSHIP. | ||
* * If specified: | ||
* it outputs specified relationships' history on the [asset_names]. It | ||
* returns an error if any of the [relationship_types] doesn't belong to the | ||
* supported relationship types of the [asset_names] or if any of the | ||
* [asset_names]'s types doesn't belong to the source types of the | ||
* [relationship_types]. | ||
* * Otherwise: | ||
* it outputs the supported relationships' history on the [asset_names] or | ||
* returns an error if any of the [asset_names]'s types has no relationship | ||
* support. | ||
* See [Introduction to Cloud Asset | ||
* Inventory](https://cloud.google.com/asset-inventory/docs/overview) for all | ||
* supported asset types and relationship types. | ||
*/ | ||
// const relationshipTypes = 'abc123' | ||
|
||
// Imports the Asset library | ||
const {AssetServiceClient} = require('@google-cloud/asset').v1; | ||
|
||
// Instantiates a client | ||
const assetClient = new AssetServiceClient(); | ||
|
||
async function batchGetAssetsHistory() { | ||
// Construct request | ||
const request = { | ||
parent, | ||
}; | ||
|
||
// Run request | ||
const response = await assetClient.batchGetAssetsHistory(request); | ||
console.log(response); | ||
} | ||
|
||
batchGetAssetsHistory(); | ||
// [END cloudasset_v1_generated_AssetService_BatchGetAssetsHistory_async] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
71 changes: 71 additions & 0 deletions
71
packages/google-cloud-asset/samples/generated/v1/asset_service.create_feed.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2021 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 | ||
// | ||
// http://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. | ||
|
||
'use strict'; | ||
|
||
function main(parent, feedId, feed) { | ||
// [START cloudasset_v1_generated_AssetService_CreateFeed_async] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
/** | ||
* Required. The name of the project/folder/organization where this feed | ||
* should be created in. It can only be an organization number (such as | ||
* "organizations/123"), a folder number (such as "folders/123"), a project ID | ||
* (such as "projects/my-project-id")", or a project number (such as | ||
* "projects/12345"). | ||
*/ | ||
// const parent = 'abc123' | ||
/** | ||
* Required. This is the client-assigned asset feed identifier and it needs to | ||
* be unique under a specific parent project/folder/organization. | ||
*/ | ||
// const feedId = 'abc123' | ||
/** | ||
* Required. The feed details. The field `name` must be empty and it will be generated | ||
* in the format of: | ||
* projects/project_number/feeds/feed_id | ||
* folders/folder_number/feeds/feed_id | ||
* organizations/organization_number/feeds/feed_id | ||
*/ | ||
// const feed = '' | ||
|
||
// Imports the Asset library | ||
const {AssetServiceClient} = require('@google-cloud/asset').v1; | ||
|
||
// Instantiates a client | ||
const assetClient = new AssetServiceClient(); | ||
|
||
async function createFeed() { | ||
// Construct request | ||
const request = { | ||
parent, | ||
feedId, | ||
feed, | ||
}; | ||
|
||
// Run request | ||
const response = await assetClient.createFeed(request); | ||
console.log(response); | ||
} | ||
|
||
createFeed(); | ||
// [END cloudasset_v1_generated_AssetService_CreateFeed_async] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
Oops, something went wrong.