Skip to content

Commit 6c543a7

Browse files
fix: failing tests for LRO check methods (#530)
feat!: *Change metadata field for the AnalyzeIamPolicyLongrunning. feat: Add AnalyzeMove API. feat: Add read_mask field for SearchAllResourcesRequest feat:Add VersionedResource/AttachedResource fields for ResourceSearchResult Committer: @alexander-fenster PiperOrigin-RevId: 387841814 PiperOrigin-RevId: 387216202 PiperOrigin-RevId: 386530026
1 parent c734d05 commit 6c543a7

11 files changed

+4517
-550
lines changed

packages/google-cloud-asset/protos/google/cloud/asset/v1/asset_service.proto

+135-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import "google/protobuf/empty.proto";
2727
import "google/protobuf/field_mask.proto";
2828
import "google/protobuf/struct.proto";
2929
import "google/protobuf/timestamp.proto";
30+
import "google/rpc/status.proto";
3031
import "google/type/expr.proto";
3132

3233
option csharp_namespace = "Google.Cloud.Asset.V1";
@@ -165,17 +166,36 @@ service AssetService {
165166
// [google.longrunning.Operation][google.longrunning.Operation], which allows you to track the operation
166167
// status. We recommend intervals of at least 2 seconds with exponential
167168
// backoff retry to poll the operation result. The metadata contains the
168-
// request to help callers to map responses to requests.
169+
// metadata for the long-running operation.
169170
rpc AnalyzeIamPolicyLongrunning(AnalyzeIamPolicyLongrunningRequest) returns (google.longrunning.Operation) {
170171
option (google.api.http) = {
171172
post: "/v1/{analysis_query.scope=*/*}:analyzeIamPolicyLongrunning"
172173
body: "*"
173174
};
174175
option (google.longrunning.operation_info) = {
175176
response_type: "google.cloud.asset.v1.AnalyzeIamPolicyLongrunningResponse"
176-
metadata_type: "google.cloud.asset.v1.AnalyzeIamPolicyLongrunningRequest"
177+
metadata_type: "google.cloud.asset.v1.AnalyzeIamPolicyLongrunningMetadata"
177178
};
178179
}
180+
181+
// Analyze moving a resource to a specified destination without kicking off
182+
// the actual move. The analysis is best effort depending on the user's
183+
// permissions of viewing different hierarchical policies and configurations.
184+
// The policies and configuration are subject to change before the actual
185+
// resource migration takes place.
186+
rpc AnalyzeMove(AnalyzeMoveRequest) returns (AnalyzeMoveResponse) {
187+
option (google.api.http) = {
188+
get: "/v1/{resource=*/*}:analyzeMove"
189+
};
190+
}
191+
}
192+
193+
// Represents the metadata of the longrunning operation for the
194+
// AnalyzeIamPolicyLongrunning rpc.
195+
message AnalyzeIamPolicyLongrunningMetadata {
196+
// The time the operation was created.
197+
google.protobuf.Timestamp create_time = 1
198+
[(google.api.field_behavior) = OUTPUT_ONLY];
179199
}
180200

181201
// Export asset request.
@@ -659,7 +679,7 @@ message Feed {
659679
// optional.
660680
//
661681
// See our [user
662-
// guide](https://cloud.google.com/asset-inventory/docs/monitoring-asset-changes#feed_with_condition)
682+
// guide](https://cloud.google.com/asset-inventory/docs/monitoring-asset-changes-with-condition)
663683
// for detailed instructions.
664684
google.type.Expr condition = 6;
665685
}
@@ -703,8 +723,8 @@ message SearchAllResourcesRequest {
703723
// encryption key whose name contains the word "key".
704724
// * `state:ACTIVE` to find Cloud resources whose state contains "ACTIVE" as a
705725
// word.
706-
// * `NOT state:ACTIVE` to find {{gcp_name}} resources whose state
707-
// doesn't contain "ACTIVE" as a word.
726+
// * `NOT state:ACTIVE` to find Cloud resources whose state doesn't contain
727+
// "ACTIVE" as a word.
708728
// * `createTime<1609459200` to find Cloud resources that were created before
709729
// "2021-01-01 00:00:00 UTC". 1609459200 is the epoch timestamp of
710730
// "2021-01-01 00:00:00 UTC" in seconds.
@@ -754,6 +774,7 @@ message SearchAllResourcesRequest {
754774
// to indicate descending order. Redundant space characters are ignored.
755775
// Example: "location DESC, name".
756776
// Only singular primitive fields in the response are sortable:
777+
//
757778
// * name
758779
// * assetType
759780
// * project
@@ -766,10 +787,41 @@ message SearchAllResourcesRequest {
766787
// * state
767788
// * parentFullResourceName
768789
// * parentAssetType
790+
//
769791
// All the other fields such as repeated fields (e.g., `networkTags`), map
770792
// fields (e.g., `labels`) and struct fields (e.g., `additionalAttributes`)
771793
// are not supported.
772794
string order_by = 6 [(google.api.field_behavior) = OPTIONAL];
795+
796+
// Optional. A comma-separated list of fields specifying which fields to be returned in
797+
// ResourceSearchResult. Only '*' or combination of top level fields can be
798+
// specified. Field names of both snake_case and camelCase are supported.
799+
// Examples: `"*"`, `"name,location"`, `"name,versionedResources"`.
800+
//
801+
// The read_mask paths must be valid field paths listed but not limited to
802+
// (both snake_case and camelCase are supported):
803+
//
804+
// * name
805+
// * assetType
806+
// * project
807+
// * displayName
808+
// * description
809+
// * location
810+
// * labels
811+
// * networkTags
812+
// * kmsKey
813+
// * createTime
814+
// * updateTime
815+
// * state
816+
// * additionalAttributes
817+
// * versionedResources
818+
//
819+
// If read_mask is not specified, all fields except versionedResources will
820+
// be returned.
821+
// If only '*' is specified, all fields including versionedResources will be
822+
// returned.
823+
// Any invalid field path will trigger INVALID_ARGUMENT error.
824+
google.protobuf.FieldMask read_mask = 8 [(google.api.field_behavior) = OPTIONAL];
773825
}
774826

775827
// Search all resources response.
@@ -1203,7 +1255,84 @@ message AnalyzeIamPolicyLongrunningRequest {
12031255
}
12041256

12051257
// A response message for [AssetService.AnalyzeIamPolicyLongrunning][google.cloud.asset.v1.AssetService.AnalyzeIamPolicyLongrunning].
1206-
message AnalyzeIamPolicyLongrunningResponse {}
1258+
message AnalyzeIamPolicyLongrunningResponse {
1259+
1260+
}
1261+
1262+
// The request message for performing resource move analysis.
1263+
message AnalyzeMoveRequest {
1264+
// View enum for supporting partial analysis responses.
1265+
enum AnalysisView {
1266+
// The default/unset value.
1267+
// The API will default to the FULL view.
1268+
ANALYSIS_VIEW_UNSPECIFIED = 0;
1269+
1270+
// Full analysis including all level of impacts of the specified resource
1271+
// move.
1272+
FULL = 1;
1273+
1274+
// Basic analysis only including blockers which will prevent the specified
1275+
// resource move at runtime.
1276+
BASIC = 2;
1277+
}
1278+
1279+
// Required. Name of the resource to perform the analysis against.
1280+
// Only GCP Project are supported as of today. Hence, this can only be Project
1281+
// ID (such as "projects/my-project-id") or a Project Number (such as
1282+
// "projects/12345").
1283+
string resource = 1 [(google.api.field_behavior) = REQUIRED];
1284+
1285+
// Required. Name of the GCP Folder or Organization to reparent the target
1286+
// resource. The analysis will be performed against hypothetically moving the
1287+
// resource to this specified desitination parent. This can only be a Folder
1288+
// number (such as "folders/123") or an Organization number (such as
1289+
// "organizations/123").
1290+
string destination_parent = 2 [(google.api.field_behavior) = REQUIRED];
1291+
1292+
// Analysis view indicating what information should be included in the
1293+
// analysis response. If unspecified, the default view is FULL.
1294+
AnalysisView view = 3;
1295+
}
1296+
1297+
// The response message for resource move analysis.
1298+
message AnalyzeMoveResponse {
1299+
// The list of analyses returned from performing the intended resource move
1300+
// analysis. The analysis is grouped by different Cloud services.
1301+
repeated MoveAnalysis move_analysis = 1;
1302+
}
1303+
1304+
// A message to group the analysis information.
1305+
message MoveAnalysis {
1306+
// The user friendly display name of the analysis. E.g. IAM, Organization
1307+
// Policy etc.
1308+
string display_name = 1;
1309+
1310+
oneof result {
1311+
// Analysis result of moving the target resource.
1312+
MoveAnalysisResult analysis = 2;
1313+
1314+
// Description of error encountered when performing the analysis.
1315+
google.rpc.Status error = 3;
1316+
}
1317+
}
1318+
1319+
// An analysis result including blockers and warnings.
1320+
message MoveAnalysisResult {
1321+
// Blocking information that would prevent the target resource from moving
1322+
// to the specified destination at runtime.
1323+
repeated MoveImpact blockers = 1;
1324+
1325+
// Warning information indicating that moving the target resource to the
1326+
// specified destination might be unsafe. This can include important policy
1327+
// information and configuration changes, but will not block moves at runtime.
1328+
repeated MoveImpact warnings = 2;
1329+
}
1330+
1331+
// A message to group impacts of moving the target resource.
1332+
message MoveImpact {
1333+
// User friendly impact detail in a free form message.
1334+
string detail = 1;
1335+
}
12071336

12081337
// Asset content type.
12091338
enum ContentType {

packages/google-cloud-asset/protos/google/cloud/asset/v1/assets.proto

+62-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ import "google/identity/accesscontextmanager/v1/access_level.proto";
2323
import "google/identity/accesscontextmanager/v1/access_policy.proto";
2424
import "google/cloud/osconfig/v1/inventory.proto";
2525
import "google/identity/accesscontextmanager/v1/service_perimeter.proto";
26-
import "google/protobuf/any.proto";
2726
import "google/protobuf/struct.proto";
2827
import "google/protobuf/timestamp.proto";
2928
import "google/rpc/code.proto";
30-
import "google/api/annotations.proto";
3129

3230
option cc_enable_arenas = true;
3331
option csharp_namespace = "Google.Cloud.Asset.V1";
@@ -420,6 +418,24 @@ message ResourceSearchResult {
420418
// `project-name`
421419
string parent_full_resource_name = 19;
422420

421+
// Versioned resource representations of this resource. This is repeated
422+
// because there could be multiple versions of resource representations during
423+
// version migration.
424+
//
425+
// This `versioned_resources` field is not searchable. Some attributes of the
426+
// resource representations are exposed in `additional_attributes` field, so
427+
// as to allow users to search on them.
428+
repeated VersionedResource versioned_resources = 16;
429+
430+
// Attached resources of this resource. For example, an OSConfig
431+
// Inventory is an attached resource of a Compute Instance. This field is
432+
// repeated because a resource could have multiple attached resources.
433+
//
434+
// This `attached_resources` field is not searchable. Some attributes
435+
// of the attached resources are exposed in `additional_attributes` field, so
436+
// as to allow users to search on them.
437+
repeated AttachedResource attached_resources = 20;
438+
423439
// The type of this resource's immediate parent, if there is one.
424440
//
425441
// To search against the `parent_asset_type`:
@@ -431,6 +447,50 @@ message ResourceSearchResult {
431447
string parent_asset_type = 103;
432448
}
433449

450+
// Resource representation as defined by the corresponding service providing the
451+
// resource for a given API version.
452+
message VersionedResource {
453+
// API version of the resource.
454+
//
455+
// Example:
456+
// If the resource is an instance provided by Compute Engine v1 API as defined
457+
// in `https://cloud.google.com/compute/docs/reference/rest/v1/instances`,
458+
// version will be "v1".
459+
string version = 1;
460+
461+
// JSON representation of the resource as defined by the corresponding
462+
// service providing this resource.
463+
//
464+
// Example:
465+
// If the resource is an instance provided by Compute Engine, this field will
466+
// contain the JSON representation of the instance as defined by Compute
467+
// Engine:
468+
// `https://cloud.google.com/compute/docs/reference/rest/v1/instances`.
469+
//
470+
// You can find the resource definition for each supported resource type in
471+
// this table:
472+
// `https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types`
473+
google.protobuf.Struct resource = 2;
474+
}
475+
476+
// Attached resource representation, which is defined by the corresponding
477+
// service provider. It represents an attached resource's payload.
478+
message AttachedResource {
479+
// The type of this attached resource.
480+
//
481+
// Example: `osconfig.googleapis.com/Inventory`
482+
//
483+
// You can find the supported attached asset types of each resource in this
484+
// table:
485+
// `https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types`
486+
string asset_type = 1;
487+
488+
// Versioned resource representations of this attached resource. This is
489+
// repeated because there could be multiple versions of the attached resource
490+
// representations during version migration.
491+
repeated VersionedResource versioned_resources = 3;
492+
}
493+
434494
// A result of IAM Policy search, containing information of an IAM policy.
435495
message IamPolicySearchResult {
436496
// Explanation about the IAM policy search result.

0 commit comments

Comments
 (0)