Class: Cloudpassage::Accounts
Overview
Instance Method Summary
collapse
Methods included from Collection
#[], #get, #to_s
Methods inherited from Base
#[], #data, #exists?, #method_missing, #object_symbol, #post, #put, #reload, #wait_for
Constructor Details
#initialize(server, token, base_resource, data = nil) ⇒ Accounts
Returns a new instance of Accounts.
55
56
57
58
|
# File 'lib/cloudpassage/servers.rb', line 55
def initialize(server, token, base_resource, data=nil)
@server = server
super(token, base_resource, data)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Cloudpassage::Base
Instance Method Details
#all ⇒ Object
64
65
66
|
# File 'lib/cloudpassage/servers.rb', line 64
def all
data.map { |i| get(i[:username], i) }
end
|
#create(username, groups = '', opts = {}) ⇒ Object
Creates username, in the given group. If opts is specified, that password will be used. Otherwise, password will be generated. If opts
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/cloudpassage/servers.rb', line 72
def create(username, groups = '', opts = {})
payload = {
:account => {
:username => username,
:comment => '',
:groups => groups,
:password => password_opts.merge(opts.fetch(:password, {}))
}
}
@server.commands.get(post(payload)['command']['id'])
end
|
#disable_account(username) ⇒ Object
99
100
101
102
|
# File 'lib/cloudpassage/servers.rb', line 99
def disable_account(username)
payload = {:account => {:active=>false}}
@server..get(JSON.parse(@base_resource[username].put(payload.to_json, ))['command']['id'])
end
|
#enable_account(username) ⇒ Object
94
95
96
97
|
# File 'lib/cloudpassage/servers.rb', line 94
def enable_account(username)
payload = {:account => {:active=>true}}
@server.commands.get(JSON.parse(@base_resource[username].put(payload.to_json, ))['command']['id'])
end
|
113
114
115
|
# File 'lib/cloudpassage/servers.rb', line 113
def
super.merge({'Content-Type'=>'application/json'})
end
|
#remove(username) ⇒ Object
109
110
111
|
# File 'lib/cloudpassage/servers.rb', line 109
def remove(username)
@server.commands.get(JSON.parse(@base_resource[username].delete())['command']['id'])
end
|
#reset(username, opts = {}) ⇒ Object
104
105
106
107
|
# File 'lib/cloudpassage/servers.rb', line 104
def reset(username, opts = {})
payload = {'password' => password_opts.merge(opts)}
@server.commands.get(JSON.parse(@base_resource[username]['password'].put(payload.to_json, ))['command']['id'])
end
|
#set_ssh_keys(username, *keys) ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/cloudpassage/servers.rb', line 84
def set_ssh_keys(username, *keys)
keys = *keys
payload = {
:account => {
:ssh_authorized_keys => keys.map{|k|{:key=>k}}
}
}
@server.commands.get(JSON.parse(@base_resource[username].put(payload.to_json, ))['command']['id'])
end
|
#singleton_class ⇒ Object
60
61
62
|
# File 'lib/cloudpassage/servers.rb', line 60
def singleton_class
Account
end
|