Class: ICWS::Configuration::ConfigurationItem

Inherits:
Object
  • Object
show all
Defined in:
lib/icws/configuration/configurationitem.rb

Overview

A representation of an object in CIC (User, Workgroup, Station, etc). This class should be subclassed as the constructor is protected.

Direct Known Subclasses

Roles, Stations, Users, Workgroups

Instance Method Summary collapse

Instance Method Details

#create_new(id, new_item) ⇒ Object

Creates a new configuration item.

Parameters:

  • id (String)

    Id of the new item.

  • new_item (Hash)

    Object with the configuration properties of the new item. See ICWS documentation for the valid properties.



50
51
52
53
54
55
56
57
58
59
# File 'lib/icws/configuration/configurationitem.rb', line 50

def create_new(id, new_item)
    if new_item['configurationId'].nil?
        config_id = {}
        config_id['id'] = id
        config_id['displayName'] = id
        new_item['configurationId'] = config_id
    end

    @client.post @uri, new_item
end

#defaultsObject

Gets the default values for the configuration item.



76
77
78
# File 'lib/icws/configuration/configurationitem.rb', line 76

def defaults
    @client.get '/configuration/defaults/' + @class_name.chomp('s')
end

#delete(id) ⇒ Object

Deletes the configuration item with the specified id.

Parameters:

  • id (String)

    ID of the configuration item.



27
28
29
# File 'lib/icws/configuration/configurationitem.rb', line 27

def delete(id)
    @client.delete @uri + '/' + id
end

#get(id, fields = "configurationId") ⇒ Object

Gets the configuration item with the specified id.

Parameters:

  • id (String)

    ID of the configuration item.

  • fields (String) (defaults to: "configurationId")

    Comma ‘,’ deliminated string of fields to return. Check the ICWS documentation for the available fields.

Returns:

  • (Object)

    The configuration item.



21
22
23
# File 'lib/icws/configuration/configurationitem.rb', line 21

def get(id, fields="configurationId")
    @client.get(@uri + '/' + id + '?select='+ fields)
end

#get_all(fields = "configurationId", where = nil, order_by = "configurationId.id", rights_filter = "admin") ⇒ Array[Hash]

Gets all of the configured items.

Parameters:

  • fields (String) (defaults to: "configurationId")

    comma-delimitedstring of fields to return. Check the ICWS documentation for the available fields.

  • where (String) (defaults to: nil)

    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

  • order_by (String) (defaults to: "configurationId.id")

    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

  • rights_filter (String) (defaults to: "admin")

    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

Returns:

  • (Array[Hash])

    The configuration items.



37
38
39
40
41
42
43
44
45
# File 'lib/icws/configuration/configurationitem.rb', line 37

def get_all(fields="configurationId", where=nil, order_by="configurationId.id", rights_filter="admin")

    query_string =  '?select='+ fields + '&orderBy=' + order_by +'rightsFilter=' + rights_filter
    if where != nil
        query_string += "&where=" + where
    end

    @client.get(@uri + query_string)["items"]
end

#update(id, configuration_item) ⇒ Object

Updates an existing configuration item.

Parameters:

  • id (String)

    Id of the item.

  • configuration_item (Hash)

    Object with the configuration properties of the new item. See ICWS documentation for the valid properties.



64
65
66
67
68
69
70
71
72
73
# File 'lib/icws/configuration/configurationitem.rb', line 64

def update(id, configuration_item)
    if configuration_item['configurationId'].nil?
        config_id = {}
        config_id['id'] = id
        config_id['displayName'] = id
        configuration_item['configurationId'] = config_id
    end

    @client.put @uri + '/' + id, configuration_item
end