Documentation
¶
Index ¶
- type AccessTokenResponse
- type AuthorizedTransport
- type GitHubClient
- type GitHubClientImpl
- func (client *GitHubClientImpl) CallRestAPI(ctx context.Context, endpoint, method string, body map[string]interface{}) ([]byte, error)
- func (client *GitHubClientImpl) GetAccessToken(ctx context.Context) (string, error)
- func (client *GitHubClientImpl) GetAppSlug() string
- func (client *GitHubClientImpl) QueryGraphQLAPI(ctx context.Context, query string, variables map[string]interface{}) ([]byte, error)
- type GraphQLRequest
- type Installation
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
}
type GitHubClient ¶
type GitHubClient interface { QueryGraphQLAPI(ctx context.Context, query string, variables map[string]interface{}) ([]byte, error) CallRestAPI(ctx context.Context, endpoint, method string, body map[string]interface{}) ([]byte, error) GetAccessToken(ctx context.Context) (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(ctx context.Context, 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(ctx context.Context) (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(ctx context.Context, 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)