lib/google/cloud/bigquery/service.rb in google-cloud-bigquery-1.24.0 vs lib/google/cloud/bigquery/service.rb in google-cloud-bigquery-1.25.0

- old
+ new

@@ -181,10 +181,38 @@ service.patch_table @project, dataset_id, table_id, patched_table_gapi, options: options end end ## + # Returns Google::Apis::BigqueryV2::Policy + def get_table_policy dataset_id, table_id + policy_options = API::GetPolicyOptions.new requested_policy_version: 1 + execute do + service.get_table_iam_policy table_path(dataset_id, table_id), + API::GetIamPolicyRequest.new(options: policy_options) + end + end + + ## + # @param [Google::Apis::BigqueryV2::Policy] new_policy + def set_table_policy dataset_id, table_id, new_policy + execute do + service.set_table_iam_policy table_path(dataset_id, table_id), + API::SetIamPolicyRequest.new(policy: new_policy) + end + end + + ## + # Returns Google::Apis::BigqueryV2::TestIamPermissionsResponse + def test_table_permissions dataset_id, table_id, permissions + execute do + service.test_table_iam_permissions table_path(dataset_id, table_id), + API::TestIamPermissionsRequest.new(permissions: permissions) + end + end + + ## # Deletes the table specified by tableId from the dataset. # If the table contains data, all the data will be deleted. def delete_table dataset_id, table_id execute { service.delete_table @project, dataset_id, table_id } end @@ -505,9 +533,14 @@ def inspect "#{self.class}(#{@project})" end protected + + # Creates a formatted table path. + def table_path dataset_id, table_id + "projects/#{@project}/datasets/#{dataset_id}/tables/#{table_id}" + end # Generate a random string similar to the BigQuery service job IDs. def generate_id SecureRandom.urlsafe_base64 21 end