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: #flags, #configs, #killswitch, #experiments, #universes, #attributes, #metrics, #events, #ops, #alerts, #projects, #profiles, #keys, #drafts, #errors, #connectors, #api_keys.

Constant Summary collapse

APIS =

Friendly reader name => generated Api class.

{
  flags: Generated::FlagsApi,
  configs: Generated::ConfigsApi,
  killswitch: Generated::KillswitchApi,
  experiments: Generated::ExperimentsApi,
  universes: Generated::UniversesApi,
  attributes: Generated::AttributesApi,
  metrics: Generated::MetricsApi,
  events: Generated::EventsApi,
  ops: Generated::OpsApi,
  alerts: Generated::AlertsApi,
  projects: Generated::ProjectsApi,
  profiles: Generated::ProfilesApi,
  keys: Generated::KeysApi,
  drafts: Generated::DraftsApi,
  errors: Generated::ErrorsApi,
  connectors: Generated::ConnectorsApi,
  api_keys: Generated::APIKeysApi,
}.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.



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/shipeasy/admin.rb', line 71

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).



84
85
86
# File 'lib/shipeasy/admin.rb', line 84

def api_client
  @api_client
end