Skip to main content
Version: Next

Client Module

Client module for ReductStore HTTP API

Client​

class Client()

HTTP Client for Reduct Storage HTTP API

__init__​

def __init__(url: str,
api_token: Optional[str] = None,
timeout: Optional[float] = None,
extra_headers: Optional[Dict[str, str]] = None,
**kwargs)

Constructor

Arguments:

  • url - URL to connect to the storage
  • api_token - API token if the storage uses it for authorization
  • timeout - total timeout for connection, request and response in seconds
  • extra_headers - extra headers to send with each request Kwargs:
  • session - an external aiohttp session to use for requests
  • verify_ssl - verify SSL certificates

Example:

      client = Client("http://127.0.0.1:8383")
info = await client.info()

info​

async def info() -> ServerInfo

Get high level server info

Returns:

  • ServerInfo - server information

Raises:

  • ReductError - if there is an HTTP error

list​

async def list() -> List[BucketInfo]

Get a list of all buckets on server

Returns:

  • List[BucketInfo] - the list of buckets

Raises:

  • ReductError - if there is an HTTP error

get_bucket​

async def get_bucket(name: str) -> Bucket

Load a bucket to work with

Arguments:

  • name - name of the bucket

Returns:

  • Bucket - the bucket object

Raises:

  • ReductError - if there is an HTTP error

create_bucket​

async def create_bucket(name: str,
settings: Optional[BucketSettings] = None,
exist_ok: bool = False) -> Bucket

Create a new bucket

Arguments:

  • name - a name for the bucket
  • settings - settings for the bucket If None, the server default settings is used.
  • exist_ok - the client raises no exception if the bucket already exists and returns it

Returns:

  • Bucket - created bucket

Raises:

  • ReductError - if there is an HTTP error

get_token_list​

async def get_token_list() -> List[Token]

Get a list of all tokens

Returns:

  • List[Token] - the list of tokens

Raises:

  • ReductError - if there is an HTTP error

get_token​

async def get_token(name: str) -> FullTokenInfo

Get a token by name

Arguments:

  • name - name of the token

Returns:

  • FullTokenInfo - the token information with permissions

Raises:

  • ReductError - if there is an HTTP error

create_token​

async def create_token(name: str, permissions: Permissions) -> str

Create a new token

Arguments:

  • name - name of the token
  • permissions - permissions for the token

Returns:

  • str - token value

Raises:

  • ReductError - if there is an HTTP error

remove_token​

async def remove_token(name: str) -> None

Delete a token

Arguments:

  • name - name of the token

Raises:

  • ReductError - if there is an HTTP error

me​

async def me() -> FullTokenInfo

Get information about the current token

Returns:

  • FullTokenInfo - the current token information with permission

Raises:

  • ReductError - if there is an HTTP error

get_replications​

async def get_replications() -> List[ReplicationInfo]

Get a list of replications

Returns:

  • List[ReplicationInfo] - List of replications with their statuses

Raises:

  • ReductError - if there is an HTTP error

get_replication_detail​

async def get_replication_detail(
replication_name: str) -> ReplicationDetailInfo

Get detailed information about a replication

Arguments:

  • replication_name - Name of the replication to show details

Returns:

  • ReplicationDetailInfo - Detailed information about the replication

Raises:

  • ReductError - if there is an HTTP error

create_replication​

async def create_replication(replication_name: str,
settings: ReplicationSettings) -> None

Create a new replication

Arguments:

  • replication_name - Name of the new replication
  • settings - Settings for the new replication

Raises:

  • ReductError - if there is an HTTP error

update_replication​

async def update_replication(replication_name: str,
settings: ReplicationSettings) -> None

Update an existing replication

Arguments:

  • replication_name - Name of the replication to update
  • settings - New settings for the replication

Raises:

  • ReductError - if there is an HTTP error

delete_replication​

async def delete_replication(replication_name: str) -> None

Delete a replication

Arguments:

  • replication_name - Name of the replication to delete

Raises:

  • ReductError - if there is an HTTP error