Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JPLachance opened this issue May 31, 2024 · 1 comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@JPLachance
Copy link
Member

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()}")
@JPLachance JPLachance added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed and removed bug Something isn't working labels May 31, 2024
@akhilk2802
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants