Class: ProjectFifo
- Inherits:
-
Object
show all
- Defined in:
- lib/project-fifo.rb,
lib/project-fifo/vm.rb,
lib/project-fifo/dataset.rb,
lib/project-fifo/iprange.rb,
lib/project-fifo/package.rb,
lib/project-fifo/resource.rb
Defined Under Namespace
Classes: Dataset, Iprange, Package, Resource, VM
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#connect ⇒ Object
-
#datasets ⇒ Object
-
#delete(path_part, additional_headers = {}, &block) ⇒ Object
-
#get(path_part, additional_headers = {}, &block) ⇒ Object
-
#initialize(endpoint, username, password) ⇒ ProjectFifo
constructor
A new instance of ProjectFifo.
-
#ipranges ⇒ Object
-
#packages ⇒ Object
-
#post(path_part, payload, additional_headers = {}, &block) ⇒ Object
-
#put(path_part, payload, additional_headers = {}, &block) ⇒ Object
-
#vms ⇒ Object
Constructor Details
#initialize(endpoint, username, password) ⇒ ProjectFifo
Returns a new instance of ProjectFifo.
14
15
16
17
18
19
20
21
|
# File 'lib/project-fifo.rb', line 14
def initialize(endpoint, username, password)
@endpoint = endpoint
@username = username
@password = password
@ssh_keys = nil
@verbose = true
@rest = RestClient::Resource.new(endpoint, :headers => { :content_type => 'application/json', :accept => :json })
end
|
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
12
13
14
|
# File 'lib/project-fifo.rb', line 12
def endpoint
@endpoint
end
|
#password ⇒ Object
Returns the value of attribute password.
12
13
14
|
# File 'lib/project-fifo.rb', line 12
def password
@password
end
|
#ssh_keys ⇒ Object
Returns the value of attribute ssh_keys.
12
13
14
|
# File 'lib/project-fifo.rb', line 12
def ssh_keys
@ssh_keys
end
|
#token ⇒ Object
Returns the value of attribute token.
12
13
14
|
# File 'lib/project-fifo.rb', line 12
def token
@token
end
|
#username ⇒ Object
Returns the value of attribute username.
12
13
14
|
# File 'lib/project-fifo.rb', line 12
def username
@username
end
|
Instance Method Details
#connect ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/project-fifo.rb', line 23
def connect()
response = post('sessions', { 'user' => @username, 'password' => @password })
@token = response["session"]
@ssh_keys = response["metadata"]["jingles"]["ssh_keys"]
@rest.[:x_snarl_token] = @token
response
end
|
#datasets ⇒ Object
51
52
53
|
# File 'lib/project-fifo.rb', line 51
def datasets
@datasets ||= ProjectFifo::Dataset.new(self)
end
|
#delete(path_part, additional_headers = {}, &block) ⇒ Object
43
44
45
|
# File 'lib/project-fifo.rb', line 43
def delete(path_part, = {}, &block)
api_request { @rest[path_part].delete(, &block) }
end
|
#get(path_part, additional_headers = {}, &block) ⇒ Object
35
36
37
|
# File 'lib/project-fifo.rb', line 35
def get(path_part, = {}, &block)
api_request { @rest[path_part].get(, &block) }
end
|
#ipranges ⇒ Object
59
60
61
|
# File 'lib/project-fifo.rb', line 59
def ipranges
@ipranges ||= ProjectFifo::Iprange.new(self)
end
|
#packages ⇒ Object
55
56
57
|
# File 'lib/project-fifo.rb', line 55
def packages
@packages ||= ProjectFifo::Package.new(self)
end
|
#post(path_part, payload, additional_headers = {}, &block) ⇒ Object
31
32
33
|
# File 'lib/project-fifo.rb', line 31
def post(path_part, payload, = {}, &block)
api_request { @rest[path_part].post(payload.to_json, , &block) }
end
|
#put(path_part, payload, additional_headers = {}, &block) ⇒ Object
39
40
41
|
# File 'lib/project-fifo.rb', line 39
def put(path_part, payload, = {}, &block)
api_request { @rest[path_part].put(payload.to_json, , &block) }
end
|
#vms ⇒ Object
47
48
49
|
# File 'lib/project-fifo.rb', line 47
def vms
@vms ||= ProjectFifo::VM.new(self)
end
|