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:



41
42
43
44
45
46
47
48
# File 'lib/atsd/services/properties_service.rb', line 41

def delete(properties)
  properties = Utils.ensure_array(properties).map do |s|
    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

#delete_match(matchers) ⇒ self

Delete rows that partially match the specified key

Parameters:

Returns:

  • (self)

Raises:



55
56
57
58
59
60
61
# File 'lib/atsd/services/properties_service.rb', line 55

def delete_match(matchers)
  matchers = Utils.ensure_array(matchers).map do |m|
    m.camelize_keys
  end
  @client.properties_delete_match matchers
  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