Skip to content

Instantly share code, notes, and snippets.

@ldclakmal
Created November 5, 2018 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldclakmal/f4bc970db0dbefe7129c943719d3eb03 to your computer and use it in GitHub Desktop.
Save ldclakmal/f4bc970db0dbefe7129c943719d3eb03 to your computer and use it in GitHub Desktop.
Print GitHub projects and list of projects withing a repository
import ballerina/config;
import ballerina/http;
import ballerina/io;
import ballerina/log;
import wso2/github4;
endpoint github4:Client githubClient {
clientConfig: {
auth: {
scheme: http:OAUTH2,
accessToken: config:getAsString("GITHUB_TOKEN")
}
}
};
public function main(string... args) {
var repository = githubClient->getRepository("exp-org/ballerina-ground");
match repository {
github4:Repository projectRepository => {
var repoProject = githubClient->getRepositoryProject(projectRepository, 1);
match repoProject {
github4:Project project => {
io:println("Project : ", project);
}
github4:GitClientError e => {
log:printError("Error occurred while reading project.", err = e);
}
}
var repoProjectList = githubClient->getRepositoryProjectList(projectRepository, github4:STATE_OPEN, 1);
match repoProjectList {
github4:ProjectList projectList => {
io:println("Project List : ", projectList.getAllProjects());
}
github4:GitClientError e => {
log:printError("Error occurred while reading project list.", err = e);
}
}
}
error e => {
log:printError("Error occurred while reading github repository.", err = e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment