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.
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
# File 'lib/smplkit/platform/client.rb', line 550 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.
548 549 550 |
# File 'lib/smplkit/platform/client.rb', line 548 def context_types @context_types end |
#contexts ⇒ Object (readonly)
Returns the value of attribute contexts.
548 549 550 |
# File 'lib/smplkit/platform/client.rb', line 548 def contexts @contexts end |
#environments ⇒ Object (readonly)
Returns the value of attribute environments.
548 549 550 |
# File 'lib/smplkit/platform/client.rb', line 548 def environments @environments end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
548 549 550 |
# File 'lib/smplkit/platform/client.rb', line 548 def services @services end |
Class Method Details
.open(**kwargs) ⇒ Object
Construct, yield to the block, and close on exit.
585 586 587 588 589 590 591 592 |
# File 'lib/smplkit/platform/client.rb', line 585 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.
576 577 578 579 580 581 582 |
# File 'lib/smplkit/platform/client.rb', line 576 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 |