Class: ATSD::EntityGroupsService
- Inherits:
-
BaseService
- Object
- BaseService
- ATSD::EntityGroupsService
- Defined in:
- lib/atsd/services/entity_groups_service.rb
Instance Method Summary collapse
-
#add_entities(entity_group, entities, parameters = {}) ⇒ self
Add specified entities to entity group.
-
#create_or_replace(entity_group) ⇒ self
Create an entity group with specified properties and tags or replace an existing entity group.
-
#delete(entity_group) ⇒ self
Delete the entity group.
-
#delete_entities(entity_group, entities) ⇒ self
Delete entities from entity group.
-
#get(entity_group) ⇒ Array<EntityGroup>
Displays entity group properties and all tags.
-
#get_entities(entity_group, parameters = {}) ⇒ Array<Entity>
Get entities for entity group.
-
#list(parameters = {}) ⇒ Array<EntityGroup>
Entity groups list.
-
#replace_entities(entity_group, entities) ⇒ self
Replace entities in the entity group with the specified collection.
-
#update(entity_group) ⇒ self
Update specified properties and tags for the given entity group.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from ATSD::BaseService
Instance Method Details
#add_entities(entity_group, entities, parameters = {}) ⇒ self
Add specified entities to entity group.
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/atsd/services/entity_groups_service.rb', line 110 def add_entities(entity_group, entities, parameters = {}) entity_group = name_for_entity_group(entity_group) parameters = parameters.camelize_keys entities = Utils.ensure_array(entities).map do |e| e = Entity.new(name: e) if e.is_a? String e = Entity.new(e) if e.is_a? Hash e = e.to_request_hash end @client.entity_groups_add_entities(entity_group, entities, parameters) self end |
#create_or_replace(entity_group) ⇒ self
If only a subset of fields is provided for an existing entity group, the remaining properties and tags will be deleted.
Create an entity group with specified properties and tags or replace an existing entity group. This method creates a new entity group or replaces an existing entity group.
44 45 46 47 48 49 |
# File 'lib/atsd/services/entity_groups_service.rb', line 44 def create_or_replace(entity_group) entity_group = EntityGroup.new(name: entity_group) if entity_group.is_a? String entity_group = EntityGroup.new(entity_group) if entity_group.is_a? Hash @client.entity_groups_create_or_replace(entity_group.name, entity_group.to_request_hash) self end |
#delete(entity_group) ⇒ self
Entities that are members of the group are retained.
Delete the entity group.
74 75 76 77 |
# File 'lib/atsd/services/entity_groups_service.rb', line 74 def delete(entity_group) @client.entity_groups_delete(name_for_entity_group(entity_group)) self end |
#delete_entities(entity_group, entities) ⇒ self
Delete entities from entity group.
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/atsd/services/entity_groups_service.rb', line 149 def delete_entities(entity_group, entities) entity_group = name_for_entity_group(entity_group) entities = Utils.ensure_array(entities).map do |e| e = Entity.new(name: e) if e.is_a? String e = Entity.new(e) if e.is_a? Hash e = e.to_request_hash end @client.entity_groups_delete_entities(entity_group, entities) self end |
#get(entity_group) ⇒ Array<EntityGroup>
Displays entity group properties and all tags.
29 30 31 |
# File 'lib/atsd/services/entity_groups_service.rb', line 29 def get(entity_group) EntityGroup.new(@client.entity_groups_get(name_for_entity_group entity_group)) end |
#get_entities(entity_group, parameters = {}) ⇒ Array<Entity>
Get entities for entity group
93 94 95 96 97 98 99 |
# File 'lib/atsd/services/entity_groups_service.rb', line 93 def get_entities(entity_group, parameters = {}) entity_group = name_for_entity_group(entity_group) parameters = parameters.camelize_keys @client.entity_groups_get_entities(entity_group, parameters).map do |json| Entity.new json end end |
#list(parameters = {}) ⇒ Array<EntityGroup>
Entity groups list.
17 18 19 20 21 22 |
# File 'lib/atsd/services/entity_groups_service.rb', line 17 def list(parameters = {}) parameters = parameters.camelize_keys @client.entity_groups_list(parameters).map do |json| EntityGroup.new json end end |
#replace_entities(entity_group, entities) ⇒ self
All existing entities that are not included in the collection will be removed. If the specified collection is empty, all entities are removed from the group (replace with empty collection).
Replace entities in the entity group with the specified collection.
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/atsd/services/entity_groups_service.rb', line 132 def replace_entities(entity_group, entities) entity_group = name_for_entity_group(entity_group) entities = Utils.ensure_array(entities).map do |e| e = Entity.new(name: e) if e.is_a? String e = Entity.new(e) if e.is_a? Hash e = e.to_request_hash end @client.entity_groups_replace_entities(entity_group, entities) self end |
#update(entity_group) ⇒ self
Properties and tags that are not specified are left unchanged.
Update specified properties and tags for the given entity group. This method updates specified properties and tags for an existing entity group.
61 62 63 64 65 |
# File 'lib/atsd/services/entity_groups_service.rb', line 61 def update(entity_group) entity_group = EntityGroup.new(entity_group) if entity_group.is_a? Hash @client.entity_groups_update(entity_group.name, entity_group.to_request_hash) self end |