Class: Runcible::Instance

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Instance

Initialize a Runcible instance

Parameters:

  • config (Hash) (defaults to: {})
  • http_auth (Hash)

    a customizable set of options

Options Hash (config):

  • :user (String)

    Pulp username

  • :oauth (String)

    Oauth credentials

  • :headers (Hash)

    Additional headers e.g. content-type => “application/json”

  • :url (String)

    Scheme and hostname for the pulp server e.g. localhost/

  • :api_path (String)

    URL path for the api e.g. pulp/api/v2/

  • :timeout (String)

    Timeout in seconds for the connection (defaults to rest client’s default)

  • :open_timeout (String)

    timeout in seconds for the connection to open(defaults to rest client’s default)

  • :http_auth (Hash)

    Needed when using simple http auth



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/runcible/instance.rb', line 19

def initialize(config = {})
  @config = {
    :api_path   => '/pulp/api/v2/',
    :url        => 'https://localhost',
    :user       => '',
    :http_auth  => {:password => {} },
    :headers    => {:content_type => 'application/json',
                    :accept       => 'application/json'},
    :logging    => {}
  }.merge(config).with_indifferent_access

  initialize_wrappers
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



40
41
42
# File 'lib/runcible/instance.rb', line 40

def config
  @config
end

#extensionsObject

Returns the value of attribute extensions.



4
5
6
# File 'lib/runcible/instance.rb', line 4

def extensions
  @extensions
end

#resourcesObject

Returns the value of attribute resources.



3
4
5
# File 'lib/runcible/instance.rb', line 3

def resources
  @resources
end

Class Method Details

.extension_classesObject



49
50
51
52
# File 'lib/runcible/instance.rb', line 49

def extension_classes
  @@extension_classes ||= gather_classes('extensions')
  @@extension_classes
end

.resource_classesObject

rubocop:disable Style/ClassVars



44
45
46
47
# File 'lib/runcible/instance.rb', line 44

def resource_classes
  @@resource_classes ||= gather_classes('resources')
  @@resource_classes
end

Instance Method Details

#update_config(key, value) ⇒ Object

Update an existing config value

Parameters:

  • key (String, Symbol)

    The key of the config to update

  • value (Object)

    The value of the config to update



36
37
38
# File 'lib/runcible/instance.rb', line 36

def update_config(key, value)
  @config[key] = value
end