binaryai.utils
Module Contents
Classes
Auth class that allows us to connect to QCloud services |
Functions
|
Computes sha256 hash sum of a file. |
|
Modified from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html |
|
Modified from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html |
- binaryai.utils.sha256sum(path: str) str [source]
Computes sha256 hash sum of a file.
- Parameters:
path – path of file
- Returns:
hex digest of sha256
- binaryai.utils.sign(key, msg)[source]
Modified from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
- binaryai.utils.getSignatureKey(key, dateStamp, serviceName)[source]
Modified from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
- class binaryai.utils.QCloudHttpxAuth(qcloud_secret_id, qcloud_secret_key, qcloud_host, qcloud_region, qcloud_service, qcloud_action, qcloud_apiversion)[source]
Bases:
httpx.Auth
Auth class that allows us to connect to QCloud services
- requires_request_body = True
- auth_flow(r: httpx.Request) Generator[httpx.Request, httpx.Response, None] [source]
Adds the authorization headers required by QCloud Signature v3.
- get_qcloud_request_headers_handler(r)[source]
Override get_qcloud_request_headers_handler() if you have a subclass that needs to call get_qcloud_request_headers() with an arbitrary set of QCloud credentials. The default implementation calls get_qcloud_request_headers() with self.qcloud_access_key, and self.qcloud_secret_access_key
- get_qcloud_request_headers(r: httpx.Request, qcloud_secret_id, qcloud_secret_key)[source]
Returns a dictionary containing the necessary headers for Amazon’s signature version 4 signing process. An example return value might look like
- {
‘Authorization’: ‘…’, ‘…’,
}
- classmethod get_canonical_path(r: httpx.Request)[source]
Create canonical path. According to QCloud, this should always be “/”
- classmethod get_canonical_querystring(r: httpx.Request)[source]
Create the canonical query string. According to QCloud, by the end of this function our query string values must be URL-encoded (space=%20) and the parameters must be sorted by name.
This method assumes that the query params in r are already url encoded. If they are not url encoded by the time they make it to this function, QCloud may complain that the signature for your request is incorrect.
- It appears elasticsearc-py url encodes query paramaters on its own:
If you are using a different client than elasticsearch-py, it will be your responsibility to urleconde your query params before this method is called.