Class: Smplkit::Platform::PlatformClient
- Inherits:
-
Object
- Object
- Smplkit::Platform::PlatformClient
- Defined in:
- lib/smplkit/platform/client.rb
Overview
The Smpl Platform client (sync).
Groups the account-wide CRUD resources that aren’t owned by a single product, reachable as client.platform (Smplkit::Client) or constructed directly:
platform = Smplkit::PlatformClient.new(api_key: "sk_...")
prod = platform.environments.new("production", name: "Production")
prod.save
platform.services.list.each { |svc| ... }
Sub-clients: environments, services, contexts, context_types. Pure CRUD — no install required.
Instance Attribute Summary collapse
-
#context_types ⇒ Object
readonly
Returns the value of attribute context_types.
-
#contexts ⇒ Object
readonly
Returns the value of attribute contexts.
-
#environments ⇒ Object
readonly
Returns the value of attribute environments.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Class Method Summary collapse
-
.open(**kwargs) ⇒ Object
Construct, yield to the block, and close on exit.
Instance Method Summary collapse
-
#close ⇒ Object
Close the app transport — only when this client owns it.
-
#initialize(api_key: nil, base_url: nil, profile: nil, base_domain: nil, scheme: nil, debug: nil, extra_headers: nil, app_transport: nil, context_buffer: nil) ⇒ PlatformClient
constructor
A new instance of PlatformClient.
Constructor Details
#initialize(api_key: nil, base_url: nil, profile: nil, base_domain: nil, scheme: nil, debug: nil, extra_headers: nil, app_transport: nil, context_buffer: nil) ⇒ PlatformClient
Returns a new instance of PlatformClient.
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/smplkit/platform/client.rb', line 425 def initialize(api_key: nil, base_url: nil, profile: nil, base_domain: nil, scheme: nil, debug: nil, extra_headers: nil, app_transport: nil, context_buffer: nil) if app_transport.nil? @app_http = Platform.app_transport( api_key: api_key, base_url: base_url, profile: profile, base_domain: base_domain, scheme: scheme, debug: debug, extra_headers: extra_headers ) @owns_transport = true else @app_http = app_transport @owns_transport = false end buffer = context_buffer || ContextRegistrationBuffer.new @context_buffer = buffer @environments = EnvironmentsClient.new(@app_http) @services = ServicesClient.new(@app_http) @contexts = ContextsClient.new(@app_http, buffer) @context_types = ContextTypesClient.new(@app_http) end |
Instance Attribute Details
#context_types ⇒ Object (readonly)
Returns the value of attribute context_types.
423 424 425 |
# File 'lib/smplkit/platform/client.rb', line 423 def context_types @context_types end |
#contexts ⇒ Object (readonly)
Returns the value of attribute contexts.
423 424 425 |
# File 'lib/smplkit/platform/client.rb', line 423 def contexts @contexts end |
#environments ⇒ Object (readonly)
Returns the value of attribute environments.
423 424 425 |
# File 'lib/smplkit/platform/client.rb', line 423 def environments @environments end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
423 424 425 |
# File 'lib/smplkit/platform/client.rb', line 423 def services @services end |
Class Method Details
.open(**kwargs) ⇒ Object
Construct, yield to the block, and close on exit.
460 461 462 463 464 465 466 467 |
# File 'lib/smplkit/platform/client.rb', line 460 def self.open(**kwargs) client = new(**kwargs) begin yield client ensure client.close end end |
Instance Method Details
#close ⇒ Object
Close the app transport — only when this client owns it.
A wired client borrows the parent’s app transport and closes nothing.
451 452 453 454 455 456 457 |
# File 'lib/smplkit/platform/client.rb', line 451 def close return unless @owns_transport # The generated ApiClient owns Faraday connections that release on GC; # there is no explicit shutdown to call. nil end |