Class: Ey::Core::Client::Provider

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

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, #to_s, #update!, #url

Instance Method Details

#accountEy::Core::Client::Account



34
35
36
# File 'lib/ey-core/models/provider.rb', line 34

def 
  self.connection.accounts.new(self.connection.("url" => self.).body["account"])
end

#database_server_snapshotsObject



25
26
27
# File 'lib/ey-core/models/provider.rb', line 25

def database_server_snapshots
  connection.database_server_snapshots.load(connection.get_database_server_snapshots("provider" => self.id).body["database_server_snapshots"])
end

#destroy!Object



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

def destroy!
  connection.requests.new(self.connection.destroy_provider(self.id).body["request"])
end

#discover_database_server_snapshotsObject



29
30
31
# File 'lib/ey-core/models/provider.rb', line 29

def discover_database_server_snapshots
  connection.requests.new(connection.discover_database_server_snapshots("provider" => self.id).body["request"])
end

#possible_locations(provider_type = self.type) ⇒ Object



21
22
23
# File 'lib/ey-core/models/provider.rb', line 21

def possible_locations(provider_type = self.type)
  self.connection.get_possible_provider_locations(provider_type).body["locations"].map { |l| l["id"] }
end

#saveObject Also known as: save!



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ey-core/models/provider.rb', line 42

def save
  params = {
    "url"      => self.collection.url,
    "account"  => self.,
    "provider" => {
      "credentials"    => self.credentials,
      "provisioned_id" => self.provisioned_id,
      "type"           => self.type,
    },
  }
  if new_record?
    connection.requests.new(self.connection.create_provider(params).body["request"])
  else raise NotImplementedError # update
  end
end