SDK Robot Client#
This documentation auto-generates details about the HMAC authentication and convenience methods provided by the SDK for robots.
Note
This document is about API authentication for robots. For anyone else, refer to OAuth and SDK Client.
Client#
- class libs.sdk.src.destiny_sdk.client.RobotClient(base_url: HttpUrl, secret_key: str, client_id: Annotated[UUID, UuidVersion(uuid_version=4)])[source]#
Client for interaction with the Destiny API.
Current implementation only supports robot results.
- poll_robot_enhancement_batch(robot_id: Annotated[UUID, UuidVersion(uuid_version=4)], limit: int = 10, lease: str | None = None, timeout: int = 60) RobotEnhancementBatch | None[source]#
Poll for a robot enhancement batch.
Signs the request with the client’s secret key.
- Parameters:
robot_id (UUID4) – The ID of the robot to poll for
limit (int) – The maximum number of pending enhancements to return
lease (str | None) – The duration to lease the pending enhancements for, in ISO 8601 duration format eg PT10M. If not provided the repository will use a default lease duration.
- Returns:
The RobotEnhancementBatch object from the response, or None if no batches available
- Return type:
- renew_robot_enhancement_batch_lease(robot_enhancement_batch_id: Annotated[UUID, UuidVersion(uuid_version=4)], lease_duration: str | None = None) None[source]#
Renew the lease for a robot enhancement batch.
Signs the request with the client’s secret key.
- Parameters:
robot_enhancement_batch_id (UUID4) – The ID of the robot enhancement batch
lease_duration (str | None) – The duration to lease the pending enhancements for, in ISO 8601 duration format eg PT10M. If not provided the repository will use a default lease duration.
- send_robot_enhancement_batch_result(robot_enhancement_batch_result: RobotEnhancementBatchResult) RobotEnhancementBatchRead[source]#
Send a RobotEnhancementBatchResult to destiny repository.
Signs the request with the client’s secret key.
- Parameters:
robot_enhancement_batch_result (RobotEnhancementBatchResult) – The RobotEnhancementBatchResult to send
- Returns:
The RobotEnhancementBatchRead object from the response.
- Return type:
- send_robot_result(robot_result: RobotResult) EnhancementRequestRead[source]#
Send a RobotResult to destiny repository.
Signs the request with the client’s secret key.
- Parameters:
robot_result (RobotResult) – The RobotResult to send
- Returns:
The EnhancementRequestRead object from the response.
- Return type:
HMAC Authentication#
The client will apply HMAC authentication automatically, but if you need to access the authentication itself you can access the below directly:
HMAC authentication assistance methods.
- exception libs.sdk.src.destiny_sdk.auth.AuthException(status_code: Annotated[int, Doc('\n HTTP status code to send to the client.\n ')], detail: Annotated[Any, Doc('\n Any data to be sent to the client in the `detail` key of the JSON\n response.\n ')] = None, headers: Annotated[Dict[str, str] | None, Doc('\n Any headers to send to the client in the response.\n ')] = None)[source]#
An exception related to HTTP authentication.
Raised by implementations of the AuthMethod protocol.
raise AuthException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Unable to parse authentication token.", )
- class libs.sdk.src.destiny_sdk.auth.BypassHMACAuth(*args, **kwargs)[source]#
A fake auth class that will always respond successfully.
Intended for use in local environments and for testing.
Not for production use!
- class libs.sdk.src.destiny_sdk.auth.HMACAuth(secret_key: str)[source]#
Adds HMAC auth when used as a router or endpoint dependency.
- class libs.sdk.src.destiny_sdk.auth.HMACAuthMethod(*args, **kwargs)[source]#
Protocol for HMAC auth methods, enforcing the implmentation of __call__().
This allows FastAPI to call class instances as depenedencies in FastAPI routes, see https://fastapi.tiangolo.com/advanced/advanced-dependencies
auth = HMACAuthMethod() router = APIRouter( prefix="/robots", tags=["robot"], dependencies=[Depends(auth)] )
- pydantic model libs.sdk.src.destiny_sdk.auth.HMACAuthorizationHeaders[source]#
The HTTP authorization headers required for HMAC authentication.
Expects the following headers to be present in the request
Authorization: Signature [request signature]
X-Client-Id: [UUID]
X-Request-Timestamp: [float]
Show Entity Relationship Diagram
![digraph "Entity Relationship Diagram created by erdantic" {
graph [fontcolor=gray66,
fontname="Times New Roman,Times,Liberation Serif,serif",
fontsize=9,
nodesep=0.5,
rankdir=LR,
ranksep=1.5
];
node [fontname="Times New Roman,Times,Liberation Serif,serif",
fontsize=14,
label="\N",
shape=plain
];
edge [dir=both];
"libs.sdk.src.destiny_sdk.auth.HMACAuthorizationHeaders" [label=<<table border="0" cellborder="1" cellspacing="0"><tr><td port="_root" colspan="2"><b>HMACAuthorizationHeaders</b></td></tr><tr><td>signature</td><td port="signature">str</td></tr><tr><td>client_id</td><td port="client_id">UUID</td></tr><tr><td>timestamp</td><td port="timestamp">float</td></tr></table>>,
tooltip="libs.sdk.src.destiny_sdk.auth.HMACAuthorizationHeaders

The HTTP authorization headers required for HMAC authentication.&#\
xA;
Expects the following headers to be present in the request

- Authorization: Signature [request signature]
- \
X-Client-Id: [UUID]
- X-Request-Timestamp: [float]
"];
}](../_images/graphviz-16643f7e976bc38759c40e1afeb3f1c3ece1a25a.png)
Show JSON schema
{ "title": "HMACAuthorizationHeaders", "description": "The HTTP authorization headers required for HMAC authentication.\n\nExpects the following headers to be present in the request\n\n- Authorization: Signature [request signature]\n- X-Client-Id: [UUID]\n- X-Request-Timestamp: [float]", "type": "object", "properties": { "signature": { "title": "Signature", "type": "string" }, "client_id": { "format": "uuid4", "title": "Client Id", "type": "string" }, "timestamp": { "title": "Timestamp", "type": "number" } }, "required": [ "signature", "client_id", "timestamp" ] }
- field client_id: Annotated[UUID, UuidVersion(uuid_version=4)] [Required][source]#
- Constraints:
uuid_version = 4
- classmethod from_request(request: Request) Self[source]#
Get the required headers for HMAC authentication.
- Parameters:
request (Request) – The incoming request
- Raises:
AuthException – Authorization header is missing
AuthException – Authorization type not supported
AuthException – X-Client-Id header is missing
AuthException – Client id format is invalid
AuthException – X-Request-Timestamp header is missing
AuthException – Request timestamp has expired
- Returns:
Header values necessary for authenticating the request
- Return type:
- libs.sdk.src.destiny_sdk.auth.create_signature(secret_key: str, request_body: bytes, client_id: Annotated[UUID, UuidVersion(uuid_version=4)], timestamp: float) str[source]#
Create an HMAC signature using SHA256.
- Parameters:
secret_key (bytes) – secret key with which to encrypt message
request_body (bytes) – request body to be encrypted
client_id – client id to include in hmac
timestamp – timestamp for when the request is sent
- Type:
UUID4
- Type:
float
- Returns:
encrypted hexdigest of the request body with the secret key
- Return type:
str