Class: Nucleus::Adapters::V1::Stub Abstract
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- Nucleus::Adapters::V1::Stub
- Defined in:
- lib/nucleus/adapters/v1/stub_adapter.rb
Overview
Stub adapter for Nucleus API version 1.
The stub provides all methods that an actual adapter should implement.
It also contains the documentation that describes the expected method behaviour, which must be matched by the adapters.
Adapter methods shall raise:
Errors::EndpointAuthenticationError == 401 if a endpoint call failed due to bad credentials
Errors::AdapterResourceNotFoundError == 404 if a resource could not be found
Errors::SemanticAdapterRequestError == 422 if the request could not be processed due to common semantic errors
Errors::PlatformSpecificSemanticError == 422 if the request could not be processed due to semantic errors that are specific to the endpoint / platform, for instance quota restrictions.
Errors::UnknownAdapterCallError == 500 if the endpoint API shows unexpected behavior, not matching the implementation
Errors::AdapterMissingImplementationError == 501 if a feature is not (yet) implemented by the adapter
If embedded in the Grape Restful API, authentication errors and bad requests are handled by Grape.
If an adapter is used within the gem, the developer must take care of authentication handling and missing form data.
Direct Known Subclasses
Constant Summary collapse
- NOT_IMPLEMENTED_ERROR =
Error message saying that the adapter feature has not been implemented yet.
Errors::AdapterMissingImplementationError.new( 'Adapter is missing an implementation to support this feature')
Instance Attribute Summary
Attributes inherited from BaseAdapter
Instance Method Summary collapse
-
#add_service(application_id, service_entity, plan_entity) ⇒ Hash, Nucleus::API::Models::InstalledService
Add the service with the service_id to the application with the application_id.
-
#application(application_id) ⇒ Hash, Nucleus::API::Models::Application
Retrieve the application entity of the application with the given application_id.
-
#applications ⇒ Hash, Nucleus::API::Models::Applications
Get a list of all applications that are accessible to the authenticated user account.
-
#auth_client ⇒ Nucleus::Adapters::AuthClient
Build an Authentication client that can handle the authentication to the endpoint given the username and a matching password.
-
#change_service(application_id, service_id, plan_entity) ⇒ Hash, Nucleus::API::Models::InstalledService
Change the service, e.g.
-
#create_application(application) ⇒ Hash, Nucleus::API::Models::Application
Create a new application on the endpoint using the given application entity.
-
#create_domain(application_id, domain) ⇒ Hash, Nucleus::API::Models::Domain
Create a new domain using the given domain entity and assign it to the application.
-
#create_env_var(application_id, env_var) ⇒ Hash, Nucleus::API::Models::EnvironmentVariable
Create a new environment variable using the given env.
-
#delete_application(application_id) ⇒ void
Delete the application with the given application_id on the endpoint.
-
#delete_domain(application_id, domain_id) ⇒ void
Delete the domain of the application with the domain_id.
-
#delete_env_var(application_id, env_var_id) ⇒ void
Delete the environment variable of the application with the env_var_id.
-
#deploy(application_id, application_archive, compression_format) ⇒ void
Deploy the data of the application given the compressed application archive.
The application shall not be running when the deployment is finished. -
#domain(application_id, domain_id) ⇒ Hash, Nucleus::API::Models::Domain
Retrieve the domain entity of the application with the given application_id and the domain with the domain_id.
-
#domains(application_id) ⇒ Hash, Nucleus::API::Models::Domains
Get a list of all domains that are assigned to the application.
-
#download(application_id, compression_format) ⇒ StringIO
Download the application data that is currently deployed on the platform.
-
#env_var(application_id, env_var_id) ⇒ Hash, Nucleus::API::Models::EnvironmentVariable
Retrieve the environment variable entity of the application with the given application_id and the env.
-
#env_vars(application_id) ⇒ Hash, Nucleus::API::Models::EnvironmentVariables
Get a list of all environment variables that are assigned to the application.
-
#installed_service(application_id, service_id) ⇒ Hash, Nucleus::API::Models::InstalledService
Retrieve the installed service entity matching the given service_id that is installed on the application with the given application_id.
-
#installed_services(application_id) ⇒ Hash, Nucleus::API::Models::InstalledServices
List all services that are installed on the application with the given application_id.
-
#log?(application_id, log_id) ⇒ Boolean
Assert whether the given log_id is valid for the application_id.
-
#log_entries(application_id, log_id) ⇒ Array<String>
Retrieve all log entries of the log.
-
#logs(application_id) ⇒ Hash, Nucleus::API::Models::Logs
Get a list of all logs that are available for the application.
-
#rebuild(application_id) ⇒ Hash, Nucleus::API::Models::Application
Rebuild the recently deployed bits of the application.
The rebuild can be used to update the application to use a new version of the underlying runtime or fix a previously failed application start after the issues have been resolved. -
#region(region_id) ⇒ Hash, Nucleus::API::Models::Region
Return the class compatible information regarding the region with the given region_id.
-
#regions ⇒ Hash, Nucleus::API::Models::Regions
Return a list of all class compatible objects that are available on the current endpoint.
If the platform does not offer multi-region support, one ‘default’ region shall be returned. -
#remove_service(application_id, service_id) ⇒ void
Remove the installed service with the service_id from the application with the application_id.
-
#restart(application_id) ⇒ Hash, Nucleus::API::Models::Application
Restart all instances of the application with the application_id.
-
#scale(application_id, instances) ⇒ Hash, Nucleus::API::Models::Application
TODO: Finish documentation when vertical scaling is added Scale the application and adjust the number of instances that shall be running.
-
#service(service_id) ⇒ Hash, Nucleus::API::Models::Service
Retrieve the service entity matching the given service_id.
-
#service_plan(service_id, plan_id) ⇒ Hash, Nucleus::API::Models::ServicePlan
Show the plan with the plan_id that is applicable to the service with the service_id.
-
#service_plans(service_id) ⇒ Hash, Nucleus::API::Models::ServicePlans
List all plans that can be chosen for the service with the service_id, ascending order on the price.
-
#services ⇒ Hash, Nucleus::API::Models::Services
List all services that are available at the endpoint.
-
#start(application_id) ⇒ Hash, Nucleus::API::Models::Application
Start all instances of the application with the application_id.
-
#stop(application_id) ⇒ Hash, Nucleus::API::Models::Application
Stop all instances of the application with the application_id.
-
#tail(application_id, log_id, stream) ⇒ Nucleus::Adapters::TailStopper
Tail the logfile of the application and send each retrieved chunk, which can be a line of a file, a new chunk in a received http message, or a websocket message, to the stream.
-
#update_application(application_id, application) ⇒ Hash, Nucleus::API::Models::Application
Update an application on the endpoint using the given application entity.
-
#update_env_var(application_id, env_var_id, env_var) ⇒ Hash, Nucleus::API::Models::EnvironmentVariable
Update the environment variable of the application, using the given env.
Methods inherited from BaseAdapter
#cache, #cache?, #cache_key, #cached, #endpoint_call, #fail_with, #headers, #initialize
Methods included from Logging
configure_logger_for, #log, logger_for
Methods included from HttpTailClient
Methods included from HttpClient
#delete, #get, #head, #patch, #post, #put
Constructor Details
This class inherits a constructor from Nucleus::Adapters::BaseAdapter
Instance Method Details
#add_service(application_id, service_entity, plan_entity) ⇒ Hash, Nucleus::API::Models::InstalledService
Add the service with the service_id to the application with the application_id.
430 431 432 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 430 def add_service(application_id, service_entity, plan_entity) fail NOT_IMPLEMENTED_ERROR end |
#application(application_id) ⇒ Hash, Nucleus::API::Models::Application
Retrieve the application entity of the application with the given application_id.
77 78 79 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 77 def application(application_id) fail NOT_IMPLEMENTED_ERROR end |
#applications ⇒ Hash, Nucleus::API::Models::Applications
Get a list of all applications that are accessible to the authenticated user account.
68 69 70 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 68 def applications fail NOT_IMPLEMENTED_ERROR end |
#auth_client ⇒ Nucleus::Adapters::AuthClient
Build an Authentication client that can handle the authentication to the endpoint given the username and a matching password.
41 42 43 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 41 def auth_client fail NOT_IMPLEMENTED_ERROR end |
#change_service(application_id, service_id, plan_entity) ⇒ Hash, Nucleus::API::Models::InstalledService
Change the service, e.g. the active plan, of the service with the service_id for the application with the application_id. Use the fields of the service_entity to execute the update.
446 447 448 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 446 def change_service(application_id, service_id, plan_entity) fail NOT_IMPLEMENTED_ERROR end |
#create_application(application) ⇒ Hash, Nucleus::API::Models::Application
Create a new application on the endpoint using the given application entity.
92 93 94 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 92 def create_application(application) fail NOT_IMPLEMENTED_ERROR end |
#create_domain(application_id, domain) ⇒ Hash, Nucleus::API::Models::Domain
Create a new domain using the given domain entity and assign it to the application.
145 146 147 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 145 def create_domain(application_id, domain) fail NOT_IMPLEMENTED_ERROR end |
#create_env_var(application_id, env_var) ⇒ Hash, Nucleus::API::Models::EnvironmentVariable
Create a new environment variable using the given env. var entity and assign it to the application.
191 192 193 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 191 def create_env_var(application_id, env_var) fail NOT_IMPLEMENTED_ERROR end |
#delete_application(application_id) ⇒ void
This method returns an undefined value.
Delete the application with the given application_id on the endpoint.
113 114 115 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 113 def delete_application(application_id) fail NOT_IMPLEMENTED_ERROR end |
#delete_domain(application_id, domain_id) ⇒ void
This method returns an undefined value.
Delete the domain of the application with the domain_id.
156 157 158 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 156 def delete_domain(application_id, domain_id) fail NOT_IMPLEMENTED_ERROR end |
#delete_env_var(application_id, env_var_id) ⇒ void
This method returns an undefined value.
Delete the environment variable of the application with the env_var_id.
216 217 218 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 216 def delete_env_var(application_id, env_var_id) fail NOT_IMPLEMENTED_ERROR end |
#deploy(application_id, application_archive, compression_format) ⇒ void
This method returns an undefined value.
Deploy the data of the application given the compressed application archive.
The application shall not be running when the deployment is finished. Postconditions (delayed):
-
state == deployed
280 281 282 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 280 def deploy(application_id, application_archive, compression_format) fail NOT_IMPLEMENTED_ERROR end |
#domain(application_id, domain_id) ⇒ Hash, Nucleus::API::Models::Domain
Retrieve the domain entity of the application with the given application_id and the domain with the domain_id.
133 134 135 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 133 def domain(application_id, domain_id) fail NOT_IMPLEMENTED_ERROR end |
#domains(application_id) ⇒ Hash, Nucleus::API::Models::Domains
Get a list of all domains that are assigned to the application.
122 123 124 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 122 def domains(application_id) fail NOT_IMPLEMENTED_ERROR end |
#download(application_id, compression_format) ⇒ StringIO
Download the application data that is currently deployed on the platform. The downloaded application archive must contain at least all files that were originally deployed, but can also contain additional files, for instance log files.
306 307 308 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 306 def download(application_id, compression_format) fail NOT_IMPLEMENTED_ERROR end |
#env_var(application_id, env_var_id) ⇒ Hash, Nucleus::API::Models::EnvironmentVariable
Retrieve the environment variable entity of the application with the given application_id and the env. var with the env_var_id.
178 179 180 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 178 def env_var(application_id, env_var_id) fail NOT_IMPLEMENTED_ERROR end |
#env_vars(application_id) ⇒ Hash, Nucleus::API::Models::EnvironmentVariables
Get a list of all environment variables that are assigned to the application.
165 166 167 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 165 def env_vars(application_id) fail NOT_IMPLEMENTED_ERROR end |
#installed_service(application_id, service_id) ⇒ Hash, Nucleus::API::Models::InstalledService
Retrieve the installed service entity matching the given service_id that is installed on the application with the given application_id.
415 416 417 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 415 def installed_service(application_id, service_id) fail NOT_IMPLEMENTED_ERROR end |
#installed_services(application_id) ⇒ Hash, Nucleus::API::Models::InstalledServices
List all services that are installed on the application with the given application_id.
405 406 407 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 405 def installed_services(application_id) fail NOT_IMPLEMENTED_ERROR end |
#log?(application_id, log_id) ⇒ Boolean
Assert whether the given log_id is valid for the application_id.
328 329 330 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 328 def log?(application_id, log_id) fail NOT_IMPLEMENTED_ERROR end |
#log_entries(application_id, log_id) ⇒ Array<String>
Retrieve all log entries of the log.
347 348 349 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 347 def log_entries(application_id, log_id) fail NOT_IMPLEMENTED_ERROR end |
#logs(application_id) ⇒ Hash, Nucleus::API::Models::Logs
Get a list of all logs that are available for the application.
337 338 339 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 337 def logs(application_id) fail NOT_IMPLEMENTED_ERROR end |
#rebuild(application_id) ⇒ Hash, Nucleus::API::Models::Application
Rebuild the recently deployed bits of the application.
The rebuild can be used to update the application to use a new version of the underlying runtime or fix a previously failed application start after the issues have been resolved.
291 292 293 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 291 def rebuild(application_id) fail NOT_IMPLEMENTED_ERROR end |
#region(region_id) ⇒ Hash, Nucleus::API::Models::Region
Return the class compatible information regarding the region with the given region_id.
61 62 63 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 61 def region(region_id) fail NOT_IMPLEMENTED_ERROR end |
#regions ⇒ Hash, Nucleus::API::Models::Regions
Return a list of all class compatible objects that are available on the current endpoint.
If the platform does not offer multi-region support, one ‘default’ region shall be returned.
50 51 52 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 50 def regions fail NOT_IMPLEMENTED_ERROR end |
#remove_service(application_id, service_id) ⇒ void
This method returns an undefined value.
Remove the installed service with the service_id from the application with the application_id.
458 459 460 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 458 def remove_service(application_id, service_id) fail NOT_IMPLEMENTED_ERROR end |
#restart(application_id) ⇒ Hash, Nucleus::API::Models::Application
Restart all instances of the application with the application_id. The state of all application instances should become running when all actions are finished (unless there are technical errors preventing the application to start). Preconditions:
-
application must have been deployed
Postconditions (delayed):
-
state == running
263 264 265 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 263 def restart(application_id) fail NOT_IMPLEMENTED_ERROR end |
#scale(application_id, instances) ⇒ Hash, Nucleus::API::Models::Application
TODO: Finish documentation when vertical scaling is added Scale the application and adjust the number of instances that shall be running.
317 318 319 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 317 def scale(application_id, instances) fail NOT_IMPLEMENTED_ERROR end |
#service(service_id) ⇒ Hash, Nucleus::API::Models::Service
Retrieve the service entity matching the given service_id.
378 379 380 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 378 def service(service_id) fail NOT_IMPLEMENTED_ERROR end |
#service_plan(service_id, plan_id) ⇒ Hash, Nucleus::API::Models::ServicePlan
Show the plan with the plan_id that is applicable to the service with the service_id.
396 397 398 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 396 def service_plan(service_id, plan_id) fail NOT_IMPLEMENTED_ERROR end |
#service_plans(service_id) ⇒ Hash, Nucleus::API::Models::ServicePlans
List all plans that can be chosen for the service with the service_id, ascending order on the price.
387 388 389 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 387 def service_plans(service_id) fail NOT_IMPLEMENTED_ERROR end |
#services ⇒ Hash, Nucleus::API::Models::Services
List all services that are available at the endpoint.
369 370 371 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 369 def services fail NOT_IMPLEMENTED_ERROR end |
#start(application_id) ⇒ Hash, Nucleus::API::Models::Application
Start all instances of the application with the application_id. The state of all application instances should become running when all actions are finished (unless there are technical errors preventing the application to start). Preconditions:
-
application must have been deployed
Postconditions (delayed):
-
state == running
232 233 234 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 232 def start(application_id) fail NOT_IMPLEMENTED_ERROR end |
#stop(application_id) ⇒ Hash, Nucleus::API::Models::Application
Stop all instances of the application with the application_id. The state of all application instances will become stopped when all actions are finished. Preconditions:
-
application must have been deployed
Postconditions (delayed):
-
state == stopped
247 248 249 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 247 def stop(application_id) fail NOT_IMPLEMENTED_ERROR end |
#tail(application_id, log_id, stream) ⇒ Nucleus::Adapters::TailStopper
Tail the logfile of the application and send each retrieved chunk, which can be a line of a file, a new chunk in a received http message, or a websocket message, to the stream. The deferred tailing process shall be stoppable when the stop method of the returned TailStopper is called.
362 363 364 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 362 def tail(application_id, log_id, stream) fail NOT_IMPLEMENTED_ERROR end |
#update_application(application_id, application) ⇒ Hash, Nucleus::API::Models::Application
Update an application on the endpoint using the given application entity.
104 105 106 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 104 def update_application(application_id, application) fail NOT_IMPLEMENTED_ERROR end |
#update_env_var(application_id, env_var_id, env_var) ⇒ Hash, Nucleus::API::Models::EnvironmentVariable
Update the environment variable of the application, using the given env. var entity.
205 206 207 |
# File 'lib/nucleus/adapters/v1/stub_adapter.rb', line 205 def update_env_var(application_id, env_var_id, env_var) fail NOT_IMPLEMENTED_ERROR end |