Skip to content

Commit

Permalink
Manual Metastore fedration resource created
Browse files Browse the repository at this point in the history
Signed-off-by: Samir <85890442+sa-progress@users.noreply.github.com>
  • Loading branch information
sa-progress committed Jul 1, 2024
1 parent c3ba385 commit e9b55cb
Show file tree
Hide file tree
Showing 6 changed files with 325 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 DataprocMetastore
module Property
class ProjectLocationFederationBackendMetastores
attr_reader :additional_properties

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@additional_properties = args['additionalProperties']
end

def to_s
"#{@parent_identifier} ProjectLocationFederationBackendMetastores"
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 DataprocMetastore
module Property
class ProjectLocationFederationLabels
attr_reader :additional_properties

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@additional_properties = args['additionalProperties']
end

def to_s
"#{@parent_identifier} ProjectLocationFederationLabels"
end
end
end
end
end
75 changes: 75 additions & 0 deletions libraries/google_dataproc_metastore_project_location_federation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 'gcp_backend'
require 'google/dataprocmetastore/property/projectlocationfederation_backend_metastores'
require 'google/dataprocmetastore/property/projectlocationfederation_labels'

# A provider to manage Dataproc metastore resources.
class DataprocMetastoreProjectLocationFederation < GcpResourceBase
name 'google_dataproc_metastore_project_location_federation'
desc 'ProjectLocationFederation'
supports platform: 'gcp'

attr_reader :params
attr_reader :name
attr_reader :create_time
attr_reader :update_time
attr_reader :labels
attr_reader :version
attr_reader :backend_metastores
attr_reader :endpoint_uri
attr_reader :state
attr_reader :state_message
attr_reader :uid

def initialize(params)
super(params.merge({ use_http_transport: true }))
@params = params
@fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get')
parse unless @fetched.nil?
end

def parse
@name = @fetched['name']
@create_time = @fetched['createTime']
@update_time = @fetched['updateTime']
@labels = GoogleInSpec::DataprocMetastore::Property::ProjectLocationFederationLabels.new(@fetched['labels'], to_s)
@version = @fetched['version']
@backend_metastores = GoogleInSpec::DataprocMetastore::Property::ProjectLocationFederationBackendMetastores.new(@fetched['backendMetastores'], to_s)
@endpoint_uri = @fetched['endpointUri']
@state = @fetched['state']
@state_message = @fetched['stateMessage']
@uid = @fetched['uid']
end

def exists?
!@fetched.nil?
end

def to_s
"ProjectLocationFederation #{@params[:]}"
end

private

def product_url(_ = nil)
'https://metastore.googleapis.com/v1beta/'
end

def resource_base_url
'{{+name}}'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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 'gcp_backend'
class DataprocMetastoreProjectLocationFederations < GcpResourceBase
name 'google_dataproc_metastore_project_location_federations'
desc 'ProjectLocationFederation plural resource'
supports platform: 'gcp'

attr_reader :table

filter_table_config = FilterTable.create

filter_table_config.add(:names, field: :name)
filter_table_config.add(:create_times, field: :create_time)
filter_table_config.add(:update_times, field: :update_time)
filter_table_config.add(:labels, field: :labels)
filter_table_config.add(:versions, field: :version)
filter_table_config.add(:backend_metastores, field: :backend_metastores)
filter_table_config.add(:endpoint_uris, field: :endpoint_uri)
filter_table_config.add(:states, field: :state)
filter_table_config.add(:state_messages, field: :state_message)
filter_table_config.add(:uids, field: :uid)

filter_table_config.connect(self, :table)

def initialize(params = {})
super(params.merge({ use_http_transport: true }))
@params = params
@table = fetch_wrapped_resource('projectLocationFederations')
end

def fetch_wrapped_resource(wrap_path)
# fetch_resource returns an array of responses (to handle pagination)
result = @connection.fetch_all(product_url, resource_base_url, @params, 'Get')
return if result.nil?

