sams_client.utils
– Client side utils¶
-
schema_relation
(resource: str, embeddable: bool = True, required: bool = False, data_type: str = 'objectid', nullable: bool = False, readonly: bool = False) → Dict[str, Any]¶ Creates an Eve/Cerberus relation attribute
This is copied from superdesk.resource.rel so that we don’t have to import Superdesk-Core for the sams_client library
- Parameters
resource (str) – The name of the resource
embeddable (bool) – If the relation can be embedded when fetching
required (bool) – If this relation is required, for validation purposes
data_type (str) – The data type to apply to the schema, defaults to ‘objectid’
nullable (bool) – If this relation can have a
null
valuereadonly (bool) – If this relation is read-only
- Returns
A dictionary to apply to a Resource schema
- Return type
-
bytes_to_human_readable
(size: int) → str¶ Converts size in bytes to a human readable string
- Converts the integer provided into one of the following:
'x bytes'
'x.yy KB'
(to 2 decimal places)'x.yy MB'
(to 2 decimal places)
-
get_aggregation_buckets
(response: requests.models.Response, bucket_name: str) → List[Dict[str, Any]]¶ Utility function to get aggregation buckets
- Parameters
response (requests.Response) – The response object from the API call
bucket_name (str) – The name of the bucket to retrieve
- Returns
The list of buckets from the aggregation query
- Return type