Class: Shipeasy::Admin::Client

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

Overview

Programmatic client for the Shipeasy Admin REST API. Each resource group is a lazily-constructed, memoized reader whose methods map 1:1 to the OpenAPI operations: #gates, #configs, #killswitches, #experiments, #universes, #metrics, #events, #alert_rules, #attributes, #projects, #ops, #i18n.

Constant Summary collapse

APIS =

Friendly reader name => generated Api class.

{
  gates: Generated::GatesApi,
  configs: Generated::ConfigsApi,
  killswitches: Generated::KillswitchesApi,
  experiments: Generated::ExperimentsApi,
  universes: Generated::UniversesApi,
  metrics: Generated::MetricsApi,
  events: Generated::EventsApi,
  alert_rules: Generated::AlertRulesApi,
  attributes: Generated::AttributesApi,
  projects: Generated::ProjectsApi,
  ops: Generated::OpsApi,
  i18n: Generated::I18nApi,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, project_id: nil, base_url: "https://shipeasy.ai") ⇒ Client

Returns a new instance of Client.

Parameters:

  • api_key (String)

    admin SDK key, sent as Authorization: Bearer <api_key>.

  • project_id (String, nil) (defaults to: nil)

    optional project id sent as the X-Project-Id header on every request. Operations also accept an explicit x_project_id: argument to override per call.

  • base_url (String) (defaults to: "https://shipeasy.ai")

    API base URL. Defaults to https://shipeasy.ai (the spec's production server); use http://localhost:3000 for local dev.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/shipeasy/admin.rb', line 65

def initialize(api_key:, project_id: nil, base_url: "https://shipeasy.ai")
  config = Generated::Configuration.new
  config.access_token = api_key
  scheme, _, host = base_url.rpartition("://")
  config.scheme = scheme unless scheme.empty?
  config.host = host.empty? ? base_url : host

  @api_client = Generated::ApiClient.new(config)
  @api_client.default_headers["X-Project-Id"] = project_id if project_id
  @apis = {}
end

Instance Attribute Details

#api_clientObject (readonly)

The underlying generated ApiClient (advanced/escape hatch).



78
79
80
# File 'lib/shipeasy/admin.rb', line 78

def api_client
  @api_client
end