Python Push API Client
Project description
Python Push API Client
Installation
pip install coveo-push-api-client.py
Usage
See more examples in the ./samples folder.
from push_api_clientpy import Source, DocumentBuilder
source = Source("my_api_key", "my_org_id")
myDocument = DocumentBuilder("https://my.document.uri", "My document title")\
.withData("these words will be searchable")
response = source.addOrUpdateDocument("my_source_id", myDocument)
print(f"Document added: {response.json()}")
Exponential backoff retry configuration
By default, the SDK leverages an exponential backoff retry mechanism. Exponential backoff allows for the SDK to make multiple attempts to resolve throttled requests, increasing the amount of time to wait for each subsequent attempt. Outgoing requests will retry when a 429 status code is returned from the platform.
The exponential backoff parameters are as follows:
retry_after - The amount of time, in seconds, to wait between throttled request attempts.
Optional, will default to 5.
max_retries - The maximum number of times to retry throttled requests.
Optional, will default to 10.
You may configure the exponential backoff that will be applied to all outgoing requests. To do so, specify a BackoffOptions object when creating either a Source or PlatformClient object:
source = Source("my_api_key", "my_org_id", BackoffOptions(3, 10))
By default, requests will retry a maximum of 10 times, waiting 10 seconds after the second attempt, with a time multiple of 2 (which will equate to a maximum execution time of roughly 1.5 hours. See urllib3 Retry documentation).
Dev
Requires Python 3.9
Requires pipenv: pip install pipenv
Install dependencies: pipenv install --dev
Build: pipenv run tox -e build
Tests: pipenv run tox
Full list of commands: pipenv run tox -av
Release
Tag the commit to release with semver format v{Major}.{Minor}.{Patch} eg: v1.2.5.
Checkout the newly created tag, e.g.: git checkout v1.2.5
Run pipenv run tox -e clean
Run pipenv run tox -e build
Run pipenv run tox -e publish
Note
This project has been set up using PyScaffold 4.0.1. For details and usage information on PyScaffold see https://pyscaffold.org/.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for coveo-push-api-client.py-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd41296e208b8c17e2ce5dd3fce50bdeff96d9913acbe3987a59cccd94a9e7f7 |
|
MD5 | 68a7270a0df571c18a7e46ee80590642 |
|
BLAKE2b-256 | f6da3bbe58835021e17018dff078ecbb2938bfab41754478d73ed039de523036 |
Hashes for coveo_push_api_client.py-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80951e46b4640bd6d198792b0a30ec6c1b5f0bc60682e3305971f30de1e6dd4d |
|
MD5 | 69b3982be54371aad948905a14a29e8d |
|
BLAKE2b-256 | 0806016a793986cc92bee1b5578bdf2aec7d9b68f405591d601a0584903cb984 |