1// Copyright 2022 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
15syntax = "proto3";
16
17package google.cloud.asset.v1p5beta1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/cloud/asset/v1p5beta1/assets.proto";
24import "google/protobuf/timestamp.proto";
25
26option csharp_namespace = "Google.Cloud.Asset.V1P5Beta1";
27option go_package = "cloud.google.com/go/asset/apiv1p5beta1/assetpb;assetpb";
28option java_multiple_files = true;
29option java_outer_classname = "AssetServiceProto";
30option java_package = "com.google.cloud.asset.v1p5beta1";
31option php_namespace = "Google\\Cloud\\Asset\\V1p5beta1";
32
33// Asset service definition.
34service AssetService {
35  option (google.api.default_host) = "cloudasset.googleapis.com";
36  option (google.api.oauth_scopes) =
37      "https://www.googleapis.com/auth/cloud-platform";
38
39  // Lists assets with time and resource types and returns paged results in
40  // response.
41  rpc ListAssets(ListAssetsRequest) returns (ListAssetsResponse) {
42    option (google.api.http) = {
43      get: "/v1p5beta1/{parent=*/*}/assets"
44    };
45    option (google.api.method_signature) = "parent";
46  }
47}
48
49// ListAssets request.
50message ListAssetsRequest {
51  // Required. Name of the organization or project the assets belong to. Format:
52  // "organizations/[organization-number]" (such as "organizations/123"),
53  // "projects/[project-id]" (such as "projects/my-project-id"), or
54  // "projects/[project-number]" (such as "projects/12345").
55  string parent = 1 [
56    (google.api.field_behavior) = REQUIRED,
57    (google.api.resource_reference) = {
58      child_type: "cloudasset.googleapis.com/Asset"
59    }
60  ];
61
62  // Timestamp to take an asset snapshot. This can only be set to a timestamp
63  // between the current time and the current time minus 35 days (inclusive).
64  // If not specified, the current time will be used. Due to delays in resource
65  // data collection and indexing, there is a volatile window during which
66  // running the same query may get different results.
67  google.protobuf.Timestamp read_time = 2;
68
69  // A list of asset types to take a snapshot for. For example:
70  // "compute.googleapis.com/Disk".
71  //
72  // Regular expression is also supported. For example:
73  //
74  // * "compute.googleapis.com.*" snapshots resources whose asset type starts
75  // with "compute.googleapis.com".
76  // * ".*Instance" snapshots resources whose asset type ends with "Instance".
77  // * ".*Instance.*" snapshots resources whose asset type contains "Instance".
78  //
79  // See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported
80  // regular expression syntax. If the regular expression does not match any
81  // supported asset type, an INVALID_ARGUMENT error will be returned.
82  //
83  // If specified, only matching assets will be returned, otherwise, it will
84  // snapshot all asset types. See [Introduction to Cloud Asset
85  // Inventory](https://cloud.google.com/asset-inventory/docs/overview)
86  // for all supported asset types.
87  repeated string asset_types = 3;
88
89  // Asset content type. If not specified, no content but the asset name will
90  // be returned.
91  ContentType content_type = 4;
92
93  // The maximum number of assets to be returned in a single response. Default
94  // is 100, minimum is 1, and maximum is 1000.
95  int32 page_size = 5;
96
97  // The `next_page_token` returned from the previous `ListAssetsResponse`, or
98  // unspecified for the first `ListAssetsRequest`. It is a continuation of a
99  // prior `ListAssets` call, and the API should return the next page of assets.
100  string page_token = 6;
101}
102
103// ListAssets response.
104message ListAssetsResponse {
105  // Time the snapshot was taken.
106  google.protobuf.Timestamp read_time = 1;
107
108  // Assets.
109  repeated Asset assets = 2;
110
111  // Token to retrieve the next page of results. It expires 72 hours after the
112  // page token for the first page is generated. Set to empty if there are no
113  // remaining results.
114  string next_page_token = 3;
115}
116
117// Asset content type.
118enum ContentType {
119  // Unspecified content type.
120  CONTENT_TYPE_UNSPECIFIED = 0;
121
122  // Resource metadata.
123  RESOURCE = 1;
124
125  // The actual IAM policy set on a resource.
126  IAM_POLICY = 2;
127
128  // The organization policy set on an asset.
129  ORG_POLICY = 4;
130
131  // The Access Context Manager policy set on an asset.
132  ACCESS_POLICY = 5;
133}
134