Class: Smplkit::ManagementClient

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/management/client.rb

Overview

Top-level management client. Owns the HTTP transports + CRUD APIs for every resource on the smplkit platform.

Sub-namespaces (mirroring the Python SDK):

- +mgmt.contexts.*+
- +mgmt.context_types.*+
- +mgmt.environments.*+
- +mgmt.account_settings.*+
- +mgmt.config.*+
- +mgmt.flags.*+
- +mgmt.loggers.*+
- +mgmt.log_groups.*+

Constructable both as Smplkit::ManagementClient.new (standalone) and as Smplkit::Client#manage (shared transports).

Defined Under Namespace

Modules: HttpHelpers Classes: AccountSettingsNamespace, ConfigNamespace, ContextTypesNamespace, ContextsNamespace, EnvironmentsNamespace, FlagsNamespace, LogGroupsNamespace, LoggersNamespace

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, base_domain: nil, scheme: nil, profile: nil, debug: nil, _resolved: nil) ⇒ ManagementClient

Returns a new instance of ManagementClient.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/smplkit/management/client.rb', line 32

def initialize(api_key: nil, base_domain: nil, scheme: nil, profile: nil,
               debug: nil, _resolved: nil)
  cfg = _resolved ||
        ConfigResolution.resolve_management_config(
          api_key: api_key, base_domain: base_domain, scheme: scheme,
          profile: profile, debug: debug
        )
  Smplkit.enable_debug if cfg.debug

  @resolved = cfg
  @app_http = build_http(ConfigResolution.service_url(cfg.scheme, "app", cfg.base_domain), cfg.api_key)
  @config_http = build_http(ConfigResolution.service_url(cfg.scheme, "config", cfg.base_domain), cfg.api_key)
  @flags_http = build_http(ConfigResolution.service_url(cfg.scheme, "flags", cfg.base_domain), cfg.api_key)
  @logging_http = build_http(ConfigResolution.service_url(cfg.scheme, "logging", cfg.base_domain), cfg.api_key)

  @contexts = ContextsNamespace.new(@app_http)
  @context_types = ContextTypesNamespace.new(@app_http)
  @environments = EnvironmentsNamespace.new(@app_http)
  @account_settings = AccountSettingsNamespace.new(@app_http)
  @config = ConfigNamespace.new(@config_http)
  @flags = FlagsNamespace.new(@flags_http)
  @loggers = LoggersNamespace.new(@logging_http)
  @log_groups = LogGroupsNamespace.new(@logging_http)
end

Instance Attribute Details

#account_settingsObject (readonly)

Returns the value of attribute account_settings.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def 
  @account_settings
end

#configObject (readonly)

Returns the value of attribute config.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def config
  @config
end

#context_typesObject (readonly)

Returns the value of attribute context_types.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def context_types
  @context_types
end

#contextsObject (readonly)

Returns the value of attribute contexts.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def contexts
  @contexts
end

#environmentsObject (readonly)

Returns the value of attribute environments.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def environments
  @environments
end

#flagsObject (readonly)

Returns the value of attribute flags.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def flags
  @flags
end

#log_groupsObject (readonly)

Returns the value of attribute log_groups.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def log_groups
  @log_groups
end

#loggersObject (readonly)

Returns the value of attribute loggers.



25
26
27
# File 'lib/smplkit/management/client.rb', line 25

def loggers
  @loggers
end

Class Method Details

.from_resolved(resolved) ⇒ Object



28
29
30
# File 'lib/smplkit/management/client.rb', line 28

def self.from_resolved(resolved)
  new(_resolved: resolved)
end

Instance Method Details

#_app_httpObject



64
# File 'lib/smplkit/management/client.rb', line 64

def _app_http = @app_http

#_config_httpObject



65
# File 'lib/smplkit/management/client.rb', line 65

def _config_http = @config_http

#_flags_httpObject



66
# File 'lib/smplkit/management/client.rb', line 66

def _flags_http = @flags_http

#_logging_httpObject



67
# File 'lib/smplkit/management/client.rb', line 67

def _logging_http = @logging_http

#_resolvedObject



63
# File 'lib/smplkit/management/client.rb', line 63

def _resolved = @resolved

#closeObject



57
58
59
60
61
# File 'lib/smplkit/management/client.rb', line 57

def close
  [@app_http, @config_http, @flags_http, @logging_http].each do |conn|
    conn.close if conn.respond_to?(:close)
  end
end