Skip to content

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

@JPLachance

Description

@JPLachance

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()}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions