Class: Ey::Core::Client::DatabaseServerSnapshot

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/database_server_snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #to_s, #update!, #url

Instance Attribute Details

#nameObject

Returns the value of attribute name.



18
19
20
# File 'lib/ey-core/models/database_server_snapshot.rb', line 18

def name
  @name
end

Instance Method Details

#destroy!Object



38
39
40
41
42
# File 'lib/ey-core/models/database_server_snapshot.rb', line 38

def destroy!
  connection.requests.new(
    connection.destroy_database_server_snapshot("id" => self.identity).body["request"]
  )
end

#save!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ey-core/models/database_server_snapshot.rb', line 20

def save!
  if new_record?
    create_params = if collection.url
                      { "url" => collection.url }
                    elsif self.database_service
                      { "database_service" => self.database_service.identity }
                    else
                      requires_one :database_server, :database_service

                      { "database_service" => self.database_server.database_service.identity }
                    end

    connection.requests.new(
      connection.create_database_service_snapshot(create_params.merge("name" => self.name)).body["request"]
    )
  end
end