Documentation
¶
Index ¶
- Constants
- func WithBaseHTTPClient(client *http.Client) func(*Client) error
- func WithBaseServerURL(u string) func(*Client) error
- func WithVCSType(vcs string) func(*Client) error
- type APIError
- type Client
- type ClientOption
- type Project
- type ProjectService
- func (p *ProjectService) Disable(ctx context.Context, project, username string) error
- func (p *ProjectService) Enable(ctx context.Context, project string, username string) error
- func (p *ProjectService) EnableAndFollow(ctx context.Context, project, username string) error
- func (p *ProjectService) Follow(ctx context.Context, project string, username string) error
- func (p *ProjectService) Get(ctx context.Context, proj string, username string) (*Project, error)
- func (p *ProjectService) List(ctx context.Context) ([]*Project, error)
- func (p *ProjectService) Unfollow(ctx context.Context, project string, username string) error
Examples ¶
Constants ¶
const ( VCSTypeGitHub = "github" VCSTypeBitBucket = "bitbucket" )
Variables ¶
This section is empty.
Functions ¶
func WithBaseHTTPClient ¶
WithBaseHTTPClient returns a function that accepts a *Client value, and modifies the underlying http.Client object. Pass this function into the NewClient() function as an optional variadic parameter.
Example ¶
httpClient := &http.Client{} _, err := circleci.NewClient("YourCircleCIAPIToken", circleci.WithBaseHTTPClient(httpClient)) if err != nil { log.Fatal(err) }
Output:
func WithBaseServerURL ¶
func WithVCSType ¶
Types ¶
type APIError ¶
type Client ¶
type Client struct { // APIKey stores the CircleCI API Token. Generate a CircleCI token by navigating // to https://circleci.com/account/api and generating a new token. // // The API token is required in order to communicate with the CircleCI API server. // The authenticated user should be "Following" the projects they want to make // changes to. // // New projects can also be followed by using the client.Projects.Follow() API. APIKey string // ServerURL should be the CircleCI server URL to make API calls against. // // For CircleCI SaaS use https://circleci.com/. For CircleCI Server (previously // Enterprise) use your internal CircleCI URL. If your CircleCI Server requires a // custom port that isn't 443, then include this in the URL. // E.g. https://circle.company.com:8080/ BaseURL *url.URL // VCSType is the Version Control System that hosts the CircleCI projects you wish // manipulate via CircleCI API. This is also included in API path when calling the // CircleCI API. This will be either "github" or "bitbucket". // // The default VCSTypeis "github" and can be overridden by passing the WithVCSType // option function when calling NewClient(). VCSType string // Projects represents the CircleCI project resources. This will be instantiated // by default with a *circleci.ProjectService object when circleci.NewClient() is // called. Projects *ProjectService // contains filtered or unexported fields }
func (*Client) GetHTTPClient ¶
type ClientOption ¶
type Project ¶
type Project struct { Name string `json:"reponame"` Username string `json:"username"` Followed bool `json:"followed"` URL string `json:"vcs_url"` }
Project type models the returned values from the /projects endpoint of the CircleCI API.
type ProjectService ¶
type ProjectService struct {
// contains filtered or unexported fields
}
ProjectService handles communication with the project related methods of the CircleCI API. https://circleci.com/docs/api/#projects
func (*ProjectService) Disable ¶
func (p *ProjectService) Disable(ctx context.Context, project, username string) error
Disable will remove the CircleCI deploy key from the repo. The authenicated user must have "admin" permissions on the repo.
func (*ProjectService) Enable ¶
Enable the project in CircleCI, this will generate and add an SSH to the repo for code checkout. The authenticated user must have "admin" permissions on the rpeo.
func (*ProjectService) EnableAndFollow ¶
func (p *ProjectService) EnableAndFollow(ctx context.Context, project, username string) error
EnableAndFollow is a helper funtion that will enable the project, and then follow the enabled project.
func (*ProjectService) Get ¶
Get retreives a project based on the project name and owner (GitHub Username). The authenticated user must be "following" the project in order to retrieve it.