Created
November 5, 2018 08:17
-
-
Save ldclakmal/f4bc970db0dbefe7129c943719d3eb03 to your computer and use it in GitHub Desktop.
Print GitHub projects and list of projects withing a repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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