Class: Keystone::V2_0::Manager::Service

Inherits:
Base
  • Object
show all
Defined in:
lib/keystone/v2_0/manager/service.rb

Constant Summary collapse

@@url_endpoint =
"OS-KSADM/services"

Instance Attribute Summary

Attributes inherited from Base

#auth_url, #token, #url_endpoint

Instance Method Summary collapse

Constructor Details

#initialize(auth_url) ⇒ Service

Returns a new instance of Service.



10
11
12
# File 'lib/keystone/v2_0/manager/service.rb', line 10

def initialize(auth_url)
  super auth_url, @@url_endpoint
end

Instance Method Details

#create(name: '', type: '', description: '') ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/keystone/v2_0/manager/service.rb', line 31

def create(name: '', type: '', description: '')
  create_key = "OS-KSADM:service"
  payload = { create_key =>
              { "name"        => name,
                "type"        => type,
                "description" => description
              }
            }
  service_data = super(payload.to_json)

  if service_data and service_data[create_key]
    return Keystone::V2_0::Resource::Service.new(service_data[create_key])
  else
    return nil
  end
end

#listObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/keystone/v2_0/manager/service.rb', line 14

def list
  services     = super
  service_list = []

  # map role hash to array of Service objects
  unless services.nil?
    services["OS-KSADM:services"].each do |service_data|
      service_resource = Keystone::V2_0::Resource::Service.new(service_data)
      service_list << service_resource
    end

    return service_list
  else
    return nil
  end
end