diff --git a/docs/resources/google_bigquery_dataset.md b/docs/resources/google_bigquery_dataset.md index ab2edc4a0..c11a919c3 100644 --- a/docs/resources/google_bigquery_dataset.md +++ b/docs/resources/google_bigquery_dataset.md @@ -14,6 +14,7 @@ describe google_bigquery_dataset(project: 'chef-gcp-inspec', name: 'inspec_gcp_d its('friendly_name') { should eq 'A BigQuery dataset test' } its('location') { should eq 'EU' } its('description') { should eq 'Test BigQuery dataset description' } + its('name') { should eq 'inspec_gcp_dataset' } its('default_table_expiration_ms') { should cmp '3600000' } end diff --git a/docs/resources/google_bigquery_tables.md b/docs/resources/google_bigquery_tables.md index 57d390276..f160c738e 100644 --- a/docs/resources/google_bigquery_tables.md +++ b/docs/resources/google_bigquery_tables.md @@ -29,6 +29,7 @@ See [google_bigquery_table.md](google_bigquery_table.md) for more detailed infor * `labels`: an array of `google_bigquery_table` labels * `last_modified_times`: an array of `google_bigquery_table` last_modified_time * `locations`: an array of `google_bigquery_table` location + * `names`: an array of `google_bigquery_table` name * `num_bytes`: an array of `google_bigquery_table` num_bytes * `num_long_term_bytes`: an array of `google_bigquery_table` num_long_term_bytes * `num_rows`: an array of `google_bigquery_table` num_rows diff --git a/libraries/google_bigquery_dataset.rb b/libraries/google_bigquery_dataset.rb index 452a91180..863dc2460 100644 --- a/libraries/google_bigquery_dataset.rb +++ b/libraries/google_bigquery_dataset.rb @@ -23,7 +23,6 @@ class Dataset < GcpResourceBase desc 'Dataset' supports platform: 'gcp' - attr_reader :name attr_reader :access attr_reader :creation_time attr_reader :dataset_reference @@ -42,7 +41,6 @@ def initialize(params) end def parse - @name = @fetched['name'] @access = GoogleInSpec::BigQuery::Property::DatasetAccessArray.parse(@fetched['access']) @creation_time = @fetched['creationTime'] @dataset_reference = GoogleInSpec::BigQuery::Property::DatasetDatasetReference.new(@fetched['datasetReference']) @@ -64,6 +62,10 @@ def exists? !@fetched.nil? end + def name + dataset_reference&.dataset_id + end + private def product_url diff --git a/libraries/google_bigquery_tables.rb b/libraries/google_bigquery_tables.rb index b07711419..eeaaa50f1 100644 --- a/libraries/google_bigquery_tables.rb +++ b/libraries/google_bigquery_tables.rb @@ -30,6 +30,7 @@ class Tables < GcpResourceBase filter_table_config.add(:labels, field: :labels) filter_table_config.add(:last_modified_times, field: :last_modified_time) filter_table_config.add(:locations, field: :location) + filter_table_config.add(:names, field: :name) filter_table_config.add(:num_bytes, field: :num_bytes) filter_table_config.add(:num_long_term_bytes, field: :num_long_term_bytes) filter_table_config.add(:num_rows, field: :num_rows) @@ -88,6 +89,7 @@ def transformers 'labels' => ->(obj) { return :labels, obj['labels'] }, 'lastModifiedTime' => ->(obj) { return :last_modified_time, obj['lastModifiedTime'] }, 'location' => ->(obj) { return :location, obj['location'] }, + 'name' => ->(obj) { return :name, obj['name'] }, 'numBytes' => ->(obj) { return :num_bytes, obj['numBytes'] }, 'numLongTermBytes' => ->(obj) { return :num_long_term_bytes, obj['numLongTermBytes'] }, 'numRows' => ->(obj) { return :num_rows, obj['numRows'] }, diff --git a/test/integration/verify/controls/google_bigquery_dataset.rb b/test/integration/verify/controls/google_bigquery_dataset.rb index 6e4e325ab..7d9963430 100644 --- a/test/integration/verify/controls/google_bigquery_dataset.rb +++ b/test/integration/verify/controls/google_bigquery_dataset.rb @@ -34,6 +34,7 @@ its('friendly_name') { should eq dataset['friendly_name'] } its('location') { should eq dataset['location'] } its('description') { should eq dataset['description'] } + its('name') { should eq dataset['dataset_id'] } its('default_table_expiration_ms') { should cmp dataset['default_table_expiration_ms'] } end