asset_service.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. syntax = "proto3";
  15. package google.cloud.asset.v1p7beta1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/cloud/asset/v1p7beta1/assets.proto";
  21. import "google/longrunning/operations.proto";
  22. import "google/protobuf/timestamp.proto";
  23. option csharp_namespace = "Google.Cloud.Asset.V1P7Beta1";
  24. option go_package = "google.golang.org/genproto/googleapis/cloud/asset/v1p7beta1;asset";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "AssetServiceProto";
  27. option java_package = "com.google.cloud.asset.v1p7beta1";
  28. option php_namespace = "Google\\Cloud\\Asset\\V1p7beta1";
  29. // Asset service definition.
  30. service AssetService {
  31. option (google.api.default_host) = "cloudasset.googleapis.com";
  32. option (google.api.oauth_scopes) =
  33. "https://www.googleapis.com/auth/cloud-platform";
  34. // Exports assets with time and resource types to a given Cloud Storage
  35. // location/BigQuery table. For Cloud Storage location destinations, the
  36. // output format is newline-delimited JSON. Each line represents a
  37. // [google.cloud.asset.v1p7beta1.Asset][google.cloud.asset.v1p7beta1.Asset] in
  38. // the JSON format; for BigQuery table destinations, the output table stores
  39. // the fields in asset proto as columns. This API implements the
  40. // [google.longrunning.Operation][google.longrunning.Operation] API , which
  41. // allows you to keep track of the export. We recommend intervals of at least
  42. // 2 seconds with exponential retry to poll the export operation result. For
  43. // regular-size resource parent, the export operation usually finishes within
  44. // 5 minutes.
  45. rpc ExportAssets(ExportAssetsRequest) returns (google.longrunning.Operation) {
  46. option (google.api.http) = {
  47. post: "/v1p7beta1/{parent=*/*}:exportAssets"
  48. body: "*"
  49. };
  50. option (google.longrunning.operation_info) = {
  51. response_type: "google.cloud.asset.v1p7beta1.ExportAssetsResponse"
  52. metadata_type: "google.cloud.asset.v1p7beta1.ExportAssetsRequest"
  53. };
  54. }
  55. }
  56. // Export asset request.
  57. message ExportAssetsRequest {
  58. // Required. The relative name of the root asset. This can only be an
  59. // organization number (such as "organizations/123"), a project ID (such as
  60. // "projects/my-project-id"), or a project number (such as "projects/12345"),
  61. // or a folder number (such as "folders/123").
  62. string parent = 1 [
  63. (google.api.field_behavior) = REQUIRED,
  64. (google.api.resource_reference) = {
  65. child_type: "cloudasset.googleapis.com/Asset"
  66. }
  67. ];
  68. // Timestamp to take an asset snapshot. This can only be set to a timestamp
  69. // between the current time and the current time minus 35 days (inclusive).
  70. // If not specified, the current time will be used. Due to delays in resource
  71. // data collection and indexing, there is a volatile window during which
  72. // running the same query may get different results.
  73. google.protobuf.Timestamp read_time = 2;
  74. // A list of asset types to take a snapshot for. For example:
  75. // "compute.googleapis.com/Disk".
  76. //
  77. // Regular expressions are also supported. For example:
  78. //
  79. // * "compute.googleapis.com.*" snapshots resources whose asset type starts
  80. // with "compute.googleapis.com".
  81. // * ".*Instance" snapshots resources whose asset type ends with "Instance".
  82. // * ".*Instance.*" snapshots resources whose asset type contains "Instance".
  83. //
  84. // See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported
  85. // regular expression syntax. If the regular expression does not match any
  86. // supported asset type, an INVALID_ARGUMENT error will be returned.
  87. //
  88. // If specified, only matching assets will be returned, otherwise, it will
  89. // snapshot all asset types. See [Introduction to Cloud Asset
  90. // Inventory](https://cloud.google.com/asset-inventory/docs/overview)
  91. // for all supported asset types.
  92. repeated string asset_types = 3;
  93. // Asset content type. If not specified, no content but the asset name will be
  94. // returned.
  95. ContentType content_type = 4;
  96. // Required. Output configuration indicating where the results will be output
  97. // to.
  98. OutputConfig output_config = 5 [(google.api.field_behavior) = REQUIRED];
  99. // A list of relationship types to export, for example:
  100. // `INSTANCE_TO_INSTANCEGROUP`. This field should only be specified if
  101. // content_type=RELATIONSHIP. If specified, it will snapshot [asset_types]'
  102. // specified relationships, or give errors if any relationship_types'
  103. // supported types are not in [asset_types]. If not specified, it will
  104. // snapshot all [asset_types]' supported relationships. An unspecified
  105. // [asset_types] field means all supported asset_types. See [Introduction to
  106. // Cloud Asset
  107. // Inventory](https://cloud.google.com/asset-inventory/docs/overview) for all
  108. // supported asset types and relationship types.
  109. repeated string relationship_types = 6;
  110. }
  111. // The export asset response. This message is returned by the
  112. // [google.longrunning.Operations.GetOperation][google.longrunning.Operations.GetOperation]
  113. // method in the returned
  114. // [google.longrunning.Operation.response][google.longrunning.Operation.response]
  115. // field.
  116. message ExportAssetsResponse {
  117. // Time the snapshot was taken.
  118. google.protobuf.Timestamp read_time = 1;
  119. // Output configuration indicating where the results were output to.
  120. OutputConfig output_config = 2;
  121. // Output result indicating where the assets were exported to. For example, a
  122. // set of actual Google Cloud Storage object uris where the assets are
  123. // exported to. The uris can be different from what [output_config] has
  124. // specified, as the service will split the output object into multiple ones
  125. // once it exceeds a single Google Cloud Storage object limit.
  126. OutputResult output_result = 3;
  127. }
  128. // Output configuration for export assets destination.
  129. message OutputConfig {
  130. // Asset export destination.
  131. oneof destination {
  132. // Destination on Cloud Storage.
  133. GcsDestination gcs_destination = 1;
  134. // Destination on BigQuery. The output table stores the fields in asset
  135. // proto as columns in BigQuery.
  136. BigQueryDestination bigquery_destination = 2;
  137. }
  138. }
  139. // Output result of export assets.
  140. message OutputResult {
  141. // Asset export result.
  142. oneof result {
  143. // Export result on Cloud Storage.
  144. GcsOutputResult gcs_result = 1;
  145. }
  146. }
  147. // A Cloud Storage output result.
  148. message GcsOutputResult {
  149. // List of uris of the Cloud Storage objects. Example:
  150. // "gs://bucket_name/object_name".
  151. repeated string uris = 1;
  152. }
  153. // A Cloud Storage location.
  154. message GcsDestination {
  155. // Required.
  156. oneof object_uri {
  157. // The uri of the Cloud Storage object. It's the same uri that is used by
  158. // gsutil. Example: "gs://bucket_name/object_name". See [Viewing and
  159. // Editing Object
  160. // Metadata](https://cloud.google.com/storage/docs/viewing-editing-metadata)
  161. // for more information.
  162. string uri = 1;
  163. // The uri prefix of all generated Cloud Storage objects. Example:
  164. // "gs://bucket_name/object_name_prefix". Each object uri is in format:
  165. // "gs://bucket_name/object_name_prefix/{ASSET_TYPE}/{SHARD_NUMBER} and only
  166. // contains assets for that type. <shard number> starts from 0. Example:
  167. // "gs://bucket_name/object_name_prefix/compute.googleapis.com/Disk/0" is
  168. // the first shard of output objects containing all
  169. // compute.googleapis.com/Disk assets. An INVALID_ARGUMENT error will be
  170. // returned if file with the same name "gs://bucket_name/object_name_prefix"
  171. // already exists.
  172. string uri_prefix = 2;
  173. }
  174. }
  175. // A BigQuery destination for exporting assets to.
  176. message BigQueryDestination {
  177. // Required. The BigQuery dataset in format
  178. // "projects/projectId/datasets/datasetId", to which the snapshot result
  179. // should be exported. If this dataset does not exist, the export call returns
  180. // an INVALID_ARGUMENT error.
  181. string dataset = 1 [(google.api.field_behavior) = REQUIRED];
  182. // Required. The BigQuery table to which the snapshot result should be
  183. // written. If this table does not exist, a new table with the given name
  184. // will be created.
  185. string table = 2 [(google.api.field_behavior) = REQUIRED];
  186. // If the destination table already exists and this flag is `TRUE`, the
  187. // table will be overwritten by the contents of assets snapshot. If the flag
  188. // is `FALSE` or unset and the destination table already exists, the export
  189. // call returns an INVALID_ARGUMEMT error.
  190. bool force = 3;
  191. // [partition_spec] determines whether to export to partitioned table(s) and
  192. // how to partition the data.
  193. //
  194. // If [partition_spec] is unset or [partition_spec.partition_key] is unset or
  195. // `PARTITION_KEY_UNSPECIFIED`, the snapshot results will be exported to
  196. // non-partitioned table(s). [force] will decide whether to overwrite existing
  197. // table(s).
  198. //
  199. // If [partition_spec] is specified. First, the snapshot results will be
  200. // written to partitioned table(s) with two additional timestamp columns,
  201. // readTime and requestTime, one of which will be the partition key. Secondly,
  202. // in the case when any destination table already exists, it will first try to
  203. // update existing table's schema as necessary by appending additional
  204. // columns. Then, if [force] is `TRUE`, the corresponding partition will be
  205. // overwritten by the snapshot results (data in different partitions will
  206. // remain intact); if [force] is unset or `FALSE`, it will append the data. An
  207. // error will be returned if the schema update or data appension fails.
  208. PartitionSpec partition_spec = 4;
  209. // If this flag is `TRUE`, the snapshot results will be written to one or
  210. // multiple tables, each of which contains results of one asset type. The
  211. // [force] and [partition_spec] fields will apply to each of them.
  212. //
  213. // Field [table] will be concatenated with "_" and the asset type names (see
  214. // https://cloud.google.com/asset-inventory/docs/supported-asset-types for
  215. // supported asset types) to construct per-asset-type table names, in which
  216. // all non-alphanumeric characters like "." and "/" will be substituted by
  217. // "_". Example: if field [table] is "mytable" and snapshot results
  218. // contain "storage.googleapis.com/Bucket" assets, the corresponding table
  219. // name will be "mytable_storage_googleapis_com_Bucket". If any of these
  220. // tables does not exist, a new table with the concatenated name will be
  221. // created.
  222. //
  223. // When [content_type] in the ExportAssetsRequest is `RESOURCE`, the schema of
  224. // each table will include RECORD-type columns mapped to the nested fields in
  225. // the Asset.resource.data field of that asset type (up to the 15 nested level
  226. // BigQuery supports
  227. // (https://cloud.google.com/bigquery/docs/nested-repeated#limitations)). The
  228. // fields in >15 nested levels will be stored in JSON format string as a child
  229. // column of its parent RECORD column.
  230. //
  231. // If error occurs when exporting to any table, the whole export call will
  232. // return an error but the export results that already succeed will persist.
  233. // Example: if exporting to table_type_A succeeds when exporting to
  234. // table_type_B fails during one export call, the results in table_type_A will
  235. // persist and there will not be partial results persisting in a table.
  236. bool separate_tables_per_asset_type = 5;
  237. }
  238. // Specifications of BigQuery partitioned table as export destination.
  239. message PartitionSpec {
  240. // This enum is used to determine the partition key column when exporting
  241. // assets to BigQuery partitioned table(s). Note that, if the partition key is
  242. // a timestamp column, the actual partition is based on its date value
  243. // (expressed in UTC. see details in
  244. // https://cloud.google.com/bigquery/docs/partitioned-tables#date_timestamp_partitioned_tables).
  245. enum PartitionKey {
  246. // Unspecified partition key. If used, it means using non-partitioned table.
  247. PARTITION_KEY_UNSPECIFIED = 0;
  248. // The time when the snapshot is taken. If specified as partition key, the
  249. // result table(s) is partitoned by the additional timestamp column,
  250. // readTime. If [read_time] in ExportAssetsRequest is specified, the
  251. // readTime column's value will be the same as it. Otherwise, its value will
  252. // be the current time that is used to take the snapshot.
  253. READ_TIME = 1;
  254. // The time when the request is received and started to be processed. If
  255. // specified as partition key, the result table(s) is partitoned by the
  256. // requestTime column, an additional timestamp column representing when the
  257. // request was received.
  258. REQUEST_TIME = 2;
  259. }
  260. // The partition key for BigQuery partitioned table.
  261. PartitionKey partition_key = 1;
  262. }
  263. // Asset content type.
  264. enum ContentType {
  265. // Unspecified content type.
  266. CONTENT_TYPE_UNSPECIFIED = 0;
  267. // Resource metadata.
  268. RESOURCE = 1;
  269. // The actual IAM policy set on a resource.
  270. IAM_POLICY = 2;
  271. // The Cloud Organization Policy set on an asset.
  272. ORG_POLICY = 4;
  273. // The Cloud Access context manager Policy set on an asset.
  274. ACCESS_POLICY = 5;
  275. // The related resources.
  276. RELATIONSHIP = 7;
  277. }