diff --git a/src/main/java/io/kestra/plugin/github/GHTopicSearchBuilder.java b/src/main/java/io/kestra/plugin/github/GHTopicSearchBuilder.java index 577a319..a1cca2a 100644 --- a/src/main/java/io/kestra/plugin/github/GHTopicSearchBuilder.java +++ b/src/main/java/io/kestra/plugin/github/GHTopicSearchBuilder.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import lombok.Data; import org.apache.commons.lang3.StringUtils; -import org.kohsuke.github.GHObject; import org.kohsuke.github.GitHub; import java.io.BufferedReader; diff --git a/src/main/java/io/kestra/plugin/github/GithubConnection.java b/src/main/java/io/kestra/plugin/github/GithubConnection.java index 50ad5a8..f6a8707 100644 --- a/src/main/java/io/kestra/plugin/github/GithubConnection.java +++ b/src/main/java/io/kestra/plugin/github/GithubConnection.java @@ -1,5 +1,6 @@ package io.kestra.plugin.github; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.Task; import jakarta.annotation.Nullable; import lombok.EqualsAndHashCode; @@ -15,11 +16,11 @@ @NoArgsConstructor public abstract class GithubConnection extends Task implements GithubConnectionInterface { - private String login; + private Property login; - private String oauthToken; + private Property oauthToken; - private String jwtToken; + private Property jwtToken; public record GithubClientConfig( @Nullable String login, diff --git a/src/main/java/io/kestra/plugin/github/GithubConnectionInterface.java b/src/main/java/io/kestra/plugin/github/GithubConnectionInterface.java index a7a7bc3..fc41ee4 100644 --- a/src/main/java/io/kestra/plugin/github/GithubConnectionInterface.java +++ b/src/main/java/io/kestra/plugin/github/GithubConnectionInterface.java @@ -1,7 +1,7 @@ package io.kestra.plugin.github; import io.kestra.core.exceptions.IllegalVariableEvaluationException; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.swagger.v3.oas.annotations.media.Schema; @@ -11,38 +11,34 @@ public interface GithubConnectionInterface { title = "GitHub login", description = "Requires additional field: oauthToken, to log-in" ) - @PluginProperty(dynamic = true) - String getLogin(); + Property getLogin(); @Schema( title = "GitHub oauthToken", description = "GitHub Personal Access Token. In addition, can be used with login or by its own" ) - @PluginProperty(dynamic = true) - String getOauthToken(); + Property getOauthToken(); @Schema( title = "GitHub JWT token", description = "Does not requires additional fields to log-in" ) - @PluginProperty(dynamic = true) - String getJwtToken(); + Property getJwtToken(); @Schema( title = "GitHub repository", description = "Repository where issue/ticket should be created. It's a string of Username + / + Repository name", example = "kestra-io/plugin-github" ) - @PluginProperty(dynamic = true) - default String getRepository() { + default Property getRepository() { return null; } default GithubConnection.GithubClientConfig getClientConfig(RunContext runContext) throws IllegalVariableEvaluationException { return new GithubConnection.GithubClientConfig( - runContext.render(this.getLogin()), - runContext.render(this.getOauthToken()), - runContext.render(this.getJwtToken()) + runContext.render(this.getLogin()).as(String.class).orElse(null), + runContext.render(this.getOauthToken()).as(String.class).orElse(null), + runContext.render(this.getJwtToken()).as(String.class).orElse(null) ); } diff --git a/src/main/java/io/kestra/plugin/github/GithubSearchTask.java b/src/main/java/io/kestra/plugin/github/GithubSearchTask.java index 0af4bda..55ab362 100644 --- a/src/main/java/io/kestra/plugin/github/GithubSearchTask.java +++ b/src/main/java/io/kestra/plugin/github/GithubSearchTask.java @@ -1,6 +1,5 @@ package io.kestra.plugin.github; -import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.core.serializers.FileSerde; import io.kestra.plugin.github.model.IssueDetails; diff --git a/src/main/java/io/kestra/plugin/github/code/Search.java b/src/main/java/io/kestra/plugin/github/code/Search.java index dbb6a5b..7d7f27e 100644 --- a/src/main/java/io/kestra/plugin/github/code/Search.java +++ b/src/main/java/io/kestra/plugin/github/code/Search.java @@ -2,7 +2,7 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.core.serializers.FileSerde; @@ -55,7 +55,7 @@ code = """ id: github_code_search_flow namespace: company.team - + tasks: - id: search_code type: io.kestra.plugin.github.code.Search @@ -99,62 +99,52 @@ public enum Fork { title = "The query contains one or more search keywords and qualifiers.", description = "Allow you to limit your search to specific areas of GitHub." ) - @PluginProperty(dynamic = true) - private String query; + private Property query; @Schema( title = "The GitHub repository." ) - @PluginProperty(dynamic = true) - private String repository; + private Property repository; @Schema( title = "Search commits in all repositories owned by a certain user." ) - @PluginProperty(dynamic = true) - private String user; + private Property user; @Schema( title = "In" ) - @PluginProperty(dynamic = true) - private String in; + private Property in; @Schema( title = "The language." ) - @PluginProperty(dynamic = true) - private String language; + private Property language; @Schema( title = "The file extension." ) - @PluginProperty(dynamic = true) - private String extension; + private Property extension; @Schema( description = "Whether to include forks." ) - @PluginProperty - private Fork fork; + private Property fork; @Schema( title = "The file name." ) - @PluginProperty(dynamic = true) - private String filename; + private Property filename; @Schema( title = "The file path." ) - @PluginProperty(dynamic = true) - private String path; + private Property path; @Schema( title = "The file size." ) - @PluginProperty(dynamic = true) - private String size; + private Property size; @Schema( name = "order", @@ -165,8 +155,7 @@ public enum Fork { """ ) @Builder.Default - @PluginProperty - private Order order = Order.ASC; + private Property order = Property.of(Order.ASC); @Schema( name = "sort", @@ -177,8 +166,7 @@ public enum Fork { """ ) @Builder.Default - @PluginProperty - private Sort sort = Sort.BEST_MATCH; + private Property sort = Property.of(Sort.BEST_MATCH); @Override public Output run(RunContext runContext) throws Exception { @@ -215,47 +203,47 @@ private GHContentSearchBuilder setupSearchParameters(RunContext runContext, GitH GHContentSearchBuilder searchBuilder = gitHub.searchContent(); searchBuilder - .sort(this.sort.value) - .order(this.order.direction); + .sort(runContext.render(this.sort).as(Sort.class).orElseThrow().value) + .order(runContext.render(this.order).as(Order.class).orElseThrow().direction); if (this.query != null) { - searchBuilder.q(runContext.render(this.query)); + searchBuilder.q(runContext.render(this.query).as(String.class).orElseThrow()); } if (this.repository != null) { - searchBuilder.repo(runContext.render(this.repository)); + searchBuilder.repo(runContext.render(this.repository).as(String.class).orElseThrow()); } if (this.user != null) { - searchBuilder.user(runContext.render(this.user)); + searchBuilder.user(runContext.render(this.user).as(String.class).orElseThrow()); } if (this.in != null) { - searchBuilder.in(runContext.render(this.in)); + searchBuilder.in(runContext.render(this.in).as(String.class).orElseThrow()); } if (this.language != null) { - searchBuilder.language(runContext.render(this.language)); + searchBuilder.language(runContext.render(this.language).as(String.class).orElseThrow()); } if (this.extension != null) { - searchBuilder.extension(runContext.render(this.extension)); + searchBuilder.extension(runContext.render(this.extension).as(String.class).orElseThrow()); } if (this.fork != null) { - searchBuilder.fork(this.fork.value); + searchBuilder.fork(runContext.render(this.fork).as(Fork.class).orElseThrow().value); } if (this.filename != null) { - searchBuilder.filename(runContext.render(this.filename)); + searchBuilder.filename(runContext.render(this.filename).as(String.class).orElseThrow()); } if (this.path != null) { - searchBuilder.path(runContext.render(this.path)); + searchBuilder.path(runContext.render(this.path).as(String.class).orElseThrow()); } if (this.size != null) { - searchBuilder.size(runContext.render(this.size)); + searchBuilder.size(runContext.render(this.size).as(String.class).orElseThrow()); } return searchBuilder; } diff --git a/src/main/java/io/kestra/plugin/github/commits/Search.java b/src/main/java/io/kestra/plugin/github/commits/Search.java index e4a1d6d..92d1815 100644 --- a/src/main/java/io/kestra/plugin/github/commits/Search.java +++ b/src/main/java/io/kestra/plugin/github/commits/Search.java @@ -2,7 +2,7 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.core.serializers.FileSerde; @@ -57,7 +57,7 @@ code = """ id: github_commit_search_flow namespace: company.team - + tasks: - id: search_commit type: io.kestra.plugin.github.commits.Search @@ -90,105 +90,88 @@ public enum Sort { title = "The query contains one or more search keywords and qualifiers.", description = "Allows you to limit your search to specific areas of GitHub." ) - @PluginProperty(dynamic = true) - private String query; + private Property query; @Schema( title = "Search in specified repository." ) - @PluginProperty(dynamic = true) - private String repository; + private Property repository; @Schema( title = "Matches commits from repositories with the specified visibility." ) - @PluginProperty(dynamic = true) - private String is; + private Property is; @Schema( title = "Matches commits with the specified SHA-1 hash." ) - @PluginProperty(dynamic = true) - private String hash; + private Property hash; @Schema( title = "Matches commits whose parent has the specified SHA-1 hash." ) - @PluginProperty(dynamic = true) - private String parent; + private Property parent; @Schema( title = "Matches commits with the specified SHA-1 git tree hash." ) - @PluginProperty(dynamic = true) - private String tree; + private Property tree; @Schema( title = "Search commits in all repositories owned by a certain user" ) - @PluginProperty(dynamic = true) - private String user; + private Property user; @Schema( title = "Search commits in all repositories owned by a certain organization." ) - @PluginProperty(dynamic = true) - private String org; + private Property org; @Schema( title = "Find commits by a particular user." ) - @PluginProperty(dynamic = true) - private String author; + private Property author; @Schema( title = "Match commits authored within the specified date range. When you search for a date, you can use greater than, less than, and range qualifiers to further filter results." ) - @PluginProperty(dynamic = true) - private String authorDate; + private Property authorDate; @Schema( title = "Match commits by the author's full email address." ) - @PluginProperty(dynamic = true) - private String authorEmail; + private Property authorEmail; @Schema( title = "Match commits by the name of the author" ) - @PluginProperty(dynamic = true) - private String authorName; + private Property authorName; @Schema( title = "Find commits by a particular user" ) - @PluginProperty(dynamic = true) - private String committer; + private Property committer; @Schema( title = "Match commits committed within the specified date range.", description = "When you search for a date, you can use greater than, less than, and range qualifiers to further filter results." ) - @PluginProperty(dynamic = true) - private String committerDate; + private Property committerDate; @Schema( title = "Match commits by the committer's full email address." ) - @PluginProperty(dynamic = true) - private String committerEmail; + private Property committerEmail; @Schema( title = "Match commits by the name of the committer" ) - @PluginProperty(dynamic = true) - private String committerName; + private Property committerName; @Schema( title = "Whether to filter merge commits." ) - @PluginProperty - private Boolean merge; + private Property merge; @Schema( title = "Order of the output.", @@ -198,8 +181,7 @@ public enum Sort { """ ) @Builder.Default - @PluginProperty - private Order order = Order.ASC; + private Property order = Property.of(Order.ASC); @Schema( title = "Sort condition for the output.", @@ -209,8 +191,7 @@ public enum Sort { """ ) @Builder.Default - @PluginProperty - private Sort sort = Sort.COMMITTER_DATE; + private Property sort = Property.of(Sort.COMMITTER_DATE); @Override public Output run(RunContext runContext) throws Exception { @@ -251,75 +232,75 @@ private GHCommitSearchBuilder setupSearchParameters(RunContext runContext, GitHu GHCommitSearchBuilder searchBuilder = gitHub.searchCommits(); searchBuilder - .sort(this.sort.value) - .order(this.order.direction); + .sort(runContext.render(this.sort).as(Sort.class).orElseThrow().value) + .order(runContext.render(this.order).as(Order.class).orElseThrow().direction); if (this.query != null) { - searchBuilder.q(runContext.render(this.query)); + searchBuilder.q(runContext.render(this.query).as(String.class).orElseThrow()); } if (this.repository != null) { - searchBuilder.repo(runContext.render(this.repository)); + searchBuilder.repo(runContext.render(this.repository).as(String.class).orElseThrow()); } if (this.is != null) { - searchBuilder.is(runContext.render(this.is)); + searchBuilder.is(runContext.render(this.is).as(String.class).orElseThrow()); } if (this.hash != null) { - searchBuilder.hash(runContext.render(this.hash)); + searchBuilder.hash(runContext.render(this.hash).as(String.class).orElseThrow()); } if (this.parent != null) { - searchBuilder.parent(runContext.render(this.parent)); + searchBuilder.parent(runContext.render(this.parent).as(String.class).orElseThrow()); } if (this.tree != null) { - searchBuilder.tree(runContext.render(this.tree)); + searchBuilder.tree(runContext.render(this.tree).as(String.class).orElseThrow()); } if (this.user != null) { - searchBuilder.user(runContext.render(this.user)); + searchBuilder.user(runContext.render(this.user).as(String.class).orElseThrow()); } if (this.org != null) { - searchBuilder.org(runContext.render(this.org)); + searchBuilder.org(runContext.render(this.org).as(String.class).orElseThrow()); } if (this.author != null) { - searchBuilder.author(runContext.render(this.author)); + searchBuilder.author(runContext.render(this.author).as(String.class).orElseThrow()); } if (this.authorDate != null) { - searchBuilder.authorDate(runContext.render(this.authorDate)); + searchBuilder.authorDate(runContext.render(this.authorDate).as(String.class).orElseThrow()); } if (this.authorEmail != null) { - searchBuilder.authorEmail(runContext.render(this.authorEmail)); + searchBuilder.authorEmail(runContext.render(this.authorEmail).as(String.class).orElseThrow()); } if (this.authorName != null) { - searchBuilder.authorName(runContext.render(this.authorName)); + searchBuilder.authorName(runContext.render(this.authorName).as(String.class).orElseThrow()); } if (this.committer != null) { - searchBuilder.committer(runContext.render(this.committer)); + searchBuilder.committer(runContext.render(this.committer).as(String.class).orElseThrow()); } if (this.committerDate != null) { - searchBuilder.committerDate(runContext.render(this.committerDate)); + searchBuilder.committerDate(runContext.render(this.committerDate).as(String.class).orElseThrow()); } if (this.committerEmail != null) { - searchBuilder.committerEmail(runContext.render(this.committerEmail)); + searchBuilder.committerEmail(runContext.render(this.committerEmail).as(String.class).orElseThrow()); } if (this.committerName != null) { - searchBuilder.committerName(runContext.render(this.committerName)); + searchBuilder.committerName(runContext.render(this.committerName).as(String.class).orElseThrow()); } if (this.merge != null) { - searchBuilder.merge(this.merge); + searchBuilder.merge(runContext.render(this.merge).as(Boolean.class).orElseThrow()); } return searchBuilder; } diff --git a/src/main/java/io/kestra/plugin/github/issues/Comment.java b/src/main/java/io/kestra/plugin/github/issues/Comment.java index 7176d83..ac35ed8 100644 --- a/src/main/java/io/kestra/plugin/github/issues/Comment.java +++ b/src/main/java/io/kestra/plugin/github/issues/Comment.java @@ -2,11 +2,12 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.plugin.github.GithubConnector; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; import lombok.*; import lombok.experimental.SuperBuilder; import org.kohsuke.github.GHIssue; @@ -32,7 +33,7 @@ code = """ id: github_comment_on_issue_flow namespace: company.team - + tasks: - id: comment_on_issue type: io.kestra.plugin.github.issues.Comment @@ -46,29 +47,28 @@ ) public class Comment extends GithubConnector implements RunnableTask { - private String repository; + private Property repository; @Schema( title = "Ticket number." ) - @PluginProperty - private Integer issueNumber; + @NotNull + private Property issueNumber; @Schema( title = "Ticket body." ) - @PluginProperty(dynamic = true) - private String body; + private Property body; @Override public Comment.Output run(RunContext runContext) throws Exception { GitHub gitHub = connect(runContext); GHIssue issue = gitHub - .getRepository(runContext.render(this.repository)) - .getIssue(this.issueNumber); + .getRepository(runContext.render(this.repository).as(String.class).orElse(null)) + .getIssue(runContext.render(this.issueNumber).as(Integer.class).orElseThrow()); - GHIssueComment comment = issue.comment(runContext.render(this.body)); + GHIssueComment comment = issue.comment(runContext.render(this.body).as(String.class).orElse(null)); return Output .builder() diff --git a/src/main/java/io/kestra/plugin/github/issues/Create.java b/src/main/java/io/kestra/plugin/github/issues/Create.java index dac2224..284541a 100644 --- a/src/main/java/io/kestra/plugin/github/issues/Create.java +++ b/src/main/java/io/kestra/plugin/github/issues/Create.java @@ -2,7 +2,7 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.plugin.github.GithubConnector; @@ -33,7 +33,7 @@ code = """ id: github_issue_create_flow namespace: company.team - + tasks: - id: create_issue type: io.kestra.plugin.github.issues.Create @@ -90,50 +90,46 @@ ) public class Create extends GithubConnector implements RunnableTask { - private String repository; + private Property repository; @Schema( title = "Ticket title." ) - @PluginProperty(dynamic = true) - private String title; + private Property title; @Schema( title = "Ticket body." ) - @PluginProperty(dynamic = true) - private String body; + private Property body; @Schema( title = "Ticket label.", description = "List of labels for ticket." ) - @PluginProperty(dynamic = true) - private List labels; + private Property> labels; @Schema( title = "Ticket assignee.", description = "List of unique names of assignees." ) - @PluginProperty(dynamic = true) - private List assignees; + private Property> assignees; @Override public Create.Output run(RunContext runContext) throws Exception { GitHub gitHub = connect(runContext); GHIssueBuilder issueBuilder = gitHub - .getRepository(runContext.render(this.repository)) - .createIssue(runContext.render(this.title)) - .body(runContext.render(this.body)); + .getRepository(runContext.render(this.repository).as(String.class).orElse(null)) + .createIssue(runContext.render(this.title).as(String.class).orElse(null)) + .body(runContext.render(this.body).as(String.class).orElse(null)); if (this.labels != null) { - runContext.render(labels) + runContext.render(labels).asList(String.class) .forEach(issueBuilder::label); } if (this.assignees != null) { - runContext.render(assignees) + runContext.render(assignees).asList(String.class) .forEach(issueBuilder::assignee); } diff --git a/src/main/java/io/kestra/plugin/github/issues/Search.java b/src/main/java/io/kestra/plugin/github/issues/Search.java index 1344f9f..3d45def 100644 --- a/src/main/java/io/kestra/plugin/github/issues/Search.java +++ b/src/main/java/io/kestra/plugin/github/issues/Search.java @@ -2,7 +2,7 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.plugin.github.GithubSearchTask; @@ -41,7 +41,7 @@ code = """ id: github_issue_search_flow namespace: company.team - + tasks: - id: search_open_issues type: io.kestra.plugin.github.issues.Search @@ -74,32 +74,27 @@ public enum Sort { @Schema( title = "The query contains one or more search keywords and qualifiers. Allows you to limit your search to specific areas of GitHub." ) - @PluginProperty(dynamic = true) - private String query; + private Property query; @Schema( title = "Searched issues mentions by specified user." ) - @PluginProperty(dynamic = true) - private String mentions; + private Property mentions; @Schema( title = "Whether the issue is open." ) - @PluginProperty - private Boolean open; + private Property open; @Schema( title = "Whether issue is closed." ) - @PluginProperty - private Boolean closed; + private Property closed; @Schema( title = "Whether issue is merged." ) - @PluginProperty - private Boolean merged; + private Property merged; @Schema( title = "Order of the output.", @@ -109,8 +104,7 @@ public enum Sort { """ ) @Builder.Default - @PluginProperty - private Order order = Order.ASC; + private Property order = Property.of(Order.ASC); @Schema( title = "Sort condition for the output.", @@ -121,8 +115,7 @@ public enum Sort { """ ) @Builder.Default - @PluginProperty - private Sort sort = Sort.CREATED; + private Property sort = Property.of(Sort.CREATED); @Override public FileOutput run(RunContext runContext) throws Exception { @@ -139,26 +132,26 @@ private GHIssueSearchBuilder setupSearchParameters(RunContext runContext, GitHub GHIssueSearchBuilder searchBuilder = gitHub.searchIssues(); searchBuilder - .sort(this.sort.value) - .order(this.order.direction); + .sort(runContext.render(this.sort).as(Sort.class).orElseThrow().value) + .order(runContext.render(this.order).as(Order.class).orElseThrow().direction); if (this.query != null) { - searchBuilder.q(runContext.render(this.query)); + searchBuilder.q(runContext.render(this.query).as(String.class).orElseThrow()); } if (this.mentions != null) { - searchBuilder.mentions(runContext.render(this.mentions)); + searchBuilder.mentions(runContext.render(this.mentions).as(String.class).orElseThrow()); } - if (this.open != null && this.open.equals(Boolean.TRUE)) { + if (runContext.render(this.open).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.isOpen(); } - if (this.closed != null && this.closed.equals(Boolean.TRUE)) { + if (runContext.render(this.closed).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.isClosed(); } - if (this.merged != null && this.merged.equals(Boolean.TRUE)) { + if (runContext.render(this.merged).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.isMerged(); } return searchBuilder; diff --git a/src/main/java/io/kestra/plugin/github/model/PullRequestDetails.java b/src/main/java/io/kestra/plugin/github/model/PullRequestDetails.java index b5a8307..c954692 100644 --- a/src/main/java/io/kestra/plugin/github/model/PullRequestDetails.java +++ b/src/main/java/io/kestra/plugin/github/model/PullRequestDetails.java @@ -11,7 +11,6 @@ import java.io.IOException; import java.net.URL; import java.util.Date; -import java.util.Objects; import java.util.Optional; @Getter diff --git a/src/main/java/io/kestra/plugin/github/pulls/Create.java b/src/main/java/io/kestra/plugin/github/pulls/Create.java index 2c33642..10f42d1 100644 --- a/src/main/java/io/kestra/plugin/github/pulls/Create.java +++ b/src/main/java/io/kestra/plugin/github/pulls/Create.java @@ -2,7 +2,7 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.plugin.github.GithubConnector; @@ -32,7 +32,7 @@ code = """ id: github_pulls_create_flow namespace: company.team - + tasks: - id: create_pull_request type: io.kestra.plugin.github.pulls.Create @@ -48,72 +48,66 @@ ) public class Create extends GithubConnector implements RunnableTask { - private String repository; + private Property repository; @Schema( title = "Source/Head branch.", description = "Required. The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: `username:branch`." ) - @PluginProperty(dynamic = true) - private String sourceBranch; + private Property sourceBranch; @Schema( title = "Target/Base branch.", description = "Required. The name of the branch you want your changes pulled into. This should be an existing branch on the current repository." ) - @PluginProperty(dynamic = true) - private String targetBranch; + private Property targetBranch; @Schema( title = "Ticket title.", description = "Required. The title of the pull request." ) - @PluginProperty(dynamic = true) - private String title; + private Property title; @Schema( title = "Ticket body.", description = "The contents of the pull request. This is the markdown description of a pull request." ) - @PluginProperty(dynamic = true) - private String body; + private Property body; @Schema( title = "Whether maintainers can modify the pull request.", description = "Boolean value indicating whether maintainers can modify the pull request. Default is false." ) - @PluginProperty @Builder.Default - private Boolean maintainerCanModify = Boolean.FALSE; + private Property maintainerCanModify = Property.of(Boolean.FALSE); @Schema( title = "Whether to create a draft pull request.", description = "Boolean value indicates whether to create a draft pull request or not. Default is false." ) - @PluginProperty @Builder.Default - private Boolean draft = Boolean.FALSE; + private Property draft = Property.of(Boolean.FALSE); @Override public Output run(RunContext runContext) throws Exception { GitHub gitHub = connect(runContext); - GHRepository repo = gitHub.getRepository(runContext.render(this.repository)); + GHRepository repo = gitHub.getRepository(runContext.render(this.repository).as(String.class).orElse(null)); if (!repo.hasPullAccess()) { return Output.builder().build(); } - String head = runContext.render(this.sourceBranch); - String base = runContext.render(this.targetBranch); + String head = runContext.render(this.sourceBranch).as(String.class).orElse(null); + String base = runContext.render(this.targetBranch).as(String.class).orElse(null); GHPullRequest pullRequest = repo.createPullRequest( - runContext.render(this.title), + runContext.render(this.title).as(String.class).orElse(null), head, base, - runContext.render(this.body), - this.maintainerCanModify, - this.draft + runContext.render(this.body).as(String.class).orElse(null), + runContext.render(this.maintainerCanModify).as(Boolean.class).orElseThrow(), + runContext.render(this.draft).as(Boolean.class).orElseThrow() ); return Output diff --git a/src/main/java/io/kestra/plugin/github/pulls/Search.java b/src/main/java/io/kestra/plugin/github/pulls/Search.java index ef309ac..2af6611 100644 --- a/src/main/java/io/kestra/plugin/github/pulls/Search.java +++ b/src/main/java/io/kestra/plugin/github/pulls/Search.java @@ -2,11 +2,11 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; -import io.kestra.plugin.github.GithubSearchTask; import io.kestra.plugin.github.GHPullRequestSearchBuilderCustom; +import io.kestra.plugin.github.GithubSearchTask; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.experimental.SuperBuilder; @@ -43,7 +43,7 @@ code = """ id: github_pulls_search_flow namespace: company.team - + tasks: - id: search_open_pull_requests type: io.kestra.plugin.github.pulls.Search @@ -77,110 +77,92 @@ public enum Sort { title = "The query contains one or more search keywords and qualifiers.", description = "Allow you to limit your search to specific areas of GitHub." ) - @PluginProperty(dynamic = true) - private String query; + private Property query; @Schema( title = "Searched issues mentions by specified user." ) - @PluginProperty(dynamic = true) - private String mentions; + private Property mentions; @Schema( title = "Specifies whether the pull request is open." ) - @PluginProperty - private Boolean open; + private Property open; @Schema( title = "Specifies whether the pull request is closed." ) - @PluginProperty - private Boolean closed; + private Property closed; @Schema( title = "Specifies whether the pull request is merged." ) - @PluginProperty - private Boolean merged; + private Property merged; @Schema( title = "Specifies whether the pull request is in draft." ) - @PluginProperty - private Boolean draft; + private Property draft; @Schema( title = "Search pull requests that are assigned to a certain user." ) - @PluginProperty - private String assigned; + private Property assigned; @Schema( title = "Search pull requests that have title like specified." ) - @PluginProperty - private String title; + private Property title; @Schema( title = "Search for code based on when pull request was closed.", description = "You can use greater than, less than, and range qualifiers (`..` between two dates) to further filter results." ) - @PluginProperty - private String closedAt; + private Property closedAt; @Schema( title = "Search for code based on when the pull request was created.", description = "You can use greater than, less than, and range qualifiers (`..` between two dates) to further filter results." ) - @PluginProperty - private String createdAt; + private Property createdAt; @Schema( title = "Search for code based on when pull request was updated last time", description = "You can use greater than, less than, and range qualifiers (`..` between two dates) to further filter results" ) - @PluginProperty - private String updatedAt; + private Property updatedAt; @Schema( title = "Search for pull requests that contain that SHA.", description = "The SHA syntax must be at least seven characters." ) - @PluginProperty - private String commit; + private Property commit; @Schema( title = "Search pull requests in a specific repository." ) - @PluginProperty - private String repository; + private Property repository; @Schema( title = "Filter pull requests based on the branch they are merging into." ) - @PluginProperty - private String base; + private Property base; @Schema( title = "Filter pull requests based on the branch they came from." ) - @PluginProperty - private String head; + private Property head; @Schema( title = "Specifies whether pull request is created by user who logged in using token.", description = "Requires authentication." ) - @PluginProperty - private Boolean createdByMe; + private Property createdByMe; @Schema( title = "Finds pull requests created by a certain user or integration account." ) - @PluginProperty - - private String author; + private Property author; @Schema( title = "Order of the output.", @@ -190,8 +172,7 @@ public enum Sort { """ ) @Builder.Default - @PluginProperty - private Order order = Order.ASC; + private Property order = Property.of(Order.ASC); @Schema( title = "Sort condition for the output.", @@ -202,8 +183,7 @@ public enum Sort { """ ) @Builder.Default - @PluginProperty - private Sort sort = Sort.CREATED; + private Property sort = Property.of(Sort.CREATED); @Override public FileOutput run(RunContext runContext) throws Exception { @@ -220,71 +200,71 @@ private GHPullRequestSearchBuilderCustom setupSearchParameters(RunContext runCon GHPullRequestSearchBuilderCustom searchBuilder = new GHPullRequestSearchBuilderCustom(gitHub); searchBuilder - .sort(this.sort.value) - .order(this.order.direction); + .sort(runContext.render(this.sort).as(Sort.class).orElseThrow().value) + .order(runContext.render(this.order).as(Order.class).orElseThrow().direction); if (this.query != null) { - searchBuilder.q(runContext.render(this.query)); + searchBuilder.q(runContext.render(this.query).as(String.class).orElseThrow()); } - if (this.open != null && this.open.equals(Boolean.TRUE)) { + if (runContext.render(this.open).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.isOpen(); } - if (this.closed != null && this.closed.equals(Boolean.TRUE)) { + if (runContext.render(this.closed).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.isClosed(); } - if (this.merged != null && this.merged.equals(Boolean.TRUE)) { + if (runContext.render(this.merged).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.isMerged(); } - if (this.draft != null && this.draft.equals(Boolean.TRUE)) { + if (runContext.render(this.draft).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.isDraft(); } if (this.assigned != null) { - searchBuilder.assigned(runContext.render(this.assigned)); + searchBuilder.assigned(runContext.render(this.assigned).as(String.class).orElseThrow()); } if (this.title != null) { - searchBuilder.titleLike(runContext.render(this.title)); + searchBuilder.titleLike(runContext.render(this.title).as(String.class).orElseThrow()); } if (this.closedAt != null) { - searchBuilder.closed(runContext.render(this.closedAt)); + searchBuilder.closed(runContext.render(this.closedAt).as(String.class).orElseThrow()); } if (this.createdAt != null) { - searchBuilder.created(runContext.render(this.createdAt)); + searchBuilder.created(runContext.render(this.createdAt).as(String.class).orElseThrow()); } if (this.updatedAt != null) { - searchBuilder.updated(runContext.render(this.updatedAt)); + searchBuilder.updated(runContext.render(this.updatedAt).as(String.class).orElseThrow()); } if (this.commit != null) { - searchBuilder.commit(runContext.render(this.commit)); + searchBuilder.commit(runContext.render(this.commit).as(String.class).orElseThrow()); } if (this.repository != null) { - searchBuilder.repo(runContext.render(this.repository)); + searchBuilder.repo(runContext.render(this.repository).as(String.class).orElseThrow()); } if (this.base != null) { - searchBuilder.base(runContext.render(this.base)); + searchBuilder.base(runContext.render(this.base).as(String.class).orElseThrow()); } if (this.head != null) { - searchBuilder.head(runContext.render(this.head)); + searchBuilder.head(runContext.render(this.head).as(String.class).orElseThrow()); } - if (this.createdByMe != null && this.createdByMe.equals(Boolean.TRUE)) { + if (runContext.render(this.createdByMe).as(Boolean.class).orElse(false).equals(Boolean.TRUE)) { searchBuilder.createdByMe(); } if (this.author != null) { - searchBuilder.author(runContext.render(this.author)); + searchBuilder.author(runContext.render(this.author).as(String.class).orElseThrow()); } return searchBuilder; diff --git a/src/main/java/io/kestra/plugin/github/repositories/Search.java b/src/main/java/io/kestra/plugin/github/repositories/Search.java index 6946437..b81b28a 100644 --- a/src/main/java/io/kestra/plugin/github/repositories/Search.java +++ b/src/main/java/io/kestra/plugin/github/repositories/Search.java @@ -2,7 +2,7 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.plugin.github.GithubSearchTask; @@ -42,7 +42,7 @@ code = """ id: github_repo_search_flow namespace: company.team - + tasks: - id: search_repositories type: io.kestra.plugin.github.repositories.Search @@ -56,7 +56,7 @@ code = """ id: github_repo_search_flow namespace: company.team - + tasks: - id: search_repositories type: io.kestra.plugin.github.repositories.Search @@ -72,7 +72,7 @@ code = """ id: github_repo_search_flow namespace: company.team - + tasks: - id: search_repositories type: io.kestra.plugin.github.repositories.Search @@ -118,47 +118,40 @@ public enum Visibility { title = "To search the code in a specific repository.", description = "Example string: \"myUserName/MyRepository\". query equivalent: \"repo:myUserName/MyRepository\"." ) - @PluginProperty(dynamic = true) - private String repository; + private Property repository; @Schema( title = "The query contains one or more search keywords and qualifiers.", description = "Qualifiers allow you to limit your search to specific areas of GitHub." ) - @PluginProperty(dynamic = true) - private String query; + private Property query; @Schema( title = "Search for code based on what language it's written in.", description = "Can be the language name or alias." ) - @PluginProperty(dynamic = true) - private String language; + private Property language; @Schema( title = "Search for code based on when repository was created." ) - @PluginProperty(dynamic = true) - private String created; + private Property created; @Schema( title = "Search for code based on how many starts repository has." ) - @PluginProperty(dynamic = true) - private String stars; + private Property stars; @Schema( title = "Search the code in all repositories owned by a certain user.", description = "To search by organization, use: \"query: org:myOrganization\"." ) - @PluginProperty(dynamic = true) - private String user; + private Property user; @Schema( title = "Search the code by topic" ) - @PluginProperty(dynamic = true) - private String topic; + private Property topic; @Schema( title = "Order of the output.", @@ -168,8 +161,7 @@ public enum Visibility { """ ) @Builder.Default - @PluginProperty - private Order order = Order.ASC; + private Property order = Property.of(Order.ASC); @Schema( title = "Sort condition of the output.", @@ -180,8 +172,7 @@ public enum Visibility { """ ) @Builder.Default - @PluginProperty - private Sort sort = Sort.UPDATED; + private Property sort = Property.of(Sort.UPDATED); @Schema( title = "Search repository that have specified repositories. By default, it's search for all repositories.", @@ -191,8 +182,7 @@ public enum Visibility { INTERNAL - shows only internal repositories """ ) - @PluginProperty - private Visibility visibility; + private Property visibility; @Override public FileOutput run(RunContext runContext) throws Exception { @@ -209,39 +199,39 @@ private GHRepositorySearchBuilder setupSearchParameters(RunContext runContext, G GHRepositorySearchBuilder searchBuilder = gitHub.searchRepositories(); searchBuilder - .sort(this.sort.value) - .order(this.order.direction); + .sort(runContext.render(this.sort).as(Sort.class).orElseThrow().value) + .order(runContext.render(this.order).as(Order.class).orElseThrow().direction); if (this.visibility != null) { - searchBuilder.visibility(this.visibility.value); + searchBuilder.visibility(runContext.render(this.visibility).as(Visibility.class).orElseThrow().value); } if (this.query != null) { - searchBuilder.q(runContext.render(this.query)); + searchBuilder.q(runContext.render(this.query).as(String.class).orElseThrow()); } if (this.language != null) { - searchBuilder.language(runContext.render(this.language)); + searchBuilder.language(runContext.render(this.language).as(String.class).orElseThrow()); } if (this.created != null) { - searchBuilder.created(runContext.render(this.created)); + searchBuilder.created(runContext.render(this.created).as(String.class).orElseThrow()); } if (this.repository != null) { - searchBuilder.repo(runContext.render(this.repository)); + searchBuilder.repo(runContext.render(this.repository).as(String.class).orElseThrow()); } if (this.stars != null) { - searchBuilder.stars(runContext.render(this.stars)); + searchBuilder.stars(runContext.render(this.stars).as(String.class).orElseThrow()); } if (this.user != null) { - searchBuilder.user(runContext.render(this.user)); + searchBuilder.user(runContext.render(this.user).as(String.class).orElseThrow()); } if (this.topic != null) { - searchBuilder.topic(runContext.render(this.topic)); + searchBuilder.topic(runContext.render(this.topic).as(String.class).orElseThrow()); } return searchBuilder; } diff --git a/src/main/java/io/kestra/plugin/github/topics/Search.java b/src/main/java/io/kestra/plugin/github/topics/Search.java index 20ab3f4..c29f49f 100644 --- a/src/main/java/io/kestra/plugin/github/topics/Search.java +++ b/src/main/java/io/kestra/plugin/github/topics/Search.java @@ -2,12 +2,12 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.core.serializers.FileSerde; -import io.kestra.plugin.github.GithubConnector; import io.kestra.plugin.github.GHTopicSearchBuilder; +import io.kestra.plugin.github.GithubConnector; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.experimental.SuperBuilder; @@ -52,7 +52,7 @@ code = """ id: github_topic_search_flow namespace: company.team - + tasks: - id: search_topics type: io.kestra.plugin.github.topics.Search @@ -92,8 +92,7 @@ public String toString() { title = "The query contains one or more search keywords and qualifiers.", description = "Allow you to limit your search to specific areas of GitHub." ) - @PluginProperty(dynamic = true) - private String query; + private Property query; @Schema( title = "The query contains one or more search keywords and qualifiers.", @@ -104,22 +103,19 @@ public String toString() { NOT_FEATURED - Matches topics that aren't featured on `https://github.com/topics/` """ ) - @PluginProperty(dynamic = true) - private Is is; + private Property is; @Schema( title = "Matches topics that have number of repositories.", description = "You can use greater than, less than, and range qualifiers to further filter results." ) - @PluginProperty(dynamic = true) - private String repositories; + private Property repositories; @Schema( title = "The query contains one or more search keywords and qualifiers.", description = "You can use greater than, less than, and range qualifiers to further filter results." ) - @PluginProperty(dynamic = true) - private String created; + private Property created; @Schema( title = "Order of the output.", @@ -129,8 +125,7 @@ public String toString() { """ ) @Builder.Default - @PluginProperty - private Order order = Order.ASC; + private Property order = Property.of(Order.ASC); @Override public Output run(RunContext runContext) throws Exception { @@ -161,25 +156,25 @@ public Output run(RunContext runContext) throws Exception { } private GHTopicSearchBuilder setupSearchParameters(RunContext runContext, GitHub gitHub) throws Exception { - GHTopicSearchBuilder searchBuilder = new GHTopicSearchBuilder(gitHub, super.getOauthToken()); + GHTopicSearchBuilder searchBuilder = new GHTopicSearchBuilder(gitHub, runContext.render(super.getOauthToken()).as(String.class).orElse(null)); searchBuilder - .order(this.order.toString()); + .order(runContext.render(this.order).as(Order.class).orElseThrow().toString()); if (this.query != null) { - searchBuilder.query(runContext.render(this.query)); + searchBuilder.query(runContext.render(this.query).as(String.class).orElseThrow()); } if (this.is != null) { - searchBuilder.is(runContext.render(this.is.toString())); + searchBuilder.is(runContext.render(this.is).as(Is.class).orElseThrow().toString()); } if (this.repositories != null) { - searchBuilder.repositories(runContext.render(this.repositories)); + searchBuilder.repositories(runContext.render(this.repositories).as(String.class).orElseThrow()); } if (this.created != null) { - searchBuilder.created(runContext.render(this.created)); + searchBuilder.created(runContext.render(this.created).as(String.class).orElseThrow()); } return searchBuilder; } diff --git a/src/main/java/io/kestra/plugin/github/users/Search.java b/src/main/java/io/kestra/plugin/github/users/Search.java index bbe8c07..7aba2ab 100644 --- a/src/main/java/io/kestra/plugin/github/users/Search.java +++ b/src/main/java/io/kestra/plugin/github/users/Search.java @@ -2,7 +2,7 @@ import io.kestra.core.models.annotations.Example; import io.kestra.core.models.annotations.Plugin; -import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.property.Property; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.runners.RunContext; import io.kestra.plugin.github.GithubSearchTask; @@ -42,7 +42,7 @@ code = """ id: github_user_search_flow namespace: company.team - + tasks: - id: search_users type: io.kestra.plugin.github.users.Search @@ -85,15 +85,13 @@ public enum Type { title = "The query contains one or more search keywords and qualifiers.", description = "Qualifiers allow you to limit your search to specific areas of GitHub." ) - @PluginProperty(dynamic = true) - private String query; + private Property query; @Schema( title = "Search for users based on the languages of repositories they own.", description = "Can be the language name or alias." ) - @PluginProperty(dynamic = true) - private String language; + private Property language; @Schema( title = "Filter users based on when they joined GitHub.", @@ -105,34 +103,29 @@ public enum Type { - 'YYYY-MM-DD..YYYY-MM-DD' - joined in period between """ ) - @PluginProperty(dynamic = true) - private String created; + private Property created; @Schema( title = "You can filter users based on the number of repositories they own." ) - @PluginProperty(dynamic = true) - private Integer repositories; + private Property repositories; @Schema( title = "With the 'in' qualifier you can restrict your search to the username/login, full name, public email.", description = "Example kenya in:login matches users with the word \"kenya\" in their username. " + "One more case of use to search users that have sponsor profile, equivalent to query: `is:sponsorable`." ) - @PluginProperty(dynamic = true) - private String in; + private Property in; @Schema( title = "Search for users by the location indicated in their profile." ) - @PluginProperty(dynamic = true) - private String location; + private Property location; @Schema( title = "Filter users based on the number of followers that they have." ) - @PluginProperty(dynamic = true) - private String followers; + private Property followers; @Schema( title = "Restrict search results to personal accounts or organizations only.", @@ -141,8 +134,7 @@ public enum Type { ORGANIZATION - the results will include only organization accounts """ ) - @PluginProperty(dynamic = true) - private Type accountType; + private Property accountType; @Schema( title = "Order of the output.", @@ -152,8 +144,7 @@ public enum Type { """ ) @Builder.Default - @PluginProperty - private Order order = Order.ASC; + private Property order = Property.of(Order.ASC); @Schema( title = "Sort condition of the output.", @@ -164,8 +155,7 @@ public enum Type { """ ) @Builder.Default - @PluginProperty - private Sort sort = Sort.JOINED; + private Property sort = Property.of(Sort.JOINED); @Override public FileOutput run(RunContext runContext) throws Exception { @@ -182,39 +172,39 @@ private GHUserSearchBuilder setupSearchParameters(RunContext runContext, GitHub GHUserSearchBuilder searchBuilder = gitHub.searchUsers(); searchBuilder - .sort(this.sort.value) - .order(this.order.direction); + .sort(runContext.render(this.sort).as(Sort.class).orElseThrow().value) + .order(runContext.render(this.order).as(Order.class).orElseThrow().direction); if (this.query != null) { - searchBuilder.q(runContext.render(this.query)); + searchBuilder.q(runContext.render(this.query).as(String.class).orElseThrow()); } if (this.language != null) { - searchBuilder.language(runContext.render(this.language)); + searchBuilder.language(runContext.render(this.language).as(String.class).orElseThrow()); } if (this.created != null) { - searchBuilder.created(runContext.render(this.created)); + searchBuilder.created(runContext.render(this.created).as(String.class).orElseThrow()); } if (this.repositories != null) { - searchBuilder.repos(this.repositories.toString()); + searchBuilder.repos(runContext.render(repositories).as(Integer.class).orElseThrow().toString()); } if (this.in != null) { - searchBuilder.in(runContext.render(this.in)); + searchBuilder.in(runContext.render(this.in).as(String.class).orElseThrow()); } if (this.location != null) { - searchBuilder.location(runContext.render(this.location)); + searchBuilder.location(runContext.render(this.location).as(String.class).orElseThrow()); } if (this.followers != null) { - searchBuilder.followers(runContext.render(this.followers)); + searchBuilder.followers(runContext.render(this.followers).as(String.class).orElseThrow()); } if (this.accountType != null) { - searchBuilder.type(this.accountType.value); + searchBuilder.type(runContext.render(this.accountType).as(Type.class).orElseThrow().value); } return searchBuilder; } diff --git a/src/test/java/io/kestra/plugin/github/code/SearchTest.java b/src/test/java/io/kestra/plugin/github/code/SearchTest.java index 022b1c0..08f7005 100644 --- a/src/test/java/io/kestra/plugin/github/code/SearchTest.java +++ b/src/test/java/io/kestra/plugin/github/code/SearchTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.code; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.FileSerde; @@ -33,8 +34,8 @@ void testQuery() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .oauthToken("") - .query("run in:file language:java repo:kestra-io/plugin-github") + .oauthToken(Property.of("")) + .query(Property.of("run in:file language:java repo:kestra-io/plugin-github")) .build(); Search.Output run = task.run(runContext); @@ -53,11 +54,11 @@ void testParameters() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .oauthToken("") - .query("run") - .in("file") - .language("java") - .repository("kestra-io/plugin-github") + .oauthToken(Property.of("")) + .query(Property.of("run")) + .in(Property.of("file")) + .language(Property.of("java")) + .repository(Property.of("kestra-io/plugin-github")) .build(); Search.Output run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/commits/SearchTest.java b/src/test/java/io/kestra/plugin/github/commits/SearchTest.java index ff5fef0..bb187b6 100644 --- a/src/test/java/io/kestra/plugin/github/commits/SearchTest.java +++ b/src/test/java/io/kestra/plugin/github/commits/SearchTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.commits; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.FileSerde; @@ -33,8 +34,8 @@ void testQuery() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .oauthToken("") - .query("Initial repo:kestra-io/plugin-github") + .oauthToken(Property.of("")) + .query(Property.of("Initial repo:kestra-io/plugin-github")) .build(); Search.Output run = task.run(runContext); @@ -54,9 +55,9 @@ void testParameters() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .oauthToken("") - .query("Initial") - .repository("kestra-io/plugin-github") + .oauthToken(Property.of("")) + .query(Property.of("Initial")) + .repository(Property.of("kestra-io/plugin-github")) .build(); Search.Output run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/issues/CommentTest.java b/src/test/java/io/kestra/plugin/github/issues/CommentTest.java index a8756bd..7425538 100644 --- a/src/test/java/io/kestra/plugin/github/issues/CommentTest.java +++ b/src/test/java/io/kestra/plugin/github/issues/CommentTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.issues; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import jakarta.inject.Inject; @@ -23,12 +24,12 @@ void run() throws Exception { RunContext runContext = runContextFactory.of(); Create createTask = Create.builder() - .oauthToken("") - .repository("kestra-io/plugin-github") - .title("Test Kestra Github plugin") - .body("This is a test for creating a new issue in repository by oauth token") - .labels(List.of("kestra", "test")) - .assignees(List.of("iNikitaGricenko")) + .oauthToken(Property.of("")) + .repository(Property.of("kestra-io/plugin-github")) + .title(Property.of("Test Kestra Github plugin")) + .body(Property.of("This is a test for creating a new issue in repository by oauth token")) + .labels(Property.of(List.of("kestra", "test"))) + .assignees(Property.of(List.of("iNikitaGricenko"))) .build(); Create.Output createOutput = createTask.run(runContext); @@ -39,10 +40,10 @@ void run() throws Exception { int issueNumber = createOutput.getIssueNumber(); Comment commentTask = Comment.builder() - .oauthToken("") - .repository("kestra-io/plugin-github") - .issueNumber(issueNumber) - .body("This comment is a test for creating a new comment in repository issue by oauth token") + .oauthToken(Property.of("")) + .repository(Property.of("kestra-io/plugin-github")) + .issueNumber(Property.of(issueNumber)) + .body(Property.of("This comment is a test for creating a new comment in repository issue by oauth token")) .build(); Comment.Output commentOutput = commentTask.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/issues/CreateTest.java b/src/test/java/io/kestra/plugin/github/issues/CreateTest.java index bf13a55..abdf875 100644 --- a/src/test/java/io/kestra/plugin/github/issues/CreateTest.java +++ b/src/test/java/io/kestra/plugin/github/issues/CreateTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.issues; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import jakarta.inject.Inject; @@ -23,12 +24,12 @@ void run() throws Exception { RunContext runContext = runContextFactory.of(); Create task = Create.builder() - .oauthToken("") - .repository("kestra-io/plugin-github") - .title("Test Kestra Github plugin") - .body("This is a test for creating a new issue in repository by oauth token") - .labels(List.of("kestra", "test")) - .assignees(List.of("iNikitaGricenko")) + .oauthToken(Property.of("")) + .repository(Property.of("kestra-io/plugin-github")) + .title(Property.of("Test Kestra Github plugin")) + .body(Property.of("This is a test for creating a new issue in repository by oauth token")) + .labels(Property.of(List.of("kestra", "test"))) + .assignees(Property.of(List.of("iNikitaGricenko"))) .build(); Create.Output run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/issues/SearchTest.java b/src/test/java/io/kestra/plugin/github/issues/SearchTest.java index 61d3303..5fb29e2 100644 --- a/src/test/java/io/kestra/plugin/github/issues/SearchTest.java +++ b/src/test/java/io/kestra/plugin/github/issues/SearchTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.issues; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.FileSerde; @@ -31,8 +32,8 @@ void testQuery() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("repo:kestra-io/plugin-github is:open") - .sort(Search.Sort.UPDATED) + .query(Property.of("repo:kestra-io/plugin-github is:open")) + .sort(Property.of(Search.Sort.UPDATED)) .build(); Search.FileOutput run = task.run(runContext); @@ -51,9 +52,9 @@ void testParameters() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("repo:kestra-io/plugin-github") - .open(Boolean.TRUE) - .sort(Search.Sort.UPDATED) + .query(Property.of("repo:kestra-io/plugin-github")) + .open(Property.of(Boolean.TRUE)) + .sort(Property.of(Search.Sort.UPDATED)) .build(); Search.FileOutput run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/pulls/CreatePullRequestTest.java b/src/test/java/io/kestra/plugin/github/pulls/CreatePullRequestTest.java index e1192c1..fc5f12d 100644 --- a/src/test/java/io/kestra/plugin/github/pulls/CreatePullRequestTest.java +++ b/src/test/java/io/kestra/plugin/github/pulls/CreatePullRequestTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.pulls; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import jakarta.inject.Inject; @@ -22,13 +23,13 @@ void run() throws Exception { RunContext runContext = runContextFactory.of(); io.kestra.plugin.github.pulls.Create task = io.kestra.plugin.github.pulls.Create.builder() - .oauthToken("") - .repository("kestra-io/plugin-github") - .sourceBranch("dev") - .targetBranch("test") - .title("Test Kestra Github plugin") - .body("This is a test for creating a new pull request in repository by oauth token") - .maintainerCanModify(true) + .oauthToken(Property.of("")) + .repository(Property.of("kestra-io/plugin-github")) + .sourceBranch(Property.of("dev")) + .targetBranch(Property.of("test")) + .title(Property.of("Test Kestra Github plugin")) + .body(Property.of("This is a test for creating a new pull request in repository by oauth token")) + .maintainerCanModify(Property.of(true)) .build(); Create.Output run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/pulls/SearchTest.java b/src/test/java/io/kestra/plugin/github/pulls/SearchTest.java index 2a685e6..935714a 100644 --- a/src/test/java/io/kestra/plugin/github/pulls/SearchTest.java +++ b/src/test/java/io/kestra/plugin/github/pulls/SearchTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.pulls; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.FileSerde; @@ -31,8 +32,8 @@ void testQuery() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("repo:kestra-io/plugin-github is:closed") - .sort(Search.Sort.UPDATED) + .query(Property.of("repo:kestra-io/plugin-github is:closed")) + .sort(Property.of(Search.Sort.UPDATED)) .build(); Search.FileOutput run = task.run(runContext); @@ -51,9 +52,9 @@ void testParameters() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("repo:kestra-io/plugin-github") - .open(Boolean.FALSE) - .sort(Search.Sort.UPDATED) + .query(Property.of("repo:kestra-io/plugin-github")) + .open(Property.of(Boolean.FALSE)) + .sort(Property.of(Search.Sort.UPDATED)) .build(); Search.FileOutput run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/repositories/SearchTest.java b/src/test/java/io/kestra/plugin/github/repositories/SearchTest.java index d3e6a29..372ea1f 100644 --- a/src/test/java/io/kestra/plugin/github/repositories/SearchTest.java +++ b/src/test/java/io/kestra/plugin/github/repositories/SearchTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.repositories; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.FileSerde; @@ -31,8 +32,8 @@ void testQuery() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("user:kestra-io language:java is:public") - .sort(Search.Sort.STARS) + .query(Property.of("user:kestra-io language:java is:public")) + .sort(Property.of(Search.Sort.STARS)) .build(); Search.FileOutput run = task.run(runContext); @@ -49,10 +50,10 @@ void testParameters() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .repository("kestra-io/plugin-github") - .language("java") - .visibility(Search.Visibility.PUBLIC) - .sort(Search.Sort.STARS) + .repository(Property.of("kestra-io/plugin-github")) + .language(Property.of("java")) + .visibility(Property.of(Search.Visibility.PUBLIC)) + .sort(Property.of(Search.Sort.STARS)) .build(); Search.FileOutput run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/topics/SearchTest.java b/src/test/java/io/kestra/plugin/github/topics/SearchTest.java index e8996a6..68c12c8 100644 --- a/src/test/java/io/kestra/plugin/github/topics/SearchTest.java +++ b/src/test/java/io/kestra/plugin/github/topics/SearchTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.topics; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.FileSerde; @@ -33,8 +34,8 @@ void testQuery() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .oauthToken("") - .query("Spring Cloud is:not-curated repositories:>10") + .oauthToken(Property.of("")) + .query(Property.of("Spring Cloud is:not-curated repositories:>10")) .build(); Search.Output run = task.run(runContext); @@ -53,9 +54,9 @@ void testParameters() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("Spring Cloud") - .is(Search.Is.NOT_CURATED) - .repositories(">10") + .query(Property.of("Spring Cloud")) + .is(Property.of(Search.Is.NOT_CURATED)) + .repositories(Property.of(">10")) .build(); Search.Output run = task.run(runContext); diff --git a/src/test/java/io/kestra/plugin/github/users/SearchTest.java b/src/test/java/io/kestra/plugin/github/users/SearchTest.java index b6ea138..23eba69 100644 --- a/src/test/java/io/kestra/plugin/github/users/SearchTest.java +++ b/src/test/java/io/kestra/plugin/github/users/SearchTest.java @@ -1,6 +1,7 @@ package io.kestra.plugin.github.users; import io.kestra.core.junit.annotations.KestraTest; +import io.kestra.core.models.property.Property; import io.kestra.core.runners.RunContext; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.FileSerde; @@ -31,7 +32,7 @@ void testQuery() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("kestra-io in:login language:java") + .query(Property.of("kestra-io in:login language:java")) .build(); Search.FileOutput run = task.run(runContext); @@ -50,9 +51,9 @@ void testParameters() throws Exception { RunContext runContext = runContextFactory.of(); Search task = Search.builder() - .query("kestra-io") - .in("login") - .language("java") + .query(Property.of("kestra-io")) + .in(Property.of("login")) + .language(Property.of("java")) .build(); Search.FileOutput run = task.run(runContext);