Class: Base

Inherits:
Object
  • Object
show all
Defined in:
lib/base/Base.rb

Direct Known Subclasses

V1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, api, path, namespace) ⇒ Base

Returns a new instance of Base.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/base/Base.rb', line 29

def initialize(version, api, path, namespace)
  @client = OcpClient.instance
  @api = api
  @version = version
  @path = path
  @namespace = namespace
  @response = nil

  @endpoint = "/"+@api+"/"+@version

  if !@namespace.nil?
    @endpoint = @endpoint+"/namespaces/"+@namespace+"/"+@path
  elsif !@path.nil?
    @endpoint = @endpoint+"/"+@path
  end

end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



27
28
29
# File 'lib/base/Base.rb', line 27

def response
  @response
end

Instance Method Details

#create(body) ⇒ Object



60
61
62
63
# File 'lib/base/Base.rb', line 60

def create(body)
  @response = @client.post(@endpoint,body)
  return @response
end

#delete(name) ⇒ Object



70
71
72
73
# File 'lib/base/Base.rb', line 70

def delete(name)
  @response = @client.delete(@endpoint+"/"+name)
  return @response
end

#listObject



55
56
57
58
# File 'lib/base/Base.rb', line 55

def list
  @response = @client.get(@endpoint)
  return @response
end

#setup(url, noverifyssl, pretty, debug, token = nil, clientcertfile = nil, clientkeyfile = nil, clientcafile = nil) ⇒ Object



47
48
49
# File 'lib/base/Base.rb', line 47

def setup(url, noverifyssl, pretty, debug , token=nil, clientcertfile=nil, clientkeyfile=nil, clientcafile=nil)
  @client.setup(url, noverifyssl, pretty, debug , token, clientcertfile, clientkeyfile, clientcafile)
end

#setup_by_config_file(configfile, pretty = nil, debug = nil) ⇒ Object



51
52
53
# File 'lib/base/Base.rb', line 51

def setup_by_config_file(configfile, pretty=nil, debug=nil)
  @client.setup_by_config_file(configfile, pretty, debug)
end

#update(body, name) ⇒ Object



65
66
67
68
# File 'lib/base/Base.rb', line 65

def update(body, name)
  @response = @client.put(@endpoint+"/"+name,body)
  return @response
end