datapolicy.proto 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. syntax = "proto3";
  15. package google.cloud.bigquery.datapolicies.v1beta1;
  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/iam/v1/iam_policy.proto";
  21. import "google/iam/v1/policy.proto";
  22. import "google/protobuf/empty.proto";
  23. import "google/protobuf/field_mask.proto";
  24. option csharp_namespace = "Google.Cloud.BigQuery.DataPolicies.V1Beta1";
  25. option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/datapolicies/v1beta1;datapolicies";
  26. option java_multiple_files = true;
  27. option java_outer_classname = "DataPolicyProto";
  28. option java_package = "com.google.cloud.bigquery.datapolicies.v1beta1";
  29. option php_namespace = "Google\\Cloud\\BigQuery\\DataPolicies\\V1beta1";
  30. option ruby_package = "Google::Cloud::Bigquery::DataPolicies::V1beta1";
  31. // Data Policy Service provides APIs for managing the label-policy bindings.
  32. service DataPolicyService {
  33. option (google.api.default_host) = "bigquerydatapolicy.googleapis.com";
  34. option (google.api.oauth_scopes) =
  35. "https://www.googleapis.com/auth/bigquery,"
  36. "https://www.googleapis.com/auth/cloud-platform";
  37. // Creates a new data policy under a project with the given `dataPolicyId`
  38. // (used as the display name), policy tag, and data policy type.
  39. rpc CreateDataPolicy(CreateDataPolicyRequest) returns (DataPolicy) {
  40. option (google.api.http) = {
  41. post: "/v1beta1/{parent=projects/*/locations/*}/dataPolicies"
  42. body: "data_policy"
  43. };
  44. option (google.api.method_signature) = "parent,data_policy";
  45. }
  46. // Updates the metadata for an existing data policy. The target data policy
  47. // can be specified by the resource name.
  48. rpc UpdateDataPolicy(UpdateDataPolicyRequest) returns (DataPolicy) {
  49. option (google.api.http) = {
  50. patch: "/v1beta1/{data_policy.name=projects/*/locations/*/dataPolicies/*}"
  51. body: "data_policy"
  52. };
  53. option (google.api.method_signature) = "data_policy,update_mask";
  54. }
  55. // Deletes the data policy specified by its resource name.
  56. rpc DeleteDataPolicy(DeleteDataPolicyRequest) returns (google.protobuf.Empty) {
  57. option (google.api.http) = {
  58. delete: "/v1beta1/{name=projects/*/locations/*/dataPolicies/*}"
  59. };
  60. option (google.api.method_signature) = "name";
  61. }
  62. // Gets the data policy specified by its resource name.
  63. rpc GetDataPolicy(GetDataPolicyRequest) returns (DataPolicy) {
  64. option (google.api.http) = {
  65. get: "/v1beta1/{name=projects/*/locations/*/dataPolicies/*}"
  66. };
  67. option (google.api.method_signature) = "name";
  68. }
  69. // List all of the data policies in the specified parent project.
  70. rpc ListDataPolicies(ListDataPoliciesRequest) returns (ListDataPoliciesResponse) {
  71. option (google.api.http) = {
  72. get: "/v1beta1/{parent=projects/*/locations/*}/dataPolicies"
  73. };
  74. option (google.api.method_signature) = "parent";
  75. }
  76. // Gets the IAM policy for the specified data policy.
  77. rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
  78. option (google.api.http) = {
  79. post: "/v1beta1/{resource=projects/*/locations/*/dataPolicies/*}:getIamPolicy"
  80. body: "*"
  81. };
  82. }
  83. // Sets the IAM policy for the specified data policy.
  84. rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
  85. option (google.api.http) = {
  86. post: "/v1beta1/{resource=projects/*/locations/*/dataPolicies/*}:setIamPolicy"
  87. body: "*"
  88. };
  89. }
  90. // Returns the caller's permission on the specified data policy resource.
  91. rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
  92. option (google.api.http) = {
  93. post: "/v1beta1/{resource=projects/*/locations/*/dataPolicies/*}:testIamPermissions"
  94. body: "*"
  95. };
  96. }
  97. }
  98. // Request message for the CreateDataPolicy method.
  99. message CreateDataPolicyRequest {
  100. // Required. Resource name of the project that the data policy will belong to. The
  101. // format is `projects/{project_number}/locations/{location_id}`.
  102. string parent = 1 [
  103. (google.api.field_behavior) = REQUIRED,
  104. (google.api.resource_reference) = {
  105. child_type: "bigquerydatapolicy.googleapis.com/DataPolicy"
  106. }
  107. ];
  108. // Required. The data policy to create. The `name` field does not need to be
  109. // provided for the data policy creation.
  110. DataPolicy data_policy = 2 [(google.api.field_behavior) = REQUIRED];
  111. }
  112. // Response message for the UpdateDataPolicy method.
  113. message UpdateDataPolicyRequest {
  114. // Required. Update the data policy's metadata.
  115. //
  116. // The target data policy is determined by the `name` field.
  117. // Other fields are updated to the specified values based on the field masks.
  118. DataPolicy data_policy = 1 [(google.api.field_behavior) = REQUIRED];
  119. // The update mask applies to the resource. For the `FieldMask` definition,
  120. // see
  121. // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
  122. // If not set, defaults to all of the fields that are allowed to update.
  123. //
  124. // Updates to the `name` and `dataPolicyId` fields are not allowed.
  125. google.protobuf.FieldMask update_mask = 2;
  126. }
  127. // Request message for the DeleteDataPolicy method.
  128. message DeleteDataPolicyRequest {
  129. // Required. Resource name of the data policy to delete. Format is
  130. // `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
  131. string name = 1 [
  132. (google.api.field_behavior) = REQUIRED,
  133. (google.api.resource_reference) = {
  134. type: "bigquerydatapolicy.googleapis.com/DataPolicy"
  135. }
  136. ];
  137. }
  138. // Request message for the GetDataPolicy method.
  139. message GetDataPolicyRequest {
  140. // Required. Resource name of the requested data policy. Format is
  141. // `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
  142. string name = 1 [
  143. (google.api.field_behavior) = REQUIRED,
  144. (google.api.resource_reference) = {
  145. type: "bigquerydatapolicy.googleapis.com/DataPolicy"
  146. }
  147. ];
  148. }
  149. // Request message for the ListDataPolicies method.
  150. message ListDataPoliciesRequest {
  151. // Required. Resource name of the project for which to list data policies. Format is
  152. // `projects/{project_number}/locations/{location_id}`.
  153. string parent = 1 [
  154. (google.api.field_behavior) = REQUIRED,
  155. (google.api.resource_reference) = {
  156. child_type: "bigquerydatapolicy.googleapis.com/DataPolicy"
  157. }
  158. ];
  159. // The maximum number of data policies to return. Must be a value between 1
  160. // and 1000.
  161. // If not set, defaults to 50.
  162. int32 page_size = 2;
  163. // The `nextPageToken` value returned from a previous list request, if any. If
  164. // not set, defaults to an empty string.
  165. string page_token = 3;
  166. }
  167. // Response message for the ListDataPolicies method.
  168. message ListDataPoliciesResponse {
  169. // Data policies that belong to the requested project.
  170. repeated DataPolicy data_policies = 1;
  171. // Token used to retrieve the next page of results, or empty if there are no
  172. // more results.
  173. string next_page_token = 2;
  174. }
  175. // Represents the label-policy binding.
  176. message DataPolicy {
  177. option (google.api.resource) = {
  178. type: "bigquerydatapolicy.googleapis.com/DataPolicy"
  179. pattern: "projects/{project}/locations/{location}/dataPolicies/{data_policy}"
  180. };
  181. // A list of supported data policy types.
  182. enum DataPolicyType {
  183. // Default value for the data policy type. This should not be used.
  184. DATA_POLICY_TYPE_UNSPECIFIED = 0;
  185. // Used to create a data policy for column-level security, without data
  186. // masking.
  187. COLUMN_LEVEL_SECURITY_POLICY = 3;
  188. // Used to create a data policy for data masking.
  189. DATA_MASKING_POLICY = 2;
  190. }
  191. // Label that is bound to this data policy.
  192. oneof matching_label {
  193. // Policy tag resource name, in the format of
  194. // `projects/{project_number}/locations/{location_id}/taxonomies/{taxonomy_id}/policyTags/{policyTag_id}`.
  195. string policy_tag = 4;
  196. }
  197. // The policy that is bound to this data policy.
  198. oneof policy {
  199. // The data masking policy that specifies the data masking rule to use.
  200. DataMaskingPolicy data_masking_policy = 5;
  201. }
  202. // Output only. Resource name of this data policy, in the format of
  203. // `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
  204. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  205. // Type of data policy.
  206. DataPolicyType data_policy_type = 2;
  207. // User-assigned (human readable) ID of the data policy that needs to be
  208. // unique within a project. Used as {data_policy_id} in part of the resource
  209. // name.
  210. string data_policy_id = 3;
  211. }
  212. // The data masking policy that is used to specify data masking rule.
  213. message DataMaskingPolicy {
  214. // The available masking rules. Learn more here:
  215. // https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options.
  216. enum PredefinedExpression {
  217. // Default, unspecified predefined expression. No masking will take place
  218. // since no expression is specified.
  219. PREDEFINED_EXPRESSION_UNSPECIFIED = 0;
  220. // Masking expression to replace data with SHA-256 hash.
  221. SHA256 = 3;
  222. // Masking expression to replace data with NULLs.
  223. ALWAYS_NULL = 5;
  224. // Masking expression to replace data with their default masking values.
  225. // The default masking values for each type listed as below:
  226. //
  227. // * STRING: ""
  228. // * BYTES: b''
  229. // * INTEGER: 0
  230. // * FLOAT: 0.0
  231. // * NUMERIC: 0
  232. // * BOOLEAN: FALSE
  233. // * TIMESTAMP: 0001-01-01 00:00:00 UTC
  234. // * DATE: 0001-01-01
  235. // * TIME: 00:00:00
  236. // * DATETIME: 0001-01-01T00:00:00
  237. // * GEOGRAPHY: POINT(0 0)
  238. // * BIGNUMERIC: 0
  239. // * ARRAY: []
  240. // * STRUCT: NOT_APPLICABLE
  241. // * JSON: NULL
  242. DEFAULT_MASKING_VALUE = 7;
  243. }
  244. // A masking expression to bind to the data masking rule.
  245. oneof masking_expression {
  246. // A predefined masking expression.
  247. PredefinedExpression predefined_expression = 1;
  248. }
  249. }