github

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenResponse

type AccessTokenResponse struct {
	Token string `json:"token"`
}

type AuthorizedTransport

type AuthorizedTransport struct {
	// contains filtered or unexported fields
}

func (*AuthorizedTransport) RoundTrip

func (t *AuthorizedTransport) RoundTrip(req *http.Request) (*http.Response, error)

type GitHubClient

type GitHubClient interface {
	QueryGraphQLAPI(query string, variables map[string]interface{}) ([]byte, error)
	CallRestAPI(endpoint, method string, body map[string]interface{}) ([]byte, error)
	GetAccessToken() (string, error)
	GetAppSlug() string
}

func NewGitHubClientImpl

func NewGitHubClientImpl(githubServer, organizationName string, appID int64, privateKeyFile string) (GitHubClient, error)

*

  • NewGitHubClient
  • @param {string} githubServer usually https://api.github.com
  • @param {string} organizationName
  • @param {string} appID
  • @param {string} privateKeyFile
  • @return {GitHubClient} client
  • @return {error} error *
  • Example:
  • client, err := NewGitHubClient(
  • "https://api.github.com",
  • "my-org",
  • "12345",
  • "private-key.pem",
  • )

type GitHubClientImpl

type GitHubClientImpl struct {
	// contains filtered or unexported fields
}

func (*GitHubClientImpl) CallRestAPI

func (client *GitHubClientImpl) CallRestAPI(endpoint, method string, body map[string]interface{}) ([]byte, error)

* CallRestAPIWithBody * @param {string} endpoint * @param {string} method * @param {map[string]interface{}} body * * Example: * body := map[string]interface{}{ * "name": "my-repo", * "private": true, * } * responseBody, err := client.CallRestAPIWithBody("orgs/my-org/repos", "POST", body)

func (*GitHubClientImpl) GetAccessToken

func (client *GitHubClientImpl) GetAccessToken() (string, error)

* GetAccessToken * It is used mostly to get an access token to clone a private repository * @return {string} accessToken * @return {error} error * * Example: * accessToken, err := client.GetAccessToken() * if err != nil { * log.Fatal(err) * } * repo, err := git.PlainClone("/path/to/clone/repository", false, &git.CloneOptions{ * URL: "https://github.com/owner/repo.git", * Auth: &http.BasicAuth{ * Username: "x-access-token", * Password: accessToken, * },

func (*GitHubClientImpl) GetAppSlug

func (client *GitHubClientImpl) GetAppSlug() string

func (*GitHubClientImpl) QueryGraphQLAPI

func (client *GitHubClientImpl) QueryGraphQLAPI(query string, variables map[string]interface{}) ([]byte, error)

* QueryGraphQLAPI * @param {string} query * @param {map[string]interface{}} variables * @return {string} responseBody * @return {error} error * * Example: * query := ` * query($name: String!) { * user(login: $name) { * name * company * } * } * ` * variables := map[string]interface{}{ * "name": "octocat", * } * responseBody, err := client.QueryGraphQLAPI(query, variables)

type GraphQLRequest

type GraphQLRequest struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables"`
}

type Installation

type Installation struct {
	ID      int64  `json:"id"`
	AppId   int64  `json:"app_id"`
	AppSlug string `json:"app_slug"`
	Account struct {
		Login string `json:"login"`
	} `json:"account"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL