Class: Cyclid::Client::Tilapia

Inherits:
Object
  • Object
show all
Includes:
Auth, Health, Job, Organization, Stage, User
Defined in:
lib/cyclid/client.rb

Overview

Tilapia is the standard Cyclid Ruby client. It provides an inteligent programmable API on top of the standard Cyclid REST API, complete with automatic signing of HTTP requests and HTTP error handling.

The client provides interfaces for managing Users, Organizations, Stages & Jobs. Refer to the documentation for those modules for more information.

In case you’re wondering, this class required a name: it couldn’t be ‘Cyclid’ and it couldn’t be ‘Client’. Tilapia are a common type of Cichlid…

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Health

#health_ping

Methods included from Auth

#token_get

Methods included from Stage

#stage_create, #stage_get, #stage_list, #stage_modify

Methods included from Job

#job_get, #job_list, #job_log, #job_stats, #job_status, #job_submit

Methods included from Organization

#org_add, #org_config_get, #org_config_set, #org_delete, #org_get, #org_list, #org_modify, #org_user_get, #org_user_permissions

Methods included from User

#user_add, #user_delete, #user_get, #user_list, #user_modify

Constructor Details

#initialize(options) ⇒ Tilapia

Returns a new instance of Tilapia.

Parameters:

  • options (Hash)

Options Hash (options):

  • :config_path (String)

    Fully qualified path to the configuration file

  • :log_level (FixNum)

    Logger output level



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cyclid/client.rb', line 56

def initialize(options)
  @config = Config.new(options)

  # Create a logger
  log_level = options[:log_level] || Logger::FATAL
  @logger = Logger.new(STDERR)
  @logger.level = log_level

  # Select the API methods to use
  @api = case @config.auth
         when AuthMethods::AUTH_NONE
           Api::None.new(@config, @logger)
         when AuthMethods::AUTH_HMAC
           Api::Hmac.new(@config, @logger)
         when AuthMethods::AUTH_BASIC
           Api::Basic.new(@config, @logger)
         when AuthMethods::AUTH_TOKEN
           Api::Token.new(@config, @logger)
         end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

rubocop:disable Style/MethodMissing



95
96
97
# File 'lib/cyclid/client.rb', line 95

def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissing
  @api.send(method, *args, &block)
end

Instance Attribute Details

#configConfig (readonly)

Returns Client configuration object.

Returns:

  • (Config)

    Client configuration object



48
49
50
# File 'lib/cyclid/client.rb', line 48

def config
  @config
end

#loggerLogger (readonly)

Returns Client logger object.

Returns:

  • (Logger)

    Client logger object



48
49
50
# File 'lib/cyclid/client.rb', line 48

def logger
  @logger
end