buildgrid.browser.rest_api module

buildgrid.browser.rest_api.query_build_events_handler(context: Context) Callable[[Request], Awaitable[Response]]

Factory function which returns a handler for QueryEventStreams.

The returned handler uses context.channel to send a QueryEventStreams request constructed based on the provided URL query parameters. Currently only querying by build_id (equivalent to correlated invocations ID) is supported.

The handler returns a serialised QueryEventStreamsResponse, and raises a 500 error in the case of some RPC error.

Parameters:

context (Context) – The context to use to send the gRPC request.

async buildgrid.browser.rest_api.get_operation_filters_handler(request: Request) Response

Return the available Operation filter keys.

buildgrid.browser.rest_api.list_operations_handler(context: Context, cache: ResponseCache) Callable[[Request], Awaitable[Response]]

Factory function which returns a handler for ListOperations.

The returned handler uses context.channel and context.instance_name to send a ListOperations request constructed based on the provided URL query parameters.

The handler returns a serialised ListOperationsResponse, raises a 400 error in the case of a bad filter or other invalid argument, or raises a 500 error in the case of some other RPC error.

Parameters:

context (Context) – The context to use to send the gRPC request.

buildgrid.browser.rest_api.get_operation_handler(context: Context, cache: ResponseCache) Callable[[Request], Awaitable[Response]]

Factory function which returns a handler for GetOperation.

The returned handler uses context.channel and context.instance_name to send a GetOperation request constructed based on the path component of the URL.

The handler returns a serialised Operation message, raises a 400 error in the case of an invalid operation name, or raises a 500 error in the case of some other RPC error.

Parameters:

context (Context) – The context to use to send the gRPC request.

buildgrid.browser.rest_api.get_operation_request_metadata_handler(context: Context) Callable[[Request], Awaitable[Response]]

Factory function which returns a handler to get RequestMetadata.

The returned handler uses context.channel and context.instance_name to send a GetOperation request constructed based on the path component of the URL.

The handler returns a serialised RequestMetadata proto message, retrieved from the trailing metadata of the GetOperation response. In the event of an invalid operation name it raises a 404 error, and raises a 500 error in the case of some other RPC error.

Parameters:

context (Context) – The context to use to send the gRPC request.

buildgrid.browser.rest_api.get_operation_client_identity_handler(context: Context) Callable[[Request], Awaitable[Response]]

Factory function which returns a handler to get ClientIdentity metadata.

The returned handler uses context.channel and context.instance_name to send a GetOperation request constructed based on the path component of the URL.

The handler returns a serialised ClientIdentity proto message, retrieved from the trailing metadata of the GetOperation response. In the event of an invalid operation name it raises a 404 error, and raises a 500 error in the case of some other RPC error.

Parameters:

context (Context) – The context to use to send the gRPC request.

buildgrid.browser.rest_api.cancel_operation_handler(context: Context) Callable[[Request], Awaitable[Response]]

Factory function which returns a handler for CancelOperation.

The returned handler uses context.channel and context.instance_name to send a CancelOperation request constructed based on the path component of the URL.

The handler raises a 404 error in the case of an invalid operation name, or a 500 error in the case of some other RPC error.

On success, the response is empty.

Parameters:

context (Context) – The context to use to send the gRPC request.

buildgrid.browser.rest_api.get_action_result_handler(context: Context, cache: ResponseCache, cache_capacity: int = 512) Callable[[Request], Awaitable[Response]]

Factory function which returns a handler for GetActionResult.

The returned handler uses context.channel and context.instance_name to send a GetActionResult request constructed based on the path components of the URL.

The handler returns a serialised ActionResult message, raises a 404 error if there’s no result cached, or raises a 500 error in the case of some other RPC error.

Parameters:
  • context (Context) – The context to use to send the gRPC request.

  • cache_capacity (int) – The number of ActionResults to cache in memory to avoid hitting the actual ActionCache.

buildgrid.browser.rest_api.get_blob_handler(context: Context, cache: ResponseCache, allow_all: bool = False, allowed_origins: Collection[str | Pattern[str] | URL] = ()) Callable[[Request], Awaitable[StreamResponse]]
buildgrid.browser.rest_api.get_tarball_handler(context: Context, cache: ResponseCache, allow_all: bool = False, allowed_origins: Collection[str | Pattern[str] | URL] = (), tarball_dir: str | None = None) Callable[[Request], Awaitable[StreamResponse]]

Factory function which returns a handler for tarball requests.

This function also takes care of cleaning up old incomplete tarball constructions when given a named directory to do the construction in.

The returned handler takes the hash and size_bytes of a Digest of a Directory message and constructs a tarball of the directory defined by the message.

Parameters:
  • context (Context) – The context to use to send the gRPC requests.

  • allow_all (bool) – Whether or not to allow all CORS origins.

  • allowed_origins (list) – List of valid CORS origins.

  • tarball_dir (str) – Base directory to use for tarball construction.

buildgrid.browser.rest_api.logstream_handler(context: Context) Callable[[Request], Awaitable[Any]]