Class: Lambda::MicroVMs::Adapters::MicroVMSdk
- Inherits:
-
Object
- Object
- Lambda::MicroVMs::Adapters::MicroVMSdk
- Defined in:
- lib/lambda/microvms/adapters/microvm_sdk.rb
Overview
Adapter for the experimental Lambda MicroVM SDK operation surface.
Constant Summary collapse
- REQUIRED_OPERATIONS =
SDK method names required by the experimental MicroVM lifecycle wrapper.
%i[ create_microvm_image get_microvm_image delete_microvm_image run_microvm get_microvm list_microvms suspend_microvm resume_microvm terminate_microvm create_microvm_auth_token ].freeze
Instance Attribute Summary collapse
-
#sdk ⇒ Object
readonly
Returns the value of attribute sdk.
Instance Method Summary collapse
-
#call(operation, **params) ⇒ Object
Dispatch a MicroVM operation to the wrapped SDK client.
-
#initialize(sdk) ⇒ MicroVMSdk
constructor
A new instance of MicroVMSdk.
-
#supported? ⇒ Boolean
Check whether the wrapped SDK client exposes all MicroVM operations.
-
#unsupported_operations ⇒ Array<Symbol>
Return MicroVM SDK operations missing from the wrapped SDK client.
Constructor Details
#initialize(sdk) ⇒ MicroVMSdk
Returns a new instance of MicroVMSdk.
25 26 27 |
# File 'lib/lambda/microvms/adapters/microvm_sdk.rb', line 25 def initialize(sdk) @sdk = sdk end |
Instance Attribute Details
#sdk ⇒ Object (readonly)
Returns the value of attribute sdk.
23 24 25 |
# File 'lib/lambda/microvms/adapters/microvm_sdk.rb', line 23 def sdk @sdk end |
Instance Method Details
#call(operation, **params) ⇒ Object
Dispatch a MicroVM operation to the wrapped SDK client.
49 50 51 52 53 54 55 |
# File 'lib/lambda/microvms/adapters/microvm_sdk.rb', line 49 def call(operation, **params) unless sdk.respond_to?(operation) raise UnsupportedOperationError, "Aws::Lambda::Client does not expose ##{operation}; run sdk-contract" end sdk.public_send(operation, **params) end |
#supported? ⇒ Boolean
Check whether the wrapped SDK client exposes all MicroVM operations.
39 40 41 |
# File 'lib/lambda/microvms/adapters/microvm_sdk.rb', line 39 def supported? unsupported_operations.empty? end |
#unsupported_operations ⇒ Array<Symbol>
Return MicroVM SDK operations missing from the wrapped SDK client.
32 33 34 |
# File 'lib/lambda/microvms/adapters/microvm_sdk.rb', line 32 def unsupported_operations REQUIRED_OPERATIONS.reject { |operation| sdk.respond_to?(operation) } end |