Skip to content

randimaS/package-github

 
 

Repository files navigation

Build Status

Ballerina GitHub Endpoint

GitHub brings together the world's largest community of developers to discover, share, and build better software. From open source projects to private team repositories, GitHub is an all-in-one platform for collaborative development.

GitHub connector provides a Ballerina API to access the GitHub GraphQL API. The connector has built-in support to handle OAuth2.0, provides auto completion and type conversions. The following sections explains how to use Ballerina GitHub4 connector. You can refer the [GitHub GraphQL API v4.0] (https://developer.github.com/v4/) to learn more about the API.

Ballerina Version GitHub API Version
0.981.0 v4

Ballerina GitHub Endpoint Overview

Prerequisites

Download the ballerina distribution.

Getting started

  • Clone the repository by running the following command
git clone https://github.com/wso2-ballerina/package-github
  • Initialize the ballerina project.
ballerina init

Working with GitHub Endpoint Actions

All the actions return objects or github4:GitClientError. If the action was a success, then the requested object will be returned while the github:GitClientError will be empty and vice-versa.

Example
  • Request
import ballerina/config;
import ballerina/http;
import ballerina/io;
import wso2/github4;

function main(string... args) {
    endpoint github4:Client githubClient {
        clientConfig: {
            auth:{
                scheme:http:OAUTH2,
                accessToken:config:getAsString("GITHUB_TOKEN")
            }
        }
    };

    github4:Repository repository = {};
    var repo = githubClient->getRepository("wso2-ballerina/package-github");
    match repo {
        github4:Repository rep => {
            repository = rep;
        }
        github4:GitClientError err => {
            io:println(err);
        }
    }

    io:println(repository);
}
  • Response object
public type Repository record {
    string id;
    string name;
    string createdAt;
    string updatedAt;
    string description;
    int forkCount;
    boolean hasIssuesEnabled;
    boolean hasWikiEnabled;
    string homepageUrl;
    boolean isArchived;
    boolean isFork;
    boolean isLocked;
    boolean isMirror;
    boolean isPrivate;
    string lockReason;
    string mirrorUrl;
    string url;
    string sshUrl;
    RepositoryOwner owner;
    Language primaryLanguage;
    int stargazerCount;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ballerina 100.0%