IoT File Service - Samples - Developer Documentation - Developer Documentation
Skip to content

IoT File Service – Bulk Deletion Samples

Create Time To Live Rule for File deletion

This API can be used by the users to create Time To Live(TTL) rules, which initiates bulk deletion of the files.

Create TTL rule using the following endpoint:

POST/fileDeleteRules

Sample Request:

[
  {
    "assetId": "0fcd06e781dd4bb0b9bd271d648741aa",
    "path": "/folder1/folder2",
    "deleteAfterDays": 30
  }
]

Parameter Details:

  • assetId: Unique identifier of the asset for which the files needs to be deleted
  • path: Path under which rule will be executed and files would be deleted
  • deleteAfterDays: Number of days after which files would be deleted (min 30 & max365) It is calculated from last update date of the file

Sample Response:

[
  {
    "id": "0fcd06e7-81dd-4bb0-b9bd-271d648741aa",
    "assetId": "089336872ce342aba1a847f53d515dc7",
    "path": "/folder1/folder2",
    "deleteAfterDays": 30,
    "created": "2023-03-15 12:29:31.0"
  }
]

Limitations on creation of TTL rules:

  • Maximum 50 TTL rules can be created per tenant. This limit is configurable and can be increased as per requirement
  • Only one rule per hierarchy of the folder can be created. It is recommended to apply rule on asset, so that all the underlying files are deleted with the rule
  • Rule will be executed on the next day of creation. Generally rule is executed at 12AM UTC time.
  • Number of days is restricted to minimum 30 and maximum 365

Retrieving TTL rules

This API gives the overall TTL rules created for file deletion on all the assets of the tenant.

Retrieve TTL rules using the below endpoint:

GET/fileDeleteRules/

This API gives the overall state of the rules. Description of TTL rules states is as shown below:

| State | Description | | ACTIVE | Rule is create and is in active state. This rule will be executed daily | | MARKED_FOR_DELETE | This Rule is deleted but cannot be removed due to some pending execution related activities. Once the activities are completed, Rule will be removed automatically. No further operations are possible on this Rule |

Sample Response:

{
  "fileDeleteRules": {
    "id": "0fcd06e7-81dd-4bb0-b9bd-271d648741aa",
    "assetId": "089336872ce342aba1a847f53d515dc7",
    "path": "abc33/",
    "deleteAfterDays": 1,
    "state": "ACTIVE",
    "created": "2020-03-01 09:12:28.110"
  },
  "page": {
    "size": 0,
    "totalElements": 0,
    "totalPages": 0,
    "number": 0
  }
}

Retrieving Rule Details

This API gives the overall TTL rules created for file deletion of the given id.

Retrieve TTL rules for the given id using the below endpoint:

GET/fileDeleteRules/{id}

Sample Response:

{
  "id": "0fcd06e7-81dd-4bb0-b9bd-271d648741aa",
  "assetId": "0fcd06e781dd4bb0b9bd271d648741aa",
  "path": "/folder1/folder2",
  "deleteAfterDays": 30,
  "state": "MARKED_FOR_DELETE",
  "created": "2020-03-01 09:12:28.110"
}

Delete TTL rule

This API deletes the already created file delete rule for a given id. If a TTL rule is deleted, its next scheduled execution will not be triggered.

Delete TTL rule for the given id using the below endpoint:

DELETE/fileDeleteRules/{id}

Last update: December 14, 2023

Except where otherwise noted, content on this site is licensed under the Development License Agreement.