diff --git a/packages/google-cloud-bigquery-datapolicies/README.md b/packages/google-cloud-bigquery-datapolicies/README.md index e3d86b52051..7842fd00d4a 100644 --- a/packages/google-cloud-bigquery-datapolicies/README.md +++ b/packages/google-cloud-bigquery-datapolicies/README.md @@ -112,6 +112,15 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | +| Data_policy_service.create_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js,samples/README.md) | +| Data_policy_service.delete_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js,samples/README.md) | +| Data_policy_service.get_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js,samples/README.md) | +| Data_policy_service.get_iam_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js,samples/README.md) | +| Data_policy_service.list_data_policies | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js,samples/README.md) | +| Data_policy_service.rename_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js,samples/README.md) | +| Data_policy_service.set_iam_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js,samples/README.md) | +| Data_policy_service.test_iam_permissions | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js,samples/README.md) | +| Data_policy_service.update_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js,samples/README.md) | | Data_policy_service.create_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1beta1/data_policy_service.create_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1beta1/data_policy_service.create_data_policy.js,samples/README.md) | | Data_policy_service.delete_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1beta1/data_policy_service.delete_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1beta1/data_policy_service.delete_data_policy.js,samples/README.md) | | Data_policy_service.get_data_policy | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1beta1/data_policy_service.get_data_policy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1beta1/data_policy_service.get_data_policy.js,samples/README.md) | diff --git a/packages/google-cloud-bigquery-datapolicies/protos/google/cloud/bigquery/datapolicies/v1/datapolicy.proto b/packages/google-cloud-bigquery-datapolicies/protos/google/cloud/bigquery/datapolicies/v1/datapolicy.proto new file mode 100644 index 00000000000..cd79acfba30 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/protos/google/cloud/bigquery/datapolicies/v1/datapolicy.proto @@ -0,0 +1,320 @@ +// 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.bigquery.datapolicies.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.BigQuery.DataPolicies.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/datapolicies/v1;datapolicies"; +option java_multiple_files = true; +option java_outer_classname = "DataPolicyProto"; +option java_package = "com.google.cloud.bigquery.datapolicies.v1"; +option php_namespace = "Google\\Cloud\\BigQuery\\DataPolicies\\V1"; +option ruby_package = "Google::Cloud::Bigquery::DataPolicies::V1"; + +// Data Policy Service provides APIs for managing the label-policy bindings. +service DataPolicyService { + option (google.api.default_host) = "bigquerydatapolicy.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/bigquery," + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new data policy under a project with the given `dataPolicyId` + // (used as the display name), policy tag, and data policy type. + rpc CreateDataPolicy(CreateDataPolicyRequest) returns (DataPolicy) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/dataPolicies" + body: "data_policy" + }; + option (google.api.method_signature) = "parent,data_policy"; + } + + // Updates the metadata for an existing data policy. The target data policy + // can be specified by the resource name. + rpc UpdateDataPolicy(UpdateDataPolicyRequest) returns (DataPolicy) { + option (google.api.http) = { + patch: "/v1/{data_policy.name=projects/*/locations/*/dataPolicies/*}" + body: "data_policy" + }; + option (google.api.method_signature) = "data_policy,update_mask"; + } + + // Renames the id (display name) of the specified data policy. + rpc RenameDataPolicy(RenameDataPolicyRequest) returns (DataPolicy) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/dataPolicies/*}:rename" + body: "*" + }; + option (google.api.method_signature) = "name,new_data_policy_id"; + } + + // Deletes the data policy specified by its resource name. + rpc DeleteDataPolicy(DeleteDataPolicyRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/dataPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the data policy specified by its resource name. + rpc GetDataPolicy(GetDataPolicyRequest) returns (DataPolicy) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/dataPolicies/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List all of the data policies in the specified parent project. + rpc ListDataPolicies(ListDataPoliciesRequest) + returns (ListDataPoliciesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/dataPolicies" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets the IAM policy for the specified data policy. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/dataPolicies/*}:getIamPolicy" + body: "*" + }; + } + + // Sets the IAM policy for the specified data policy. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) + returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/dataPolicies/*}:setIamPolicy" + body: "*" + }; + } + + // Returns the caller's permission on the specified data policy resource. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) + returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/dataPolicies/*}:testIamPermissions" + body: "*" + }; + } +} + +// Request message for the CreateDataPolicy method. +message CreateDataPolicyRequest { + // Required. Resource name of the project that the data policy will belong to. + // The format is `projects/{project_number}/locations/{location_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "bigquerydatapolicy.googleapis.com/DataPolicy" + } + ]; + + // Required. The data policy to create. The `name` field does not need to be + // provided for the data policy creation. + DataPolicy data_policy = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for the UpdateDataPolicy method. +message UpdateDataPolicyRequest { + // Required. Update the data policy's metadata. + // + // The target data policy is determined by the `name` field. + // Other fields are updated to the specified values based on the field masks. + DataPolicy data_policy = 1 [(google.api.field_behavior) = REQUIRED]; + + // The update mask applies to the resource. For the `FieldMask` definition, + // see + // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + // If not set, defaults to all of the fields that are allowed to update. + // + // Updates to the `name` and `dataPolicyId` fields are not allowed. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for the RenameDataPolicy method. +message RenameDataPolicyRequest { + // Required. Resource name of the data policy to rename. The format is + // `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The new data policy id. + string new_data_policy_id = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request message for the DeleteDataPolicy method. +message DeleteDataPolicyRequest { + // Required. Resource name of the data policy to delete. Format is + // `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "bigquerydatapolicy.googleapis.com/DataPolicy" + } + ]; +} + +// Request message for the GetDataPolicy method. +message GetDataPolicyRequest { + // Required. Resource name of the requested data policy. Format is + // `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "bigquerydatapolicy.googleapis.com/DataPolicy" + } + ]; +} + +// Request message for the ListDataPolicies method. +message ListDataPoliciesRequest { + // Required. Resource name of the project for which to list data policies. + // Format is `projects/{project_number}/locations/{location_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "bigquerydatapolicy.googleapis.com/DataPolicy" + } + ]; + + // The maximum number of data policies to return. Must be a value between 1 + // and 1000. + // If not set, defaults to 50. + int32 page_size = 2; + + // The `nextPageToken` value returned from a previous list request, if any. If + // not set, defaults to an empty string. + string page_token = 3; + + // Filters the data policies by policy tags that they + // are associated with. Currently filter only supports + // "policy_tag" based filtering and OR based predicates. Sample + // filter can be "policy_tag: + // `'projects/1/locations/us/taxonomies/2/policyTags/3'`". You may use + // wildcard such as "policy_tag: + // `'projects/1/locations/us/taxonomies/2/*'`". + string filter = 4; +} + +// Response message for the ListDataPolicies method. +message ListDataPoliciesResponse { + // Data policies that belong to the requested project. + repeated DataPolicy data_policies = 1; + + // Token used to retrieve the next page of results, or empty if there are no + // more results. + string next_page_token = 2; +} + +// Represents the label-policy binding. +message DataPolicy { + option (google.api.resource) = { + type: "bigquerydatapolicy.googleapis.com/DataPolicy" + pattern: "projects/{project}/locations/{location}/dataPolicies/{data_policy}" + }; + + // A list of supported data policy types. + enum DataPolicyType { + // Default value for the data policy type. This should not be used. + DATA_POLICY_TYPE_UNSPECIFIED = 0; + + // Used to create a data policy for column-level security, without data + // masking. + COLUMN_LEVEL_SECURITY_POLICY = 3; + + // Used to create a data policy for data masking. + DATA_MASKING_POLICY = 2; + } + + // Label that is bound to this data policy. + oneof matching_label { + // Policy tag resource name, in the format of + // `projects/{project_number}/locations/{location_id}/taxonomies/{taxonomy_id}/policyTags/{policyTag_id}`. + string policy_tag = 4; + } + + // The policy that is bound to this data policy. + oneof policy { + // The data masking policy that specifies the data masking rule to use. + DataMaskingPolicy data_masking_policy = 5; + } + + // Output only. Resource name of this data policy, in the format of + // `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Type of data policy. + DataPolicyType data_policy_type = 2; + + // User-assigned (human readable) ID of the data policy that needs to be + // unique within a project. Used as {data_policy_id} in part of the resource + // name. + string data_policy_id = 3; +} + +// The data masking policy that is used to specify data masking rule. +message DataMaskingPolicy { + // The available masking rules. Learn more here: + // https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options. + enum PredefinedExpression { + // Default, unspecified predefined expression. No masking will take place + // since no expression is specified. + PREDEFINED_EXPRESSION_UNSPECIFIED = 0; + + // Masking expression to replace data with SHA-256 hash. + SHA256 = 3; + + // Masking expression to replace data with NULLs. + ALWAYS_NULL = 5; + + // Masking expression to replace data with their default masking values. + // The default masking values for each type listed as below: + // + // * STRING: "" + // * BYTES: b'' + // * INTEGER: 0 + // * FLOAT: 0.0 + // * NUMERIC: 0 + // * BOOLEAN: FALSE + // * TIMESTAMP: 0001-01-01 00:00:00 UTC + // * DATE: 0001-01-01 + // * TIME: 00:00:00 + // * DATETIME: 0001-01-01T00:00:00 + // * GEOGRAPHY: POINT(0 0) + // * BIGNUMERIC: 0 + // * ARRAY: [] + // * STRUCT: NOT_APPLICABLE + // * JSON: NULL + DEFAULT_MASKING_VALUE = 7; + } + + // A masking expression to bind to the data masking rule. + oneof masking_expression { + // A predefined masking expression. + PredefinedExpression predefined_expression = 1; + } +} diff --git a/packages/google-cloud-bigquery-datapolicies/protos/protos.d.ts b/packages/google-cloud-bigquery-datapolicies/protos/protos.d.ts index e17249c1cc5..c4508f17a70 100644 --- a/packages/google-cloud-bigquery-datapolicies/protos/protos.d.ts +++ b/packages/google-cloud-bigquery-datapolicies/protos/protos.d.ts @@ -26,6 +26,1192 @@ export namespace google { /** Namespace datapolicies. */ namespace datapolicies { + /** Namespace v1. */ + namespace v1 { + + /** Represents a DataPolicyService */ + class DataPolicyService extends $protobuf.rpc.Service { + + /** + * Constructs a new DataPolicyService service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new DataPolicyService service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): DataPolicyService; + + /** + * Calls CreateDataPolicy. + * @param request CreateDataPolicyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and DataPolicy + */ + public createDataPolicy(request: google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.CreateDataPolicyCallback): void; + + /** + * Calls CreateDataPolicy. + * @param request CreateDataPolicyRequest message or plain object + * @returns Promise + */ + public createDataPolicy(request: google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest): Promise; + + /** + * Calls UpdateDataPolicy. + * @param request UpdateDataPolicyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and DataPolicy + */ + public updateDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.UpdateDataPolicyCallback): void; + + /** + * Calls UpdateDataPolicy. + * @param request UpdateDataPolicyRequest message or plain object + * @returns Promise + */ + public updateDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest): Promise; + + /** + * Calls RenameDataPolicy. + * @param request RenameDataPolicyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and DataPolicy + */ + public renameDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.RenameDataPolicyCallback): void; + + /** + * Calls RenameDataPolicy. + * @param request RenameDataPolicyRequest message or plain object + * @returns Promise + */ + public renameDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest): Promise; + + /** + * Calls DeleteDataPolicy. + * @param request DeleteDataPolicyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.DeleteDataPolicyCallback): void; + + /** + * Calls DeleteDataPolicy. + * @param request DeleteDataPolicyRequest message or plain object + * @returns Promise + */ + public deleteDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest): Promise; + + /** + * Calls GetDataPolicy. + * @param request GetDataPolicyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and DataPolicy + */ + public getDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetDataPolicyCallback): void; + + /** + * Calls GetDataPolicy. + * @param request GetDataPolicyRequest message or plain object + * @returns Promise + */ + public getDataPolicy(request: google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest): Promise; + + /** + * Calls ListDataPolicies. + * @param request ListDataPoliciesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListDataPoliciesResponse + */ + public listDataPolicies(request: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.ListDataPoliciesCallback): void; + + /** + * Calls ListDataPolicies. + * @param request ListDataPoliciesRequest message or plain object + * @returns Promise + */ + public listDataPolicies(request: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest): Promise; + + /** + * Calls GetIamPolicy. + * @param request GetIamPolicyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Policy + */ + public getIamPolicy(request: google.iam.v1.IGetIamPolicyRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetIamPolicyCallback): void; + + /** + * Calls GetIamPolicy. + * @param request GetIamPolicyRequest message or plain object + * @returns Promise + */ + public getIamPolicy(request: google.iam.v1.IGetIamPolicyRequest): Promise; + + /** + * Calls SetIamPolicy. + * @param request SetIamPolicyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Policy + */ + public setIamPolicy(request: google.iam.v1.ISetIamPolicyRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.SetIamPolicyCallback): void; + + /** + * Calls SetIamPolicy. + * @param request SetIamPolicyRequest message or plain object + * @returns Promise + */ + public setIamPolicy(request: google.iam.v1.ISetIamPolicyRequest): Promise; + + /** + * Calls TestIamPermissions. + * @param request TestIamPermissionsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and TestIamPermissionsResponse + */ + public testIamPermissions(request: google.iam.v1.ITestIamPermissionsRequest, callback: google.cloud.bigquery.datapolicies.v1.DataPolicyService.TestIamPermissionsCallback): void; + + /** + * Calls TestIamPermissions. + * @param request TestIamPermissionsRequest message or plain object + * @returns Promise + */ + public testIamPermissions(request: google.iam.v1.ITestIamPermissionsRequest): Promise; + } + + namespace DataPolicyService { + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|createDataPolicy}. + * @param error Error, if any + * @param [response] DataPolicy + */ + type CreateDataPolicyCallback = (error: (Error|null), response?: google.cloud.bigquery.datapolicies.v1.DataPolicy) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|updateDataPolicy}. + * @param error Error, if any + * @param [response] DataPolicy + */ + type UpdateDataPolicyCallback = (error: (Error|null), response?: google.cloud.bigquery.datapolicies.v1.DataPolicy) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|renameDataPolicy}. + * @param error Error, if any + * @param [response] DataPolicy + */ + type RenameDataPolicyCallback = (error: (Error|null), response?: google.cloud.bigquery.datapolicies.v1.DataPolicy) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|deleteDataPolicy}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteDataPolicyCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|getDataPolicy}. + * @param error Error, if any + * @param [response] DataPolicy + */ + type GetDataPolicyCallback = (error: (Error|null), response?: google.cloud.bigquery.datapolicies.v1.DataPolicy) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|listDataPolicies}. + * @param error Error, if any + * @param [response] ListDataPoliciesResponse + */ + type ListDataPoliciesCallback = (error: (Error|null), response?: google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|getIamPolicy}. + * @param error Error, if any + * @param [response] Policy + */ + type GetIamPolicyCallback = (error: (Error|null), response?: google.iam.v1.Policy) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|setIamPolicy}. + * @param error Error, if any + * @param [response] Policy + */ + type SetIamPolicyCallback = (error: (Error|null), response?: google.iam.v1.Policy) => void; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|testIamPermissions}. + * @param error Error, if any + * @param [response] TestIamPermissionsResponse + */ + type TestIamPermissionsCallback = (error: (Error|null), response?: google.iam.v1.TestIamPermissionsResponse) => void; + } + + /** Properties of a CreateDataPolicyRequest. */ + interface ICreateDataPolicyRequest { + + /** CreateDataPolicyRequest parent */ + parent?: (string|null); + + /** CreateDataPolicyRequest dataPolicy */ + dataPolicy?: (google.cloud.bigquery.datapolicies.v1.IDataPolicy|null); + } + + /** Represents a CreateDataPolicyRequest. */ + class CreateDataPolicyRequest implements ICreateDataPolicyRequest { + + /** + * Constructs a new CreateDataPolicyRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest); + + /** CreateDataPolicyRequest parent. */ + public parent: string; + + /** CreateDataPolicyRequest dataPolicy. */ + public dataPolicy?: (google.cloud.bigquery.datapolicies.v1.IDataPolicy|null); + + /** + * Creates a new CreateDataPolicyRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateDataPolicyRequest instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest): google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest; + + /** + * Encodes the specified CreateDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest.verify|verify} messages. + * @param message CreateDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest.verify|verify} messages. + * @param message CreateDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateDataPolicyRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest; + + /** + * Decodes a CreateDataPolicyRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest; + + /** + * Verifies a CreateDataPolicyRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateDataPolicyRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest; + + /** + * Creates a plain object from a CreateDataPolicyRequest message. Also converts values to other types if specified. + * @param message CreateDataPolicyRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateDataPolicyRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateDataPolicyRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UpdateDataPolicyRequest. */ + interface IUpdateDataPolicyRequest { + + /** UpdateDataPolicyRequest dataPolicy */ + dataPolicy?: (google.cloud.bigquery.datapolicies.v1.IDataPolicy|null); + + /** UpdateDataPolicyRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateDataPolicyRequest. */ + class UpdateDataPolicyRequest implements IUpdateDataPolicyRequest { + + /** + * Constructs a new UpdateDataPolicyRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest); + + /** UpdateDataPolicyRequest dataPolicy. */ + public dataPolicy?: (google.cloud.bigquery.datapolicies.v1.IDataPolicy|null); + + /** UpdateDataPolicyRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateDataPolicyRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateDataPolicyRequest instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest): google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest; + + /** + * Encodes the specified UpdateDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest.verify|verify} messages. + * @param message UpdateDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest.verify|verify} messages. + * @param message UpdateDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateDataPolicyRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest; + + /** + * Decodes an UpdateDataPolicyRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest; + + /** + * Verifies an UpdateDataPolicyRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdateDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateDataPolicyRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest; + + /** + * Creates a plain object from an UpdateDataPolicyRequest message. Also converts values to other types if specified. + * @param message UpdateDataPolicyRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateDataPolicyRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UpdateDataPolicyRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RenameDataPolicyRequest. */ + interface IRenameDataPolicyRequest { + + /** RenameDataPolicyRequest name */ + name?: (string|null); + + /** RenameDataPolicyRequest newDataPolicyId */ + newDataPolicyId?: (string|null); + } + + /** Represents a RenameDataPolicyRequest. */ + class RenameDataPolicyRequest implements IRenameDataPolicyRequest { + + /** + * Constructs a new RenameDataPolicyRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest); + + /** RenameDataPolicyRequest name. */ + public name: string; + + /** RenameDataPolicyRequest newDataPolicyId. */ + public newDataPolicyId: string; + + /** + * Creates a new RenameDataPolicyRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RenameDataPolicyRequest instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest): google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest; + + /** + * Encodes the specified RenameDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest.verify|verify} messages. + * @param message RenameDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RenameDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest.verify|verify} messages. + * @param message RenameDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RenameDataPolicyRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RenameDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest; + + /** + * Decodes a RenameDataPolicyRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RenameDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest; + + /** + * Verifies a RenameDataPolicyRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RenameDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RenameDataPolicyRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest; + + /** + * Creates a plain object from a RenameDataPolicyRequest message. Also converts values to other types if specified. + * @param message RenameDataPolicyRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RenameDataPolicyRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RenameDataPolicyRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteDataPolicyRequest. */ + interface IDeleteDataPolicyRequest { + + /** DeleteDataPolicyRequest name */ + name?: (string|null); + } + + /** Represents a DeleteDataPolicyRequest. */ + class DeleteDataPolicyRequest implements IDeleteDataPolicyRequest { + + /** + * Constructs a new DeleteDataPolicyRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest); + + /** DeleteDataPolicyRequest name. */ + public name: string; + + /** + * Creates a new DeleteDataPolicyRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteDataPolicyRequest instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest): google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest; + + /** + * Encodes the specified DeleteDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest.verify|verify} messages. + * @param message DeleteDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest.verify|verify} messages. + * @param message DeleteDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteDataPolicyRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest; + + /** + * Decodes a DeleteDataPolicyRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest; + + /** + * Verifies a DeleteDataPolicyRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteDataPolicyRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest; + + /** + * Creates a plain object from a DeleteDataPolicyRequest message. Also converts values to other types if specified. + * @param message DeleteDataPolicyRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteDataPolicyRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteDataPolicyRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetDataPolicyRequest. */ + interface IGetDataPolicyRequest { + + /** GetDataPolicyRequest name */ + name?: (string|null); + } + + /** Represents a GetDataPolicyRequest. */ + class GetDataPolicyRequest implements IGetDataPolicyRequest { + + /** + * Constructs a new GetDataPolicyRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest); + + /** GetDataPolicyRequest name. */ + public name: string; + + /** + * Creates a new GetDataPolicyRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetDataPolicyRequest instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest): google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest; + + /** + * Encodes the specified GetDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest.verify|verify} messages. + * @param message GetDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest.verify|verify} messages. + * @param message GetDataPolicyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetDataPolicyRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest; + + /** + * Decodes a GetDataPolicyRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest; + + /** + * Verifies a GetDataPolicyRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetDataPolicyRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest; + + /** + * Creates a plain object from a GetDataPolicyRequest message. Also converts values to other types if specified. + * @param message GetDataPolicyRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetDataPolicyRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetDataPolicyRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListDataPoliciesRequest. */ + interface IListDataPoliciesRequest { + + /** ListDataPoliciesRequest parent */ + parent?: (string|null); + + /** ListDataPoliciesRequest pageSize */ + pageSize?: (number|null); + + /** ListDataPoliciesRequest pageToken */ + pageToken?: (string|null); + + /** ListDataPoliciesRequest filter */ + filter?: (string|null); + } + + /** Represents a ListDataPoliciesRequest. */ + class ListDataPoliciesRequest implements IListDataPoliciesRequest { + + /** + * Constructs a new ListDataPoliciesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest); + + /** ListDataPoliciesRequest parent. */ + public parent: string; + + /** ListDataPoliciesRequest pageSize. */ + public pageSize: number; + + /** ListDataPoliciesRequest pageToken. */ + public pageToken: string; + + /** ListDataPoliciesRequest filter. */ + public filter: string; + + /** + * Creates a new ListDataPoliciesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListDataPoliciesRequest instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest; + + /** + * Encodes the specified ListDataPoliciesRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest.verify|verify} messages. + * @param message ListDataPoliciesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListDataPoliciesRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest.verify|verify} messages. + * @param message ListDataPoliciesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListDataPoliciesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListDataPoliciesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest; + + /** + * Decodes a ListDataPoliciesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListDataPoliciesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest; + + /** + * Verifies a ListDataPoliciesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListDataPoliciesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDataPoliciesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest; + + /** + * Creates a plain object from a ListDataPoliciesRequest message. Also converts values to other types if specified. + * @param message ListDataPoliciesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDataPoliciesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListDataPoliciesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListDataPoliciesResponse. */ + interface IListDataPoliciesResponse { + + /** ListDataPoliciesResponse dataPolicies */ + dataPolicies?: (google.cloud.bigquery.datapolicies.v1.IDataPolicy[]|null); + + /** ListDataPoliciesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListDataPoliciesResponse. */ + class ListDataPoliciesResponse implements IListDataPoliciesResponse { + + /** + * Constructs a new ListDataPoliciesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse); + + /** ListDataPoliciesResponse dataPolicies. */ + public dataPolicies: google.cloud.bigquery.datapolicies.v1.IDataPolicy[]; + + /** ListDataPoliciesResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListDataPoliciesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListDataPoliciesResponse instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse; + + /** + * Encodes the specified ListDataPoliciesResponse message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse.verify|verify} messages. + * @param message ListDataPoliciesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListDataPoliciesResponse message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse.verify|verify} messages. + * @param message ListDataPoliciesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListDataPoliciesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListDataPoliciesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse; + + /** + * Decodes a ListDataPoliciesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListDataPoliciesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse; + + /** + * Verifies a ListDataPoliciesResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListDataPoliciesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListDataPoliciesResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse; + + /** + * Creates a plain object from a ListDataPoliciesResponse message. Also converts values to other types if specified. + * @param message ListDataPoliciesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListDataPoliciesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListDataPoliciesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DataPolicy. */ + interface IDataPolicy { + + /** DataPolicy policyTag */ + policyTag?: (string|null); + + /** DataPolicy dataMaskingPolicy */ + dataMaskingPolicy?: (google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy|null); + + /** DataPolicy name */ + name?: (string|null); + + /** DataPolicy dataPolicyType */ + dataPolicyType?: (google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType|keyof typeof google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType|null); + + /** DataPolicy dataPolicyId */ + dataPolicyId?: (string|null); + } + + /** Represents a DataPolicy. */ + class DataPolicy implements IDataPolicy { + + /** + * Constructs a new DataPolicy. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IDataPolicy); + + /** DataPolicy policyTag. */ + public policyTag?: (string|null); + + /** DataPolicy dataMaskingPolicy. */ + public dataMaskingPolicy?: (google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy|null); + + /** DataPolicy name. */ + public name: string; + + /** DataPolicy dataPolicyType. */ + public dataPolicyType: (google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType|keyof typeof google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType); + + /** DataPolicy dataPolicyId. */ + public dataPolicyId: string; + + /** DataPolicy matchingLabel. */ + public matchingLabel?: "policyTag"; + + /** DataPolicy policy. */ + public policy?: "dataMaskingPolicy"; + + /** + * Creates a new DataPolicy instance using the specified properties. + * @param [properties] Properties to set + * @returns DataPolicy instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IDataPolicy): google.cloud.bigquery.datapolicies.v1.DataPolicy; + + /** + * Encodes the specified DataPolicy message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataPolicy.verify|verify} messages. + * @param message DataPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IDataPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DataPolicy message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataPolicy.verify|verify} messages. + * @param message DataPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IDataPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DataPolicy message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DataPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.DataPolicy; + + /** + * Decodes a DataPolicy message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DataPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.DataPolicy; + + /** + * Verifies a DataPolicy message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DataPolicy message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DataPolicy + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.DataPolicy; + + /** + * Creates a plain object from a DataPolicy message. Also converts values to other types if specified. + * @param message DataPolicy + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.DataPolicy, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DataPolicy to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DataPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace DataPolicy { + + /** DataPolicyType enum. */ + enum DataPolicyType { + DATA_POLICY_TYPE_UNSPECIFIED = 0, + COLUMN_LEVEL_SECURITY_POLICY = 3, + DATA_MASKING_POLICY = 2 + } + } + + /** Properties of a DataMaskingPolicy. */ + interface IDataMaskingPolicy { + + /** DataMaskingPolicy predefinedExpression */ + predefinedExpression?: (google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression|keyof typeof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression|null); + } + + /** Represents a DataMaskingPolicy. */ + class DataMaskingPolicy implements IDataMaskingPolicy { + + /** + * Constructs a new DataMaskingPolicy. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy); + + /** DataMaskingPolicy predefinedExpression. */ + public predefinedExpression?: (google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression|keyof typeof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression|null); + + /** DataMaskingPolicy maskingExpression. */ + public maskingExpression?: "predefinedExpression"; + + /** + * Creates a new DataMaskingPolicy instance using the specified properties. + * @param [properties] Properties to set + * @returns DataMaskingPolicy instance + */ + public static create(properties?: google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy): google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy; + + /** + * Encodes the specified DataMaskingPolicy message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.verify|verify} messages. + * @param message DataMaskingPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DataMaskingPolicy message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.verify|verify} messages. + * @param message DataMaskingPolicy message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DataMaskingPolicy message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DataMaskingPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy; + + /** + * Decodes a DataMaskingPolicy message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DataMaskingPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy; + + /** + * Verifies a DataMaskingPolicy message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DataMaskingPolicy message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DataMaskingPolicy + */ + public static fromObject(object: { [k: string]: any }): google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy; + + /** + * Creates a plain object from a DataMaskingPolicy message. Also converts values to other types if specified. + * @param message DataMaskingPolicy + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DataMaskingPolicy to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DataMaskingPolicy + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace DataMaskingPolicy { + + /** PredefinedExpression enum. */ + enum PredefinedExpression { + PREDEFINED_EXPRESSION_UNSPECIFIED = 0, + SHA256 = 3, + ALWAYS_NULL = 5, + DEFAULT_MASKING_VALUE = 7 + } + } + } + /** Namespace v1beta1. */ namespace v1beta1 { diff --git a/packages/google-cloud-bigquery-datapolicies/protos/protos.js b/packages/google-cloud-bigquery-datapolicies/protos/protos.js index 4730bddaa14..9d27b5d61c1 100644 --- a/packages/google-cloud-bigquery-datapolicies/protos/protos.js +++ b/packages/google-cloud-bigquery-datapolicies/protos/protos.js @@ -66,6 +66,2617 @@ */ var datapolicies = {}; + datapolicies.v1 = (function() { + + /** + * Namespace v1. + * @memberof google.cloud.bigquery.datapolicies + * @namespace + */ + var v1 = {}; + + v1.DataPolicyService = (function() { + + /** + * Constructs a new DataPolicyService service. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a DataPolicyService + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function DataPolicyService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (DataPolicyService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = DataPolicyService; + + /** + * Creates new DataPolicyService service using the specified rpc implementation. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {DataPolicyService} RPC service. Useful where requests and/or responses are streamed. + */ + DataPolicyService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|createDataPolicy}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef CreateDataPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicy} [response] DataPolicy + */ + + /** + * Calls CreateDataPolicy. + * @function createDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest} request CreateDataPolicyRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.CreateDataPolicyCallback} callback Node-style callback called with the error, if any, and DataPolicy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.createDataPolicy = function createDataPolicy(request, callback) { + return this.rpcCall(createDataPolicy, $root.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest, $root.google.cloud.bigquery.datapolicies.v1.DataPolicy, request, callback); + }, "name", { value: "CreateDataPolicy" }); + + /** + * Calls CreateDataPolicy. + * @function createDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest} request CreateDataPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|updateDataPolicy}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef UpdateDataPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicy} [response] DataPolicy + */ + + /** + * Calls UpdateDataPolicy. + * @function updateDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest} request UpdateDataPolicyRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.UpdateDataPolicyCallback} callback Node-style callback called with the error, if any, and DataPolicy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.updateDataPolicy = function updateDataPolicy(request, callback) { + return this.rpcCall(updateDataPolicy, $root.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest, $root.google.cloud.bigquery.datapolicies.v1.DataPolicy, request, callback); + }, "name", { value: "UpdateDataPolicy" }); + + /** + * Calls UpdateDataPolicy. + * @function updateDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest} request UpdateDataPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|renameDataPolicy}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef RenameDataPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicy} [response] DataPolicy + */ + + /** + * Calls RenameDataPolicy. + * @function renameDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest} request RenameDataPolicyRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.RenameDataPolicyCallback} callback Node-style callback called with the error, if any, and DataPolicy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.renameDataPolicy = function renameDataPolicy(request, callback) { + return this.rpcCall(renameDataPolicy, $root.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest, $root.google.cloud.bigquery.datapolicies.v1.DataPolicy, request, callback); + }, "name", { value: "RenameDataPolicy" }); + + /** + * Calls RenameDataPolicy. + * @function renameDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest} request RenameDataPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|deleteDataPolicy}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef DeleteDataPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteDataPolicy. + * @function deleteDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest} request DeleteDataPolicyRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.DeleteDataPolicyCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.deleteDataPolicy = function deleteDataPolicy(request, callback) { + return this.rpcCall(deleteDataPolicy, $root.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteDataPolicy" }); + + /** + * Calls DeleteDataPolicy. + * @function deleteDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest} request DeleteDataPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|getDataPolicy}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef GetDataPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicy} [response] DataPolicy + */ + + /** + * Calls GetDataPolicy. + * @function getDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest} request GetDataPolicyRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetDataPolicyCallback} callback Node-style callback called with the error, if any, and DataPolicy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.getDataPolicy = function getDataPolicy(request, callback) { + return this.rpcCall(getDataPolicy, $root.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest, $root.google.cloud.bigquery.datapolicies.v1.DataPolicy, request, callback); + }, "name", { value: "GetDataPolicy" }); + + /** + * Calls GetDataPolicy. + * @function getDataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest} request GetDataPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|listDataPolicies}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef ListDataPoliciesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse} [response] ListDataPoliciesResponse + */ + + /** + * Calls ListDataPolicies. + * @function listDataPolicies + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest} request ListDataPoliciesRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.ListDataPoliciesCallback} callback Node-style callback called with the error, if any, and ListDataPoliciesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.listDataPolicies = function listDataPolicies(request, callback) { + return this.rpcCall(listDataPolicies, $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest, $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse, request, callback); + }, "name", { value: "ListDataPolicies" }); + + /** + * Calls ListDataPolicies. + * @function listDataPolicies + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest} request ListDataPoliciesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|getIamPolicy}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef GetIamPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.iam.v1.Policy} [response] Policy + */ + + /** + * Calls GetIamPolicy. + * @function getIamPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.iam.v1.IGetIamPolicyRequest} request GetIamPolicyRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetIamPolicyCallback} callback Node-style callback called with the error, if any, and Policy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.getIamPolicy = function getIamPolicy(request, callback) { + return this.rpcCall(getIamPolicy, $root.google.iam.v1.GetIamPolicyRequest, $root.google.iam.v1.Policy, request, callback); + }, "name", { value: "GetIamPolicy" }); + + /** + * Calls GetIamPolicy. + * @function getIamPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.iam.v1.IGetIamPolicyRequest} request GetIamPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|setIamPolicy}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef SetIamPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.iam.v1.Policy} [response] Policy + */ + + /** + * Calls SetIamPolicy. + * @function setIamPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.iam.v1.ISetIamPolicyRequest} request SetIamPolicyRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.SetIamPolicyCallback} callback Node-style callback called with the error, if any, and Policy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.setIamPolicy = function setIamPolicy(request, callback) { + return this.rpcCall(setIamPolicy, $root.google.iam.v1.SetIamPolicyRequest, $root.google.iam.v1.Policy, request, callback); + }, "name", { value: "SetIamPolicy" }); + + /** + * Calls SetIamPolicy. + * @function setIamPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.iam.v1.ISetIamPolicyRequest} request SetIamPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.bigquery.datapolicies.v1.DataPolicyService|testIamPermissions}. + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @typedef TestIamPermissionsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.iam.v1.TestIamPermissionsResponse} [response] TestIamPermissionsResponse + */ + + /** + * Calls TestIamPermissions. + * @function testIamPermissions + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.iam.v1.ITestIamPermissionsRequest} request TestIamPermissionsRequest message or plain object + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicyService.TestIamPermissionsCallback} callback Node-style callback called with the error, if any, and TestIamPermissionsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DataPolicyService.prototype.testIamPermissions = function testIamPermissions(request, callback) { + return this.rpcCall(testIamPermissions, $root.google.iam.v1.TestIamPermissionsRequest, $root.google.iam.v1.TestIamPermissionsResponse, request, callback); + }, "name", { value: "TestIamPermissions" }); + + /** + * Calls TestIamPermissions. + * @function testIamPermissions + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicyService + * @instance + * @param {google.iam.v1.ITestIamPermissionsRequest} request TestIamPermissionsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return DataPolicyService; + })(); + + v1.CreateDataPolicyRequest = (function() { + + /** + * Properties of a CreateDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface ICreateDataPolicyRequest + * @property {string|null} [parent] CreateDataPolicyRequest parent + * @property {google.cloud.bigquery.datapolicies.v1.IDataPolicy|null} [dataPolicy] CreateDataPolicyRequest dataPolicy + */ + + /** + * Constructs a new CreateDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a CreateDataPolicyRequest. + * @implements ICreateDataPolicyRequest + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest=} [properties] Properties to set + */ + function CreateDataPolicyRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateDataPolicyRequest parent. + * @member {string} parent + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @instance + */ + CreateDataPolicyRequest.prototype.parent = ""; + + /** + * CreateDataPolicyRequest dataPolicy. + * @member {google.cloud.bigquery.datapolicies.v1.IDataPolicy|null|undefined} dataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @instance + */ + CreateDataPolicyRequest.prototype.dataPolicy = null; + + /** + * Creates a new CreateDataPolicyRequest instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest} CreateDataPolicyRequest instance + */ + CreateDataPolicyRequest.create = function create(properties) { + return new CreateDataPolicyRequest(properties); + }; + + /** + * Encodes the specified CreateDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest} message CreateDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateDataPolicyRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.dataPolicy != null && Object.hasOwnProperty.call(message, "dataPolicy")) + $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.encode(message.dataPolicy, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest} message CreateDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateDataPolicyRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateDataPolicyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest} CreateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateDataPolicyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.dataPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateDataPolicyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest} CreateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateDataPolicyRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateDataPolicyRequest message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateDataPolicyRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.dataPolicy != null && message.hasOwnProperty("dataPolicy")) { + var error = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.verify(message.dataPolicy); + if (error) + return "dataPolicy." + error; + } + return null; + }; + + /** + * Creates a CreateDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest} CreateDataPolicyRequest + */ + CreateDataPolicyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.dataPolicy != null) { + if (typeof object.dataPolicy !== "object") + throw TypeError(".google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest.dataPolicy: object expected"); + message.dataPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.fromObject(object.dataPolicy); + } + return message; + }; + + /** + * Creates a plain object from a CreateDataPolicyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest} message CreateDataPolicyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateDataPolicyRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.dataPolicy = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.dataPolicy != null && message.hasOwnProperty("dataPolicy")) + object.dataPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.toObject(message.dataPolicy, options); + return object; + }; + + /** + * Converts this CreateDataPolicyRequest to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @instance + * @returns {Object.} JSON object + */ + CreateDataPolicyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateDataPolicyRequest + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateDataPolicyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest"; + }; + + return CreateDataPolicyRequest; + })(); + + v1.UpdateDataPolicyRequest = (function() { + + /** + * Properties of an UpdateDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IUpdateDataPolicyRequest + * @property {google.cloud.bigquery.datapolicies.v1.IDataPolicy|null} [dataPolicy] UpdateDataPolicyRequest dataPolicy + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateDataPolicyRequest updateMask + */ + + /** + * Constructs a new UpdateDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents an UpdateDataPolicyRequest. + * @implements IUpdateDataPolicyRequest + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest=} [properties] Properties to set + */ + function UpdateDataPolicyRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateDataPolicyRequest dataPolicy. + * @member {google.cloud.bigquery.datapolicies.v1.IDataPolicy|null|undefined} dataPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @instance + */ + UpdateDataPolicyRequest.prototype.dataPolicy = null; + + /** + * UpdateDataPolicyRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @instance + */ + UpdateDataPolicyRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateDataPolicyRequest instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest} UpdateDataPolicyRequest instance + */ + UpdateDataPolicyRequest.create = function create(properties) { + return new UpdateDataPolicyRequest(properties); + }; + + /** + * Encodes the specified UpdateDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest} message UpdateDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateDataPolicyRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dataPolicy != null && Object.hasOwnProperty.call(message, "dataPolicy")) + $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.encode(message.dataPolicy, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest} message UpdateDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateDataPolicyRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateDataPolicyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest} UpdateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateDataPolicyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.dataPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.decode(reader, reader.uint32()); + break; + } + case 2: { + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateDataPolicyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest} UpdateDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateDataPolicyRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateDataPolicyRequest message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateDataPolicyRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dataPolicy != null && message.hasOwnProperty("dataPolicy")) { + var error = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.verify(message.dataPolicy); + if (error) + return "dataPolicy." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest} UpdateDataPolicyRequest + */ + UpdateDataPolicyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest(); + if (object.dataPolicy != null) { + if (typeof object.dataPolicy !== "object") + throw TypeError(".google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest.dataPolicy: object expected"); + message.dataPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.fromObject(object.dataPolicy); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateDataPolicyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest} message UpdateDataPolicyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateDataPolicyRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.dataPolicy = null; + object.updateMask = null; + } + if (message.dataPolicy != null && message.hasOwnProperty("dataPolicy")) + object.dataPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.toObject(message.dataPolicy, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateDataPolicyRequest to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateDataPolicyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UpdateDataPolicyRequest + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UpdateDataPolicyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest"; + }; + + return UpdateDataPolicyRequest; + })(); + + v1.RenameDataPolicyRequest = (function() { + + /** + * Properties of a RenameDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IRenameDataPolicyRequest + * @property {string|null} [name] RenameDataPolicyRequest name + * @property {string|null} [newDataPolicyId] RenameDataPolicyRequest newDataPolicyId + */ + + /** + * Constructs a new RenameDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a RenameDataPolicyRequest. + * @implements IRenameDataPolicyRequest + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest=} [properties] Properties to set + */ + function RenameDataPolicyRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RenameDataPolicyRequest name. + * @member {string} name + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @instance + */ + RenameDataPolicyRequest.prototype.name = ""; + + /** + * RenameDataPolicyRequest newDataPolicyId. + * @member {string} newDataPolicyId + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @instance + */ + RenameDataPolicyRequest.prototype.newDataPolicyId = ""; + + /** + * Creates a new RenameDataPolicyRequest instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest} RenameDataPolicyRequest instance + */ + RenameDataPolicyRequest.create = function create(properties) { + return new RenameDataPolicyRequest(properties); + }; + + /** + * Encodes the specified RenameDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest} message RenameDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RenameDataPolicyRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.newDataPolicyId != null && Object.hasOwnProperty.call(message, "newDataPolicyId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.newDataPolicyId); + return writer; + }; + + /** + * Encodes the specified RenameDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest} message RenameDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RenameDataPolicyRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RenameDataPolicyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest} RenameDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RenameDataPolicyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.newDataPolicyId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RenameDataPolicyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest} RenameDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RenameDataPolicyRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RenameDataPolicyRequest message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RenameDataPolicyRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.newDataPolicyId != null && message.hasOwnProperty("newDataPolicyId")) + if (!$util.isString(message.newDataPolicyId)) + return "newDataPolicyId: string expected"; + return null; + }; + + /** + * Creates a RenameDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest} RenameDataPolicyRequest + */ + RenameDataPolicyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.newDataPolicyId != null) + message.newDataPolicyId = String(object.newDataPolicyId); + return message; + }; + + /** + * Creates a plain object from a RenameDataPolicyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest} message RenameDataPolicyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RenameDataPolicyRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.newDataPolicyId = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.newDataPolicyId != null && message.hasOwnProperty("newDataPolicyId")) + object.newDataPolicyId = message.newDataPolicyId; + return object; + }; + + /** + * Converts this RenameDataPolicyRequest to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @instance + * @returns {Object.} JSON object + */ + RenameDataPolicyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RenameDataPolicyRequest + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RenameDataPolicyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest"; + }; + + return RenameDataPolicyRequest; + })(); + + v1.DeleteDataPolicyRequest = (function() { + + /** + * Properties of a DeleteDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IDeleteDataPolicyRequest + * @property {string|null} [name] DeleteDataPolicyRequest name + */ + + /** + * Constructs a new DeleteDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a DeleteDataPolicyRequest. + * @implements IDeleteDataPolicyRequest + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest=} [properties] Properties to set + */ + function DeleteDataPolicyRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteDataPolicyRequest name. + * @member {string} name + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @instance + */ + DeleteDataPolicyRequest.prototype.name = ""; + + /** + * Creates a new DeleteDataPolicyRequest instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest} DeleteDataPolicyRequest instance + */ + DeleteDataPolicyRequest.create = function create(properties) { + return new DeleteDataPolicyRequest(properties); + }; + + /** + * Encodes the specified DeleteDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest} message DeleteDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteDataPolicyRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified DeleteDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest} message DeleteDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteDataPolicyRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteDataPolicyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest} DeleteDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteDataPolicyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteDataPolicyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest} DeleteDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteDataPolicyRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteDataPolicyRequest message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteDataPolicyRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a DeleteDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest} DeleteDataPolicyRequest + */ + DeleteDataPolicyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteDataPolicyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest} message DeleteDataPolicyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteDataPolicyRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteDataPolicyRequest to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteDataPolicyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteDataPolicyRequest + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteDataPolicyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest"; + }; + + return DeleteDataPolicyRequest; + })(); + + v1.GetDataPolicyRequest = (function() { + + /** + * Properties of a GetDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IGetDataPolicyRequest + * @property {string|null} [name] GetDataPolicyRequest name + */ + + /** + * Constructs a new GetDataPolicyRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a GetDataPolicyRequest. + * @implements IGetDataPolicyRequest + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest=} [properties] Properties to set + */ + function GetDataPolicyRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetDataPolicyRequest name. + * @member {string} name + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @instance + */ + GetDataPolicyRequest.prototype.name = ""; + + /** + * Creates a new GetDataPolicyRequest instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest} GetDataPolicyRequest instance + */ + GetDataPolicyRequest.create = function create(properties) { + return new GetDataPolicyRequest(properties); + }; + + /** + * Encodes the specified GetDataPolicyRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest} message GetDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDataPolicyRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetDataPolicyRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest} message GetDataPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetDataPolicyRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetDataPolicyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest} GetDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDataPolicyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetDataPolicyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest} GetDataPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetDataPolicyRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetDataPolicyRequest message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetDataPolicyRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetDataPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest} GetDataPolicyRequest + */ + GetDataPolicyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetDataPolicyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest} message GetDataPolicyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetDataPolicyRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetDataPolicyRequest to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @instance + * @returns {Object.} JSON object + */ + GetDataPolicyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetDataPolicyRequest + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetDataPolicyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest"; + }; + + return GetDataPolicyRequest; + })(); + + v1.ListDataPoliciesRequest = (function() { + + /** + * Properties of a ListDataPoliciesRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IListDataPoliciesRequest + * @property {string|null} [parent] ListDataPoliciesRequest parent + * @property {number|null} [pageSize] ListDataPoliciesRequest pageSize + * @property {string|null} [pageToken] ListDataPoliciesRequest pageToken + * @property {string|null} [filter] ListDataPoliciesRequest filter + */ + + /** + * Constructs a new ListDataPoliciesRequest. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a ListDataPoliciesRequest. + * @implements IListDataPoliciesRequest + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest=} [properties] Properties to set + */ + function ListDataPoliciesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListDataPoliciesRequest parent. + * @member {string} parent + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @instance + */ + ListDataPoliciesRequest.prototype.parent = ""; + + /** + * ListDataPoliciesRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @instance + */ + ListDataPoliciesRequest.prototype.pageSize = 0; + + /** + * ListDataPoliciesRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @instance + */ + ListDataPoliciesRequest.prototype.pageToken = ""; + + /** + * ListDataPoliciesRequest filter. + * @member {string} filter + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @instance + */ + ListDataPoliciesRequest.prototype.filter = ""; + + /** + * Creates a new ListDataPoliciesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest} ListDataPoliciesRequest instance + */ + ListDataPoliciesRequest.create = function create(properties) { + return new ListDataPoliciesRequest(properties); + }; + + /** + * Encodes the specified ListDataPoliciesRequest message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest} message ListDataPoliciesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDataPoliciesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.filter); + return writer; + }; + + /** + * Encodes the specified ListDataPoliciesRequest message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest} message ListDataPoliciesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDataPoliciesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListDataPoliciesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest} ListDataPoliciesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDataPoliciesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.filter = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListDataPoliciesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest} ListDataPoliciesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDataPoliciesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListDataPoliciesRequest message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListDataPoliciesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + return null; + }; + + /** + * Creates a ListDataPoliciesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest} ListDataPoliciesRequest + */ + ListDataPoliciesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + if (object.filter != null) + message.filter = String(object.filter); + return message; + }; + + /** + * Creates a plain object from a ListDataPoliciesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest} message ListDataPoliciesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListDataPoliciesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + object.filter = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + return object; + }; + + /** + * Converts this ListDataPoliciesRequest to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @instance + * @returns {Object.} JSON object + */ + ListDataPoliciesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListDataPoliciesRequest + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListDataPoliciesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest"; + }; + + return ListDataPoliciesRequest; + })(); + + v1.ListDataPoliciesResponse = (function() { + + /** + * Properties of a ListDataPoliciesResponse. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IListDataPoliciesResponse + * @property {Array.|null} [dataPolicies] ListDataPoliciesResponse dataPolicies + * @property {string|null} [nextPageToken] ListDataPoliciesResponse nextPageToken + */ + + /** + * Constructs a new ListDataPoliciesResponse. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a ListDataPoliciesResponse. + * @implements IListDataPoliciesResponse + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse=} [properties] Properties to set + */ + function ListDataPoliciesResponse(properties) { + this.dataPolicies = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListDataPoliciesResponse dataPolicies. + * @member {Array.} dataPolicies + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @instance + */ + ListDataPoliciesResponse.prototype.dataPolicies = $util.emptyArray; + + /** + * ListDataPoliciesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @instance + */ + ListDataPoliciesResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListDataPoliciesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse} ListDataPoliciesResponse instance + */ + ListDataPoliciesResponse.create = function create(properties) { + return new ListDataPoliciesResponse(properties); + }; + + /** + * Encodes the specified ListDataPoliciesResponse message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse} message ListDataPoliciesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDataPoliciesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dataPolicies != null && message.dataPolicies.length) + for (var i = 0; i < message.dataPolicies.length; ++i) + $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.encode(message.dataPolicies[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListDataPoliciesResponse message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse} message ListDataPoliciesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListDataPoliciesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListDataPoliciesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse} ListDataPoliciesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDataPoliciesResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.dataPolicies && message.dataPolicies.length)) + message.dataPolicies = []; + message.dataPolicies.push($root.google.cloud.bigquery.datapolicies.v1.DataPolicy.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListDataPoliciesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse} ListDataPoliciesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListDataPoliciesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListDataPoliciesResponse message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListDataPoliciesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dataPolicies != null && message.hasOwnProperty("dataPolicies")) { + if (!Array.isArray(message.dataPolicies)) + return "dataPolicies: array expected"; + for (var i = 0; i < message.dataPolicies.length; ++i) { + var error = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.verify(message.dataPolicies[i]); + if (error) + return "dataPolicies." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListDataPoliciesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse} ListDataPoliciesResponse + */ + ListDataPoliciesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse(); + if (object.dataPolicies) { + if (!Array.isArray(object.dataPolicies)) + throw TypeError(".google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse.dataPolicies: array expected"); + message.dataPolicies = []; + for (var i = 0; i < object.dataPolicies.length; ++i) { + if (typeof object.dataPolicies[i] !== "object") + throw TypeError(".google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse.dataPolicies: object expected"); + message.dataPolicies[i] = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.fromObject(object.dataPolicies[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListDataPoliciesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse} message ListDataPoliciesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListDataPoliciesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.dataPolicies = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.dataPolicies && message.dataPolicies.length) { + object.dataPolicies = []; + for (var j = 0; j < message.dataPolicies.length; ++j) + object.dataPolicies[j] = $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.toObject(message.dataPolicies[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListDataPoliciesResponse to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @instance + * @returns {Object.} JSON object + */ + ListDataPoliciesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListDataPoliciesResponse + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListDataPoliciesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse"; + }; + + return ListDataPoliciesResponse; + })(); + + v1.DataPolicy = (function() { + + /** + * Properties of a DataPolicy. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IDataPolicy + * @property {string|null} [policyTag] DataPolicy policyTag + * @property {google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy|null} [dataMaskingPolicy] DataPolicy dataMaskingPolicy + * @property {string|null} [name] DataPolicy name + * @property {google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType|null} [dataPolicyType] DataPolicy dataPolicyType + * @property {string|null} [dataPolicyId] DataPolicy dataPolicyId + */ + + /** + * Constructs a new DataPolicy. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a DataPolicy. + * @implements IDataPolicy + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IDataPolicy=} [properties] Properties to set + */ + function DataPolicy(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DataPolicy policyTag. + * @member {string|null|undefined} policyTag + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + */ + DataPolicy.prototype.policyTag = null; + + /** + * DataPolicy dataMaskingPolicy. + * @member {google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy|null|undefined} dataMaskingPolicy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + */ + DataPolicy.prototype.dataMaskingPolicy = null; + + /** + * DataPolicy name. + * @member {string} name + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + */ + DataPolicy.prototype.name = ""; + + /** + * DataPolicy dataPolicyType. + * @member {google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType} dataPolicyType + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + */ + DataPolicy.prototype.dataPolicyType = 0; + + /** + * DataPolicy dataPolicyId. + * @member {string} dataPolicyId + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + */ + DataPolicy.prototype.dataPolicyId = ""; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * DataPolicy matchingLabel. + * @member {"policyTag"|undefined} matchingLabel + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + */ + Object.defineProperty(DataPolicy.prototype, "matchingLabel", { + get: $util.oneOfGetter($oneOfFields = ["policyTag"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * DataPolicy policy. + * @member {"dataMaskingPolicy"|undefined} policy + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + */ + Object.defineProperty(DataPolicy.prototype, "policy", { + get: $util.oneOfGetter($oneOfFields = ["dataMaskingPolicy"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new DataPolicy instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDataPolicy=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.DataPolicy} DataPolicy instance + */ + DataPolicy.create = function create(properties) { + return new DataPolicy(properties); + }; + + /** + * Encodes the specified DataPolicy message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataPolicy.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDataPolicy} message DataPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DataPolicy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.dataPolicyType != null && Object.hasOwnProperty.call(message, "dataPolicyType")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.dataPolicyType); + if (message.dataPolicyId != null && Object.hasOwnProperty.call(message, "dataPolicyId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.dataPolicyId); + if (message.policyTag != null && Object.hasOwnProperty.call(message, "policyTag")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.policyTag); + if (message.dataMaskingPolicy != null && Object.hasOwnProperty.call(message, "dataMaskingPolicy")) + $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.encode(message.dataMaskingPolicy, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DataPolicy message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataPolicy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDataPolicy} message DataPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DataPolicy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DataPolicy message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.DataPolicy} DataPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DataPolicy.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.DataPolicy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 4: { + message.policyTag = reader.string(); + break; + } + case 5: { + message.dataMaskingPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.decode(reader, reader.uint32()); + break; + } + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.dataPolicyType = reader.int32(); + break; + } + case 3: { + message.dataPolicyId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DataPolicy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.DataPolicy} DataPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DataPolicy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DataPolicy message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DataPolicy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.policyTag != null && message.hasOwnProperty("policyTag")) { + properties.matchingLabel = 1; + if (!$util.isString(message.policyTag)) + return "policyTag: string expected"; + } + if (message.dataMaskingPolicy != null && message.hasOwnProperty("dataMaskingPolicy")) { + properties.policy = 1; + { + var error = $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.verify(message.dataMaskingPolicy); + if (error) + return "dataMaskingPolicy." + error; + } + } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.dataPolicyType != null && message.hasOwnProperty("dataPolicyType")) + switch (message.dataPolicyType) { + default: + return "dataPolicyType: enum value expected"; + case 0: + case 3: + case 2: + break; + } + if (message.dataPolicyId != null && message.hasOwnProperty("dataPolicyId")) + if (!$util.isString(message.dataPolicyId)) + return "dataPolicyId: string expected"; + return null; + }; + + /** + * Creates a DataPolicy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.DataPolicy} DataPolicy + */ + DataPolicy.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.DataPolicy) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.DataPolicy(); + if (object.policyTag != null) + message.policyTag = String(object.policyTag); + if (object.dataMaskingPolicy != null) { + if (typeof object.dataMaskingPolicy !== "object") + throw TypeError(".google.cloud.bigquery.datapolicies.v1.DataPolicy.dataMaskingPolicy: object expected"); + message.dataMaskingPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.fromObject(object.dataMaskingPolicy); + } + if (object.name != null) + message.name = String(object.name); + switch (object.dataPolicyType) { + default: + if (typeof object.dataPolicyType === "number") { + message.dataPolicyType = object.dataPolicyType; + break; + } + break; + case "DATA_POLICY_TYPE_UNSPECIFIED": + case 0: + message.dataPolicyType = 0; + break; + case "COLUMN_LEVEL_SECURITY_POLICY": + case 3: + message.dataPolicyType = 3; + break; + case "DATA_MASKING_POLICY": + case 2: + message.dataPolicyType = 2; + break; + } + if (object.dataPolicyId != null) + message.dataPolicyId = String(object.dataPolicyId); + return message; + }; + + /** + * Creates a plain object from a DataPolicy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicy} message DataPolicy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DataPolicy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.dataPolicyType = options.enums === String ? "DATA_POLICY_TYPE_UNSPECIFIED" : 0; + object.dataPolicyId = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.dataPolicyType != null && message.hasOwnProperty("dataPolicyType")) + object.dataPolicyType = options.enums === String ? $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType[message.dataPolicyType] === undefined ? message.dataPolicyType : $root.google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType[message.dataPolicyType] : message.dataPolicyType; + if (message.dataPolicyId != null && message.hasOwnProperty("dataPolicyId")) + object.dataPolicyId = message.dataPolicyId; + if (message.policyTag != null && message.hasOwnProperty("policyTag")) { + object.policyTag = message.policyTag; + if (options.oneofs) + object.matchingLabel = "policyTag"; + } + if (message.dataMaskingPolicy != null && message.hasOwnProperty("dataMaskingPolicy")) { + object.dataMaskingPolicy = $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.toObject(message.dataMaskingPolicy, options); + if (options.oneofs) + object.policy = "dataMaskingPolicy"; + } + return object; + }; + + /** + * Converts this DataPolicy to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @instance + * @returns {Object.} JSON object + */ + DataPolicy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DataPolicy + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.DataPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DataPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.DataPolicy"; + }; + + /** + * DataPolicyType enum. + * @name google.cloud.bigquery.datapolicies.v1.DataPolicy.DataPolicyType + * @enum {number} + * @property {number} DATA_POLICY_TYPE_UNSPECIFIED=0 DATA_POLICY_TYPE_UNSPECIFIED value + * @property {number} COLUMN_LEVEL_SECURITY_POLICY=3 COLUMN_LEVEL_SECURITY_POLICY value + * @property {number} DATA_MASKING_POLICY=2 DATA_MASKING_POLICY value + */ + DataPolicy.DataPolicyType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DATA_POLICY_TYPE_UNSPECIFIED"] = 0; + values[valuesById[3] = "COLUMN_LEVEL_SECURITY_POLICY"] = 3; + values[valuesById[2] = "DATA_MASKING_POLICY"] = 2; + return values; + })(); + + return DataPolicy; + })(); + + v1.DataMaskingPolicy = (function() { + + /** + * Properties of a DataMaskingPolicy. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @interface IDataMaskingPolicy + * @property {google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression|null} [predefinedExpression] DataMaskingPolicy predefinedExpression + */ + + /** + * Constructs a new DataMaskingPolicy. + * @memberof google.cloud.bigquery.datapolicies.v1 + * @classdesc Represents a DataMaskingPolicy. + * @implements IDataMaskingPolicy + * @constructor + * @param {google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy=} [properties] Properties to set + */ + function DataMaskingPolicy(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DataMaskingPolicy predefinedExpression. + * @member {google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression|null|undefined} predefinedExpression + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @instance + */ + DataMaskingPolicy.prototype.predefinedExpression = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * DataMaskingPolicy maskingExpression. + * @member {"predefinedExpression"|undefined} maskingExpression + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @instance + */ + Object.defineProperty(DataMaskingPolicy.prototype, "maskingExpression", { + get: $util.oneOfGetter($oneOfFields = ["predefinedExpression"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new DataMaskingPolicy instance using the specified properties. + * @function create + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy=} [properties] Properties to set + * @returns {google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy} DataMaskingPolicy instance + */ + DataMaskingPolicy.create = function create(properties) { + return new DataMaskingPolicy(properties); + }; + + /** + * Encodes the specified DataMaskingPolicy message. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.verify|verify} messages. + * @function encode + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy} message DataMaskingPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DataMaskingPolicy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.predefinedExpression != null && Object.hasOwnProperty.call(message, "predefinedExpression")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.predefinedExpression); + return writer; + }; + + /** + * Encodes the specified DataMaskingPolicy message, length delimited. Does not implicitly {@link google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.IDataMaskingPolicy} message DataMaskingPolicy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DataMaskingPolicy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DataMaskingPolicy message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy} DataMaskingPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DataMaskingPolicy.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.predefinedExpression = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DataMaskingPolicy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy} DataMaskingPolicy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DataMaskingPolicy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DataMaskingPolicy message. + * @function verify + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DataMaskingPolicy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.predefinedExpression != null && message.hasOwnProperty("predefinedExpression")) { + properties.maskingExpression = 1; + switch (message.predefinedExpression) { + default: + return "predefinedExpression: enum value expected"; + case 0: + case 3: + case 5: + case 7: + break; + } + } + return null; + }; + + /** + * Creates a DataMaskingPolicy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy} DataMaskingPolicy + */ + DataMaskingPolicy.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy) + return object; + var message = new $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy(); + switch (object.predefinedExpression) { + default: + if (typeof object.predefinedExpression === "number") { + message.predefinedExpression = object.predefinedExpression; + break; + } + break; + case "PREDEFINED_EXPRESSION_UNSPECIFIED": + case 0: + message.predefinedExpression = 0; + break; + case "SHA256": + case 3: + message.predefinedExpression = 3; + break; + case "ALWAYS_NULL": + case 5: + message.predefinedExpression = 5; + break; + case "DEFAULT_MASKING_VALUE": + case 7: + message.predefinedExpression = 7; + break; + } + return message; + }; + + /** + * Creates a plain object from a DataMaskingPolicy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy} message DataMaskingPolicy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DataMaskingPolicy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.predefinedExpression != null && message.hasOwnProperty("predefinedExpression")) { + object.predefinedExpression = options.enums === String ? $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression[message.predefinedExpression] === undefined ? message.predefinedExpression : $root.google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression[message.predefinedExpression] : message.predefinedExpression; + if (options.oneofs) + object.maskingExpression = "predefinedExpression"; + } + return object; + }; + + /** + * Converts this DataMaskingPolicy to JSON. + * @function toJSON + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @instance + * @returns {Object.} JSON object + */ + DataMaskingPolicy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DataMaskingPolicy + * @function getTypeUrl + * @memberof google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DataMaskingPolicy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy"; + }; + + /** + * PredefinedExpression enum. + * @name google.cloud.bigquery.datapolicies.v1.DataMaskingPolicy.PredefinedExpression + * @enum {number} + * @property {number} PREDEFINED_EXPRESSION_UNSPECIFIED=0 PREDEFINED_EXPRESSION_UNSPECIFIED value + * @property {number} SHA256=3 SHA256 value + * @property {number} ALWAYS_NULL=5 ALWAYS_NULL value + * @property {number} DEFAULT_MASKING_VALUE=7 DEFAULT_MASKING_VALUE value + */ + DataMaskingPolicy.PredefinedExpression = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "PREDEFINED_EXPRESSION_UNSPECIFIED"] = 0; + values[valuesById[3] = "SHA256"] = 3; + values[valuesById[5] = "ALWAYS_NULL"] = 5; + values[valuesById[7] = "DEFAULT_MASKING_VALUE"] = 7; + return values; + })(); + + return DataMaskingPolicy; + })(); + + return v1; + })(); + datapolicies.v1beta1 = (function() { /** diff --git a/packages/google-cloud-bigquery-datapolicies/protos/protos.json b/packages/google-cloud-bigquery-datapolicies/protos/protos.json index d946eec2d46..e36f69c175e 100644 --- a/packages/google-cloud-bigquery-datapolicies/protos/protos.json +++ b/packages/google-cloud-bigquery-datapolicies/protos/protos.json @@ -8,6 +8,379 @@ "nested": { "datapolicies": { "nested": { + "v1": { + "options": { + "csharp_namespace": "Google.Cloud.BigQuery.DataPolicies.V1", + "go_package": "google.golang.org/genproto/googleapis/cloud/bigquery/datapolicies/v1;datapolicies", + "java_multiple_files": true, + "java_outer_classname": "DataPolicyProto", + "java_package": "com.google.cloud.bigquery.datapolicies.v1", + "php_namespace": "Google\\Cloud\\BigQuery\\DataPolicies\\V1", + "ruby_package": "Google::Cloud::Bigquery::DataPolicies::V1" + }, + "nested": { + "DataPolicyService": { + "options": { + "(google.api.default_host)": "bigquerydatapolicy.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/bigquery,https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreateDataPolicy": { + "requestType": "CreateDataPolicyRequest", + "responseType": "DataPolicy", + "options": { + "(google.api.http).post": "/v1/{parent=projects/*/locations/*}/dataPolicies", + "(google.api.http).body": "data_policy", + "(google.api.method_signature)": "parent,data_policy" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=projects/*/locations/*}/dataPolicies", + "body": "data_policy" + } + }, + { + "(google.api.method_signature)": "parent,data_policy" + } + ] + }, + "UpdateDataPolicy": { + "requestType": "UpdateDataPolicyRequest", + "responseType": "DataPolicy", + "options": { + "(google.api.http).patch": "/v1/{data_policy.name=projects/*/locations/*/dataPolicies/*}", + "(google.api.http).body": "data_policy", + "(google.api.method_signature)": "data_policy,update_mask" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1/{data_policy.name=projects/*/locations/*/dataPolicies/*}", + "body": "data_policy" + } + }, + { + "(google.api.method_signature)": "data_policy,update_mask" + } + ] + }, + "RenameDataPolicy": { + "requestType": "RenameDataPolicyRequest", + "responseType": "DataPolicy", + "options": { + "(google.api.http).post": "/v1/{name=projects/*/locations/*/dataPolicies/*}:rename", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name,new_data_policy_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=projects/*/locations/*/dataPolicies/*}:rename", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name,new_data_policy_id" + } + ] + }, + "DeleteDataPolicy": { + "requestType": "DeleteDataPolicyRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{name=projects/*/locations/*/dataPolicies/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=projects/*/locations/*/dataPolicies/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "GetDataPolicy": { + "requestType": "GetDataPolicyRequest", + "responseType": "DataPolicy", + "options": { + "(google.api.http).get": "/v1/{name=projects/*/locations/*/dataPolicies/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=projects/*/locations/*/dataPolicies/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListDataPolicies": { + "requestType": "ListDataPoliciesRequest", + "responseType": "ListDataPoliciesResponse", + "options": { + "(google.api.http).get": "/v1/{parent=projects/*/locations/*}/dataPolicies", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{parent=projects/*/locations/*}/dataPolicies" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "GetIamPolicy": { + "requestType": "google.iam.v1.GetIamPolicyRequest", + "responseType": "google.iam.v1.Policy", + "options": { + "(google.api.http).post": "/v1/{resource=projects/*/locations/*/dataPolicies/*}:getIamPolicy", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{resource=projects/*/locations/*/dataPolicies/*}:getIamPolicy", + "body": "*" + } + } + ] + }, + "SetIamPolicy": { + "requestType": "google.iam.v1.SetIamPolicyRequest", + "responseType": "google.iam.v1.Policy", + "options": { + "(google.api.http).post": "/v1/{resource=projects/*/locations/*/dataPolicies/*}:setIamPolicy", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{resource=projects/*/locations/*/dataPolicies/*}:setIamPolicy", + "body": "*" + } + } + ] + }, + "TestIamPermissions": { + "requestType": "google.iam.v1.TestIamPermissionsRequest", + "responseType": "google.iam.v1.TestIamPermissionsResponse", + "options": { + "(google.api.http).post": "/v1/{resource=projects/*/locations/*/dataPolicies/*}:testIamPermissions", + "(google.api.http).body": "*" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{resource=projects/*/locations/*/dataPolicies/*}:testIamPermissions", + "body": "*" + } + } + ] + } + } + }, + "CreateDataPolicyRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "bigquerydatapolicy.googleapis.com/DataPolicy" + } + }, + "dataPolicy": { + "type": "DataPolicy", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateDataPolicyRequest": { + "fields": { + "dataPolicy": { + "type": "DataPolicy", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "RenameDataPolicyRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "newDataPolicyId": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "DeleteDataPolicyRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "bigquerydatapolicy.googleapis.com/DataPolicy" + } + } + } + }, + "GetDataPolicyRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "bigquerydatapolicy.googleapis.com/DataPolicy" + } + } + } + }, + "ListDataPoliciesRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "bigquerydatapolicy.googleapis.com/DataPolicy" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + }, + "filter": { + "type": "string", + "id": 4 + } + } + }, + "ListDataPoliciesResponse": { + "fields": { + "dataPolicies": { + "rule": "repeated", + "type": "DataPolicy", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "DataPolicy": { + "options": { + "(google.api.resource).type": "bigquerydatapolicy.googleapis.com/DataPolicy", + "(google.api.resource).pattern": "projects/{project}/locations/{location}/dataPolicies/{data_policy}" + }, + "oneofs": { + "matchingLabel": { + "oneof": [ + "policyTag" + ] + }, + "policy": { + "oneof": [ + "dataMaskingPolicy" + ] + } + }, + "fields": { + "policyTag": { + "type": "string", + "id": 4 + }, + "dataMaskingPolicy": { + "type": "DataMaskingPolicy", + "id": 5 + }, + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "dataPolicyType": { + "type": "DataPolicyType", + "id": 2 + }, + "dataPolicyId": { + "type": "string", + "id": 3 + } + }, + "nested": { + "DataPolicyType": { + "values": { + "DATA_POLICY_TYPE_UNSPECIFIED": 0, + "COLUMN_LEVEL_SECURITY_POLICY": 3, + "DATA_MASKING_POLICY": 2 + } + } + } + }, + "DataMaskingPolicy": { + "oneofs": { + "maskingExpression": { + "oneof": [ + "predefinedExpression" + ] + } + }, + "fields": { + "predefinedExpression": { + "type": "PredefinedExpression", + "id": 1 + } + }, + "nested": { + "PredefinedExpression": { + "values": { + "PREDEFINED_EXPRESSION_UNSPECIFIED": 0, + "SHA256": 3, + "ALWAYS_NULL": 5, + "DEFAULT_MASKING_VALUE": 7 + } + } + } + } + } + }, "v1beta1": { "options": { "csharp_namespace": "Google.Cloud.BigQuery.DataPolicies.V1Beta1", diff --git a/packages/google-cloud-bigquery-datapolicies/samples/README.md b/packages/google-cloud-bigquery-datapolicies/samples/README.md index 723ffa5c7c6..7567e0c6d69 100644 --- a/packages/google-cloud-bigquery-datapolicies/samples/README.md +++ b/packages/google-cloud-bigquery-datapolicies/samples/README.md @@ -12,6 +12,15 @@ * [Before you begin](#before-you-begin) * [Samples](#samples) + * [Data_policy_service.create_data_policy](#data_policy_service.create_data_policy) + * [Data_policy_service.delete_data_policy](#data_policy_service.delete_data_policy) + * [Data_policy_service.get_data_policy](#data_policy_service.get_data_policy) + * [Data_policy_service.get_iam_policy](#data_policy_service.get_iam_policy) + * [Data_policy_service.list_data_policies](#data_policy_service.list_data_policies) + * [Data_policy_service.rename_data_policy](#data_policy_service.rename_data_policy) + * [Data_policy_service.set_iam_policy](#data_policy_service.set_iam_policy) + * [Data_policy_service.test_iam_permissions](#data_policy_service.test_iam_permissions) + * [Data_policy_service.update_data_policy](#data_policy_service.update_data_policy) * [Data_policy_service.create_data_policy](#data_policy_service.create_data_policy) * [Data_policy_service.delete_data_policy](#data_policy_service.delete_data_policy) * [Data_policy_service.get_data_policy](#data_policy_service.get_data_policy) @@ -38,6 +47,159 @@ Before running the samples, make sure you've followed the steps outlined in +### Data_policy_service.create_data_policy + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js` + + +----- + + + + +### Data_policy_service.delete_data_policy + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js` + + +----- + + + + +### Data_policy_service.get_data_policy + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js` + + +----- + + + + +### Data_policy_service.get_iam_policy + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js` + + +----- + + + + +### Data_policy_service.list_data_policies + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js` + + +----- + + + + +### Data_policy_service.rename_data_policy + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js` + + +----- + + + + +### Data_policy_service.set_iam_policy + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js` + + +----- + + + + +### Data_policy_service.test_iam_permissions + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js` + + +----- + + + + +### Data_policy_service.update_data_policy + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js` + + +----- + + + + ### Data_policy_service.create_data_policy View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-bigquery-datapolicies/samples/generated/v1beta1/data_policy_service.create_data_policy.js). diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js new file mode 100644 index 00000000000..1e8300ae4f1 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.create_data_policy.js @@ -0,0 +1,68 @@ +// 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, dataPolicy) { + // [START bigquerydatapolicy_v1_generated_DataPolicyService_CreateDataPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the project that the data policy will belong to. + * The format is `projects/{project_number}/locations/{location_id}`. + */ + // const parent = 'abc123' + /** + * Required. The data policy to create. The `name` field does not need to be + * provided for the data policy creation. + */ + // const dataPolicy = {} + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callCreateDataPolicy() { + // Construct request + const request = { + parent, + dataPolicy, + }; + + // Run request + const response = await datapoliciesClient.createDataPolicy(request); + console.log(response); + } + + callCreateDataPolicy(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_CreateDataPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js new file mode 100644 index 00000000000..bfae7b78a07 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.delete_data_policy.js @@ -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 bigquerydatapolicy_v1_generated_DataPolicyService_DeleteDataPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the data policy to delete. Format is + * `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. + */ + // const name = 'abc123' + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callDeleteDataPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datapoliciesClient.deleteDataPolicy(request); + console.log(response); + } + + callDeleteDataPolicy(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_DeleteDataPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js new file mode 100644 index 00000000000..3460963686e --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_data_policy.js @@ -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 bigquerydatapolicy_v1_generated_DataPolicyService_GetDataPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the requested data policy. Format is + * `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. + */ + // const name = 'abc123' + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callGetDataPolicy() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await datapoliciesClient.getDataPolicy(request); + console.log(response); + } + + callGetDataPolicy(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_GetDataPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js new file mode 100644 index 00000000000..84533025be7 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.get_iam_policy.js @@ -0,0 +1,67 @@ +// 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(resource) { + // [START bigquerydatapolicy_v1_generated_DataPolicyService_GetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await datapoliciesClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js new file mode 100644 index 00000000000..f96591c6b47 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.list_data_policies.js @@ -0,0 +1,85 @@ +// 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) { + // [START bigquerydatapolicy_v1_generated_DataPolicyService_ListDataPolicies_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the project for which to list data policies. + * Format is `projects/{project_number}/locations/{location_id}`. + */ + // const parent = 'abc123' + /** + * The maximum number of data policies to return. Must be a value between 1 + * and 1000. + * If not set, defaults to 50. + */ + // const pageSize = 1234 + /** + * The `nextPageToken` value returned from a previous list request, if any. If + * not set, defaults to an empty string. + */ + // const pageToken = 'abc123' + /** + * Filters the data policies by policy tags that they + * are associated with. Currently filter only supports + * "policy_tag" based filtering and OR based predicates. Sample + * filter can be "policy_tag: + * `'projects/1/locations/us/taxonomies/2/policyTags/3'`". You may use + * wildcard such as "policy_tag: + * `'projects/1/locations/us/taxonomies/2/*'`". + */ + // const filter = 'abc123' + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callListDataPolicies() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await datapoliciesClient.listDataPoliciesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDataPolicies(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_ListDataPolicies_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js new file mode 100644 index 00000000000..af2892b048a --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.rename_data_policy.js @@ -0,0 +1,67 @@ +// 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, newDataPolicyId) { + // [START bigquerydatapolicy_v1_generated_DataPolicyService_RenameDataPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name of the data policy to rename. The format is + * `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}` + */ + // const name = 'abc123' + /** + * Required. The new data policy id. + */ + // const newDataPolicyId = 'abc123' + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callRenameDataPolicy() { + // Construct request + const request = { + name, + newDataPolicyId, + }; + + // Run request + const response = await datapoliciesClient.renameDataPolicy(request); + console.log(response); + } + + callRenameDataPolicy(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_RenameDataPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js new file mode 100644 index 00000000000..7cfda4aa49b --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.set_iam_policy.js @@ -0,0 +1,77 @@ +// 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(resource, policy) { + // [START bigquerydatapolicy_v1_generated_DataPolicyService_SetIamPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await datapoliciesClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js new file mode 100644 index 00000000000..49d6f841c1d --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.test_iam_permissions.js @@ -0,0 +1,70 @@ +// 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(resource, permissions) { + // [START bigquerydatapolicy_v1_generated_DataPolicyService_TestIamPermissions_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await datapoliciesClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js new file mode 100644 index 00000000000..a459efd1583 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/data_policy_service.update_data_policy.js @@ -0,0 +1,71 @@ +// 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(dataPolicy) { + // [START bigquerydatapolicy_v1_generated_DataPolicyService_UpdateDataPolicy_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Update the data policy's metadata. + * The target data policy is determined by the `name` field. + * Other fields are updated to the specified values based on the field masks. + */ + // const dataPolicy = {} + /** + * The update mask applies to the resource. For the `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * If not set, defaults to all of the fields that are allowed to update. + * Updates to the `name` and `dataPolicyId` fields are not allowed. + */ + // const updateMask = {} + + // Imports the Datapolicies library + const {DataPolicyServiceClient} = require('@google-cloud/datapolicies').v1; + + // Instantiates a client + const datapoliciesClient = new DataPolicyServiceClient(); + + async function callUpdateDataPolicy() { + // Construct request + const request = { + dataPolicy, + }; + + // Run request + const response = await datapoliciesClient.updateDataPolicy(request); + console.log(response); + } + + callUpdateDataPolicy(); + // [END bigquerydatapolicy_v1_generated_DataPolicyService_UpdateDataPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datapolicies.v1.json b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datapolicies.v1.json new file mode 100644 index 00000000000..1ebb10a73c9 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datapolicies.v1.json @@ -0,0 +1,415 @@ +{ + "clientLibrary": { + "name": "nodejs-datapolicies", + "version": "0.1.2", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.bigquery.datapolicies.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_CreateDataPolicy_async", + "title": "DataPolicyService createDataPolicy Sample", + "origin": "API_DEFINITION", + "description": " Creates a new data policy under a project with the given `dataPolicyId` (used as the display name), policy tag, and data policy type.", + "canonical": true, + "file": "data_policy_service.create_data_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.CreateDataPolicy", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "data_policy", + "type": ".google.cloud.bigquery.datapolicies.v1.DataPolicy" + } + ], + "resultType": ".google.cloud.bigquery.datapolicies.v1.DataPolicy", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "CreateDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.CreateDataPolicy", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_UpdateDataPolicy_async", + "title": "DataPolicyService updateDataPolicy Sample", + "origin": "API_DEFINITION", + "description": " Updates the metadata for an existing data policy. The target data policy can be specified by the resource name.", + "canonical": true, + "file": "data_policy_service.update_data_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.UpdateDataPolicy", + "async": true, + "parameters": [ + { + "name": "data_policy", + "type": ".google.cloud.bigquery.datapolicies.v1.DataPolicy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.bigquery.datapolicies.v1.DataPolicy", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "UpdateDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.UpdateDataPolicy", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_RenameDataPolicy_async", + "title": "DataPolicyService renameDataPolicy Sample", + "origin": "API_DEFINITION", + "description": " Renames the id (display name) of the specified data policy.", + "canonical": true, + "file": "data_policy_service.rename_data_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RenameDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.RenameDataPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "new_data_policy_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.bigquery.datapolicies.v1.DataPolicy", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "RenameDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.RenameDataPolicy", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_DeleteDataPolicy_async", + "title": "DataPolicyService deleteDataPolicy Sample", + "origin": "API_DEFINITION", + "description": " Deletes the data policy specified by its resource name.", + "canonical": true, + "file": "data_policy_service.delete_data_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.DeleteDataPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "DeleteDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.DeleteDataPolicy", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_GetDataPolicy_async", + "title": "DataPolicyService getDataPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the data policy specified by its resource name.", + "canonical": true, + "file": "data_policy_service.get_data_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetDataPolicy", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.bigquery.datapolicies.v1.DataPolicy", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "GetDataPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetDataPolicy", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_ListDataPolicies_async", + "title": "DataPolicyService listDataPolicies Sample", + "origin": "API_DEFINITION", + "description": " List all of the data policies in the specified parent project.", + "canonical": true, + "file": "data_policy_service.list_data_policies.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 77, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDataPolicies", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.ListDataPolicies", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.bigquery.datapolicies.v1.ListDataPoliciesResponse", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "ListDataPolicies", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.ListDataPolicies", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_GetIamPolicy_async", + "title": "DataPolicyService getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the IAM policy for the specified data policy.", + "canonical": true, + "file": "data_policy_service.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.GetIamPolicy", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_SetIamPolicy_async", + "title": "DataPolicyService setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the IAM policy for the specified data policy.", + "canonical": true, + "file": "data_policy_service.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.SetIamPolicy", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + }, + { + "regionTag": "bigquerydatapolicy_v1_generated_DataPolicyService_TestIamPermissions_async", + "title": "DataPolicyService testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns the caller's permission on the specified data policy resource.", + "canonical": true, + "file": "data_policy_service.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "DataPolicyServiceClient", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyServiceClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService.TestIamPermissions", + "service": { + "shortName": "DataPolicyService", + "fullName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService" + } + } + } + } + ] +} \ No newline at end of file diff --git a/packages/google-cloud-bigquery-datapolicies/src/index.ts b/packages/google-cloud-bigquery-datapolicies/src/index.ts index f169154e1d0..b99d8b6433e 100644 --- a/packages/google-cloud-bigquery-datapolicies/src/index.ts +++ b/packages/google-cloud-bigquery-datapolicies/src/index.ts @@ -16,12 +16,13 @@ // ** https://github.com/googleapis/synthtool ** // ** All changes to this file may be overwritten. ** +import * as v1 from './v1'; import * as v1beta1 from './v1beta1'; const DataPolicyServiceClient = v1beta1.DataPolicyServiceClient; type DataPolicyServiceClient = v1beta1.DataPolicyServiceClient; -export {v1beta1, DataPolicyServiceClient}; -export default {v1beta1, DataPolicyServiceClient}; +export {v1, v1beta1, DataPolicyServiceClient}; +export default {v1, v1beta1, DataPolicyServiceClient}; import * as protos from '../protos/protos'; export {protos}; diff --git a/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_client.ts b/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_client.ts new file mode 100644 index 00000000000..821691f125b --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_client.ts @@ -0,0 +1,1482 @@ +// 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. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/data_policy_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './data_policy_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Data Policy Service provides APIs for managing the label-policy bindings. + * @class + * @memberof v1 + */ +export class DataPolicyServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + dataPolicyServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DataPolicyServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new DataPolicyServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DataPolicyServiceClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest') { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + dataPolicyPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/dataPolicies/{data_policy}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listDataPolicies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'dataPolicies' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.bigquery.datapolicies.v1.DataPolicyService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.dataPolicyServiceStub) { + return this.dataPolicyServiceStub; + } + + // Put together the "service stub" for + // google.cloud.bigquery.datapolicies.v1.DataPolicyService. + this.dataPolicyServiceStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.bigquery.datapolicies.v1.DataPolicyService' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.bigquery.datapolicies.v1 + .DataPolicyService, + this._opts, + this._providedCustomServicePath + ) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const dataPolicyServiceStubMethods = [ + 'createDataPolicy', + 'updateDataPolicy', + 'renameDataPolicy', + 'deleteDataPolicy', + 'getDataPolicy', + 'listDataPolicies', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + ]; + for (const methodName of dataPolicyServiceStubMethods) { + const callPromise = this.dataPolicyServiceStub.then( + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { + throw err; + } + ); + + const descriptor = this.descriptors.page[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.dataPolicyServiceStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'bigquerydatapolicy.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'bigquerydatapolicy.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/bigquery', + 'https://www.googleapis.com/auth/cloud-platform', + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId( + callback?: Callback + ): Promise | void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + /** + * Creates a new data policy under a project with the given `dataPolicyId` + * (used as the display name), policy tag, and data policy type. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project that the data policy will belong to. + * The format is `projects/{project_number}/locations/{location_id}`. + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicy} request.dataPolicy + * Required. The data policy to create. The `name` field does not need to be + * provided for the data policy creation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DataPolicy]{@link google.cloud.bigquery.datapolicies.v1.DataPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.create_data_policy.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_CreateDataPolicy_async + */ + createDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest + | undefined + ), + {} | undefined + ] + >; + createDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.ICreateDataPolicyRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createDataPolicy(request, options, callback); + } + /** + * Updates the metadata for an existing data policy. The target data policy + * can be specified by the resource name. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.bigquery.datapolicies.v1.DataPolicy} request.dataPolicy + * Required. Update the data policy's metadata. + * + * The target data policy is determined by the `name` field. + * Other fields are updated to the specified values based on the field masks. + * @param {google.protobuf.FieldMask} request.updateMask + * The update mask applies to the resource. For the `FieldMask` definition, + * see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * If not set, defaults to all of the fields that are allowed to update. + * + * Updates to the `name` and `dataPolicyId` fields are not allowed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DataPolicy]{@link google.cloud.bigquery.datapolicies.v1.DataPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.update_data_policy.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_UpdateDataPolicy_async + */ + updateDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest + | undefined + ), + {} | undefined + ] + >; + updateDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IUpdateDataPolicyRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'data_policy.name': request.dataPolicy!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateDataPolicy(request, options, callback); + } + /** + * Renames the id (display name) of the specified data policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the data policy to rename. The format is + * `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}` + * @param {string} request.newDataPolicyId + * Required. The new data policy id. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DataPolicy]{@link google.cloud.bigquery.datapolicies.v1.DataPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.rename_data_policy.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_RenameDataPolicy_async + */ + renameDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest + | undefined + ), + {} | undefined + ] + >; + renameDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + renameDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + renameDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IRenameDataPolicyRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.renameDataPolicy(request, options, callback); + } + /** + * Deletes the data policy specified by its resource name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the data policy to delete. Format is + * `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.delete_data_policy.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_DeleteDataPolicy_async + */ + deleteDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest + | undefined + ), + {} | undefined + ] + >; + deleteDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IDeleteDataPolicyRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteDataPolicy(request, options, callback); + } + /** + * Gets the data policy specified by its resource name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name of the requested data policy. Format is + * `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DataPolicy]{@link google.cloud.bigquery.datapolicies.v1.DataPolicy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.get_data_policy.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_GetDataPolicy_async + */ + getDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest + | undefined + ), + {} | undefined + ] + >; + getDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getDataPolicy( + request: protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest, + callback: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getDataPolicy( + request?: protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + | protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy, + ( + | protos.google.cloud.bigquery.datapolicies.v1.IGetDataPolicyRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDataPolicy(request, options, callback); + } + /** + * Gets the IAM policy for the specified data policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.get_iam_policy.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined + ] + >; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } + /** + * Sets the IAM policy for the specified data policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.set_iam_policy.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined + ] + >; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } + /** + * Returns the caller's permission on the specified data policy resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.test_iam_permissions.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined + ] + >; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + resource: request.resource ?? '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * List all of the data policies in the specified parent project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project for which to list data policies. + * Format is `projects/{project_number}/locations/{location_id}`. + * @param {number} request.pageSize + * The maximum number of data policies to return. Must be a value between 1 + * and 1000. + * If not set, defaults to 50. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous list request, if any. If + * not set, defaults to an empty string. + * @param {string} request.filter + * Filters the data policies by policy tags that they + * are associated with. Currently filter only supports + * "policy_tag" based filtering and OR based predicates. Sample + * filter can be "policy_tag: + * `'projects/1/locations/us/taxonomies/2/policyTags/3'`". You may use + * wildcard such as "policy_tag: + * `'projects/1/locations/us/taxonomies/2/*'`". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [DataPolicy]{@link google.cloud.bigquery.datapolicies.v1.DataPolicy}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDataPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDataPolicies( + request?: protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy[], + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest | null, + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse + ] + >; + listDataPolicies( + request: protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + | protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse + | null + | undefined, + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy + > + ): void; + listDataPolicies( + request: protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + callback: PaginationCallback< + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + | protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse + | null + | undefined, + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy + > + ): void; + listDataPolicies( + request?: protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + | protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse + | null + | undefined, + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy + >, + callback?: PaginationCallback< + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + | protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse + | null + | undefined, + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy + > + ): Promise< + [ + protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy[], + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest | null, + protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listDataPolicies(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project for which to list data policies. + * Format is `projects/{project_number}/locations/{location_id}`. + * @param {number} request.pageSize + * The maximum number of data policies to return. Must be a value between 1 + * and 1000. + * If not set, defaults to 50. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous list request, if any. If + * not set, defaults to an empty string. + * @param {string} request.filter + * Filters the data policies by policy tags that they + * are associated with. Currently filter only supports + * "policy_tag" based filtering and OR based predicates. Sample + * filter can be "policy_tag: + * `'projects/1/locations/us/taxonomies/2/policyTags/3'`". You may use + * wildcard such as "policy_tag: + * `'projects/1/locations/us/taxonomies/2/*'`". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [DataPolicy]{@link google.cloud.bigquery.datapolicies.v1.DataPolicy} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDataPoliciesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDataPoliciesStream( + request?: protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDataPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDataPolicies.createStream( + this.innerApiCalls.listDataPolicies as GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listDataPolicies`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project for which to list data policies. + * Format is `projects/{project_number}/locations/{location_id}`. + * @param {number} request.pageSize + * The maximum number of data policies to return. Must be a value between 1 + * and 1000. + * If not set, defaults to 50. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous list request, if any. If + * not set, defaults to an empty string. + * @param {string} request.filter + * Filters the data policies by policy tags that they + * are associated with. Currently filter only supports + * "policy_tag" based filtering and OR based predicates. Sample + * filter can be "policy_tag: + * `'projects/1/locations/us/taxonomies/2/policyTags/3'`". You may use + * wildcard such as "policy_tag: + * `'projects/1/locations/us/taxonomies/2/*'`". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [DataPolicy]{@link google.cloud.bigquery.datapolicies.v1.DataPolicy}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/data_policy_service.list_data_policies.js + * region_tag:bigquerydatapolicy_v1_generated_DataPolicyService_ListDataPolicies_async + */ + listDataPoliciesAsync( + request?: protos.google.cloud.bigquery.datapolicies.v1.IListDataPoliciesRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listDataPolicies']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDataPolicies.asyncIterate( + this.innerApiCalls['listDataPolicies'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified dataPolicy resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} data_policy + * @returns {string} Resource name string. + */ + dataPolicyPath(project: string, location: string, dataPolicy: string) { + return this.pathTemplates.dataPolicyPathTemplate.render({ + project: project, + location: location, + data_policy: dataPolicy, + }); + } + + /** + * Parse the project from DataPolicy resource. + * + * @param {string} dataPolicyName + * A fully-qualified path representing DataPolicy resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDataPolicyName(dataPolicyName: string) { + return this.pathTemplates.dataPolicyPathTemplate.match(dataPolicyName) + .project; + } + + /** + * Parse the location from DataPolicy resource. + * + * @param {string} dataPolicyName + * A fully-qualified path representing DataPolicy resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDataPolicyName(dataPolicyName: string) { + return this.pathTemplates.dataPolicyPathTemplate.match(dataPolicyName) + .location; + } + + /** + * Parse the data_policy from DataPolicy resource. + * + * @param {string} dataPolicyName + * A fully-qualified path representing DataPolicy resource. + * @returns {string} A string representing the data_policy. + */ + matchDataPolicyFromDataPolicyName(dataPolicyName: string) { + return this.pathTemplates.dataPolicyPathTemplate.match(dataPolicyName) + .data_policy; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project: string, location: string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project: string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.dataPolicyServiceStub && !this._terminated) { + return this.dataPolicyServiceStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_client_config.json b/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_client_config.json new file mode 100644 index 00000000000..a9942095e60 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_client_config.json @@ -0,0 +1,83 @@ +{ + "interfaces": { + "google.cloud.bigquery.datapolicies.v1.DataPolicyService": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "ce5b960a6ed052e690863808e4f0deff3dc7d49f": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateDataPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "UpdateDataPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "RenameDataPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "DeleteDataPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetDataPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "ListDataPolicies": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "TestIamPermissions": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + } + } + } + } +} diff --git a/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_proto_list.json b/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_proto_list.json new file mode 100644 index 00000000000..3a4a27a5092 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/src/v1/data_policy_service_proto_list.json @@ -0,0 +1,3 @@ +[ + "../../protos/google/cloud/bigquery/datapolicies/v1/datapolicy.proto" +] diff --git a/packages/google-cloud-bigquery-datapolicies/src/v1/gapic_metadata.json b/packages/google-cloud-bigquery-datapolicies/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..957e44d2537 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/src/v1/gapic_metadata.json @@ -0,0 +1,117 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.bigquery.datapolicies.v1", + "libraryPackage": "@google-cloud/datapolicies", + "services": { + "DataPolicyService": { + "clients": { + "grpc": { + "libraryClient": "DataPolicyServiceClient", + "rpcs": { + "CreateDataPolicy": { + "methods": [ + "createDataPolicy" + ] + }, + "UpdateDataPolicy": { + "methods": [ + "updateDataPolicy" + ] + }, + "RenameDataPolicy": { + "methods": [ + "renameDataPolicy" + ] + }, + "DeleteDataPolicy": { + "methods": [ + "deleteDataPolicy" + ] + }, + "GetDataPolicy": { + "methods": [ + "getDataPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "ListDataPolicies": { + "methods": [ + "listDataPolicies", + "listDataPoliciesStream", + "listDataPoliciesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DataPolicyServiceClient", + "rpcs": { + "CreateDataPolicy": { + "methods": [ + "createDataPolicy" + ] + }, + "UpdateDataPolicy": { + "methods": [ + "updateDataPolicy" + ] + }, + "RenameDataPolicy": { + "methods": [ + "renameDataPolicy" + ] + }, + "DeleteDataPolicy": { + "methods": [ + "deleteDataPolicy" + ] + }, + "GetDataPolicy": { + "methods": [ + "getDataPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "ListDataPolicies": { + "methods": [ + "listDataPolicies", + "listDataPoliciesStream", + "listDataPoliciesAsync" + ] + } + } + } + } + } + } +} diff --git a/packages/google-cloud-bigquery-datapolicies/src/v1/index.ts b/packages/google-cloud-bigquery-datapolicies/src/v1/index.ts new file mode 100644 index 00000000000..81030a61690 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/src/v1/index.ts @@ -0,0 +1,19 @@ +// 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. ** + +export {DataPolicyServiceClient} from './data_policy_service_client'; diff --git a/packages/google-cloud-bigquery-datapolicies/test/gapic_data_policy_service_v1.ts b/packages/google-cloud-bigquery-datapolicies/test/gapic_data_policy_service_v1.ts new file mode 100644 index 00000000000..6be92dd3740 --- /dev/null +++ b/packages/google-cloud-bigquery-datapolicies/test/gapic_data_policy_service_v1.ts @@ -0,0 +1,1762 @@ +// 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. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as datapolicyserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DataPolicyServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + datapolicyserviceModule.v1.DataPolicyServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + datapolicyserviceModule.v1.DataPolicyServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = datapolicyserviceModule.v1.DataPolicyServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.dataPolicyServiceStub, undefined); + await client.initialize(); + assert(client.dataPolicyServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.dataPolicyServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.dataPolicyServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('createDataPolicy', () => { + it('invokes createDataPolicy without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.createDataPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.createDataPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDataPolicy without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.createDataPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDataPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDataPolicy with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDataPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createDataPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createDataPolicy with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.CreateDataPolicyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDataPolicy(request), expectedError); + }); + }); + + describe('updateDataPolicy', () => { + it('invokes updateDataPolicy without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest() + ); + request.dataPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); + request.dataPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `data_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.updateDataPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.updateDataPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDataPolicy without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest() + ); + request.dataPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); + request.dataPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `data_policy.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.updateDataPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDataPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDataPolicy with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest() + ); + request.dataPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); + request.dataPolicy.name = defaultValue1; + const expectedHeaderRequestParams = `data_policy.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDataPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateDataPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateDataPolicy with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest() + ); + request.dataPolicy ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); + request.dataPolicy.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDataPolicy(request), expectedError); + }); + }); + + describe('renameDataPolicy', () => { + it('invokes renameDataPolicy without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.renameDataPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.renameDataPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.renameDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.renameDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes renameDataPolicy without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.renameDataPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.renameDataPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.renameDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.renameDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes renameDataPolicy with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.renameDataPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.renameDataPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.renameDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.renameDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes renameDataPolicy with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.RenameDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.renameDataPolicy(request), expectedError); + }); + }); + + describe('deleteDataPolicy', () => { + it('invokes deleteDataPolicy without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDataPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDataPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDataPolicy without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteDataPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDataPolicy( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDataPolicy with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDataPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteDataPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteDataPolicy with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.DeleteDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDataPolicy(request), expectedError); + }); + }); + + describe('getDataPolicy', () => { + it('invokes getDataPolicy without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.getDataPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getDataPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDataPolicy without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ); + client.innerApiCalls.getDataPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDataPolicy( + request, + ( + err?: Error | null, + result?: protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDataPolicy with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDataPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getDataPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDataPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDataPolicy with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.GetDataPolicyRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDataPolicy(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('listDataPolicies', () => { + it('invokes listDataPolicies without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + ]; + client.innerApiCalls.listDataPolicies = stubSimpleCall(expectedResponse); + const [response] = await client.listDataPolicies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDataPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDataPolicies without error using callback', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + ]; + client.innerApiCalls.listDataPolicies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDataPolicies( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy[] + | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDataPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDataPolicies with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDataPolicies = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listDataPolicies(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDataPolicies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataPolicies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listDataPoliciesStream without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + ]; + client.descriptors.page.listDataPolicies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDataPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.bigquery.datapolicies.v1.DataPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.bigquery.datapolicies.v1.DataPolicy + ) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDataPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDataPolicies, request) + ); + assert( + (client.descriptors.page.listDataPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listDataPoliciesStream with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDataPolicies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDataPoliciesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.bigquery.datapolicies.v1.DataPolicy[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.bigquery.datapolicies.v1.DataPolicy + ) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDataPolicies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDataPolicies, request) + ); + assert( + (client.descriptors.page.listDataPolicies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDataPolicies without error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.DataPolicy() + ), + ]; + client.descriptors.page.listDataPolicies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy[] = + []; + const iterable = client.listDataPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDataPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listDataPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listDataPolicies with error', async () => { + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1.ListDataPoliciesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDataPolicies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDataPoliciesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.bigquery.datapolicies.v1.IDataPolicy[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDataPolicies.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert( + (client.descriptors.page.listDataPolicies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + + describe('Path templates', () => { + describe('dataPolicy', () => { + const fakePath = '/rendered/path/dataPolicy'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + data_policy: 'dataPolicyValue', + }; + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.dataPolicyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.dataPolicyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('dataPolicyPath', () => { + const result = client.dataPolicyPath( + 'projectValue', + 'locationValue', + 'dataPolicyValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.dataPolicyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromDataPolicyName', () => { + const result = client.matchProjectFromDataPolicyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.dataPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromDataPolicyName', () => { + const result = client.matchLocationFromDataPolicyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.dataPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchDataPolicyFromDataPolicyName', () => { + const result = client.matchDataPolicyFromDataPolicyName(fakePath); + assert.strictEqual(result, 'dataPolicyValue'); + assert( + (client.pathTemplates.dataPolicyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new datapolicyserviceModule.v1.DataPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-bigquery-datapolicies/test/gapic_data_policy_service_v1beta1.ts b/packages/google-cloud-bigquery-datapolicies/test/gapic_data_policy_service_v1beta1.ts index 7e89fb41497..866d5ed75b6 100644 --- a/packages/google-cloud-bigquery-datapolicies/test/gapic_data_policy_service_v1beta1.ts +++ b/packages/google-cloud-bigquery-datapolicies/test/gapic_data_policy_service_v1beta1.ts @@ -245,9 +245,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateDataPolicyRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -276,9 +277,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateDataPolicyRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -323,9 +325,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateDataPolicyRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -354,9 +357,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('CreateDataPolicyRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.CreateDataPolicyRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -376,10 +380,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { new protos.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest() ); request.dataPolicy ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateDataPolicyRequest', [ - 'dataPolicy', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); request.dataPolicy.name = defaultValue1; const expectedHeaderRequestParams = `data_policy.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -409,10 +413,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { new protos.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest() ); request.dataPolicy ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateDataPolicyRequest', [ - 'dataPolicy', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); request.dataPolicy.name = defaultValue1; const expectedHeaderRequestParams = `data_policy.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -458,10 +462,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { new protos.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest() ); request.dataPolicy ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateDataPolicyRequest', [ - 'dataPolicy', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); request.dataPolicy.name = defaultValue1; const expectedHeaderRequestParams = `data_policy.name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -491,10 +495,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { new protos.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest() ); request.dataPolicy ??= {}; - const defaultValue1 = getTypeDefaultValue('UpdateDataPolicyRequest', [ - 'dataPolicy', - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.UpdateDataPolicyRequest', + ['dataPolicy', 'name'] + ); request.dataPolicy.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -513,9 +517,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -544,9 +549,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -591,9 +597,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -622,9 +629,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('DeleteDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.DeleteDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -643,9 +651,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -674,9 +683,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -721,9 +731,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); @@ -752,9 +763,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetDataPolicyRequest', [ - 'name', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.GetDataPolicyRequest', + ['name'] + ); request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -773,9 +785,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -804,9 +817,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -851,9 +865,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); @@ -882,9 +897,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.GetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('GetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -903,9 +919,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -934,9 +951,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -981,9 +999,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1012,9 +1031,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.SetIamPolicyRequest() ); - const defaultValue1 = getTypeDefaultValue('SetIamPolicyRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1033,9 +1053,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1065,9 +1086,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedResponse = generateSampleMessage( @@ -1112,9 +1134,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedHeaderRequestParams = `resource=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1143,9 +1166,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.iam.v1.TestIamPermissionsRequest() ); - const defaultValue1 = getTypeDefaultValue('TestIamPermissionsRequest', [ - 'resource', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'] + ); request.resource = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); @@ -1164,9 +1188,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListDataPoliciesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -1203,9 +1228,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListDataPoliciesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -1260,9 +1286,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListDataPoliciesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1291,9 +1318,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListDataPoliciesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -1354,9 +1382,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListDataPoliciesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); @@ -1406,9 +1435,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListDataPoliciesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ @@ -1456,9 +1486,10 @@ describe('v1beta1.DataPolicyServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest() ); - const defaultValue1 = getTypeDefaultValue('ListDataPoliciesRequest', [ - 'parent', - ]); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.bigquery.datapolicies.v1beta1.ListDataPoliciesRequest', + ['parent'] + ); request.parent = defaultValue1; const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected');