Class: Diplomat::Service

Inherits:
RestClient show all
Defined in:
lib/diplomat/service.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RestClient

#initialize

Constructor Details

This class inherits a constructor from Diplomat::RestClient

Class Method Details

.get(*args) ⇒ Object

Note:

This is sugar, see (#get)



21
22
23
# File 'lib/diplomat/service.rb', line 21

def self.get *args
  Diplomat::Service.new.get *args
end

Instance Method Details

#get(key, scope = :first) ⇒ OpenStruct

Get a service by it’s key

Parameters:

  • key (String)

    the key

  • scope (Symbol) (defaults to: :first)

    :first or :all results

Returns:

  • (OpenStruct)

    all data associated with the service



11
12
13
14
15
16
17
18
# File 'lib/diplomat/service.rb', line 11

def get key, scope=:first
  ret = @conn.get "/v1/catalog/service/#{key}"

  if scope == :all
    return JSON.parse(ret.body).map { |service| OpenStruct.new service }
  end
  return OpenStruct.new JSON.parse(ret.body).first
end