Class: ATSD::ATSD

Inherits:
Object
  • Object
show all
Defined in:
lib/atsd/atsd.rb

Overview

Main class which holds REST client and resource services.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) {|Faraday::Connection| ... } ⇒ ATSD

Returns a new instance of ATSD.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :url (String)

    API Endpoint

  • :basic_auth (Hash{Symbol => String}, String)

    A string ‘login:password’ or hash with :login and :password keys

  • :logger (Boolean, Logger)

    ‘true` to use default logger, false to disable logging or a custom logger

Yields:

  • (Faraday::Connection)

    Modify middleware in the block

See Also:



23
24
25
# File 'lib/atsd/atsd.rb', line 23

def initialize(options, &block)
  @client = Client.new(options, &block)
end

Instance Attribute Details

#clientClient (readonly)

Returns REST API client.

Returns:

  • (Client)

    REST API client



14
15
16
# File 'lib/atsd/atsd.rb', line 14

def client
  @client
end

Class Method Details

.service(name, type) ⇒ Object

Defines a new lazy-loaded service

Parameters:

  • name (Symbol)

    the service name

  • type (Class)

    the service’s type



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/atsd/atsd.rb', line 33

def service(name, type)
  define_method(name) do
    var_name = "@#{name}"
    if instance_variable_defined? var_name
      instance_variable_get var_name
    else
      obj = type.new instance_variable_get('@client')
      instance_variable_set var_name, obj
      obj
    end
  end
end

Instance Method Details

#alerts_serviceAlertsService

Returns the alerts_service service.

Returns:



49
# File 'lib/atsd/atsd.rb', line 49

service :alerts_service, AlertsService

#entities_serviceEntitiesService

Returns the entities_service service.

Returns:



51
# File 'lib/atsd/atsd.rb', line 51

service :entities_service, EntitiesService

#entity_groups_serviceEntityGroupsService

Returns the entity_groups_service service.

Returns:



52
# File 'lib/atsd/atsd.rb', line 52

service :entity_groups_service, EntityGroupsService

#metrics_serviceMetricsService

Returns the metrics_service service.

Returns:



50
# File 'lib/atsd/atsd.rb', line 50

service :metrics_service, MetricsService

#properties_servicePropertiesService

Returns the properties_service service.

Returns:



48
# File 'lib/atsd/atsd.rb', line 48

service :properties_service, PropertiesService

#series_serviceSeriesService

Returns the series_service service.

Returns:



47
# File 'lib/atsd/atsd.rb', line 47

service :series_service, SeriesService