coveo / push-api-client.py

Apache License 2.0
1 stars 1 forks source link

[Feature Request]: Add a function to call DELETE on documents/olderthan #37

Open JPLachance opened 3 months ago

JPLachance commented 3 months ago

Current Behavior

Coveo has a feature to delete documents that are older than a given date. When doing a full refresh, that endpoint can be called to delete documents that don't exist anymore.

The endpoint documentation: https://docs.coveo.com/en/131/index-content/deleting-old-items-in-a-push-source

The current SDK implementation does not expose this method.

Expected Behavior

The SDK should expose this method.

Steps To Reproduce

  1. Install the SDK
  2. Look for methods available on a Source
  3. The method is not there

Environment

Python Version -> Latest
OS Version -> Latest macOS
...

Debug logs

No response

Anything else?

Here is a bad piece of code I ended up using:

url = (
    f"https://api.cloud.coveo.com/push/v1/organizations/{self.organization_id}/sources/{self.source_id}/"
    f"documents/olderthan"
)
response = self.source.client.session.delete(
    url,
    params={"orderingId": self.clear_items_older_than},
    headers={"Authorization": f"Bearer {self.coveo_api_key}"},
)

if response.status_code == 202:
    logger.info("Old documents deleted successfully.")
else:
    logger.error(f"Failed to delete old documents: {response.json()}")
akhilk2802 commented 3 months ago

Damn, Thats so good explanation about the issue. Love it, trying to reproduce