diff --git a/docs/source/redact/redacting_text.rst b/docs/source/redact/redacting_text.rst index a04260f..4b77d83 100644 --- a/docs/source/redact/redacting_text.rst +++ b/docs/source/redact/redacting_text.rst @@ -323,4 +323,4 @@ When you use the :meth:`redact` meth tags=["my_first_request"]) ) -The above code runs the redaction in the same way as any other redaction request, and then records the API request and its results. The request itself is automatically purged after 1 hour. You can view the results from the **API Explorer** page in Textual. \ No newline at end of file +The above code runs the redaction in the same way as any other redaction request, and then records the API request and its results. The request itself is automatically purged after 1 hour. You can view the results from the **API Explorer** page in Textual. The retention time is specified in hours and can be set to a value between 1 and 720. \ No newline at end of file diff --git a/tonic_textual/redact_api.py b/tonic_textual/redact_api.py index 13ec67d..89c38e9 100644 --- a/tonic_textual/redact_api.py +++ b/tonic_textual/redact_api.py @@ -24,6 +24,7 @@ from tonic_textual.classes.dataset import Dataset from tonic_textual.classes.datasetfile import DatasetFile from tonic_textual.classes.tonic_exception import ( + BadArgumentsException, DatasetNameAlreadyExists, InvalidJsonForRedactionRequest, FileNotReadyForDownload, @@ -257,7 +258,7 @@ def redact( the text is marked as the entity type and is included in the redaction or synthesis. record_options: RecordApiRequestOptions - A value to record the API request and results for analysis in the Textual application. The default value is to not record the API request and results in the Textual application. + A value to record the API request and results for analysis in the Textual application. The default value is to not record the API request. Returns ------- @@ -299,6 +300,9 @@ def redact( } if record_options.record: + if record_options.retention_time_in_hours <= 0 or record_options.retention_time_in_hours>720: + raise BadArgumentsException("The retention time must be set between 1 and 720 hours") + record_payload = { "retentionTimeInHours": record_options.retention_time_in_hours, "tags": record_options.tags, "record": True} payload["recordApiRequestOptions"] = record_payload else: