Skip to content

Commit e401344

Browse files
authored
docs(api): document API and classes (#908)
1 parent 128a989 commit e401344

File tree

70 files changed

+1165
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1165
-18
lines changed

schema/openapi.yaml

Lines changed: 284 additions & 1 deletion
Large diffs are not rendered by default.

schema/schema.graphql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ type Annotations {
5050

5151
type ArchivedRecording {
5252
archivedTime: BigInteger!
53+
"Delete an archived recording"
5354
doDelete: ArchivedRecording!
55+
"Update the metadata associated with an archived recording"
5456
doPutMetadata(metadataInput: MetadataLabelsInput): ArchivedRecording!
5557
downloadUrl: String
5658
jvmId: String
@@ -160,6 +162,7 @@ type OperatingSystemMetrics {
160162

161163
"Query root"
162164
type Query {
165+
"List archived recordings"
163166
archivedRecordings(filter: ArchivedRecordingsFilterInput): ArchivedRecordings
164167
"Get all environment nodes in the discovery tree with optional filtering"
165168
environmentNodes(filter: DiscoveryNodeFilterInput): [DiscoveryNode]
@@ -177,7 +180,9 @@ type RecordingAggregateInfo {
177180
}
178181

179182
type Recordings {
183+
"List and optionally filter active recordings belonging to a Target"
180184
active(filter: ActiveRecordingsFilterInput): ActiveRecordings
185+
"List and optionally filter archived recordings belonging to a Target"
181186
archived(filter: ArchivedRecordingsFilterInput): ArchivedRecordings
182187
}
183188

@@ -226,10 +231,12 @@ type Suggestion {
226231
}
227232

228233
type Target {
234+
"Retrieve a list of active recordings currently available on the target"
229235
activeRecordings(filter: ActiveRecordingsFilterInput): ActiveRecordings
230236
agent: Boolean!
231237
alias: String!
232238
annotations: Annotations!
239+
"Retrieve a list of archived recordings belonging to the target"
233240
archivedRecordings(filter: ArchivedRecordingsFilterInput): ArchivedRecordings
234241
connectUrl: String!
235242
"Create a new Flight Recorder Snapshot on the specified Target"
@@ -246,6 +253,12 @@ type Target {
246253
mbeanMetrics: MBeanMetrics
247254
"Get the active and archived recordings belonging to this target"
248255
recordings: Recordings
256+
"""
257+
Retrieve an automated analysis report from the selected target(s). If there is no report currently
258+
available then this request will not cause a report to be generated, and instead it will return an empty
259+
result. Report generation may be an expensive operation, especially if many reports are to be generated at
260+
once, and should not be triggered by broad GraphQL selections.
261+
"""
249262
report: Report
250263
}
251264

src/main/java/io/cryostat/BuildInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import jakarta.inject.Inject;
2626
import org.jboss.logging.Logger;
2727

28+
/** Describes the current build of the application. Contains information about the VCS commit. */
2829
@ApplicationScoped
2930
public class BuildInfo {
3031

src/main/java/io/cryostat/ConfigProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package io.cryostat;
1717

18+
/** Java constants corresponding to configuration keys set in application.properties. */
1819
public class ConfigProperties {
1920
public static final String AWS_BUCKET_NAME_ARCHIVES = "storage.buckets.archives.name";
2021
public static final String AWS_BUCKET_NAME_EVENT_TEMPLATES =

src/main/java/io/cryostat/Cryostat.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
import io.quarkus.runtime.QuarkusApplication;
2424
import io.quarkus.runtime.annotations.QuarkusMain;
2525

26+
/**
27+
* Main application entrypoint. Perform any required early initialization tasks, then kick off the
28+
* webserver.
29+
*/
2630
@QuarkusMain
2731
public class Cryostat {
2832

src/main/java/io/cryostat/ExceptionMappers.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
import software.amazon.awssdk.services.s3.model.NoSuchKeyException;
3838
import software.amazon.awssdk.services.s3.model.S3Exception;
3939

40+
/**
41+
* Map uncaught exceptions at the endpoint level to REST responses. For example, without a
42+
* corresponding exception mapper, an uncaught jakarta.persistence.NoResultException would result in
43+
* the web server responding with an HTTP 500 Internal Server Error (the default behaviour for all
44+
* uncaught exceptions). Defining a mapper for NoResultException allows the global behaviour to be
45+
* overridden to an HTTP 404 Not Found response. Individual endpoints may still use standard
46+
* try-catch handling to deal with NoResultExceptions in other ways as needed.
47+
*/
4048
public class ExceptionMappers {
4149

4250
@Inject Logger logger;

src/main/java/io/cryostat/Health.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
import jakarta.ws.rs.core.MediaType;
3838
import org.apache.commons.lang3.StringUtils;
3939
import org.eclipse.microprofile.config.inject.ConfigProperty;
40+
import org.eclipse.microprofile.openapi.annotations.Operation;
4041
import org.jboss.logging.Logger;
4142

43+
/** Status and configuration verification for the application. */
4244
@Path("")
4345
class Health {
4446

@@ -70,6 +72,15 @@ class Health {
7072
@Blocking
7173
@Path("/health")
7274
@PermitAll
75+
@Operation(
76+
summary = "Check the overall status of the application",
77+
description =
78+
"""
79+
Returns a map indicating whether various external components (ex.
80+
jfr-datasource, grafana-dashboard) are configured and whether those
81+
components can be reached by the Cryostat application. Also includes
82+
application semantic version and build information.
83+
""")
7384
public ApplicationHealth health() {
7485
CompletableFuture<Boolean> datasourceAvailable = new CompletableFuture<>();
7586
CompletableFuture<Boolean> dashboardAvailable = new CompletableFuture<>();
@@ -113,12 +124,31 @@ public ApplicationHealth health() {
113124
@Blocking
114125
@Path("/health/liveness")
115126
@PermitAll
127+
@Operation(
128+
summary = "Check if the application is able to accept and respond to requests.",
129+
description =
130+
"""
131+
Performs a no-op on a worker thread. This is a simply check to determine if
132+
the application has available threads to service requests. HTTP 204 No Content
133+
is the only expected response. If the application is not live and no worker
134+
threads are available, then the client will never receive a response.
135+
""")
116136
public void liveness() {}
117137

118138
@GET
119139
@Path("/api/v4/grafana_dashboard_url")
120140
@PermitAll
121141
@Produces({MediaType.APPLICATION_JSON})
142+
@Operation(
143+
summary =
144+
"Return the URL which users can visit to access the associated Grafana"
145+
+ " dashboard instance.",
146+
description =
147+
"""
148+
Returns the URL for the associated Grafana dashboard instance. If there is an internally-accessible
149+
(for Cryostat) URL and an externally-accessible URL (for users) URL, the externally-accessible URL
150+
is preferred. If neither are configured then the response is an HTTP 400 Bad Request.
151+
""")
122152
public DashboardUrl grafanaDashboardUrl() {
123153
String url =
124154
dashboardExternalURL.orElseGet(
@@ -130,6 +160,14 @@ public DashboardUrl grafanaDashboardUrl() {
130160
@Path("/api/v4/grafana_datasource_url")
131161
@PermitAll
132162
@Produces({MediaType.APPLICATION_JSON})
163+
@Operation(
164+
summary = "Return the URL to the associated jfr-datasource instance.",
165+
description =
166+
"""
167+
Returns the URL for the jfr-datasource instance which Cryostat is configured to use. This datasource
168+
accepts JFR file uploads from Cryostat and allows the Grafana dashboard to perform queries on the
169+
data within the recording file.
170+
""")
133171
public DatasourceUrl grafanaDatasourceUrl() {
134172
String url = datasourceURL.orElseThrow(() -> new BadRequestException());
135173
return new DatasourceUrl(url);

src/main/java/io/cryostat/JsonRequestFilter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import jakarta.ws.rs.ext.Provider;
3535

3636
@Provider
37+
/** Filter incoming request bodies or outgoing response bodies to scrub particular content. */
3738
public class JsonRequestFilter implements ContainerRequestFilter {
3839

3940
static final Set<String> disallowedFields = Set.of("id");

src/main/java/io/cryostat/ProgressInputStream.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
import org.apache.commons.io.input.ProxyInputStream;
2222

23+
/**
24+
* An InputStream which informs a provided {@link java.util.function.Consumer} about the number of
25+
* bytes read each time a chunk is read from this stream.
26+
*/
2327
public class ProgressInputStream extends ProxyInputStream {
2428

2529
private final Consumer<Integer> onUpdate;

src/main/java/io/cryostat/StorageBuckets.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
3636
import software.amazon.awssdk.services.s3.model.HeadBucketRequest;
3737

38+
/**
39+
* Utility for interacting with S3 object storage buckets. Use to ensure that the S3 object storage
40+
* meets the application requirements, ex. that the expected buckets exist.
41+
*/
3842
@ApplicationScoped
3943
public class StorageBuckets {
4044

0 commit comments

Comments
 (0)