Client#

class blacksmith.service._async.client.AsyncClient(name: str, endpoint: str, resources: Mapping[str, blacksmith.domain.registry.ApiRoutes], transport: blacksmith.service._async.base.AsyncAbstractTransport, timeout: blacksmith.domain.model.http.HTTPTimeout, collection_parser: Type[blacksmith.domain.model.params.AbstractCollectionParser], middlewares: List[blacksmith.middleware._async.base.AsyncHTTPMiddleware], error_parser: blacksmith.domain.error.AbstractErrorParser[blacksmith.domain.error.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, blacksmith.domain.registry.ApiRoutes]#
transport: blacksmith.service._async.base.AsyncAbstractTransport#
timeout: blacksmith.domain.model.http.HTTPTimeout#
collection_parser: Type[blacksmith.domain.model.params.AbstractCollectionParser]#
middlewares: List[blacksmith.middleware._async.base.AsyncHTTPMiddleware]#
add_middleware(middleware: blacksmith.middleware._async.base.AsyncHTTPMiddleware) blacksmith.service._async.client.AsyncClient[blacksmith.domain.error.TError_co]#
__getattr__(name: str) blacksmith.service._async.route_proxy.AsyncRouteProxy[Any, Any, blacksmith.domain.error.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: Optional[blacksmith.service._async.base.AsyncAbstractTransport] = None, registry: blacksmith.domain.registry.Registry = <blacksmith.domain.registry.Registry object>, timeout: Union[blacksmith.domain.model.http.HTTPTimeout, float, Tuple[float, float]] = <blacksmith.domain.model.http.HTTPTimeout object>, proxies: Optional[Union[URL, str, Proxy, Dict[Union[URL, str], Union[None, URL, str, Proxy]]]] = None, verify_certificate: bool = False, collection_parser: Type[blacksmith.domain.model.params.AbstractCollectionParser] = <class 'blacksmith.domain.model.params.CollectionParser'>, error_parser: Optional[blacksmith.domain.error.AbstractErrorParser[blacksmith.domain.error.TError_co]] = 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: blacksmith.sd._async.base.AsyncAbstractServiceDiscovery#
registry: blacksmith.domain.registry.Registry#
transport: blacksmith.service._async.base.AsyncAbstractTransport#
timeout: blacksmith.domain.model.http.HTTPTimeout#
collection_parser: Type[blacksmith.domain.model.params.AbstractCollectionParser]#
error_parser: blacksmith.domain.error.AbstractErrorParser[blacksmith.domain.error.TError_co]#
middlewares: List[blacksmith.middleware._async.base.AsyncHTTPMiddleware]#
add_middleware(middleware: blacksmith.middleware._async.base.AsyncHTTPMiddleware) blacksmith.service._async.client.AsyncClientFactory[blacksmith.domain.error.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) blacksmith.service._async.client.AsyncClient[blacksmith.domain.error.TError_co]#

Call self as a function.