Documentation
¶
Overview ¶
Package bitballoon provides a client for using the BitBalloon API.
To work with the BitBalloon API, start by instantiating a client:
client := bitballoon.NewClient(&bitballoon.Config{AccessToken: AccessToken})
// List sites
sites, resp, err := client.Sites.List(&bitballoon.ListOptions{Page: 1})
// Create a new site
site, resp, err := client.Sites.Create(&SiteAttributes{
Name: "site-subdomain",
CustomDomain: "www.example.com",
Password: "secret",
NotificationEmail: "[email protected]",
})
// Deploy a directory
deploy, resp, err := site.Deploys.Create("/path/to/directory")
// Wait for the deploy to process
err := deploy.WaitForReady(0)
// Get a single site
site, resp, err := client.Sites.Get("my-site-id")
// Set the domain of the site
site.CustomDomain = "www.example.com"
// Update the site
resp, err := site.Update()
// Deploy a new version of the site from a zip file
deploy, resp, err := site.Deploys.Create("/path/to/file.zip")
deploy.WaitForReady(0)
// Delete the site
resp, err := site.Destroy()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
BaseUrl *url.URL
UserAgent string
Sites *SitesService
Deploys *DeploysService
// contains filtered or unexported fields
}
The BitBalloon Client
func (*Client) Request ¶
func (c *Client) Request(method, path string, options *RequestOptions, decodeTo interface{}) (*Response, error)
Request sends an authenticated HTTP request to the BitBalloon API
When error is nil, resp always contains a non-nil Response object ¶
Generally methods on the various services should be used over raw API requests
type Config ¶
type Config struct {
AccessToken string
ClientId string
ClientSecret string
BaseUrl string
UserAgent string
HttpClient *http.Client
}
Config is used to configure the BitBalloon client. Typically you'll just want to set an AccessToken
type Deploy ¶
type Deploy struct {
Id string `json:"id"`
SiteId string `json:"site_id"`
UserId string `json:"user_id"`
// State of the deploy (uploading/uploaded/processing/ready/error)
State string `json:"state"`
// Cause of error if State is "error"
ErrorMessage string `json:"error_message"`
// Shas of files that needs to be uploaded before the deploy is ready
Required []string `json:"required"`
DeployUrl string `json:"deploy_url"`
ScreenshotUrl string `json:"screenshot_url"`
CreatedAt Timestamp `json:"created_at"`
UpdatedAt Timestamp `json:"updated_at"`
// contains filtered or unexported fields
}
Deploy represents a specific deploy of a site
type DeployInfo ¶
type DeployInfo struct {
Id string `json:"id"`
DeployId string `json:"deploy_id"`
Required []string `json:"required"`
}
Info returned when creating a new deploy
type DeploysService ¶
type DeploysService struct {
// contains filtered or unexported fields
}
DeploysService is used to access all Deploy related API methods
func (*DeploysService) Create ¶
func (s *DeploysService) Create(dirOrZip string) (*Deploy, *Response, error)
Create a new deploy
Example: site.Deploys.Create("/path/to/site-dir")
func (*DeploysService) Get ¶
func (d *DeploysService) Get(id string) (*Deploy, *Response, error)
Get a specific deploy.
func (*DeploysService) List ¶
func (s *DeploysService) List(options *ListOptions) ([]Deploy, *Response, error)
List all deploys. Takes ListOptions to control pagination.
type ErrorResponse ¶
ErrorResponse is returned when a request to the API fails
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type ListOptions ¶
All List methods takes a ListOptions object controlling pagination
type RequestOptions ¶
type RequestOptions struct {
JsonBody interface{}
RawBody io.Reader
RawBodyLength int64
QueryParams *url.Values
Headers *map[string]string
}
RequestOptions for doing raw requests to the BitBalloon API
type Response ¶
BitBalloon API Response. All API methods on the different client services will return a Response object. For any list operation this object will hold pagination information
type Site ¶
type Site struct {
Id string `json:"id"`
UserId string `json:"user_id"`
// These fields can be updated through the API
Name string `json:"name"`
CustomDomain string `json:"custom_domain"`
Password string `json:"password"`
NotificationEmail string `json:"notification_email"`
State string `json:"state"`
Premium bool `json:"premium"`
Claimed bool `json:"claimed"`
Url string `json:"url"`
AdminUrl string `json:"admin_url"`
DeployUrl string `json:"deploy_url"`
ScreenshotUrl string `json:"screenshot_url"`
CreatedAt Timestamp `json:"created_at"`
UpdatedAt Timestamp `json:"updated_at"`
// Access deploys for this site
Deploys *DeploysService
// contains filtered or unexported fields
}
Site represents a BitBalloon Site
type SiteAttributes ¶
type SiteAttributes struct {
Name string `json:"name"`
CustomDomain string `json:"custom_domain"`
Password string `json:"password"`
NotificationEmail string `json:"notification_email"`
}
Attributes for Sites.Create
type SitesService ¶
type SitesService struct {
// contains filtered or unexported fields
}
SitesService is used to access all Site related API methods
func (*SitesService) Create ¶
func (s *SitesService) Create(attributes *SiteAttributes) (*Site, *Response, error)
Create a new empty site.
func (*SitesService) Get ¶
func (s *SitesService) Get(id string) (*Site, *Response, error)
Get a single Site from the API. The id can be either a site Id or the domain of a site (ie. site.Get("mysite.bitballoon.com"))
func (*SitesService) List ¶
func (s *SitesService) List(options *ListOptions) ([]Site, *Response, error)
List all sites you have access to. Takes ListOptions to control pagination.
type Timestamp ¶
Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. This is necessary for some fields since the GitHub API is inconsistent in how it represents times. All exported methods of time.Time can be called on Timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.