icws 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/icws/configuration/configurationitem.rb +75 -73
- data/lib/icws/configuration/roles.rb +3 -1
- data/lib/icws/configuration/stations.rb +3 -1
- data/lib/icws/configuration/users.rb +21 -16
- data/lib/icws/configuration/workgroups.rb +8 -7
- data/lib/icws/connection.rb +79 -80
- data/lib/icws/feature.rb +14 -13
- data/lib/icws/icwsclient.rb +88 -33
- data/lib/icws/messages/messagequeue.rb +66 -63
- data/lib/icws/messages/messagesubscriber.rb +13 -12
- data/lib/icws/statistics/statisticcategory.rb +26 -18
- data/lib/icws/statistics/statisticdefinition.rb +25 -17
- data/lib/icws/statistics/statistics.rb +23 -19
- data/lib/icws/status/status.rb +41 -30
- metadata +8 -22
- data/lib/configuration/configurationitem.rb +0 -35
- data/lib/configuration/users.rb +0 -11
- data/lib/configuration/workgroups.rb +0 -11
- data/lib/connection.rb +0 -75
- data/lib/feature.rb +0 -12
- data/lib/icws/INTERNAL/challangemessagehandler.rb +0 -25
- data/lib/icws/INTERNAL/internalconnection.rb +0 -1
- data/lib/icwsclient.rb +0 -40
- data/lib/messages/messagequeue.rb +0 -65
- data/lib/messages/messagesubscriber.rb +0 -14
- data/lib/statistics/statisticcategory.rb +0 -22
- data/lib/statistics/statisticdefinition.rb +0 -20
- data/lib/statistics/statistics.rb +0 -24
- data/lib/status/status.rb +0 -35
- data/lib/status/statusmessage.rb +0 -41
- data/lib/status/userstatus.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51ae20e8401fa11a039502013feec4fa9ac3bc72
|
4
|
+
data.tar.gz: c47b130b74d603c37d99e970eee2a8ff1f325d73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e6bda8d7475b21d65995dd848dabefa78d188301e7a57c7567434f3df3f7a50063f2a9ce0909088702cb2dd859d1deb51bc2b5ed825e65650824bba09287da2
|
7
|
+
data.tar.gz: 92d1fe0ffc491192cafa27698db0b962110107c9807c488aa81d4e157d80f871735628b5b030f933de7a1fc8e2a632351a10a04d75eee8b6c54f7fa448cff97e
|
@@ -2,78 +2,80 @@ require 'icws/connection'
|
|
2
2
|
require 'icws/icwsclient'
|
3
3
|
|
4
4
|
class ICWS
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
5
|
+
class Configuration
|
6
|
+
# A representation of an object in CIC (User, Workgroup, Station, etc). This class should be subclassed as the constructor is protected.
|
7
|
+
|
8
|
+
class ConfigurationItem
|
9
|
+
protected
|
10
|
+
def initialize(connection, class_name)
|
11
|
+
@class_name = class_name
|
12
|
+
@uri = '/configuration/'+ @class_name
|
13
|
+
@client = ICWS::Client.new connection
|
14
|
+
end
|
15
|
+
|
16
|
+
public
|
17
|
+
# Gets the configuration item with the specified id.
|
18
|
+
# @param id [String] ID of the configuration item.
|
19
|
+
# @param fields [String] Comma ',' deliminated string of fields to return. Check the ICWS documentation for the available fields.
|
20
|
+
# @return [Object] The configuration item.
|
21
|
+
def get(id, fields="configurationId")
|
22
|
+
@client.get(@uri + '/' + id + '?select='+ fields)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Deletes the configuration item with the specified id.
|
26
|
+
# @param id [String] ID of the configuration item.
|
27
|
+
def delete(id)
|
28
|
+
@client.delete @uri + '/' + id
|
29
|
+
end
|
30
|
+
|
31
|
+
# Gets all of the configured items.
|
32
|
+
# @param fields [String] comma-delimitedstring of fields to return. Check the ICWS documentation for the available fields.
|
33
|
+
# @param where [String] A comma-delimited list of conditions to apply to the query. Only items that satisfy all conditions will be returned. The following operators can be used: eq - equals, sw - starts with, ct - contains Example: where=configurationId.id sw St
|
34
|
+
# @param order_by [String] The name of the field to sort the results by. The default is to sort by configurationId.id in ascending order. A query can only be sorted by one field. To order in descending order use: orderBy=configurationId.id desc
|
35
|
+
# @param rights_filter [String] A comma-delimited list of conditions to apply to the query. Only items that satisfy all conditions will be returned. The following operators can be used: eq - equals, sw - starts with, ct - contains Example: where=configurationId.id sw St
|
36
|
+
# @return [Array[Hash]] The configuration items.
|
37
|
+
def get_all(fields="configurationId", where=nil, order_by="configurationId.id", rights_filter="admin")
|
38
|
+
|
39
|
+
query_string = '?select='+ fields + '&orderBy=' + order_by +'rightsFilter=' + rights_filter
|
40
|
+
if where != nil
|
41
|
+
query_string += "&where=" + where
|
42
|
+
end
|
43
|
+
|
44
|
+
@client.get(@uri + query_string)["items"]
|
45
|
+
end
|
46
|
+
|
47
|
+
# Creates a new configuration item.
|
48
|
+
# @param id [String] Id of the new item.
|
49
|
+
# @param new_item [Hash] Object with the configuration properties of the new item. See ICWS documentation for the valid properties.
|
50
|
+
def create_new(id, new_item)
|
51
|
+
if new_item['configurationId'].nil?
|
52
|
+
config_id = {}
|
53
|
+
config_id['id'] = id
|
54
|
+
config_id['displayName'] = id
|
55
|
+
new_item['configurationId'] = config_id
|
56
|
+
end
|
57
|
+
|
58
|
+
@client.post @uri, new_item
|
59
|
+
end
|
60
|
+
|
61
|
+
# Updates an existing configuration item.
|
62
|
+
# @param id [String] Id of the item.
|
63
|
+
# @param configuration_item [Hash] Object with the configuration properties of the new item. See ICWS documentation for the valid properties.
|
64
|
+
def update(id, configuration_item)
|
65
|
+
if configuration_item['configurationId'].nil?
|
66
|
+
config_id = {}
|
67
|
+
config_id['id'] = id
|
68
|
+
config_id['displayName'] = id
|
69
|
+
configuration_item['configurationId'] = config_id
|
70
|
+
end
|
71
|
+
|
72
|
+
@client.put @uri + '/' + id, configuration_item
|
73
|
+
end
|
74
|
+
|
75
|
+
# Gets the default values for the configuration item.
|
76
|
+
def defaults
|
77
|
+
@client.get '/configuration/defaults/' + @class_name.chomp('s')
|
78
|
+
end
|
68
79
|
end
|
69
|
-
|
70
|
-
@client.put @uri + '/' + id, configuration_item
|
71
|
-
end
|
72
|
-
|
73
|
-
# Gets the default values for the configuration item.
|
74
|
-
def defaults
|
75
|
-
@client.get '/configuration/defaults/' + @class_name.chomp('s')
|
76
|
-
end
|
77
80
|
end
|
78
|
-
|
79
|
-
end
|
81
|
+
end
|
@@ -2,10 +2,12 @@ require 'icws/configuration/configurationitem'
|
|
2
2
|
|
3
3
|
class ICWS
|
4
4
|
class Configuration
|
5
|
+
# Represents the roles configuration in CIC. This class can perform operations to create/edit/delete roles.
|
6
|
+
|
5
7
|
class Roles < ICWS::Configuration::ConfigurationItem
|
6
8
|
def initialize(connection)
|
7
9
|
super(connection,'roles')
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
11
|
-
end
|
13
|
+
end
|
@@ -2,10 +2,12 @@ require 'icws/configuration/configurationitem'
|
|
2
2
|
|
3
3
|
class ICWS
|
4
4
|
class Configuration
|
5
|
+
# Represents the stations configuration in CIC. This class can perform operations to create/edit/delete stations.
|
6
|
+
|
5
7
|
class Stations < ICWS::Configuration::ConfigurationItem
|
6
8
|
def initialize(connection)
|
7
9
|
super(connection,'stations')
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
11
|
-
end
|
13
|
+
end
|
@@ -1,20 +1,25 @@
|
|
1
1
|
require 'icws/configuration/configurationitem'
|
2
2
|
|
3
3
|
class ICWS
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
class Configuration
|
5
|
+
# Represents the users configuration in CIC. This class can perform operations to create/edit/delete users.
|
6
|
+
class Users < ICWS::Configuration::ConfigurationItem
|
7
|
+
def initialize(connection)
|
8
|
+
super(connection,'users')
|
9
|
+
end
|
10
|
+
|
11
|
+
#sets the password on a user
|
12
|
+
# @param user_id [String] Id user to change.
|
13
|
+
# @param password [String] new password to change to.
|
14
|
+
# @param force [bool] Forces the password change, false will fail if password does not meet password policies..
|
15
|
+
def set_password(user_id, password, force)
|
16
|
+
icws_uri = @uri + '/' + user_id + '/password'
|
17
|
+
puts 'setting password to ' + password
|
18
|
+
puts 'to: ' + icws_uri
|
19
|
+
@client.put icws_uri,
|
20
|
+
{ :password => password,
|
21
|
+
:force => force}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
18
25
|
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'icws/configuration/configurationitem'
|
2
2
|
|
3
3
|
class ICWS
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
class Configuration
|
5
|
+
# Represents the workgroups configuration in CIC. This class can perform operations to create/edit/delete Workgroups.
|
6
|
+
class Workgroups < ICWS::Configuration::ConfigurationItem
|
7
|
+
def initialize(connection)
|
8
|
+
super(connection,'workgroups')
|
9
|
+
end
|
10
|
+
end
|
9
11
|
end
|
10
|
-
|
11
|
-
end
|
12
|
+
end
|
data/lib/icws/connection.rb
CHANGED
@@ -4,85 +4,84 @@ require 'json'
|
|
4
4
|
require 'icws/feature'
|
5
5
|
|
6
6
|
class ICWS
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
7
|
+
#Representation of a connectio nto a CIC server.
|
8
|
+
class Connection
|
9
|
+
# Creates a new connection
|
10
|
+
# @param application_name [String] the name of the application
|
11
|
+
# @param server [String] the server to connect to
|
12
|
+
def initialize(application_name, server)
|
13
|
+
@application_name = application_name
|
14
|
+
@server = server
|
15
|
+
end
|
16
|
+
|
17
|
+
# Connects to the server
|
18
|
+
# @param user [String] the name of the user to connect with
|
19
|
+
# @param password [String] the password for the user
|
20
|
+
def connect(user, password)
|
21
|
+
connectResponse = RestClient.post @server +'/icws/connection',
|
22
|
+
{ :applicationName => @application_name,
|
23
|
+
:userID => user,
|
24
|
+
:password => password}.to_json,
|
25
|
+
:content_type => :json,
|
26
|
+
:accept => :json,
|
27
|
+
'Accept-Language' => 'en-us'
|
28
|
+
|
29
|
+
response = JSON.parse(connectResponse);
|
30
|
+
@cookie = connectResponse.headers[:set_cookie][0]
|
31
|
+
@csrf_token = response['csrfToken']
|
32
|
+
@session_id = response['sessionId']
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
# Gets the name of the application.
|
37
|
+
# @return [String] Application name.
|
38
|
+
def application_name
|
39
|
+
@application_name
|
40
|
+
end
|
41
|
+
|
42
|
+
# Gets the connection token.
|
43
|
+
# @return [String] connection token
|
44
|
+
def token
|
45
|
+
@csrf_token
|
46
|
+
end
|
47
|
+
|
48
|
+
# Gets the connection cookie.
|
49
|
+
# @return [String] connection cookie
|
50
|
+
def cookie
|
51
|
+
@cookie
|
52
|
+
end
|
53
|
+
|
54
|
+
# Gets the url of the server
|
55
|
+
# @return [String] the url of the server
|
56
|
+
def server
|
57
|
+
@server
|
58
|
+
end
|
59
|
+
|
60
|
+
# Gets the version of the server.
|
61
|
+
# @return the version of the server.
|
62
|
+
def version
|
63
|
+
JSON.parse RestClient.get @server+'/icws/connection/version'
|
64
|
+
end
|
65
|
+
|
66
|
+
# Gets the features of the server.
|
67
|
+
# @return [Array[ICWS::Connection::Features]] the features of the server
|
68
|
+
def features
|
69
|
+
data = JSON.parse RestClient.get @server+'/icws/connection/features'
|
70
|
+
features = data["featureInfoList"].map { |rd| ICWS::Connection::Feature.new(rd["featureId"], rd["version"]) }
|
71
|
+
end
|
72
|
+
|
73
|
+
# Generates a full uri given the resource path.
|
74
|
+
# @param path [String] The path to the ReST resource.
|
75
|
+
# @return [String] The full url.
|
76
|
+
def generate_uri(path)
|
77
|
+
base_uri + path
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns the base uri to the server, including the session id
|
81
|
+
# @return [String] The base url with session id.
|
82
|
+
def base_uri
|
83
|
+
@server+'/icws/' + @session_id +'/'
|
84
|
+
end
|
85
|
+
end
|
85
86
|
end
|
86
|
-
end
|
87
87
|
end
|
88
|
-
|
data/lib/icws/feature.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
class ICWS
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class Connection
|
3
|
+
#A feature of the CIC server
|
4
|
+
class Feature
|
5
|
+
attr_accessor :feature, :version
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
def initialize(feature, version)
|
8
|
+
@feature = feature
|
9
|
+
@version = version
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
@feature + ' - ' + @version.to_s
|
14
|
+
end
|
15
|
+
end
|
14
16
|
end
|
15
|
-
|
16
|
-
end
|
17
|
+
end
|