Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Templates, inspec.yaml for bigquery table #110

Merged
merged 1 commit into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions docs/resources/google_bigquery_table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
title: About the google_bigquery_table resource
platform: gcp
---

## Syntax
A `google_bigquery_table` is used to test a Google Table resource

## Examples
```
describe google_bigquery_table(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset', name: 'inspec_gcp_bigquery_table') do
it { should exist }

its('expiration_time') { should cmp '1738882264000' }
its('time_partitioning.type') { should eq 'DAY' }
its('description') { should eq 'A BigQuery table' }
end

describe google_bigquery_table(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset', name: 'nonexistent') do
it { should_not exist }
end
```

## Properties
Properties that can be accessed from the `google_bigquery_table` resource:

* `table_reference`: Reference describing the ID of this table

* `datasetId`: The ID of the dataset containing this table

* `projectId`: The ID of the project containing this table

* `tableId`: The ID of the the table

* `creation_time`: The time when this dataset was created, in milliseconds since the epoch.

* `description`: A user-friendly description of the dataset

* `friendly_name`: A descriptive name for this table

* `id`: An opaque ID uniquely identifying the table.

* `labels`: The labels associated with this dataset. You can use these to organize and group your datasets

* `last_modified_time`: The time when this table was last modified, in milliseconds since the epoch.

* `location`: The geographic location where the table resides. This value is inherited from the dataset.

* `name`: Name of the table

* `num_bytes`: The size of this table in bytes, excluding any data in the streaming buffer.

* `num_long_term_bytes`: The number of bytes in the table that are considered "long-term storage".

* `num_rows`: The number of rows of data in this table, excluding any data in the streaming buffer.

* `type`: Describes the table type

* `view`: The view definition.

* `useLegacySql`: Specifies whether to use BigQuery's legacy SQL for this view

* `userDefinedFunctionResources`: Describes user-defined function resources used in the query.

* `time_partitioning`: If specified, configures time-based partitioning for this table.

* `expirationMs`: Number of milliseconds for which to keep the storage for a partition.

* `type`: The only type supported is DAY, which will generate one partition per day.

* `streaming_buffer`: Contains information regarding this table's streaming buffer, if one is present. This field will be absent if the table is not being streamed to or if there is no data in the streaming buffer.

* `estimatedBytes`: A lower-bound estimate of the number of bytes currently in the streaming buffer.

* `estimatedRows`: A lower-bound estimate of the number of rows currently in the streaming buffer.

* `oldestEntryTime`: Contains the timestamp of the oldest entry in the streaming buffer, in milliseconds since the epoch, if the streaming buffer is available.

* `schema`: Describes the schema of this table

* `fields`: Describes the fields in a table.

* `encryption_configuration`: Custom encryption configuration

* `kmsKeyName`: Describes the Cloud KMS encryption key that will be used to protect destination BigQuery table. The BigQuery Service Account associated with your project requires access to this encryption key.

* `expiration_time`: The time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely.

* `external_data_configuration`: Describes the data format, location, and other properties of a table stored outside of BigQuery. By defining these properties, the data source can then be queried as if it were a standard BigQuery table.

* `autodetect`: Try to detect schema and format options automatically. Any option specified explicitly will be honored.

* `compression`: The compression type of the data source

* `ignoreUnknownValues`: Indicates if BigQuery should allow extra values that are not represented in the table schema

* `maxBadRecords`: The maximum number of bad records that BigQuery can ignore when reading data

* `sourceFormat`: The data format

* `sourceUris`: The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each URI can contain one '*' wildcard character and it must come after the 'bucket' name. Size limits related to load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups, exactly one URI can be specified. Also, the '*' wildcard character is not allowed.

* `schema`: The schema for the data. Schema is required for CSV and JSON formats

* `googleSheetsOptions`: Additional options if sourceFormat is set to GOOGLE_SHEETS.

* `csvOptions`: Additional properties to set if sourceFormat is set to CSV.

* `bigtableOptions`: Additional options if sourceFormat is set to BIGTABLE.

* `dataset`: Name of the dataset
47 changes: 47 additions & 0 deletions docs/resources/google_bigquery_tables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: About the google_bigquery_tables resource
platform: gcp
---

## Syntax
A `google_bigquery_tables` is used to test a Google Table resource

## Examples
```
describe.one do
google_bigquery_tables(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset').table_references.each do |table_reference|
describe google_bigquery_table(project: 'chef-gcp-inspec', dataset: 'inspec_gcp_dataset', name: table_reference.table_id) do
its('expiration_time') { should cmp '1738882264000' }
its('description') { should eq 'A BigQuery table' }
end
end
end
```

## Properties
Properties that can be accessed from the `google_bigquery_tables` resource:

