Client
reduct.Client
¶
HTTP Client for Reduct Storage HTTP API
__init__(url, api_token=None, timeout=None)
¶
Constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
URL to connect to the storage |
required |
api_token |
Optional[str]
|
API token if the storage uses it for authorization |
None
|
timeout |
Optional[float]
|
total timeout for connection, request and response in seconds |
None
|
Examples:
>>> client = Client("http://127.0.0.1:8383")
>>> info = await client.info()
create_bucket(name, settings=None, exist_ok=False)
async
¶
Create a new bucket
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
a name for the bucket |
required |
settings |
Optional[BucketSettings]
|
settings for the bucket If None, the server |
None
|
exist_ok |
bool
|
the client raises no exception if the bucket already exists and returns it |
False
|
Returns:
Name | Type | Description |
---|---|---|
Bucket |
Bucket
|
created bucket |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
create_token(name, permissions)
async
¶
Create a new token
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
name of the token |
required |
permissions |
Permissions
|
permissions for the token |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
token value |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
get_bucket(name)
async
¶
Load a bucket to work with
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
name of the bucket |
required |
Returns:
Type | Description |
---|---|
Bucket
|
Bucket |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
get_token(name)
async
¶
Get a token by name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
name of the token |
required |
Returns:
Type | Description |
---|---|
FullTokenInfo
|
Token |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
get_token_list()
async
¶
Get a list of all tokens
Returns:
Type | Description |
---|---|
List[Token]
|
List[Token] |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
info()
async
¶
Get high level server info
Returns:
Name | Type | Description |
---|---|---|
ServerInfo |
ServerInfo
|
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
list()
async
¶
Return a list of all buckets on server
Returns:
Type | Description |
---|---|
List[BucketInfo]
|
List[BucketInfo] |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
me()
async
¶
Get information about the current token
Returns:
Type | Description |
---|---|
FullTokenInfo
|
FullTokenInfo |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
remove_token(name)
async
¶
Delete a token
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
name of the token |
required |
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |