Method: Fog::AWS::RDS::Mock#modify_db_instance

Defined in:
lib/fog/aws/requests/rds/modify_db_instance.rb

#modify_db_instance(db_name, apply_immediately, options = {}) ⇒ Object

[View source]

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fog/aws/requests/rds/modify_db_instance.rb', line 47

def modify_db_instance(db_name, apply_immediately, options={})
  response = Excon::Response.new
  if self.data[:servers][db_name]
    if self.data[:servers][db_name]["DBInstanceStatus"] != "available"
      raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not available for modification")
    else
      self.data[:modify_time] = Time.now
      # TODO verify the params options
      # if apply_immediately is false, all the options go to pending_modified_values and then apply and clear after either
      # a reboot or the maintainance window
      #if apply_immediately
      #  modified_server = server.merge(options)
      #else
      #  modified_server = server["PendingModifiedValues"].merge!(options) # it appends
      #end
      self.data[:servers][db_name]["PendingModifiedValues"].merge!(options) # it appends
      self.data[:servers][db_name]["DBInstanceStatus"] = "modifying"
      response.status = 200
      response.body = {
        "ResponseMetadata"=>{ "RequestId"=> Fog::AWS::Mock.request_id },
        "ModifyDBInstanceResult" => { "DBInstance" => self.data[:servers][db_name] }
      }
      response

    end
  else
    raise Fog::AWS::RDS::NotFound.new("DBInstance #{db_name} not found")
  end
end