From 97539ebac6639837d4f8e674fc532e7c6d949266 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 5 Aug 2020 17:08:26 +0000 Subject: [PATCH] Add additional fields to Memcached Instance (#3821) Signed-off-by: Modular Magician --- docs/resources/google_memcache_instance.md | 18 +++++++ docs/resources/google_memcache_instances.md | 3 ++ .../property/instance_memcache_nodes.rb | 54 +++++++++++++++++++ libraries/google_memcache_instance.rb | 7 +++ libraries/google_memcache_instances.rb | 6 +++ 5 files changed, 88 insertions(+) create mode 100644 libraries/google/memcache/property/instance_memcache_nodes.rb diff --git a/docs/resources/google_memcache_instance.md b/docs/resources/google_memcache_instance.md index 4eea79b07..2d95981ba 100644 --- a/docs/resources/google_memcache_instance.md +++ b/docs/resources/google_memcache_instance.md @@ -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. diff --git a/docs/resources/google_memcache_instances.md b/docs/resources/google_memcache_instances.md index 4481b7e44..0cce03cec 100644 --- a/docs/resources/google_memcache_instances.md +++ b/docs/resources/google_memcache_instances.md @@ -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 diff --git a/libraries/google/memcache/property/instance_memcache_nodes.rb b/libraries/google/memcache/property/instance_memcache_nodes.rb new file mode 100644 index 000000000..f9d52dbf3 --- /dev/null +++ b/libraries/google/memcache/property/instance_memcache_nodes.rb @@ -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 diff --git a/libraries/google_memcache_instance.rb b/libraries/google_memcache_instance.rb index 8d67d0a17..5d11c0ca2 100644 --- a/libraries/google_memcache_instance.rb +++ b/libraries/google_memcache_instance.rb @@ -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' @@ -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 @@ -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'] diff --git a/libraries/google_memcache_instances.rb b/libraries/google_memcache_instances.rb index 8989ef5c7..af1d03d28 100644 --- a/libraries/google_memcache_instances.rb +++ b/libraries/google_memcache_instances.rb @@ -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) @@ -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'] },