Class: ATSD::EntitiesService
- Inherits:
-
BaseService
- Object
- BaseService
- ATSD::EntitiesService
- Defined in:
- lib/atsd/services/entities_service.rb
Overview
Entities service
Instance Method Summary collapse
-
#create_or_replace(entity) ⇒ self
Create an entity with specified properties and tags or replace an existing entity.
-
#delete(entity) ⇒ self
Delete the entity.
-
#get(entity) ⇒ Entity
Displays entity properties and all tags.
-
#list(options = {}) ⇒ Array<Entity>
Entities list.
-
#metrics(entity, options = {}) ⇒ Array<Metric>
Returns a list of metrics collected by the entity.
-
#property_types(entity, start_time = nil) ⇒ Array<String>
Returns an array of property types for the entity.
-
#update(entity) ⇒ self
Update specified properties and tags for the given entity.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from ATSD::BaseService
Instance Method Details
#create_or_replace(entity) ⇒ self
If only a subset of fields is provided for an existing entity, the remaining properties will be set to default values and tags will be deleted.
Create an entity with specified properties and tags or replace an existing entity. This method creates a new entity or replaces an existing entity.
49 50 51 52 53 54 55 |
# File 'lib/atsd/services/entities_service.rb', line 49 def create_or_replace(entity) entity = Entity.new(entity) if entity.is_a? Hash name = name_for_entity entity raise ArgumentError unless name @client.entities_create_or_replace(name, entity.to_request_hash) self end |
#delete(entity) ⇒ self
Delete the entity. Delete the entity from any Entity Groups that it belongs to. Data collected by the entity will be removed asynchronously in the background.
77 78 79 80 |
# File 'lib/atsd/services/entities_service.rb', line 77 def delete(entity) @client.entities_delete(name_for_entity entity) self end |
#get(entity) ⇒ Entity
Displays entity properties and all tags.
34 35 36 |
# File 'lib/atsd/services/entities_service.rb', line 34 def get(entity) Entity.new(@client.entities_get(name_for_entity entity)) end |
#list(options = {}) ⇒ Array<Entity>
Entities list
22 23 24 25 26 27 |
# File 'lib/atsd/services/entities_service.rb', line 22 def list( = {}) = .camelize_keys @client.entities_list().map do |json| Entity.new json end end |
#metrics(entity, options = {}) ⇒ Array<Metric>
Returns a list of metrics collected by the entity. The list is based on memory cache which is rebuilt on ATSD restart.
108 109 110 111 112 113 |
# File 'lib/atsd/services/entities_service.rb', line 108 def metrics(entity, = {}) = .camelize_keys @client.entities_metrics(name_for_entity(entity), ).map do |json| Metric.new json end end |
#property_types(entity, start_time = nil) ⇒ Array<String>
Returns an array of property types for the entity.
89 90 91 92 93 |
# File 'lib/atsd/services/entities_service.rb', line 89 def property_types(entity, start_time = nil) start_time = start_time.to_i * 1000 if start_time.is_a? Time params = start_time ? { :start_time => start_time } : {} @client.entities_property_types(name_for_entity(entity), params) end |
#update(entity) ⇒ self
updates specified properties and tags for an existing entity. Properties and tags that are not specified are left unchanged.
Update specified properties and tags for the given entity.
64 65 66 67 68 |
# File 'lib/atsd/services/entities_service.rb', line 64 def update(entity) entity = Entity.new(entity) if entity.is_a? Hash @client.entities_update(name_for_entity(entity), entity.to_request_hash) self end |