Visit Azul.com Support

API for Code Inventory

The Code Inventory API allows you to create and download reports to get insights into how your Java code is used in production.

Reports can be grouped by JAR, classes and/or methods.

Reports are generated asynchronously. By using the endpoint, a task to generate a report is created. In response, you get a unique report identifier. With this identifier, you can retrieve the report.

Request Report Generation

You can request the generation of a report with a POST call to https://YOUR_ENDPOINT.azul.com/public/report/codeInventory and a set of parameters.

Request Parameters

Argument Default Description

filter

array[string]

Array of filters for one or more of the following:

  • sourceName

  • className

  • methodName

from

timestamp

Timestamp for the start of the report.

Example: "2023-02-15T00:00:00.000+0200`

to

timestampe

Timestamp for the end of the report.

Similar to from.

Example Request

 
curl -X 'POST' \ 'https://YOUR_ENDPOINT.azul.com/report/codeInventory' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -H 'x-api-key: YOUR_API_KEY' \ -d '{ "filter": [ "sourceName:myapp.jar", "className:com/company/firstclass", "methodName:mymethod" ], "from": "2023-02-15T00:00:00.000+0200", "to": "2023-02-16T23:59:59.999+0200" }'

Example Response

In response, you will get a reportId that can be used with the GET endpoint to retrieve the report.

 
{ "reportId": "1cc40ee6-87a7-4147-b02d-7d26ce0387d0", "state": "PROCESSING", "stateMessages": [ "1st message", "2nd message" ], "userId": "[email protected]", "params": { "filter": [ "sourceName:myapp.jar", "className:com/company/firstclass", "methodName:mymethod" ], "from": "2023-02-15T00:00:00.000+0200", "to": "2023-02-16T23:59:59.999+0200" }, "requestTime": "2023-02-15T00:00:00.000Z" }

Retrieve the Report

You can retrieve a report with a GET call to /public/report/codeInventory/YOUR_REPORT_ID.

The response must be checked to define if the data is available, based on the following possible return data:

  • state: State of the request, one of the following options:

    • PROCESSING

    • SUCCEEDED

    • FAILED

    • PARTIALLY_FAILED

    • TIMED_OUT

  • stateMessages: More info related to the state.

  • errors: Errors while creating the report (if applicable).

Large reports are split into pages (up to 5.5MB per page). You can find the total number of pages in the response and use this value to retrieve all the report pages.

Note
Regardless of whether a report is generated successfully or not, when the generation is finished, at least one page of the report is available for retrieval.

Example Request

 
curl -X 'GET' \ 'https://YOUR_ENDPOINT.azul.com/public/report/codeInventory/YOUR_REPORT_ID' \ -H 'accept: application/json' \ -H 'x-api-key: YOUR_API_KEY' \ -H 'Content-Type: application/json'

Example Response

 
{ "reportId": "1cc40ee6-87a7-4147-b02d-7d26ce0387d0", "userId": "[email protected]", "params": { "filter": [ "sourceName:myapp.jar", "className:com/company/firstclass", "methodName:mymethod" ], "from": "2023-02-15T00:00:00.000+0200", "to": "2023-02-16T23:59:59.999+0200" }, "from": "2023-07-13T16:42:37.268", "to": "2023-07-13T16:42:37.268", "state": "PROCESSING", "stateMessages": [ "1st message", "2nd message" ], "requestTime": "2023-07-13T16:42:37.268", "startTime": "2023-07-13T16:42:37.268", "finishTime": "2023-07-13T16:42:47.231", "data": [ { "sourceName": "myapp.jar", "className": "com/company/firstclass", "methodName": "getHost(java/lang/String)", "firstSeen": "2023-07-13T16:12:51.181", "lastSeen": "2023-07-14T11:10:01.112" } ], "totalCount": 35352, "totalPages": 36, "page": 1, "afterToken": "2" }

When the JMV is configured with the AppEnv tag, as described here, the data block includes that extra info. For example:

 
{ "reportId": "1cc40ee6-87a7-4147-b02d-7d26ce0387d0", ... "data": [ { "sourceName": "myapp.jar", "className": "com/company/firstclass", "methodName": "getHost(java/lang/String)", "firstSeen": "2023-07-13T16:12:51.181", "lastSeen": "2023-07-14T11:10:01.112", "tags": [ "AppEnv:test" ] } ], ... }

Retrieve All Reports

You can retrieve a list with all reports with a GET call to https://YOUR_ENDPOINT.azul.com/public/report/codeInventory.

 
curl -X 'GET' \ 'https://YOUR_ENDPOINT.azul.com/public/report/codeInventory' \ -H 'accept: application/json' \ -H 'x-api-key: YOUR_API_KEY' \ -H 'Content-Type: application/json'

Example Response

 
{ "data": [ { "reportId": "1cc40ee6-87a7-4147-b02d-7d26ce0387d0", "state": "SUCCEEDED", "stateMessages": [ "1st message", "2nd message" ], "userId": "[email protected]", "params": { "filter": [ "sourceName:myapp.jar", "className:com/company/firstclass", "methodName:mymethod" ], "from": "2023-02-15T00:00:00.000+0200", "to": "2023-02-16T23:59:59.999+0200" }, "requestTime": "2023-02-15T00:00:00.000Z", "startTime": "2023-02-15T00:00:00.000Z", "finishTime": "2023-02-15T00:00:00.000Z" } ], "afterToken": "1683200412" }

Delete a Report

You can delete a report with a DELETE call to https://YOUR_ENDPOINT.azul.com/public/report/codeInventory/YOUR_REPORT_ID.

Example Request

 
curl -X 'DELETE' \ 'https://YOUR_ENDPOINT.azul.com/public/report/codeInventory/YOUR_REPORT_ID' \ -H 'accept: application/json' \ -H 'x-api-key: YOUR_API_KEY' \ -H 'Content-Type: application/json'

Example Response

HTTP 204: Report deleted successfully.