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

Commit

Permalink
[Ansible] Service Usage Services (#248)
Browse files Browse the repository at this point in the history
[Ansible] Service Usage Services
  • Loading branch information
rambleraptor authored Nov 7, 2019
2 parents 1447ad3 + 5f54921 commit 6b0cd67
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/resources/google_project_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ Properties that can be accessed from the `google_project_service` resource:

* `name`: The resource name of the service

* `parent`: The name of the parent of this service. For example: `projects/123`
* `parent`: The name of the parent of this service. For example 'projects/123'

* `state`: Whether or not the service has been enabled for use by the consumer.

* `disable_dependent_services`: Indicates if dependent services should also be disabled. Can only be turned on if service is disabled.

* `config`: The service configuration of the available service.

* `name`: The DNS address at which this service is available.

* `title`: The product title for this service

* `apis`: The list of API interfaces exported by this service.

* `name`: Name of the API

* `version`: The version of the API


## GCP Permissions

Expand Down
2 changes: 2 additions & 0 deletions docs/resources/google_project_services.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ See [google_project_service.md](google_project_service.md) for more detailed inf
* `names`: an array of `google_project_service` name
* `parents`: an array of `google_project_service` parent
* `states`: an array of `google_project_service` state
* `disable_dependent_services`: an array of `google_project_service` disable_dependent_services
* `configs`: an array of `google_project_service` config

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
Expand Down
41 changes: 41 additions & 0 deletions libraries/google/serviceusage/property/service_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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/serviceusage/property/service_config_apis'
module GoogleInSpec
module ServiceUsage
module Property
class ServiceConfig
attr_reader :name

attr_reader :title

attr_reader :apis

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@name = args['name']
@title = args['title']
@apis = GoogleInSpec::ServiceUsage::Property::ServiceConfigApisArray.parse(args['apis'], to_s)
end

def to_s
"#{@parent_identifier} ServiceConfig"
end
end
end
end
end
45 changes: 45 additions & 0 deletions libraries/google/serviceusage/property/service_config_apis.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 ServiceUsage
module Property
class ServiceConfigApis
attr_reader :name

attr_reader :version

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

def to_s
"#{@parent_identifier} ServiceConfigApis"
end
end

class ServiceConfigApisArray
def self.parse(value, parent_identifier)
return if value.nil?
return ServiceConfigApis.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| ServiceConfigApis.new(v, parent_identifier) }
end
end
end
end
end
6 changes: 6 additions & 0 deletions libraries/google_project_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/serviceusage/property/service_config'
require 'google/serviceusage/property/service_config_apis'

# A provider to manage Service Usage resources.
class ServiceUsageService < GcpResourceBase
Expand All @@ -25,6 +27,8 @@ class ServiceUsageService < GcpResourceBase
attr_reader :name
attr_reader :parent
attr_reader :state
attr_reader :disable_dependent_services
attr_reader :config

def initialize(params)
super(params.merge({ use_http_transport: true }))
Expand All @@ -37,6 +41,8 @@ def parse
@name = @fetched['name']
@parent = @fetched['parent']
@state = @fetched['state']
@disable_dependent_services = @fetched['disableDependentServices']
@config = GoogleInSpec::ServiceUsage::Property::ServiceConfig.new(@fetched['config'], to_s)
end

# Handles parsing RFC3339 time string
Expand Down
4 changes: 4 additions & 0 deletions libraries/google_project_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ServiceUsageServices < GcpResourceBase
filter_table_config.add(:names, field: :name)
filter_table_config.add(:parents, field: :parent)
filter_table_config.add(:states, field: :state)
filter_table_config.add(:disable_dependent_services, field: :disable_dependent_services)
filter_table_config.add(:configs, field: :config)

filter_table_config.connect(self, :table)

Expand Down Expand Up @@ -68,6 +70,8 @@ def transformers
'name' => ->(obj) { return :name, obj['name'] },
'parent' => ->(obj) { return :parent, obj['parent'] },
'state' => ->(obj) { return :state, obj['state'] },
'disableDependentServices' => ->(obj) { return :disable_dependent_services, obj['disableDependentServices'] },
'config' => ->(obj) { return :config, GoogleInSpec::ServiceUsage::Property::ServiceConfig.new(obj['config'], to_s) },
}
end

Expand Down

0 comments on commit 6b0cd67

Please sign in to comment.