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

Add additional fields to Memcached Instance #427

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
18 changes: 18 additions & 0 deletions docs/resources/google_memcache_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,34 @@ Properties that can be accessed from the `google_memcache_instance` resource:

* `display_name`: (Beta only) A user-visible name for the instance.

* `memcache_nodes`: (Beta only) Additional information about the instance state, if available.

* `node_id`: (Beta only) Identifier of the Memcached node. The node id does not include project or location like the Memcached instance name.

* `zone`: (Beta only) Location (GCP Zone) for the Memcached node.

* `port`: (Beta only) The port number of the Memcached server on this node.

* `host`: (Beta only) Hostname or IP address of the Memcached node used by the clients to connect to the Memcached server on this node.

* `state`: (Beta only) Current state of the Memcached node.

* `create_time`: (Beta only) Creation timestamp in RFC3339 text format.

* `labels`: (Beta only) Resource labels to represent user-provided metadata.

* `memcache_full_version`: (Beta only) The full version of memcached server running on this instance.

* `zones`: (Beta only) Zones where memcache nodes should be provisioned. If not provided, all zones will be used.

* `authorized_network`: (Beta only) The full name of the GCE network to connect the instance to. If not provided, 'default' will be used.

* `node_count`: (Beta only) Number of nodes in the memcache instance.

* `memcache_version`: (Beta only) The major version of Memcached software. If not provided, latest supported version will be used. Currently the latest supported major version is MEMCACHE_1_5. The minor version will be automatically determined by our system based on the latest supported minor version.
Possible values:
* MEMCACHE_1_5

* `node_config`: (Beta only) Configuration for memcache nodes.

* `cpu_count`: (Beta only) Number of CPUs per node.
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/google_memcache_instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ Properties that can be accessed from the `google_memcache_instances` resource:
See [google_memcache_instance.md](google_memcache_instance.md) for more detailed information
* `names`: (Beta only) an array of `google_memcache_instance` name
* `display_names`: (Beta only) an array of `google_memcache_instance` display_name
* `memcache_nodes`: (Beta only) an array of `google_memcache_instance` memcache_nodes
* `create_times`: (Beta only) an array of `google_memcache_instance` create_time
* `labels`: (Beta only) an array of `google_memcache_instance` labels
* `memcache_full_versions`: (Beta only) an array of `google_memcache_instance` memcache_full_version
* `zones`: (Beta only) an array of `google_memcache_instance` zones
* `authorized_networks`: (Beta only) an array of `google_memcache_instance` authorized_network
* `node_counts`: (Beta only) an array of `google_memcache_instance` node_count
* `memcache_versions`: (Beta only) an array of `google_memcache_instance` memcache_version
* `node_configs`: (Beta only) an array of `google_memcache_instance` node_config
* `parameters`: (Beta only) an array of `google_memcache_instance` parameters
* `regions`: (Beta only) an array of `google_memcache_instance` region
Expand Down
54 changes: 54 additions & 0 deletions libraries/google/memcache/property/instance_memcache_nodes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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 Memcache
module Property
class InstanceMemcacheNodes
attr_reader :node_id

attr_reader :zone

attr_reader :port

attr_reader :host

attr_reader :state

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@node_id = args['nodeId']
@zone = args['zone']
@port = args['port']
@host = args['host']
@state = args['state']
end

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

class InstanceMemcacheNodesArray
def self.parse(value, parent_identifier)
return if value.nil?
return InstanceMemcacheNodes.new(value, parent_identifier) unless value.is_a?(::Array)
value.map { |v| InstanceMemcacheNodes.new(v, parent_identifier) }
end
end
end
end
end
7 changes: 7 additions & 0 deletions libraries/google_memcache_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/memcache/property/instance_memcache_nodes'
require 'google/memcache/property/instance_node_config'
require 'google/memcache/property/instance_parameters'

Expand All @@ -26,11 +27,14 @@ class MemcacheInstance < GcpResourceBase
attr_reader :params
attr_reader :name
attr_reader :display_name
attr_reader :memcache_nodes
attr_reader :create_time
attr_reader :labels
attr_reader :memcache_full_version
attr_reader :zones
attr_reader :authorized_network
attr_reader :node_count
attr_reader :memcache_version
attr_reader :node_config
attr_reader :parameters
attr_reader :region
Expand All @@ -45,11 +49,14 @@ def initialize(params)
def parse
@name = @fetched['name']
@display_name = @fetched['displayName']
@memcache_nodes = GoogleInSpec::Memcache::Property::InstanceMemcacheNodesArray.parse(@fetched['memcacheNodes'], to_s)
@create_time = parse_time_string(@fetched['createTime'])
@labels = @fetched['labels']
@memcache_full_version = @fetched['memcacheFullVersion']
@zones = @fetched['zones']
@authorized_network = @fetched['authorizedNetwork']
@node_count = @fetched['nodeCount']
@memcache_version = @fetched['memcacheVersion']
@node_config = GoogleInSpec::Memcache::Property::InstanceNodeConfig.new(@fetched['nodeConfig'], to_s)
@parameters = GoogleInSpec::Memcache::Property::InstanceParameters.new(@fetched['parameters'], to_s)
@region = @fetched['region']
Expand Down
6 changes: 6 additions & 0 deletions libraries/google_memcache_instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ class MemcacheInstances < GcpResourceBase

filter_table_config.add(:names, field: :name)
filter_table_config.add(:display_names, field: :display_name)
filter_table_config.add(:memcache_nodes, field: :memcache_nodes)
filter_table_config.add(:create_times, field: :create_time)
filter_table_config.add(:labels, field: :labels)
filter_table_config.add(:memcache_full_versions, field: :memcache_full_version)
filter_table_config.add(:zones, field: :zones)
filter_table_config.add(:authorized_networks, field: :authorized_network)
filter_table_config.add(:node_counts, field: :node_count)
filter_table_config.add(:memcache_versions, field: :memcache_version)
filter_table_config.add(:node_configs, field: :node_config)
filter_table_config.add(:parameters, field: :parameters)
filter_table_config.add(:regions, field: :region)
Expand Down Expand Up @@ -74,11 +77,14 @@ def transformers
{
'name' => ->(obj) { return :name, obj['name'] },
'displayName' => ->(obj) { return :display_name, obj['displayName'] },
'memcacheNodes' => ->(obj) { return :memcache_nodes, GoogleInSpec::Memcache::Property::InstanceMemcacheNodesArray.parse(obj['memcacheNodes'], to_s) },
'createTime' => ->(obj) { return :create_time, parse_time_string(obj['createTime']) },
'labels' => ->(obj) { return :labels, obj['labels'] },
'memcacheFullVersion' => ->(obj) { return :memcache_full_version, obj['memcacheFullVersion'] },
'zones' => ->(obj) { return :zones, obj['zones'] },
'authorizedNetwork' => ->(obj) { return :authorized_network, obj['authorizedNetwork'] },
'nodeCount' => ->(obj) { return :node_count, obj['nodeCount'] },
'memcacheVersion' => ->(obj) { return :memcache_version, obj['memcacheVersion'] },
'nodeConfig' => ->(obj) { return :node_config, GoogleInSpec::Memcache::Property::InstanceNodeConfig.new(obj['nodeConfig'], to_s) },
'parameters' => ->(obj) { return :parameters, GoogleInSpec::Memcache::Property::InstanceParameters.new(obj['parameters'], to_s) },
'region' => ->(obj) { return :region, obj['region'] },
Expand Down