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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4582f84a075afdde9d1679e342dc83d0c62cb97f
4
- data.tar.gz: c32ccd82c47d0cbfa157f00cf8d0d6cc2f86657e
3
+ metadata.gz: 51ae20e8401fa11a039502013feec4fa9ac3bc72
4
+ data.tar.gz: c47b130b74d603c37d99e970eee2a8ff1f325d73
5
5
  SHA512:
6
- metadata.gz: 47362ab14203ae5f2be291318011c0f57f7d3fa38430d17ed68a346e6055a04248095ea5217af938147c27740de54e7a93f6caee913642131436a5ccb0375f41
7
- data.tar.gz: 9b1a60ce897d7e3ad9c517b91d220e5db0c365b455ab98ab5da6f83f4d540d8956ecd38eb780583a0f55a3df54e76f840fe686bd4a9f5111d4399b015aad16ef
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
- class Configuration
6
- class ConfigurationItem
7
- protected
8
- def initialize(connection, class_name)
9
- @class_name = class_name
10
- @uri = '/configuration/'+ @class_name
11
- @client = ICWS::Client.new connection
12
- end
13
-
14
- public
15
- # Gets the configuration item with the specified id.
16
- # @param id [String] ID of the configuration item.
17
- # @param fields [String] Comma ',' deliminated string of fields to return. Check the ICWS documentation for the available fields.
18
- # @return [Object] The configuration item.
19
- def get(id, fields="configurationId")
20
- @client.get(@uri + '/' + id + '?select='+ fields)
21
- end
22
-
23
- # Deletes the configuration item with the specified id.
24
- # @param id [String] ID of the configuration item.
25
- def delete(id)
26
- @client.delete @uri + '/' + id
27
- end
28
-
29
- # Gets all of the configured items.
30
- # @param fields [String] comma-delimitedstring of fields to return. Check the ICWS documentation for the available fields.
31
- # @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
32
- # @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
33
- # @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
34
- # @return [Array[Hash]] The configuration items.
35
- def get_all(fields="configurationId", where=nil, order_by="configurationId.id", rights_filter="admin")
36
-
37
- query_string = '?select='+ fields + '&orderBy=' + order_by +'rightsFilter=' + rights_filter
38
- if where != nil
39
- query_string += "&where=" + where
40
- end
41
-
42
- @client.get(@uri + query_string)["items"]
43
- end
44
-
45
- # Creates a new configuration item.
46
- # @param id [String] Id of the new item.
47
- # @param new_item [Hash] Object with the configuration properties of the new item. See ICWS documentation for the valid properties.
48
- def create_new(id, new_item)
49
- if new_item['configurationId'].nil?
50
- config_id = {}
51
- config_id['id'] = id
52
- config_id['displayName'] = id
53
- new_item['configurationId'] = config_id
54
- end
55
-
56
- @client.post @uri, new_item
57
- end
58
-
59
- # Updates an existing configuration item.
60
- # @param id [String] Id of the item.
61
- # @param new_item [Hash] Object with the configuration properties of the new item. See ICWS documentation for the valid properties.
62
- def update(id, configuration_item)
63
- if configuration_item['configurationId'].nil?
64
- config_id = {}
65
- config_id['id'] = id
66
- config_id['displayName'] = id
67
- configuration_item['configurationId'] = config_id
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
- end
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
- class Configuration
5
- class Users < ICWS::Configuration::ConfigurationItem
6
- def initialize(connection)
7
- super(connection,'users')
8
- end
9
-
10
- def set_password(user_id, password, force)
11
- icws_uri = @uri + '/' + user_id + '/password'
12
- puts 'setting password to ' + password
13
- puts 'to: ' + icws_uri
14
- @client.put icws_uri,
15
- { :password => password,
16
- :force => force}
17
- end
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
- class Configuration
5
- class Workgroups < ICWS::Configuration::ConfigurationItem
6
- def initialize(connection)
7
- super(connection,'workgroups')
8
- end
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
- end
11
- end
12
+ end
@@ -4,85 +4,84 @@ require 'json'
4
4
  require 'icws/feature'
5
5
 
6
6
  class ICWS
7
- class Connection
8
- # Creates a new connection
9
- # @param applicationName [String] the name of the application
10
- # @param server [String] the server to connect to
11
- def initialize(application_name, server)
12
- @application_name = application_name
13
- @server = server
14
- end
15
-
16
- # Connects to the server
17
- # @param user [String] the name of the user to connect with
18
- # @param password [String] the password for the user
19
- def connect(user, password)
20
- connectResponse = RestClient.post @server +'/icws/connection',
21
- { :ininInternalUseOnly => 'aaIZoS5tNSy81oNrtp3r+N2cZVal5Gbk+3vYO5k9nho=',
22
- '__type' => "urn:inin.com:connection:icAuthConnectionRequestSettings",
23
- :applicationName => @application_name,
24
- :userID => user,
25
- :password => password}.to_json,
26
- :content_type => :json,
27
- :accept => :json,
28
- 'Accept-Language' => 'en-us'
29
-
30
- response = JSON.parse(connectResponse);
31
- @cookie = connectResponse.headers[:set_cookie][0]
32
- @csrf_token = response['csrfToken']
33
- @session_id = response['sessionId']
34
-
35
- end
36
-
37
- # Gets the name of the application.
38
- # @return [String] Application name.
39
- def application_name
40
- @application_name
41
- end
42
-
43
- # Gets the connection token.
44
- # @return [String] connection token
45
- def token
46
- @csrf_token
47
- end
48
-
49
- # Gets the connection cookie.
50
- # @return [String] connection cookie
51
- def cookie
52
- @cookie
53
- end
54
-
55
- # Gets the url of the server
56
- # @return [String] the url of the server
57
- def server
58
- @server
59
- end
60
-
61
- # Gets the version of the server.
62
- # @return the version of the server.
63
- def version
64
- JSON.parse RestClient.get @server+'/icws/connection/version'
65
- end
66
-
67
- # Gets the features of the server.
68
- # @return [Array[ICWS::Connection::Features]] the features of the server
69
- def features
70
- data = JSON.parse RestClient.get @server+'/icws/connection/features'
71
- features = data["featureInfoList"].map { |rd| ICWS::Connection::Feature.new(rd["featureId"], rd["version"]) }
72
- end
73
-
74
- # Generates a full uri given the resource path.
75
- # @param path [String] The path to the ReST resource.
76
- # @return [String] The full url.
77
- def generate_uri(path)
78
- base_uri + path
79
- end
80
-
81
- # Returns the base uri to the server, including the session id
82
- # @return [String] The base url with session id.
83
- def base_uri
84
- @server+'/icws/' + @session_id +'/'
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
- class Connection
3
- class Feature
4
- attr_accessor :feature, :version
2
+ class Connection
3
+ #A feature of the CIC server
4
+ class Feature
5
+ attr_accessor :feature, :version
5
6
 
6
- def initialize(feature, version)
7
- @feature = feature
8
- @version = version
9
- end
10
-
11
- def to_s
12
- @feature + ' - ' + @version.to_s
13
- end
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
- end
16
- end
17
+ end