# Conversion of string -> object hash to symbol -> object hash that InSpec needs
converted = []
result.each do |response|
next if response.nil? || !response.key?(wrap_path)
response[wrap_path].each do |hash|
hash_with_symbols = {}
hash.each_key do |key|
name, value = transform(key, hash)
hash_with_symbols[name] = value
end
converted.push(hash_with_symbols)
end
end

converted
end

def transform(key, value)
return transformers[key].call(value) if transformers.key?(key)

[key.to_sym, value]
end

def transformers
{
'name' => ->(obj) { [:name, obj['name']] },
'createTime' => ->(obj) { [:create_time, obj['createTime']] },
'updateTime' => ->(obj) { [:update_time, obj['updateTime']] },
'labels' => ->(obj) { [:labels, GoogleInSpec::DataprocMetastore::Property::ProjectLocationFederationLabels.new(obj['labels'], to_s)] },
'version' => ->(obj) { [:version, obj['version']] },
'backendMetastores' => ->(obj) { [:backend_metastores, GoogleInSpec::DataprocMetastore::Property::ProjectLocationFederationBackendMetastores.new(obj['backendMetastores'], to_s)] },
'endpointUri' => ->(obj) { [:endpoint_uri, obj['endpointUri']] },
'state' => ->(obj) { [:state, obj['state']] },
'stateMessage' => ->(obj) { [:state_message, obj['stateMessage']] },
'uid' => ->(obj) { [:uid, obj['uid']] },
}
end

private

def product_url(_ = nil)
'https://metastore.googleapis.com/v1beta/'
end

def resource_base_url
'{{+parent}}/federations'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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.
#
# ----------------------------------------------------------------------------

title 'Test GCP google_dataproc_metastore_project_location_federation resource.'

gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')
project_location_federation = input('project_location_federation', value: {
"name": "value_name",
"parent": "value_parent",
"create_time": "value_createtime",
"update_time": "value_updatetime",
"version": "value_version",
"endpoint_uri": "value_endpointuri",
"state": "value_state",
"state_message": "value_statemessage",
"uid": "value_uid"
}, description: 'project_location_federation description')
control 'google_dataproc_metastore_project_location_federation-1.0' do
impact 1.0
title 'google_dataproc_metastore_project_location_federation resource test'

describe google_dataproc_metastore_project_location_federation(name: project_location_federation['name']) do
it { should exist }
its('name') { should cmp project_location_federation['name'] }
its('create_time') { should cmp project_location_federation['create_time'] }
its('update_time') { should cmp project_location_federation['update_time'] }
its('version') { should cmp project_location_federation['version'] }
its('endpoint_uri') { should cmp project_location_federation['endpoint_uri'] }
its('state') { should cmp project_location_federation['state'] }
its('state_message') { should cmp project_location_federation['state_message'] }
its('uid') { should cmp project_location_federation['uid'] }

end

describe google_dataproc_metastore_project_location_federation(name: "does_not_exit") do
it { should_not exist }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# 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.
#
# ----------------------------------------------------------------------------

title 'Test GCP google_dataproc_metastore_project_location_federations resource.'

gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.')
project_location_federation = input('project_location_federation', value: {
"name": "value_name",
"parent": "value_parent",
"create_time": "value_createtime",
"update_time": "value_updatetime",
"version": "value_version",
"endpoint_uri": "value_endpointuri",
"state": "value_state",
"state_message": "value_statemessage",
"uid": "value_uid"
}, description: 'project_location_federation description')
control 'google_dataproc_metastore_project_location_federations-1.0' do
impact 1.0
title 'google_dataproc_metastore_project_location_federations resource test'

describe google_dataproc_metastore_project_location_federations(parent: project_location_federation['parent']) do
it { should exist }
end
end

0 comments on commit e9b55cb

Please sign in to comment.