Method: Fog::AWS::Elasticache::Mock#modify_cache_cluster

Defined in:
lib/fog/aws/requests/elasticache/modify_cache_cluster.rb

#modify_cache_cluster(id, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/fog/aws/requests/elasticache/modify_cache_cluster.rb', line 64

def modify_cache_cluster(id, options = {})
  response        = Excon::Response.new
  cluster         = self.data[:clusters][id]
  pending_values  = Hash.new
  # For any given option, update the cluster's corresponding value
  { :auto_minor_version_upgrade   => 'AutoMinorVersionUpgrade',
    :preferred_maintenance_window => 'PreferredMaintenanceWindow',
    :engine_version               => 'EngineVersion',
    :num_nodes                    => 'NumCacheNodes',
  }.each do |option, cluster_key|
    if options[option] != nil
      cluster[cluster_key] = options[option].to_s
      pending_values[cluster_key] = options[option]
    end
  end
  cache['CacheParameterGroup'] = {
    'CacheParameterGroupName' => options[:parameter_group_name]
  } if options[:parameter_group_name]
  if options[:num_nodes] || options[:engine_version]
    cluster['CacheNodes'] =
      create_cache_nodes(cluster['CacheClusterId'], options[:num_nodes])
    cluster['NumCacheNodes'] = cluster['CacheNodes'].size
  end
  if options[:nodes_to_remove]
    pending_values['CacheNodeId'] = options[:nodes_to_remove].join(',')
  end
  response.body = {
    'CacheCluster' => cluster.merge({
      'PendingModifiedValues' => pending_values
    }),
    'ResponseMetadata' => { 'RequestId' => Fog::AWS::Mock.request_id }
  }
  response
end