use of software.amazon.awssdk.services.codecommit.model.CodeCommitException in project aws-doc-sdk-examples by awsdocs.
the class DescribePullRequestEvents method describePREvents.
// snippet-start:[codecommit.java2.describe_pr_events.main]
public static void describePREvents(CodeCommitClient codeCommitClient, String prId) {
try {
DescribePullRequestEventsRequest eventsRequest = DescribePullRequestEventsRequest.builder().pullRequestId(prId).build();
DescribePullRequestEventsResponse eventsResponse = codeCommitClient.describePullRequestEvents(eventsRequest);
List<PullRequestEvent> events = eventsResponse.pullRequestEvents();
for (PullRequestEvent event : events) {
System.out.println("The event name is: " + event.pullRequestEventType().toString());
}
} catch (CodeCommitException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.codecommit.model.CodeCommitException in project aws-doc-sdk-examples by awsdocs.
the class ListRepositories method listRepos.
// snippet-start:[codecommit.java2.get_repos.main]
public static void listRepos(CodeCommitClient codeCommitClient) {
try {
ListRepositoriesResponse repResponse = codeCommitClient.listRepositories();
List<RepositoryNameIdPair> repoList = repResponse.repositories();
for (RepositoryNameIdPair repo : repoList) {
System.out.println("The repository name is " + repo.repositoryName());
}
} catch (CodeCommitException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.codecommit.model.CodeCommitException in project aws-doc-sdk-examples by awsdocs.
the class MergeBranches method merge.
// snippet-start:[codecommit.java2.merge.main]
public static void merge(CodeCommitClient codeCommitClient, String repoName, String targetBranch, String sourceReference, String destinationCommitId) {
try {
MergeBranchesByFastForwardRequest fastForwardRequest = MergeBranchesByFastForwardRequest.builder().destinationCommitSpecifier(destinationCommitId).targetBranch(targetBranch).sourceCommitSpecifier(sourceReference).repositoryName(repoName).build();
MergeBranchesByFastForwardResponse response = codeCommitClient.mergeBranchesByFastForward(fastForwardRequest);
System.out.println("The commit id is " + response.commitId());
} catch (CodeCommitException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.codecommit.model.CodeCommitException in project aws-doc-sdk-examples by awsdocs.
the class CreateBranch method createSpecificBranch.
// snippet-start:[codecommit.java2.create_branch.main]
public static void createSpecificBranch(CodeCommitClient codeCommitClient, String repoName, String branchName, String commitId) {
try {
CreateBranchRequest branchRequest = CreateBranchRequest.builder().branchName(branchName).repositoryName(repoName).commitId(commitId).build();
codeCommitClient.createBranch(branchRequest);
System.out.println("Branch " + branchName + " was created");
} catch (CodeCommitException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.codecommit.model.CodeCommitException in project aws-doc-sdk-examples by awsdocs.
the class CreateRepository method createRepo.
// snippet-start:[codecommit.java2.create_repo.main]
public static void createRepo(CodeCommitClient codeCommitClient, String repoName) {
try {
CreateRepositoryRequest repositoryRequest = CreateRepositoryRequest.builder().repositoryDescription("Created by the CodeCommit Java API").repositoryName(repoName).build();
CreateRepositoryResponse repositoryResponse = codeCommitClient.createRepository(repositoryRequest);
System.out.println("The ARN of the new repository is " + repositoryResponse.repositoryMetadata().arn());
} catch (CodeCommitException e) {
System.err.println(e.getMessage());
System.exit(1);
}
}
Aggregations