Skaha Client¶
The skaha.client
module provides a client for the Skaha server. The client is based of the
httpx
library and provides a simple interface to the Skaha server. The client configures the
authorization headers for user authentication and container registry access.
Bases: BaseModel
Skaha Client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
server
|
str
|
Server URL. |
required |
version
|
str
|
Skaha API version. |
required |
certificate
|
str
|
Certificate file. |
required |
timeout
|
int
|
HTTP Timeout. |
required |
verify
|
bool
|
Verify SSL certificate. |
required |
registry
|
ContainerRegistry
|
Credentials for a private registry. |
required |
client
|
Client
|
HTTPx Client. |
required |
asynclient
|
AsyncClient
|
HTTPx Async Client. |
required |
concurrency
|
int
|
Number of concurrent requests. |
required |
token
|
str
|
Authentication token. |
required |
loglevel
|
int
|
Logging level. Default is 20 (INFO). |
required |
Raises:
Type | Description |
---|---|
ValidationError
|
If the client is misconfigured. |
FileNotFoundError
|
If the cert file does not exist or is not readable. |
Examples:
>>> from skaha.client import SkahaClient
class Sample(SkahaClient):
pass
Source code in skaha/client.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 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 259 260 261 262 |
|
_check_certificate(value, info)
classmethod
¶
Validate the certificate file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
FilePath
|
Path to the certificate file. |
required |
Returns:
Name | Type | Description |
---|---|---|
FilePath |
str
|
Validated Path to the certificate file. |
Source code in skaha/client.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
_check_server(value)
classmethod
¶
Validate the server URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Server URL. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Validated Server URL. |
Source code in skaha/client.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
_configure_clients()
¶
Configure the HTTPx Clients.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
Updated SkahaClient object. |
Source code in skaha/client.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
_get_cert_clients()
¶
Get the clients with certificate authentication.
Returns:
Type | Description |
---|---|
Tuple[Client, AsyncClient]
|
Tuple[Client, AsyncClient]: Synchronous and Asynchronous HTTPx Clients. |
Source code in skaha/client.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
_get_headers()
¶
Get the HTTP headers for the client.
Returns:
Type | Description |
---|---|
Dict[str, str]
|
Dict[str, str]: HTTP headers. |
Source code in skaha/client.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
_get_token_clients()
¶
Get the clients with token authentication.
Returns:
Type | Description |
---|---|
Tuple[Client, AsyncClient]
|
Tuple[Client, AsyncClient]: Synchronous and Asynchronous HTTPx Clients. |
Source code in skaha/client.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
_set_log_level(value)
classmethod
¶
Set the log level for the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
Logging level. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Logging level. |
Source code in skaha/client.py
143 144 145 146 147 148 149 150 151 152 153 154 155 |
|