Brokers
Smarter API command-line interface Brokers. These are the broker classes that implement the broker service pattern for an underlying object. Brokers receive a Yaml manifest representation of a model, convert this to a Pydantic model, and then instantiate the appropriate Python class that performs the necessary operations to facilitate cli requests that include:
delete
deploy
describe
get
logs
manifest
undeploy
- class smarter.apps.api.v1.cli.brokers.Brokers[source]
Bases:
objectThe Broker service pattern for the Smarter Broker Model.
This class provides the mapping and logic for selecting the correct Broker implementation based on the manifest
Kind. Brokers are used throughout theapi/v1/cliinterface to process Smarter YAML manifests and to facilitate common CLI operations, including:applydeletedeploydescribegetmanifestexamplestatusundeploylogsschema
Each Broker is responsible for brokering the correct implementation class for a given operation by analyzing the manifest’s
Kindfield. This enables a unified interface for handling different resource types in the Smarter platform.Key Methods
- get_broker(kind: str) -> Optional[Type[AbstractBroker]]:
Returns the Broker class definition for the given manifest kind. The lookup is case-insensitive.
Usage
Brokers are primarily used for processing Smarter YAML manifests in CLI workflows. By calling
get_broker(), you can retrieve the appropriate Broker class to handle a specific resource type.Example
>>> broker_cls = Brokers.get_broker("Account") >>> broker = broker_cls() >>> broker.describe(...)
- classmethod from_url(url)[source]
Returns the kind of broker from the given URL. This is used to determine the broker to use when the kind is not provided in the request.
example: http://localhost:9357/api/v1/cli/example_manifest/account/ returns: “Account”