Client

class blacksmith.service._async.client.AsyncClient(name: str, endpoint: str, resources: Mapping[str, ApiRoutes], transport: AsyncAbstractTransport, timeout: HTTPTimeout, collection_parser: type[AbstractCollectionParser], middlewares: list[AsyncHTTPMiddleware], error_parser: AbstractErrorParser[TError_co])

Client representation for the client name.

A client will have dymanic property, based on the registered resources.

name: str
endpoint: str
resources: Mapping[str, ApiRoutes]
transport: AsyncAbstractTransport
timeout: HTTPTimeout
collection_parser: type[AbstractCollectionParser]
middlewares: list[AsyncHTTPMiddleware]
add_middleware(middleware: AsyncHTTPMiddleware) AsyncClient[TError_co]
__getattr__(name: str) AsyncRouteProxy[Any, Any, TError_co]

The client has attributes that are the registered resource.

The resource are registered using the blacksmith.register() function.

__orig_bases__ = (typing.Generic[+TError_co],)
class blacksmith.service._async.client.AsyncClientFactory(sd: ~blacksmith.sd._async.base.AsyncAbstractServiceDiscovery, transport: ~blacksmith.service._async.base.AsyncAbstractTransport | None = None, registry: ~blacksmith.domain.registry.Registry = <blacksmith.domain.registry.Registry object>, timeout: ~blacksmith.domain.model.http.HTTPTimeout | float | tuple[float, float] = <blacksmith.domain.model.http.HTTPTimeout object>, proxies: dict[str, str] | None = None, verify_certificate: bool = False, collection_parser: type[~blacksmith.domain.model.params.AbstractCollectionParser] = <class 'blacksmith.domain.model.params.CollectionParser'>, error_parser: ~blacksmith.domain.error.AbstractErrorParser[~blacksmith.domain.error.TError_co] | None = None)

Client creator, for the given configuration.

Parameters:
  • sd – Service Discovery instance

  • transport – HTTP Client that process the call, default use blacksmith.service._async.adapters.httpx.HttpxTransport

  • timeout – configure timeout, this parameter is ignored if the transport has been passed

  • proxies – configure proxies, this parameter is ignored if the transport has been passed

  • verify_certificate – Reject request if certificate are invalid for https

  • collection_parser – use to customize the collection parser default use blacksmith.domain.model.params.CollectionParser

__orig_bases__ = (typing.Generic[+TError_co],)
sd: AsyncAbstractServiceDiscovery
registry: Registry
transport: AsyncAbstractTransport
timeout: HTTPTimeout
collection_parser: type[AbstractCollectionParser]
error_parser: AbstractErrorParser[TError_co]
middlewares: list[AsyncHTTPMiddleware]
add_middleware(middleware: AsyncHTTPMiddleware) AsyncClientFactory[TError_co]

Add a middleware to the client factory and return the client for chaining.

..note:: Clients created before the call of this method will also be

altered. The middleware stack is a reference for all clients.

async initialize() None
async __call__(client_name: str) AsyncClient[TError_co]

Call self as a function.