buildgrid.server.request_metadata_utils module

buildgrid.server.request_metadata_utils.printable_request_metadata(metadata_entries: Any) str

Given a metadata object, return a human-readable representation of its RequestMetadata entry.

Parameters:

metadata_entries – tuple of entries obtained from a gRPC context with, for example, context.invocation_metadata().

Returns:

A string with the metadata contents.

buildgrid.server.request_metadata_utils.extract_request_metadata(metadata_entries: Any) RequestMetadata

Given a list of string tuples, extract the RequestMetadata header values if they are present. If they were not provided, returns an empty message.

Parameters:

metadata_entries – tuple of entries obtained from a gRPC context with, for example, context.invocation_metadata().

Returns:

A RequestMetadata proto. If the metadata is not defined in the request, the message will be empty.

buildgrid.server.request_metadata_utils.request_metadata_to_string(request_metadata: RequestMetadata) str
buildgrid.server.request_metadata_utils.request_metadata_from_scheduler_dict(scheduler_request_metadata: Dict[str, str]) RequestMetadata
buildgrid.server.request_metadata_utils.extract_client_identity(instance: str, invocation_metadata: Iterable[Tuple[str, Any]]) ClientIdentityEntry | None

Extract the ClientIdentity from gRPC metadata

Parameters:

invocation_metadata (List[Tuple[str, str]]) – grpc metadata

Returns:

identity of the client if exists

Return type:

Optional[ClientIdentityEntry]

buildgrid.server.request_metadata_utils.printable_client_identity(instance: str, invocation_metadata: Iterable[Tuple[str, Any]]) str

Given a metadata object, return a human-readable representation of its ClientIdentity entry.

Parameters:
  • instance – REAPI instance name

  • invocation_metadata – tuple of entries obtained from a gRPC context with, for example, context.invocation_metadata().

Returns:

A string with the ClientIdentity contents.