Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Mar 11, 2024
1 parent bf588c2 commit a192439
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/io/cryostat/graphql/ActiveRecordings.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import jdk.jfr.RecordingState;
import org.eclipse.microprofile.graphql.Description;
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Mutation;
import org.eclipse.microprofile.graphql.NonNull;
import org.eclipse.microprofile.graphql.Source;

Expand Down Expand Up @@ -121,16 +120,16 @@ public RecordingOptions asOptions() {
}
}

@Mutation
@Description(
"Updates the metadata labels for an existing Flight Recorder recording specified by the"
+ " recording ID.")
public Uni<ActiveRecording> doPutMetadata(Long recordingId, MetadataInput metadataInput) {
public Uni<ActiveRecording> doPutMetadata(
@Source ActiveRecording recording, MetadataInput metadataInput) {
return Uni.createFrom()
.item(
() -> {
Map<String, String> labels = metadataInput.getLabels();
return recordingHelper.updateRecordingMetadata(recordingId, labels);
return recordingHelper.updateRecordingMetadata(recording.id, labels);
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/cryostat/recordings/RecordingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -932,12 +932,14 @@ private Metadata taggingToMetadata(List<Tag> tagSet) {
public ActiveRecording updateRecordingMetadata(
Long recordingId, Map<String, String> newLabels) {
ActiveRecording recording = ActiveRecording.findById(recordingId);

if (recording == null) {
throw new NotFoundException("Recording not found for ID: " + recordingId);
}

Metadata updatedMetadata = new Metadata(newLabels);
recording.setMetadata(updatedMetadata);

recording.persist();

return recording;
Expand Down

0 comments on commit a192439

Please sign in to comment.