Client
HTTP Client for Reduct Storage HTTP API
Source code in reduct/client.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
__init__(url, api_token=None, timeout=None, extra_headers=None, **kwargs)
¶
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
|
extra_headers |
Optional[Dict[str, str]]
|
extra headers to send with each request |
None
|
Kwargs: session: an external aiohttp session to use for requests Examples: >>> client = Client("http://127.0.0.1:8383") >>> info = await client.info()
Source code in reduct/client.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
create_bucket(name, settings=None, exist_ok=False)
async
¶
Create a new bucket Args: 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
Source code in reduct/client.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
create_token(name, permissions)
async
¶
Create a new token Args: name: name of the token permissions: permissions for the token Returns: str: token value Raises: ReductError: if there is an HTTP error
Source code in reduct/client.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
get_bucket(name)
async
¶
Load a bucket to work with Args: name: name of the bucket Returns: Bucket Raises: ReductError: if there is an HTTP error
Source code in reduct/client.py
158 159 160 161 162 163 164 165 166 167 168 169 |
|
get_token(name)
async
¶
Get a token by name Args: name: name of the token Returns: Token Raises: ReductError: if there is an HTTP error
Source code in reduct/client.py
210 211 212 213 214 215 216 217 218 219 220 221 |
|
get_token_list()
async
¶
Get a list of all tokens Returns: List[Token] Raises: ReductError: if there is an HTTP error
Source code in reduct/client.py
199 200 201 202 203 204 205 206 207 208 |
|
info()
async
¶
Get high level server info
Returns:
Name | Type | Description |
---|---|---|
ServerInfo |
ServerInfo
|
|
Raises:
Type | Description |
---|---|
ReductError
|
if there is an HTTP error |
Source code in reduct/client.py
133 134 135 136 137 138 139 140 141 142 143 144 |
|
list()
async
¶
Return a list of all buckets on server
Returns:
Type | Description |
---|---|
List[BucketInfo]
|
List[BucketInfo] |
Raises: ReductError: if there is an HTTP error
Source code in reduct/client.py
146 147 148 149 150 151 152 153 154 155 156 |
|
me()
async
¶
Get information about the current token Returns: FullTokenInfo Raises: ReductError: if there is an HTTP error
Source code in reduct/client.py
249 250 251 252 253 254 255 256 257 258 |
|
remove_token(name)
async
¶
Delete a token Args: name: name of the token Raises: ReductError: if there is an HTTP error
Source code in reduct/client.py
239 240 241 242 243 244 245 246 247 |
|