The following section provides a sample code for an After Create Property worker.
export default async (context: PlatformContext, data: AfterPropertyCreateRequest): Promise<AfterPropertyCreateResponse> => { try { // The HTTP client facilitates calls to the JFrog Platform REST APIs //To call an external endpoint, use 'await context.clients.axios.get("https://foo.com")' const res = await context.clients.platformHttp.get('/artifactory/api/v1/system/readiness'); // You should reach this part if the HTTP request status is successful (HTTP Status 399 or lower) if (res.status === 200) { console.log("Artifactory ping success"); } else { console.warn(`Request was successful and returned status code : ${res.status}`); } } catch(error) { // The platformHttp client throws PlatformHttpClientError if the HTTP request status is 400 or higher console.error(`Request failed with status code ${error.status || '<none>'} caused by : ${error.message}`) } return { 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 created property 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": "servlet.com", "skipJarIndexing": false, "disableRedirect": false, "repoType": 1 }, "headers": { "Content-Type": { "value": [ "text/plain" ] }, "Accept": { "value": [ "application/json" ] } }, "userContext": { "id": "id", "isToken": false, "realm": "realm" } }
Response
{ "data": { "message": "proceed" }, "executionStatus": "STATUS_SUCCESS" }