Skip to content

Commit a0636a5

Browse files
committed
chore: return comment Id as Output of Comment Task
1 parent bf00139 commit a0636a5

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/main/java/io/kestra/plugin/trello/cards/Comment.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
package io.kestra.plugin.trello.cards;
22

3+
import com.fasterxml.jackson.databind.JsonNode;
34
import io.kestra.core.http.HttpRequest;
45
import io.kestra.core.http.HttpResponse;
56
import io.kestra.core.http.client.HttpClient;
67
import io.kestra.core.models.annotations.Example;
78
import io.kestra.core.models.annotations.Plugin;
89
import io.kestra.core.models.property.Property;
9-
import io.kestra.core.models.tasks.VoidOutput;
1010
import io.kestra.core.runners.RunContext;
11+
import io.kestra.core.serializers.JacksonMapper;
1112
import io.kestra.plugin.trello.AbstractTrelloTask;
1213
import io.swagger.v3.oas.annotations.media.Schema;
1314
import jakarta.validation.constraints.NotNull;
14-
import lombok.EqualsAndHashCode;
15-
import lombok.Getter;
16-
import lombok.NoArgsConstructor;
17-
import lombok.ToString;
15+
import lombok.*;
1816
import lombok.experimental.SuperBuilder;
1917

2018
import java.net.URI;
@@ -62,7 +60,7 @@ public class Comment extends AbstractTrelloTask {
6260
protected Property<String> text;
6361

6462
@Override
65-
public VoidOutput run(RunContext runContext) throws Exception {
63+
public io.kestra.core.models.tasks.Output run(RunContext runContext) throws Exception {
6664
String rId = runContext.render(this.cardId).as(String.class).orElseThrow();
6765
String rText = runContext.render(this.text).as(String.class).orElseThrow();
6866

@@ -87,7 +85,18 @@ public VoidOutput run(RunContext runContext) throws Exception {
8785
+ response.getBody());
8886
}
8987

90-
return null;
88+
JsonNode jsonNode = JacksonMapper.ofJson().readTree(response.getBody());
89+
90+
return Output.builder()
91+
.commentId(jsonNode.has("id")?jsonNode.get("id").asText():null)
92+
.build();
9193
}
9294
}
95+
96+
@Builder
97+
@Getter
98+
public static class Output implements io.kestra.core.models.tasks.Output {
99+
@Schema(title = "Comment ID")
100+
private final String commentId;
101+
}
93102
}

0 commit comments

Comments
 (0)