Class: KaseyaWS::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kaseyaws/client.rb

Overview

The client class is just a wrapper for the Kaseya VSA WSDL. All methods return a Hash object

Constant Summary collapse

HASH_ALGORITHM =
"SHA-256"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, hostname) ⇒ Client

Returns a new instance of Client.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kaseyaws/client.rb', line 23

def initialize (username,password,hostname)

  @vsa_serviceurl = "https://" + hostname + "/vsaWS/kaseyaWS.asmx?WSDL"
  @client_ip = KaseyaWS::Security.client_ip
  @savon_options={
    wsdl: @vsa_serviceurl,
    convert_request_keys_to: :camelcase,
    env_namespace: :soap,
    open_timeout: 30,
    log: true
  }
  @sessionid = self.authenticate(username,password)

end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



21
22
23
# File 'lib/kaseyaws/client.rb', line 21

def client
  @client
end

Instance Method Details

#add_mach_group_to_scope(group_name, scope_name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/kaseyaws/client.rb', line 38

def add_mach_group_to_scope(group_name,scope_name)

  response = self.client.call(:add_mach_group_to_scope, :message => {:req =>[{
                                                                               :group_name => group_name,
                                                                               :scope_name => scope_name,
                                                                               :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:add_mach_group_to_scope_response][:add_mach_group_to_scope_result]
end

#add_org_to_scope(company_id, scope_id) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/kaseyaws/client.rb', line 51

def add_org_to_scope(company_id,scope_id)

  response = self.client.call(:add_org_to_scope, :message => {:req =>[{
                                                                        :company_i_d => company_id,
                                                                        :scope_i_d => scope_id,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:add_org_to_scope_response][:add_org_to_scope_result]
end

#add_user_to_role(username, role_id) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/kaseyaws/client.rb', line 61

def add_user_to_role(username,role_id)

  response = self.client.call(:add_user_to_role, :message => {:req =>[{
                                                                        :user_name => user_name,
                                                                        :role_i_d => role_id,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:add_user_to_role_response][:add_user_to_role_result]
end

#authenticate(username, password) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/kaseyaws/client.rb', line 71

def authenticate(username,password)

  random_number = KaseyaWS::Security.secure_random
  covered_password = KaseyaWS::Security.compute_covered_password(username,password, random_number, HASH_ALGORITHM)

  self.client = Savon::Client.new(@savon_options)

  response = self.client.call(:authenticate, :message => {:req =>[{
                                                                    :user_name => username,
                                                                    :covered_password => covered_password,
                                                                    :random_number => random_number,
                                                                    :browser_i_p => @client_ip,
                              :hashing_algorithm => HASH_ALGORITHM}]}
                              )
  @sessionid = response.body[:authenticate_response][:authenticate_result][:session_id]
end

#close_alarm(monitor_alarm_id, notes) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/kaseyaws/client.rb', line 88

def close_alarm (monitor_alarm_id, notes)

  response = self.client.call(:close_alarm, :message => {:req =>[{
                                                                   :monitor_alarm_i_d => monitor_alarm_id,
                                                                   :notes => notes,
                                                                   :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:close_alarm_response][:close_alarm_result]
end

#create_machine_group(group_name, org_name, parent_name) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/kaseyaws/client.rb', line 99

def create_machine_group (group_name,org_name,parent_name)

  response = self.client.call(:create_machine_group, :message => {:req =>[{
                                                                            :group_name => group_name,
                                                                            :org_name => org_name,
                                                                            :parent_name => parent_name,
                                                                            :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:create_machine_group_response][:create_machine_group_result]
end

#create_role(role_name, role_type, parent_role_name) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/kaseyaws/client.rb', line 111

def create_role (role_name,role_type,parent_role_name)

  response = self.client.call(:create_role, :message => {:req =>[{
                                                                   :role_name => role_name,
                                                                   :role_type => role_type,
                                                                   :parent_role_name => parent_role_name,
                                                                   :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:create_role_response][:create_role_result]
end

#delete_admin(user_name) ⇒ Object



123
124
125
126
127
128
129
130
131
# File 'lib/kaseyaws/client.rb', line 123

def delete_admin (user_name)

  response = self.client.call(:delete_admin, :message => {:req =>[{
                                                                    :user_name => user_name,
                                                                    :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:delete_admin_response][:delete_admin_result]
end

#delete_agent(agent_guid, uninstall_agent_first) ⇒ Object



134
135
136
137
138
139
140
141
142
143
# File 'lib/kaseyaws/client.rb', line 134

def delete_agent (agent_guid, uninstall_agent_first)

  response = self.client.call(:delete_agent, :message => {:req =>[{
                                                                    :agent_guid => agent_guid,
                                                                    :uninstall_agent_first => uninstall_agent_first,
                                                                    :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:delete_agent_response][:delete_agent_result]
end

#delete_agent_install_package(package_id) ⇒ Object



145
146
147
148
149
150
151
152
153
# File 'lib/kaseyaws/client.rb', line 145

def delete_agent_install_package (package_id)

  response = self.client.call(:delete_agent_install_package, :message => {:req =>[{
                                                                                    :package_id => package_id,
                                                                                    :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:delete_agent_install_package_response][:delete_agent_install_package_result]
end

#delete_machine_group(group_name) ⇒ Object



155
156
157
158
159
160
161
162
163
# File 'lib/kaseyaws/client.rb', line 155

def delete_machine_group (group_name)

  response = self.client.call(:delete_machine_group, :message => {:req =>[{
                                                                            :group_name => group_name,
                                                                            :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:delete_machine_group_response][:delete_machine_group_result]
end

#echo(input) ⇒ Object



165
166
167
168
169
170
# File 'lib/kaseyaws/client.rb', line 165

def echo (input)

  response = self.client.call(:echo, :message => { :input => input })

  response.body[:echo_response][:echo_result]
end

#echo_mt(payload) ⇒ Object



172
173
174
175
176
177
178
179
# File 'lib/kaseyaws/client.rb', line 172

def echo_mt (payload)

  response = self.client.call(:echo_mt, :message => {:req =>[{
                                                               :payload => payload,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:echo_mt_response][:echo_mt_result]
end

#get_alarm(monitor_alarm_id) ⇒ Object



181
182
183
184
185
186
187
188
189
# File 'lib/kaseyaws/client.rb', line 181

def get_alarm (monitor_alarm_id)

  response = self.client.call(:get_alarm, :message => {:req =>[{
                                                                 :monitor_alarm_i_d => monitor_alarm_id,
                                                                 :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_alarm_response][:get_alarm_result]
end

#get_alarm_list(get_all_records = true) ⇒ Object



191
192
193
194
195
196
197
198
199
# File 'lib/kaseyaws/client.rb', line 191

def get_alarm_list (get_all_records=true)

  response = self.client.call(:get_alarm_list, :message => {:req =>[{
                                                                      :return_all_records => get_all_records,
                                                                      :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_alarm_list_response][:get_alarm_list_result]
end

#get_machine(machine_group_id) ⇒ Object



201
202
203
204
205
206
207
208
209
# File 'lib/kaseyaws/client.rb', line 201

def get_machine(machine_group_id)

  response = self.client.call(:get_machine, :message => {:req =>[{
                                                                   :machine___group_i_d => machine_group_id,
                                                                   :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_machine_response][:get_machine_result]
end

#get_machine_group_listObject



211
212
213
214
215
216
217
218
# File 'lib/kaseyaws/client.rb', line 211

def get_machine_group_list

  response = self.client.call(:get_machine_group_list, :message => {:req =>[{
                                                                              :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_machine_group_list_response][:get_machine_group_list_result]
end

#get_machine_list(machine_group, machine_collection) ⇒ Object



220
221
222
223
224
225
226
227
228
229
# File 'lib/kaseyaws/client.rb', line 220

def get_machine_list(machine_group,machine_collection)

  response = self.client.call(:get_machine_list, :message => {:req =>[{
                                                                        :machine_group => machine_group,
                                                                        :machine_collection => machine_collection,
                                                                        :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_machine_list_response][:get_machine_list_result]
end

#get_notes_list(added_since) ⇒ Object



231
232
233
234
235
236
237
238
239
# File 'lib/kaseyaws/client.rb', line 231

def get_notes_list(added_since)

  response = self.client.call(:get_notes_list, :message => {:req =>[{
                                                                      :added_since => get_notes_list,
                                                                      :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_notes_list_response][:get_notes_list_result]
end

#get_org_typesObject



249
250
251
252
253
254
255
256
# File 'lib/kaseyaws/client.rb', line 249

def get_org_types

  response = self.client.call(:get_org_types, :message => {:req =>[{
                                                                     :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_org_types_response][:get_org_types_result]
end

#get_orgsObject



241
242
243
244
245
246
247
# File 'lib/kaseyaws/client.rb', line 241

def get_orgs

  response = self.client.call(:get_orgs, :message => {:req =>[{
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_orgs_response][:get_orgs_result]
end

#get_orgs_by_scope_id(scope_id) ⇒ Object



258
259
260
261
262
263
264
265
# File 'lib/kaseyaws/client.rb', line 258

def get_orgs_by_scope_id (scope_id)

  response = self.client.call(:get_orgs_by_scope_id, :message => {:req =>[{
                                                                            :scope_i_d => scope_id,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_orgs_by_scope_id_response][:get_orgs_by_scope_id_result]
end

#get_package_urls(group_name) ⇒ Object



267
268
269
270
271
272
273
274
275
# File 'lib/kaseyaws/client.rb', line 267

def get_package_urls (group_name)

  response = self.client.call(:get_package_urls, :message => {:req =>[{
                                                                        :group_name => group_name,
                                                                        :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_package_urls_response][:get_package_urls_result]
end

#get_partner_user_location(admin_id) ⇒ Object



277
278
279
280
281
282
283
284
285
# File 'lib/kaseyaws/client.rb', line 277

def get_partner_user_location (admin_id)

  response = self.client.call(:get_partner_user_location, :message => {:req =>[{
                                                                                 :admin_id => admin_id,
                                                                                 :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_partner_user_location_response][:get_partner_user_location_result]
end

#get_published_view_columns(view_name) ⇒ Object



287
288
289
290
291
292
293
294
295
# File 'lib/kaseyaws/client.rb', line 287

def get_published_view_columns (view_name)

  response = self.client.call(:get_published_view_columns, :message => {:req =>[{
                                                                                  :view_name => view_name,
                                                                                  :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_published_view_columns_response][:get_published_view_columns_result]
end

#get_published_viewsObject



297
298
299
300
301
302
303
304
# File 'lib/kaseyaws/client.rb', line 297

def get_published_views

  response = self.client.call(:get_published_views, :message => {:req =>[{
                                                                           :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_published_views_response][:get_published_views_result]
end

#get_rolesObject



306
307
308
309
310
311
312
# File 'lib/kaseyaws/client.rb', line 306

def get_roles

  response = self.client.call(:get_roles, :message => {:req =>[{
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_roles_response][:get_roles_result]
end

#get_scopesObject



314
315
316
317
318
319
320
# File 'lib/kaseyaws/client.rb', line 314

def get_scopes

  response = self.client.call(:get_scopes, :message => {:req =>[{
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_scopes_response][:get_scopes_result]
end

#get_tic_request_ticket(id) ⇒ Object



322
323
324
325
326
327
328
329
330
# File 'lib/kaseyaws/client.rb', line 322

def get_tic_request_ticket (id)

  response = self.client.call(:get_tic_request_ticket, :message => {:req =>[{
                                                                              :id => id,
                                                                              :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_tic_request_ticket_response][:get_tic_request_ticket_result]
end

#get_ticket(ticket_id) ⇒ Object



332
333
334
335
336
337
338
339
340
# File 'lib/kaseyaws/client.rb', line 332

def get_ticket (ticket_id)

  response = self.client.call(:get_ticket, :message => {:req =>[{
                                                                  :ticket_i_d => ticket_id,
                                                                  :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_ticket_response][:get_ticket_result]
end

#get_ticket_list(return_all_records = true) ⇒ Object



342
343
344
345
346
347
348
349
350
# File 'lib/kaseyaws/client.rb', line 342

def get_ticket_list (return_all_records=true)

  response = self.client.call(:get_ticket_list, :message => {:req =>[{
                                                                       :return_all_records => return_all_records,
                                                                       :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_ticket_list_response][:get_ticket_list_result]
end

#get_ticket_notes(ticket_id) ⇒ Object



352
353
354
355
356
357
358
359
360
# File 'lib/kaseyaws/client.rb', line 352

def get_ticket_notes (ticket_id)

  response = self.client.call(:get_ticket_notes, :message => {:req =>[{
                                                                        :ticket_i_d => ticket_id,
                                                                        :browser_i_p => @client_ip,
                              :session_i_d => @sessionid}]}
                              )
  response.body[:get_ticket_notes_response][:get_ticket_notes_result]
end