See [google_bigquery_table.md](google_bigquery_table.md) for more detailed information
* `table_references`: an array of `google_bigquery_table` table_reference
* `creation_times`: an array of `google_bigquery_table` creation_time
* `friendly_names`: an array of `google_bigquery_table` friendly_name
* `ids`: an array of `google_bigquery_table` id
* `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
* `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
* `types`: an array of `google_bigquery_table` type
* `views`: an array of `google_bigquery_table` view
* `time_partitionings`: an array of `google_bigquery_table` time_partitioning
* `streaming_buffers`: an array of `google_bigquery_table` streaming_buffer
* `schemas`: an array of `google_bigquery_table` schema
* `encryption_configurations`: an array of `google_bigquery_table` encryption_configuration
* `expiration_times`: an array of `google_bigquery_table` expiration_time
* `external_data_configurations`: an array of `google_bigquery_table` external_data_configuration
* `datasets`: an array of `google_bigquery_table` dataset

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module BigQuery
module Property
class TableEncryptionConfiguration
attr_reader :kms_key_name

def initialize(args = nil)
return if args.nil?
@kms_key_name = args['kmsKeyName']
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/bigquery/property/table_external_data_configuration_bigtable_options'
require 'google/bigquery/property/table_external_data_configuration_bigtable_options_column_families'
require 'google/bigquery/property/table_external_data_configuration_csv_options'
require 'google/bigquery/property/table_external_data_configuration_google_sheets_options'
require 'google/bigquery/property/table_external_data_configuration_schema'
require 'google/bigquery/property/table_external_data_configuration_schema_fields'
module GoogleInSpec
module BigQuery
module Property
class TableExternalDataConfiguration
attr_reader :autodetect

attr_reader :compression

attr_reader :ignore_unknown_values

attr_reader :max_bad_records

attr_reader :source_format

attr_reader :source_uris

attr_reader :schema

attr_reader :google_sheets_options

attr_reader :csv_options

attr_reader :bigtable_options

def initialize(args = nil)
return if args.nil?
@autodetect = args['autodetect']
@compression = args['compression']
@ignore_unknown_values = args['ignoreUnknownValues']
@max_bad_records = args['maxBadRecords']
@source_format = args['sourceFormat']
@source_uris = args['sourceUris']
@schema = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationSchema.new(args['schema'])
@google_sheets_options = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationGoogleSheetsOptions.new(args['googleSheetsOptions'])
@csv_options = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationCsvOptions.new(args['csvOptions'])
@bigtable_options = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationBigtableOptions.new(args['bigtableOptions'])
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/bigquery/property/table_external_data_configuration_bigtable_options_column_families'
module GoogleInSpec
module BigQuery
module Property
class TableExternalDataConfigurationBigtableOptions
attr_reader :ignore_unspecified_column_families

attr_reader :read_rowkey_as_string

attr_reader :column_families

def initialize(args = nil)
return if args.nil?
@ignore_unspecified_column_families = args['ignoreUnspecifiedColumnFamilies']
@read_rowkey_as_string = args['readRowkeyAsString']
@column_families = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationBigtableOptionsColumnFamiliesArray.parse(args['columnFamilies'])
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'google/bigquery/property/table_external_data_configuration_bigtable_options_column_families_columns'
module GoogleInSpec
module BigQuery
module Property
class TableExternalDataConfigurationBigtableOptionsColumnFamilies
attr_reader :columns

attr_reader :encoding

attr_reader :family_id

attr_reader :only_read_latest

attr_reader :type

def initialize(args = nil)
return if args.nil?
@columns = GoogleInSpec::BigQuery::Property::TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumnsArray.parse(args['columns'])
@encoding = args['encoding']
@family_id = args['familyId']
@only_read_latest = args['onlyReadLatest']
@type = args['type']
end
end

class TableExternalDataConfigurationBigtableOptionsColumnFamiliesArray
def self.parse(value)
return if value.nil?
return TableExternalDataConfigurationBigtableOptionsColumnFamilies.new(value) unless value.is_a?(::Array)
value.map { |v| TableExternalDataConfigurationBigtableOptionsColumnFamilies.new(v) }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module BigQuery
module Property
class TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumns
attr_reader :encoding

attr_reader :field_name

attr_reader :only_read_latest

attr_reader :qualifier_string

attr_reader :type

def initialize(args = nil)
return if args.nil?
@encoding = args['encoding']
@field_name = args['fieldName']
@only_read_latest = args['onlyReadLatest']
@qualifier_string = args['qualifierString']
@type = args['type']
end
end

class TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumnsArray
def self.parse(value)
return if value.nil?
return TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumns.new(value) unless value.is_a?(::Array)
value.map { |v| TableExternalDataConfigurationBigtableOptionsColumnFamiliesColumns.new(v) }
end
end
end
end
end
Loading