Documentation
¶
Index ¶
- Constants
- func NewAnonymousGraphQLClient(opts ClientOptions) (*githubv4.Client, error)
- func NewAnonymousRESTClient(opts ClientOptions) (*github.Client, error)
- func NewAnonymousSource(opts SourceOptions) (*anonymousSource, error)
- func NewAppGraphQLClient(clientID string, privateKey []byte, installationID *int64, opts ClientOptions) (*githubv4.Client, error)
- func NewAppRESTClient(clientID string, privateKey []byte, installationID *int64, opts ClientOptions) (*github.Client, error)
- func NewAppSource(clientID string, privateKey []byte, opts SourceOptions) (*appSource, error)
- func NewTokenGraphQLClient(token string, opts ClientOptions) (*githubv4.Client, error)
- func NewTokenRESTClient(token string, opts ClientOptions) (*github.Client, error)
- func NewTokenSource(token string, opts SourceOptions) (*tokenSource, error)
- type ClientOptions
- type Source
- type SourceOptions
Constants ¶
const ( // RESTAPIPath is the rest api path for api.github.com & ghe.com. RESTAPIPath = "/" // GraphQLAPIPath is the graphql api path for api.github.com & ghe.com. GraphQLAPIPath = "/graphql" // GHESRESTAPISuffix is the rest api suffix for GitHub Enterprise Server. GHESRESTAPIPath = "api/v3/" // GHESGraphQLAPISuffix is the GraphQL api suffix for GitHub Enterprise Server. GHESGraphQLAPIPath = "api/graphql" )
const (
// DotComAPIURL is the base API URL for github.com.
DotComAPIURL = "https://api.github.com/"
)
Variables ¶
This section is empty.
Functions ¶
func NewAnonymousGraphQLClient ¶
func NewAnonymousGraphQLClient(opts ClientOptions) (*githubv4.Client, error)
NewAnonymousGraphQLClient creates a new GitHub GraphQL client that is unauthenticated. This client will have limited access to public resources and will be subject to stricter rate limits compared to authenticated clients.
func NewAnonymousRESTClient ¶
func NewAnonymousRESTClient(opts ClientOptions) (*github.Client, error)
NewAnonymousRESTClient creates a new GitHub client that is unauthenticated. This client will have limited access to public resources and will be subject to stricter rate limits compared to authenticated clients.
func NewAnonymousSource ¶
func NewAnonymousSource(opts SourceOptions) (*anonymousSource, error)
NewAnonymousSource creates a new anonymousSource that provides an unauthenticated GitHub client. This client will have limited access to public resources and will be subject to stricter rate limits compared to authenticated clients.
func NewAppGraphQLClient ¶
func NewAppGraphQLClient(clientID string, privateKey []byte, installationID *int64, opts ClientOptions) (*githubv4.Client, error)
NewAppGraphQLClient creates a new GitHub GraphQL client authenticated as either the app itself (if installationID is nil) or as the specified installation (if installationID is provided), using the app's private key.
func NewAppRESTClient ¶
func NewAppRESTClient(clientID string, privateKey []byte, installationID *int64, opts ClientOptions) (*github.Client, error)
NewAppRESTClient creates a new GitHub client authenticated as either the app itself (if installationID is nil) or as the specified installation (if installationID is provided), using the app's private key.
func NewAppSource ¶
func NewAppSource(clientID string, privateKey []byte, opts SourceOptions) (*appSource, error)
NewAppSource creates a new appSource that provides GitHub clients authenticated as either the app itself or as an installation.
func NewTokenGraphQLClient ¶
func NewTokenGraphQLClient(token string, opts ClientOptions) (*githubv4.Client, error)
NewTokenGraphQLClient creates a new GitHub GraphQL client authenticated with the provided personal access token.
func NewTokenRESTClient ¶
func NewTokenRESTClient(token string, opts ClientOptions) (*github.Client, error)
NewTokenRESTClient creates a new GitHub client authenticated with the provided personal access token.
func NewTokenSource ¶
func NewTokenSource(token string, opts SourceOptions) (*tokenSource, error)
NewTokenSource creates a new tokenSource that provides a GitHub client authenticated with the provided personal access token.
Types ¶
type ClientOptions ¶
type ClientOptions struct {
BaseURL string
IsGHES bool
UserAgent string
Cache bool
CachePath string
RetryMax int
RetryWaitMin time.Duration
RetryWaitMax time.Duration
Sema *semaphore.Weighted
MaxIdleConns int
IdleConnTimeout time.Duration
}
ClientOptions defines the configuration options for creating a GitHub client.
type Source ¶
type Source interface {
// RESTClient returns the default GitHub client for the source.
RESTClient() (*github.Client, error)
// OwnerRESTClient returns a GitHub client authenticated to access resources owned by the specified owner (which can be either a user or an organization). This method is only applicable for app and token sources.
OwnerRESTClient(ctx context.Context, owner string) (*github.Client, error)
// GraphQLClient returns the default GitHub GraphQL client for the source.
GraphQLClient() (*githubv4.Client, error)
// OwnerGraphQLClient returns a GitHub GraphQL client authenticated to access resources owned by the specified owner (which can be either a user or an organization). This method is only applicable for app and token sources.
OwnerGraphQLClient(ctx context.Context, owner string) (*githubv4.Client, error)
}
Source provides an interface for obtaining GitHub clients. It abstracts away the details of how the clients are created and authenticated, allowing different implementations (such as app-based, token-based, or anonymous) to be used interchangeably.