Skip to content

Commit

Permalink
feat: Add SavedQuery CURD support (#627)
Browse files Browse the repository at this point in the history
* feat: Add SavedQuery CURD support
feat: Add tags support
feat!:*Add RelatedAsset and deprecate RelatedAssets for relationship GA

*The previous representation of the relationship feature is deprecated and unimplemented. The RelatedAsset message represents the new stable format.

PiperOrigin-RevId: 449306805

Source-Link: googleapis/googleapis@3d7bd9d

Source-Link: https://github.com/googleapis/googleapis-gen/commit/71a93d05d6076271d04b7592f7fad0d3f0c7a040
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzFhOTNkMDVkNjA3NjI3MWQwNGI3NTkyZjdmYWQwZDNmMGM3YTA0MCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed May 18, 2022
1 parent ada7aca commit ca22baa
Show file tree
Hide file tree
Showing 15 changed files with 805 additions and 58 deletions.
19 changes: 18 additions & 1 deletion asset/snippets/generated/v1/asset_service.analyze_iam_policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,24 @@ function main(analysisQuery) {
*/
// const analysisQuery = {}
/**
* Optional. Amount of time executable has to complete. See JSON representation of
* Optional. The name of a saved query, which must be in the format of:
* * projects/project_number/savedQueries/saved_query_id
* * folders/folder_number/savedQueries/saved_query_id
* * organizations/organization_number/savedQueries/saved_query_id
* If both `analysis_query` and `saved_analysis_query` are provided, they
* will be merged together with the `saved_analysis_query` as base and
* the `analysis_query` as overrides. For more details of the merge behavior,
* please refer to the
* MergeFrom (https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message#Message.MergeFrom.details)
* page.
* Note that you cannot override primitive fields with default value, such as
* 0 or empty string, etc., because we use proto3, which doesn't support field
* presence yet.
*/
// const savedAnalysisQuery = 'abc123'
/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,24 @@ function main(analysisQuery, outputConfig) {
*/
// const analysisQuery = {}
/**
* Required. Output configuration indicating where the results will be output to.
* Optional. The name of a saved query, which must be in the format of:
* * projects/project_number/savedQueries/saved_query_id
* * folders/folder_number/savedQueries/saved_query_id
* * organizations/organization_number/savedQueries/saved_query_id
* If both `analysis_query` and `saved_analysis_query` are provided, they
* will be merged together with the `saved_analysis_query` as base and
* the `analysis_query` as overrides. For more details of the merge behavior,
* please refer to the
* MergeFrom (https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message#Message.MergeFrom.details)
* doc.
* Note that you cannot override primitive fields with default value, such as
* 0 or empty string, etc., because we use proto3, which doesn't support field
* presence yet.
*/
// const savedAnalysisQuery = 'abc123'
/**
* Required. Output configuration indicating where the results will be output
* to.
*/
// const outputConfig = {}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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(scope, names) {
// [START cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Only IAM policies on or below the scope will be returned.
* This 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").
* To know how to get organization id, visit here
* (https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
* To know how to get folder or project id, visit here
* (https://cloud.google.com/resource-manager/docs/creating-managing-folders#viewing_or_listing_folders_and_projects).
*/
// const scope = 'abc123'
/**
* Required. The names refer to the full_resource_names
* (https://cloud.google.com/asset-inventory/docs/resource-name-format)
* of searchable asset
* types (https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types).
* A maximum of 20 resources' effective policies can be retrieved in a batch.
*/
// const names = 'abc123'

// Imports the Asset library
const {AssetServiceClient} = require('@google-cloud/asset').v1;

// Instantiates a client
const assetClient = new AssetServiceClient();

async function callBatchGetEffectiveIamPolicies() {
// Construct request
const request = {
scope,
names,
};

// Run request
const response = await assetClient.batchGetEffectiveIamPolicies(request);
console.log(response);
}

callBatchGetEffectiveIamPolicies();
// [END cloudasset_v1_generated_AssetService_BatchGetEffectiveIamPolicies_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
5 changes: 2 additions & 3 deletions asset/snippets/generated/v1/asset_service.create_feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ function main(parent, feedId, feed) {
*/
// 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
* 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
*/
Expand Down
79 changes: 79 additions & 0 deletions asset/snippets/generated/v1/asset_service.create_saved_query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// 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, savedQuery, savedQueryId) {
// [START cloudasset_v1_generated_AssetService_CreateSavedQuery_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the project/folder/organization where this
* saved_query 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. The saved_query details. The `name` field must be empty as it
* will be generated based on the parent and saved_query_id.
*/
// const savedQuery = {}
/**
* Required. The ID to use for the saved query, which must be unique in the
* specified parent. It will become the final component of the saved query's
* resource name.
* This value should be 4-63 characters, and valid characters
* are /[a-z][0-9]-/.
* Notice that this field is required in the saved query creation, and the
* `name` field of the `saved_query` will be ignored.
*/
// const savedQueryId = 'abc123'

// Imports the Asset library
const {AssetServiceClient} = require('@google-cloud/asset').v1;

// Instantiates a client
const assetClient = new AssetServiceClient();

async function callCreateSavedQuery() {
// Construct request
const request = {
parent,
savedQuery,
savedQueryId,
};

// Run request
const response = await assetClient.createSavedQuery(request);
console.log(response);
}

callCreateSavedQuery();
// [END cloudasset_v1_generated_AssetService_CreateSavedQuery_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
62 changes: 62 additions & 0 deletions asset/snippets/generated/v1/asset_service.delete_saved_query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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(name) {
// [START cloudasset_v1_generated_AssetService_DeleteSavedQuery_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the saved query to delete. It must be in the format
* of:
* * projects/project_number/savedQueries/saved_query_id
* * folders/folder_number/savedQueries/saved_query_id
* * organizations/organization_number/savedQueries/saved_query_id
*/
// const name = 'abc123'

// Imports the Asset library
const {AssetServiceClient} = require('@google-cloud/asset').v1;

// Instantiates a client
const assetClient = new AssetServiceClient();

async function callDeleteSavedQuery() {
// Construct request
const request = {
name,
};

// Run request
const response = await assetClient.deleteSavedQuery(request);
console.log(response);
}

callDeleteSavedQuery();
// [END cloudasset_v1_generated_AssetService_DeleteSavedQuery_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
3 changes: 2 additions & 1 deletion asset/snippets/generated/v1/asset_service.export_assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ function main(parent, outputConfig) {
*/
// const contentType = {}
/**
* Required. Output configuration indicating where the results will be output to.
* Required. Output configuration indicating where the results will be output
* to.
*/
// const outputConfig = {}
/**
Expand Down
61 changes: 61 additions & 0 deletions asset/snippets/generated/v1/asset_service.get_saved_query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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(name) {
// [START cloudasset_v1_generated_AssetService_GetSavedQuery_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the saved query and it must be in the format of:
* * projects/project_number/savedQueries/saved_query_id
* * folders/folder_number/savedQueries/saved_query_id
* * organizations/organization_number/savedQueries/saved_query_id
*/
// const name = 'abc123'

// Imports the Asset library
const {AssetServiceClient} = require('@google-cloud/asset').v1;

// Instantiates a client
const assetClient = new AssetServiceClient();

async function callGetSavedQuery() {
// Construct request
const request = {
name,
};

// Run request
const response = await assetClient.getSavedQuery(request);
console.log(response);
}

callGetSavedQuery();
// [END cloudasset_v1_generated_AssetService_GetSavedQuery_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
9 changes: 5 additions & 4 deletions asset/snippets/generated/v1/asset_service.list_assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ function main(parent) {
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Name of the organization or project the assets belong to. Format:
* "organizations/[organization-number]" (such as "organizations/123"),
* "projects/[project-id]" (such as "projects/my-project-id"), or
* "projects/[project-number]" (such as "projects/12345").
* Required. Name of the organization, folder, or project the assets belong
* to. Format: "organizations/[organization-number]" (such as
* "organizations/123"), "projects/[project-id]" (such as
* "projects/my-project-id"), "projects/[project-number]" (such as
* "projects/12345"), or "folders/[folder-number]" (such as "folders/12345").
*/
// const parent = 'abc123'
/**
Expand Down
Loading

0 comments on commit ca22baa

Please sign in to comment.