Before Delete Property Worker Code Sample

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

The following section provides a sample code for a Before Delete Property worker.

export default async (context: PlatformContext, data: BeforePropertyCreateRequest): Promise<BeforePropertyCreateResponse> => {

   console.log(await context.clients.platformHttp.get('/artifactory/api/system/ping'));
   console.log(await axios.get('https://my.external.resource'));
   return {
       status: BeforePropertyCreateStatus.BEFORE_PROPERTY_CREATE_PROCEED,
       message: 'proceed',
   }
};

Input Parameters

context

Provides baseUrl, token, and clients to communicate with the JFrog Platform (for more information, see PlatformContext).

data

The request with delete details sent by Artifactory.

{
  "metadata": {
    "repoPath": {
      "key": "local-repo",
      "path": "folder/subfolder/my-file",
      "id": "local-repo:folder/subfolder/my-file",
      "isRoot": false,
      "isFolder": false
    },
    "contentLength": 100,
    "lastModified": 0,
    "trustServerChecksums": false,
    "servletContextUrl": "https://jpd.jfrog.io/artifactory",
    "skipJarIndexing": false,
    "disableRedirect": false,
    "repoType": 1
  },
  "userContext": {
    "id": "id",
    "isToken": false,
    "realm": "realm"
  },
  "itemInfo": {
    "repoPath": {
      "key": "local-repo",
      "path": "folder/subfolder/my-file",
      "id": "local-repo:folder/subfolder/my-file",
      "isRoot": false,
      "isFolder": false
    },
    "name": "my-artifact",
    "created": 1,
    "lastModified": 0
  },
  "name": "property-name"
}
Response
{
  status: BeforePropertyDeleteStatus.BEFORE_PROPERTY_DELETE_PROCEED,
  message: 'proceed',
}
Possible Statuses
  • BeforePropertyDeleteStatus.BEFORE_PROPERTY_DELETE_PROCEED - The worker allows Artifactory to proceed with deleting a property.

  • BeforePropertyDeleteStatus.BEFORE_PROPERTY_DELETE_STOP - The worker does not allow Artifactory to delete a property.

  • BeforePropertyDeleteStatus.BEFORE_PROPERTY_Delete_WARN - The worker provides a warning before Artifactory can proceed with deleting a property.