kaseyaws 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +4 -0
- data/kaseyaws.gemspec +4 -4
- data/lib/kaseyaws/client.rb +181 -0
- data/lib/kaseyaws/version.rb +1 -1
- data/lib/kaseyaws.rb +1 -162
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 780aecac9c46c96b12234d9e8cb5f6a910077a8b
|
4
|
+
data.tar.gz: e4a9e46956778d2e4ee53fc7cf48608b40a1dd4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c265dc2bad37597cdc232942e2a6b6f3e967b30c9c6070dd9676cf5f66db206a64fab4028690e166849fdfe18ad1d36fcd6b57cf1f47fac9be57a098834ea44
|
7
|
+
data.tar.gz: 9ce9d480b7cd7e1983b5f16021c0d28bac3645aac7650c616fefd0c9fd8789c009cc8af37a4f80705cff7b6bf45d944772ce21a29708e0f73db313b4efed262b
|
data/.yardopts
ADDED
data/kaseyaws.gemspec
CHANGED
@@ -6,10 +6,10 @@ require 'kaseyaws/version'
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "kaseyaws"
|
8
8
|
s.version = KaseyaWS::VERSION
|
9
|
-
s.authors =
|
10
|
-
s.email =
|
11
|
-
s.description =
|
12
|
-
s.summary =
|
9
|
+
s.authors = "Phillip Henslee"
|
10
|
+
s.email = "phenslee@towerdigital.us"
|
11
|
+
s.description = "A Ruby Gem for Kaseya's VSA web services"
|
12
|
+
s.summary = "A simple client for the Kaseya VSA web service"
|
13
13
|
s.homepage = "https://github.com/towerdigital/kaseyaws"
|
14
14
|
s.license = "MIT"
|
15
15
|
|
@@ -0,0 +1,181 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright 2013 by Phillip Henslee (phenslee@towerdigital.us).
|
4
|
+
# All rights reserved.
|
5
|
+
|
6
|
+
# Permission is granted for use, copying, modification, distribution,
|
7
|
+
# and distribution of modified versions of this work as long as the
|
8
|
+
# above copyright notice is included.
|
9
|
+
#
|
10
|
+
|
11
|
+
# Provides a simple client for the Kaseya VSA web service.
|
12
|
+
|
13
|
+
require "savon"
|
14
|
+
|
15
|
+
module KaseyaWS
|
16
|
+
|
17
|
+
class Client
|
18
|
+
HASH_ALGORITHM = "SHA-256"
|
19
|
+
attr_accessor :client
|
20
|
+
|
21
|
+
def initialize (username,password,hostname)
|
22
|
+
|
23
|
+
@vsa_serviceurl = "https://" + hostname + "/vsaWS/kaseyaWS.asmx?WSDL"
|
24
|
+
@client_ip = KaseyaWS::Security.client_ip
|
25
|
+
@savon_options={
|
26
|
+
wsdl: @vsa_serviceurl,
|
27
|
+
convert_request_keys_to: :camelcase,
|
28
|
+
env_namespace: :soap,
|
29
|
+
open_timeout: 30,
|
30
|
+
log: false
|
31
|
+
}
|
32
|
+
@sessionid = self.authenticate(username,password)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_mach_group_to_scope(group_name,scope_name)
|
37
|
+
|
38
|
+
response = self.client.call(:add_mach_group_to_scope, message: {req:[{
|
39
|
+
group_name: group_name,
|
40
|
+
scope_name: scope_name,
|
41
|
+
browser_ip: @client_ip,
|
42
|
+
session_i_d: @sessionid}]}
|
43
|
+
)
|
44
|
+
response.body[:add_mach_group_to_scope_response][:add_mach_group_to_scope_result]
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_org_to_scope(company_id,scope_id)
|
48
|
+
|
49
|
+
response = self.client.call(:add_org_to_scope, message: {req:[{
|
50
|
+
company_i_d: company_id,
|
51
|
+
scope_i_d: scope_id,
|
52
|
+
session_i_d: @sessionid}]}
|
53
|
+
)
|
54
|
+
response.body[:add_org_to_scope_response][:add_org_to_scope_result]
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_user_to_role(username,role_id)
|
58
|
+
|
59
|
+
response = self.client.call(:add_user_to_role, message: {req:[{
|
60
|
+
user_name: user_name,
|
61
|
+
role_i_d: role_id,
|
62
|
+
session_i_d: @sessionid}]}
|
63
|
+
)
|
64
|
+
response.body[:add_user_to_role_response][:add_user_to_role_result]
|
65
|
+
end
|
66
|
+
|
67
|
+
def authenticate(username,password)
|
68
|
+
|
69
|
+
random_number = KaseyaWS::Security.secure_random
|
70
|
+
covered_password = KaseyaWS::Security.compute_covered_password(username,password, random_number, HASH_ALGORITHM)
|
71
|
+
browser_ip = @client_ip
|
72
|
+
|
73
|
+
self.client = Savon::Client.new(@savon_options)
|
74
|
+
|
75
|
+
response = self.client.call(:authenticate, message: {req:[{
|
76
|
+
user_name: username,
|
77
|
+
covered_password: covered_password,
|
78
|
+
random_number: random_number,
|
79
|
+
browser_ip: browser_ip,
|
80
|
+
hashing_algorithm: HASH_ALGORITHM}]}
|
81
|
+
)
|
82
|
+
@sessionid = response.body[:authenticate_response][:authenticate_result][:session_id]
|
83
|
+
end
|
84
|
+
|
85
|
+
def close_alarm (monitor_alarm_id, notes)
|
86
|
+
|
87
|
+
response = self.client.call(:close_alarm, message: {req:[{
|
88
|
+
monitor_alarm_i_d: monitor_alarm_id,
|
89
|
+
notes: notes,
|
90
|
+
browser_ip: @client_ip,
|
91
|
+
session_i_d: @sessionid}]}
|
92
|
+
)
|
93
|
+
response.body[:close_alarm_response][:close_alarm_result]
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_machine_group (group_name,org_name,parent_name)
|
97
|
+
|
98
|
+
response = self.client.call(:create_machine_group, message: {req:[{
|
99
|
+
group_name: group_name,
|
100
|
+
org_name: org_name,
|
101
|
+
parent_name: parent_name,
|
102
|
+
browser_ip: @client_ip,
|
103
|
+
session_i_d: @sessionid}]}
|
104
|
+
)
|
105
|
+
response.body[:create_machine_group_response][:create_machine_group_result]
|
106
|
+
end
|
107
|
+
|
108
|
+
def create_role (role_name,role_type,parent_role_name)
|
109
|
+
|
110
|
+
response = self.client.call(:create_role, message: {req:[{
|
111
|
+
role_name: role_name,
|
112
|
+
role_type: role_type,
|
113
|
+
parent_role_name: parent_role_name,
|
114
|
+
browser_ip: @client_ip,
|
115
|
+
session_i_d: @sessionid}]}
|
116
|
+
)
|
117
|
+
response.body[:create_role_response][:create_role_result]
|
118
|
+
end
|
119
|
+
|
120
|
+
def delete_admin (user_name)
|
121
|
+
|
122
|
+
response = self.client.call(:delete_admin, message: {req:[{
|
123
|
+
user_name: user_name,
|
124
|
+
browser_ip: @client_ip,
|
125
|
+
session_i_d: @sessionid}]}
|
126
|
+
)
|
127
|
+
response.body[:delete_admin_response][:delete_admin_result]
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_alarm (monitor_alarm_id)
|
131
|
+
|
132
|
+
response = self.client.call(:get_alarm, message: {req:[{
|
133
|
+
monitor_alarm_i_d: monitor_alarm_id,
|
134
|
+
browser_ip: @client_ip,
|
135
|
+
session_i_d: @sessionid}]}
|
136
|
+
)
|
137
|
+
response.body[:get_alarm_response][:get_alarm_result]
|
138
|
+
end
|
139
|
+
|
140
|
+
def get_alarm_list (get_all_records=true)
|
141
|
+
|
142
|
+
response = self.client.call(:get_alarm_list, message: {req:[{
|
143
|
+
return_all_records: get_all_records,
|
144
|
+
browser_ip: @client_ip,
|
145
|
+
session_i_d: @sessionid}]}
|
146
|
+
)
|
147
|
+
response.body[:get_alarm_list_response][:get_alarm_list_result]
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_machine(machine_group_id)
|
151
|
+
|
152
|
+
response = self.client.call(:get_machine, message: {req:[{
|
153
|
+
machine___group_i_d: machine_group_id,
|
154
|
+
browser_ip: @client_ip,
|
155
|
+
session_i_d: @sessionid}]}
|
156
|
+
)
|
157
|
+
response.body[:get_machine_response][:get_machine_result]
|
158
|
+
end
|
159
|
+
|
160
|
+
def get_machine_group_list
|
161
|
+
|
162
|
+
response = self.client.call(:get_machine_group_list, message: {req:[{
|
163
|
+
browser_ip: @client_ip,
|
164
|
+
session_i_d: @sessionid}]}
|
165
|
+
)
|
166
|
+
response.body[:get_machine_group_list_response][:get_machine_group_list_result]
|
167
|
+
end
|
168
|
+
|
169
|
+
def get_machine_list(machine_group,machine_collection)
|
170
|
+
|
171
|
+
response = self.client.call(:get_machine_list, message: {req:[{
|
172
|
+
machine_group: machine_group,
|
173
|
+
machine_collection: machine_collection,
|
174
|
+
browser_ip: @client_ip,
|
175
|
+
session_i_d: @sessionid}]}
|
176
|
+
)
|
177
|
+
response.body[:get_machine_list_response][:get_machine_list_result]
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
end
|
data/lib/kaseyaws/version.rb
CHANGED
data/lib/kaseyaws.rb
CHANGED
@@ -12,167 +12,6 @@
|
|
12
12
|
|
13
13
|
require "kaseyaws/version"
|
14
14
|
require "kaseyaws/security"
|
15
|
-
require "
|
15
|
+
require "kaseyaws/client"
|
16
16
|
|
17
|
-
module KaseyaWS
|
18
17
|
|
19
|
-
class Client
|
20
|
-
HASH_ALGORITHM = "SHA-256"
|
21
|
-
attr_accessor :client
|
22
|
-
|
23
|
-
def initialize (username,password,hostname)
|
24
|
-
|
25
|
-
@vsa_serviceurl = "https://" + hostname + "/vsaWS/kaseyaWS.asmx?WSDL"
|
26
|
-
@client_ip = KaseyaWS::Security.client_ip
|
27
|
-
@savon_options={
|
28
|
-
wsdl: @vsa_serviceurl,
|
29
|
-
convert_request_keys_to: :camelcase,
|
30
|
-
env_namespace: :soap,
|
31
|
-
open_timeout: 30,
|
32
|
-
log: false
|
33
|
-
}
|
34
|
-
@sessionid = self.authenticate(username,password)
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
# TODO To be added...
|
39
|
-
# def add_org(org_ref, org_name, default_dept_name, default_mg_name, website, no_emps, ann_revenue,
|
40
|
-
# method_of_contact, org_parent_ref, addr1, city, state, postal_code, country_ref, org_type
|
41
|
-
# primary_email, primary_phone, primary_fax, primary_staff_fk, browser_ip, sesion_id)
|
42
|
-
|
43
|
-
# client = Savon.client(@savon_options)
|
44
|
-
|
45
|
-
# response = client.call(:add_org, message: {req:[{
|
46
|
-
# group_name: group_name,
|
47
|
-
# scope_name: scope_name,
|
48
|
-
# browser_ip: @client_ip,
|
49
|
-
# session_i_d: @sessionid}]}
|
50
|
-
# )
|
51
|
-
# response.body[:get_machine_list_response][:get_machine_list_result]
|
52
|
-
# end
|
53
|
-
|
54
|
-
|
55
|
-
def add_mach_group_to_scope(group_name,scope_name)
|
56
|
-
|
57
|
-
response = self.client.call(:add_mach_group_to_scope, message: {req:[{
|
58
|
-
group_name: group_name,
|
59
|
-
scope_name: scope_name,
|
60
|
-
browser_ip: @client_ip,
|
61
|
-
session_i_d: @sessionid}]}
|
62
|
-
)
|
63
|
-
response.body[:add_mach_group_to_scope_response][:add_mach_group_to_scope_result]
|
64
|
-
end
|
65
|
-
|
66
|
-
def add_org_to_scope(company_id,scope_id)
|
67
|
-
|
68
|
-
response = self.client.call(:add_org_to_scope, message: {req:[{
|
69
|
-
company_i_d: company_id,
|
70
|
-
scope_i_d: scope_id,
|
71
|
-
session_i_d: @sessionid}]}
|
72
|
-
)
|
73
|
-
response.body[:add_org_to_scope_response][:add_org_to_scope_result]
|
74
|
-
end
|
75
|
-
|
76
|
-
def add_user_to_role(username,role_id)
|
77
|
-
|
78
|
-
response = self.client.call(:add_user_to_role, message: {req:[{
|
79
|
-
user_name: user_name,
|
80
|
-
role_i_d: role_id,
|
81
|
-
session_i_d: @sessionid}]}
|
82
|
-
)
|
83
|
-
response.body[:add_user_to_role_response][:add_user_to_role_result]
|
84
|
-
end
|
85
|
-
|
86
|
-
def authenticate(username,password)
|
87
|
-
|
88
|
-
random_number = KaseyaWS::Security.secure_random
|
89
|
-
covered_password = KaseyaWS::Security.compute_covered_password(username,password, random_number, HASH_ALGORITHM)
|
90
|
-
browser_ip = @client_ip
|
91
|
-
|
92
|
-
self.client = Savon::Client.new(@savon_options)
|
93
|
-
|
94
|
-
response = self.client.call(:authenticate, message: {req:[{
|
95
|
-
user_name: username,
|
96
|
-
covered_password: covered_password,
|
97
|
-
random_number: random_number,
|
98
|
-
browser_ip: browser_ip,
|
99
|
-
hashing_algorithm: HASH_ALGORITHM}]}
|
100
|
-
)
|
101
|
-
@sessionid = response.body[:authenticate_response][:authenticate_result][:session_id]
|
102
|
-
end
|
103
|
-
|
104
|
-
def close_alarm (monitor_alarm_id, notes)
|
105
|
-
|
106
|
-
response = self.client.call(:close_alarm, message: {req:[{
|
107
|
-
monitor_alarm_i_d: monitor_alarm_id,
|
108
|
-
notes: notes,
|
109
|
-
browser_ip: @client_ip,
|
110
|
-
session_i_d: @sessionid}]}
|
111
|
-
)
|
112
|
-
response.body[:close_alarm_response][:close_alarm_result]
|
113
|
-
end
|
114
|
-
|
115
|
-
def create_role (role_name,role_type,parent_role_name)
|
116
|
-
|
117
|
-
response = self.client.call(:create_role, message: {req:[{
|
118
|
-
role_name: role_name,
|
119
|
-
role_type: role_type,
|
120
|
-
parent_role_name: parent_role_name,
|
121
|
-
browser_ip: @client_ip,
|
122
|
-
session_i_d: @sessionid}]}
|
123
|
-
)
|
124
|
-
response.body[:create_role_response][:create_role_result]
|
125
|
-
end
|
126
|
-
|
127
|
-
def get_alarm (monitor_alarm_id)
|
128
|
-
|
129
|
-
response = self.client.call(:get_alarm, message: {req:[{
|
130
|
-
monitor_alarm_i_d: monitor_alarm_id,
|
131
|
-
browser_ip: @client_ip,
|
132
|
-
session_i_d: @sessionid}]}
|
133
|
-
)
|
134
|
-
response.body[:get_alarm_response][:get_alarm_result]
|
135
|
-
end
|
136
|
-
|
137
|
-
def get_alarm_list (get_all_records=true)
|
138
|
-
|
139
|
-
response = self.client.call(:get_alarm_list, message: {req:[{
|
140
|
-
return_all_records: get_all_records,
|
141
|
-
browser_ip: @client_ip,
|
142
|
-
session_i_d: @sessionid}]}
|
143
|
-
)
|
144
|
-
response.body[:get_alarm_list_response][:get_alarm_list_result]
|
145
|
-
end
|
146
|
-
|
147
|
-
def get_machine(machine_group_id)
|
148
|
-
|
149
|
-
response = self.client.call(:get_machine, message: {req:[{
|
150
|
-
machine___group_i_d: machine_group_id,
|
151
|
-
browser_ip: @client_ip,
|
152
|
-
session_i_d: @sessionid}]}
|
153
|
-
)
|
154
|
-
response.body[:get_machine_response][:get_machine_result]
|
155
|
-
end
|
156
|
-
|
157
|
-
def get_machine_group_list
|
158
|
-
|
159
|
-
response = self.client.call(:get_machine_group_list, message: {req:[{
|
160
|
-
browser_ip: @client_ip,
|
161
|
-
session_i_d: @sessionid}]}
|
162
|
-
)
|
163
|
-
response.body[:get_machine_group_list_response][:get_machine_group_list_result]
|
164
|
-
end
|
165
|
-
|
166
|
-
def get_machine_list(machine_group,machine_collection)
|
167
|
-
|
168
|
-
response = self.client.call(:get_machine_list, message: {req:[{
|
169
|
-
machine_group: machine_group,
|
170
|
-
machine_collection: machine_collection,
|
171
|
-
browser_ip: @client_ip,
|
172
|
-
session_i_d: @sessionid}]}
|
173
|
-
)
|
174
|
-
response.body[:get_machine_list_response][:get_machine_list_result]
|
175
|
-
end
|
176
|
-
|
177
|
-
end
|
178
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaseyaws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phillip Henslee
|
@@ -66,20 +66,21 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
70
|
-
email:
|
71
|
-
- phenslee@towerdigital.us
|
69
|
+
description: A Ruby Gem for Kaseya's VSA web services
|
70
|
+
email: phenslee@towerdigital.us
|
72
71
|
executables: []
|
73
72
|
extensions: []
|
74
73
|
extra_rdoc_files: []
|
75
74
|
files:
|
76
75
|
- .gitignore
|
76
|
+
- .yardopts
|
77
77
|
- Gemfile
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
81
|
- kaseyaws.gemspec
|
82
82
|
- lib/kaseyaws.rb
|
83
|
+
- lib/kaseyaws/client.rb
|
83
84
|
- lib/kaseyaws/security.rb
|
84
85
|
- lib/kaseyaws/version.rb
|
85
86
|
homepage: https://github.com/towerdigital/kaseyaws
|
@@ -105,5 +106,6 @@ rubyforge_project:
|
|
105
106
|
rubygems_version: 2.0.3
|
106
107
|
signing_key:
|
107
108
|
specification_version: 4
|
108
|
-
summary:
|
109
|
+
summary: A simple client for the Kaseya VSA web service
|
109
110
|
test_files: []
|
111
|
+
has_rdoc:
|