Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.bytechef.component.github.action.GithubCreateCommentOnIssueAction;
import com.bytechef.component.github.action.GithubCreateIssueAction;
import com.bytechef.component.github.action.GithubGetIssueAction;
import com.bytechef.component.github.action.GithubStarRepositoryAction;
import com.bytechef.component.github.trigger.GithubNewIssueTrigger;
import com.bytechef.component.github.trigger.GithubNewPullRequestTrigger;
import com.google.auto.service.AutoService;
Expand All @@ -48,7 +49,8 @@ public class GithubComponentHandler implements ComponentHandler {
GithubAddLabelsToIssueAction.ACTION_DEFINITION,
GithubCreateCommentOnIssueAction.ACTION_DEFINITION,
GithubCreateIssueAction.ACTION_DEFINITION,
GithubGetIssueAction.ACTION_DEFINITION)
GithubGetIssueAction.ACTION_DEFINITION,
GithubStarRepositoryAction.ACTION_DEFINITION)
.icon("path:assets/github.svg")
.triggers(
GithubNewIssueTrigger.TRIGGER_DEFINITION,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2023-present ByteChef Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.bytechef.component.github.action;

import static com.bytechef.component.definition.ComponentDsl.ModifiableActionDefinition;
import static com.bytechef.component.definition.ComponentDsl.action;
import static com.bytechef.component.definition.ComponentDsl.string;
import static com.bytechef.component.definition.Context.Http.ResponseType;
import static com.bytechef.component.definition.Context.Http.responseType;
import static com.bytechef.component.github.constant.GithubConstants.OWNER;
import static com.bytechef.component.github.constant.GithubConstants.REPOSITORY;

import com.bytechef.component.definition.ActionContext;
import com.bytechef.component.definition.Parameters;

/**
* @author Monika Kušter
*/
public class GithubStarRepositoryAction {

public static final ModifiableActionDefinition ACTION_DEFINITION = action("starRepository")
.title("Star Repository")
.description("Stars a repository for the authenticated user.")
.properties(
string(OWNER)
.label("Owner")
.description("The account owner of the repository. The name is not case sensitive.")
.exampleValue("bytechefhq")
.required(true),
string(REPOSITORY)
.label("Repository")
.description(
"The name of the repository including owner without the .git extension. The name is not case " +
"sensitive.")
.exampleValue("bytechef")
.required(true))
.perform(GithubStarRepositoryAction::perform);

private GithubStarRepositoryAction() {
}

public static Object perform(
Parameters inputParameters, Parameters connectionParameters, ActionContext context) {

context.http(http -> http.put(
"/user/starred/" + inputParameters.getRequiredString(OWNER) + "/"
+ inputParameters.getRequiredString(REPOSITORY)))
.configuration(responseType(ResponseType.JSON))
.execute();

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class GithubConstants {
public static final String ISSUE = "issue";
public static final String LABELS = "labels";
public static final String NAME = "name";
public static final String OWNER = "owner";
public static final String REPOSITORY = "repository";
public static final String TITLE = "title";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2023-present ByteChef Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.bytechef.component.github.action;

import static org.junit.jupiter.api.Assertions.assertNull;

import com.bytechef.component.definition.Parameters;
import com.bytechef.component.test.definition.MockParametersFactory;
import java.util.Map;
import org.junit.jupiter.api.Test;

/**
* @author Monika Kušter
*/
class GithubStarRepositoryActionTest extends AbstractGithubActionTest {

private final Parameters mockedParameters = MockParametersFactory.create(Map.of());

@Test
void testPerform() {
Object result = GithubGetIssueAction.perform(mockedParameters, mockedParameters, mockedContext);

assertNull(result);
}
}
Loading
Loading