Class: ATSD::PropertiesService

Inherits:
BaseService show all
Defined in:
lib/atsd/services/properties_service.rb

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from ATSD::BaseService

Instance Method Details

#delete(properties) ⇒ self

Delete properties.

Parameters:

Returns:

  • (self)

Raises:



60
61
62
63
64
65
66
67
68
# File 'lib/atsd/services/properties_service.rb', line 60

def delete(properties)
  properties = Utils.ensure_array(properties).map do |s|
    s = s.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
    s = Property.new(s) if s.is_a? Hash
    s.to_request_hash.select { |k, v| [:entity, :type, :key].include? k }
  end
  @client.properties_delete(properties)
  self
end

#insert(properties) ⇒ self

Insert properties.

Parameters:

Returns:

  • (self)

Raises:



27
28
29
30
31
32
33
34
# File 'lib/atsd/services/properties_service.rb', line 27

def insert(properties)
  properties = Utils.ensure_array(properties).map do |s|
    s = Property.new(s) if s.is_a? Hash
    s.to_request_hash
  end
  @client.properties_insert properties
  self
end

#query(entity, type, options = {}) ⇒ PropertiesQuery

Create query builder for properties.

Parameters:

  • entity (String, Entity)
  • type (String)
  • options (Hash) (defaults to: {})

    other query parameters

Returns:



14
15
16
17
18
19
20
# File 'lib/atsd/services/properties_service.rb', line 14

def query(entity, type, options = {})
  query = PropertiesQuery.new @client
  entity = entity.name if entity.is_a? Entity
  options.merge! entity: entity, type: type
  options.each { |option, value| query[option] = value }
  query
end

#type_query(entity) ⇒ self

Returns an array of property types for the entity.

Parameters:

  • entity (String)

Returns:

  • (self)

Raises:



41
42
43
# File 'lib/atsd/services/properties_service.rb', line 41

def type_query(entity)
  @client.properties_for_entity(entity)
end

#url_query(entity, type) ⇒ self

Retrieve property records for the specified entity and type.

Parameters:

  • entity (String)
  • type (String)

Returns:

  • (self)

Raises:



51
52
53
# File 'lib/atsd/services/properties_service.rb', line 51

def url_query(entity, type)
  @client.properties_for_entity_and_type(entity,type)
end