Documentation ¶
Overview ¶
Atlas Api
This is the documentation and guide for the Atlas API. You can use it to create and update boxes, versions and providers.
import "github.com/larryli/atlas.v1" api := atlas.New("--replace-your-access-token--") box := api.Box("yourname", "boxname") if box.New() == nil { version := box.Version(0) version.Version = "0.0.1" if version.New() == nil { provider := version.Provider(atlas.ProviderVirtualbox) provider.OriginalUrl = "http://your.box.url" if provider.New() == nil { version.Release() } } }
Index ¶
- func NewError(msg string, errs string) error
- type Api
- func (a *Api) Box(username, name string) *Box
- func (a *Api) Delete(uri string) ([]byte, error)
- func (a *Api) Download(uri string, data io.Writer) error
- func (a *Api) Get(uri string) ([]byte, error)
- func (a *Api) Post(uri string, params url.Values) ([]byte, error)
- func (a *Api) Put(uri string, params url.Values) ([]byte, error)
- func (a *Api) Upload(uri string, data io.Reader) ([]byte, error)
- type Box
- type Error
- type Provider
- type ProviderName
- type Version
- type VersionStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
func New ¶
All requests must be authenticated with an access_token and sent as a URL parameter. This token can be generated or revoked on the account tokens page. Your token will have access to all resources your account has access to.
func NewFromFile ¶
type Box ¶
type Box struct { CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Tag string `json:"tag"` Name string `json:"name"` ShortDescription string `json:"short_description"` DescriptionHtml string `json:"description_html"` DescriptionMarkdown string `json:"description_markdown"` Username string `json:"username"` Private bool `json:"private"` CurrentVersion Version `json:"current_version"` Versions []Version `json:"versions"` // contains filtered or unexported fields }
Boxes are the primary resource on Atlas. Before creating versions with attached providers, you'll need to create a box.
func (*Box) Delete ¶
DESTROY A BOX
Name (required) The name of the box, used to identify it. The name makes up the latter half of the tag. It has a maximum length of 36 characters and must contain only letters, numbers, dashes, underscores or periods. Username (required) The username to assign the box to. You must be a member of the organization and have the ability to create boxes. Defaults to the users username that is making the API request.
func (*Box) New ¶
CREATE A BOX
Name (required) The name of the box, used to identify it. The name makes up the latter half of the tag. It has a maximum length of 36 characters and must contain only letters, numbers, dashes, underscores or periods. Username The username to assign the box to. You must be a member of the organization and have the ability to create boxes. Defaults to the users username that is making the API request. ShortDescription The short description is used on small box previews, in search results and other places where displaying markdown isn't functional. It has a maxium length of 120 characters. DescriptionMarkdown Markdown text used as a full-length and in-depth description of the box. Markdown is parsed according to GitHub Flavored Markdown. There is no maximum length. Private A boolean if the box should be private or not.
func (*Box) Set ¶
UPDATE A BOX
Name (required) The name of the box, used to identify it. The name makes up the latter half of the tag. It has a maximum length of 36 characters and must contain only letters, numbers, dashes, underscores or periods. Username (required) The username to assign the box to. You must be a member of the organization and have the ability to create boxes. Defaults to the users username that is making the API request. ShortDescription The short description is used on small box previews, in search results and other places where displaying markdown isn't functional. It has a maxium length of 120 characters. DescriptionMarkdown Markdown text used as a full-length and in-depth description of the box. Markdown is parsed according to GitHub Flavored Markdown. There is no maximum length. Private A boolean if the box should be private or not.
type Error ¶
type Error struct { Msg string Errors interface{} }
Standard HTTP response codes are returned. 404 Not Found codes are returned for all resources that a user does not have access to, as well as for resources that don't exist. This is done to avoid a potential attacker discovery the existence of a resource.
Errors format:
{ "name": [ "has already been taken" ] }
type Provider ¶
type Provider struct { Name ProviderName `json:"name"` Hosted bool `json:"hosted"` HostedToken string `json:"hosted_token"` OriginalUrl string `json:"original_url"` UploadUrl string `json:"upload_url"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DownloadUrl string `json:"download_url"` // contains filtered or unexported fields }
Providers contain the pointers to the box files, be it a hosted or self-hosted box. Versions can have many providers, each which represents a Vagrant compatible provider, either from Vagrant Core as a 3rd party plugin.
func (*Provider) Delete ¶
DESTROY A PROVIDER
Name (required) The name of the provider. Vagrant will use this to determine compatible boxes on the client. Common providers include virtualbox, vmware_desktop, digitalocean, aws, rackspace, and hyperv.
func (*Provider) Download ¶
DOWNLOAD A .BOX FOR PROVIDER
Name (required) The name of the provider. Vagrant will use this to determine compatible boxes on the client. Common providers include virtualbox, vmware_desktop, digitalocean, aws, rackspace, and hyperv.
func (*Provider) Get ¶
RETRIEVE A PROVIDER
Name (required) The name of the provider. Vagrant will use this to determine compatible boxes on the client. Common providers include virtualbox, vmware_desktop, digitalocean, aws, rackspace, and hyperv.
func (*Provider) New ¶
CREATE A PROVIDER
Name (required) The name of the provider. Vagrant will use this to determine compatible boxes on the client. Common providers include virtualbox, vmware_desktop, digitalocean, aws, rackspace, and hyperv. OriginalUrl An HTTP URL to the box file. This must be accessible at this URL from the machine where you expect a user to download the box by using Vagrant. If ommitted, we assume you wish to host the provider with Atlas.
The provider API is used to host boxes. To create a hosted box, simply omit the URL parameter. You will then be able to use the upload endpoint to upload a box to us.
func (*Provider) Set ¶
UPDATE A PROVIDER
Name (required) The name of the provider. Vagrant will use this to determine compatible boxes on the client. Common providers include virtualbox, vmware_desktop, digitalocean, aws, rackspace, and hyperv. OriginalUrl An HTTP URL to the box file. This must be accessible at this URL from the machine where you expect a user to download the box by using Vagrant. If ommitted, we assume you wish to host the provider with Atlas.
func (*Provider) Upload ¶
UPLOAD A .BOX FOR PROVIDER
Name (required) The name of the provider. Vagrant will use this to determine compatible boxes on the client. Common providers include virtualbox, vmware_desktop, digitalocean, aws, rackspace, and hyperv. data (io.Reader, required)
The upload path returns a URL that you can then PUT the boxes payload to. After streaming the box, you can confirm the upload by comparing the token provided in the UPLOAD response with the token returned from the providers GET route. When these tokens match, the upload has been successful.
type ProviderName ¶
type ProviderName string
const ( ProviderVirtualbox ProviderName = "virtualbox" ProviderVmwareDesktop ProviderName = "vmware_desktop" ProviderDigitalocean ProviderName = "digitalocean" ProviderAws ProviderName = "aws" ProviderRackspace ProviderName = "rackspace" ProviderHyperv ProviderName = "hyperv" )
type Version ¶
type Version struct { Version string `json:"version"` Status VersionStatus `json:"status"` DescriptionHtml string `json:"description_html"` DescriptionMarkdown string `json:"description_markdown"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Number string `json:"number"` Downloads int `json:"downloads"` ReleaseUrl string `json:"release_url"` RevokeUrl string `json:"revoke_url"` Providers []Provider `json:"providers"` // contains filtered or unexported fields }
Versions represent new releases for boxes, and contain both information about the changes in that version as well as being the parent object for providers, which contain the eventual box file.
func (*Version) Delete ¶
DESTROY A VERSION
Version (required) The version number, typically incrementing a previous version. We validate this version string based on Semantic Versioning. We only require that the string matches a pattern that could be semver, and don't validate that the version comes after your previous versions, and so on.
func (*Version) Get ¶
RETRIEVE A VERSION
Version (required) The version number, typically incrementing a previous version. We validate this version string based on Semantic Versioning. We only require that the string matches a pattern that could be semver, and don't validate that the version comes after your previous versions, and so on.
func (*Version) New ¶
CREATE A VERSION
Version (required) The version number, typically incrementing a previous version. We validate this version string based on Semantic Versioning. We only require that the string matches a pattern that could be semver, and don't validate that the version comes after your previous versions, and so on. DescriptionMarkdown Markdown text used as a full-length and in-depth description of the version, typically for denoting changes introduced. Markdown is parsed according to GitHub Flavored Markdown. There is no maximum length.
When a version is first created, its status is set to unreleased.
func (*Version) Provider ¶
func (v *Version) Provider(name ProviderName) *Provider
func (*Version) Release ¶
RELEASE A VERSION
Version (required) The version number, typically incrementing a previous version. We validate this version string based on Semantic Versioning. We only require that the string matches a pattern that could be semver, and don't validate that the version comes after your previous versions, and so on.
This allows you to update the providers and description prior to release. Once a version is ready to release, you can then make a request to move it to an active state.
func (*Version) Revoke ¶
REVOKE A VERSION
Version (required) The version number, typically incrementing a previous version. We validate this version string based on Semantic Versioning. We only require that the string matches a pattern that could be semver, and don't validate that the version comes after your previous versions, and so on.
Versions that have been "released" can then no longer be deleted. Instead, you should "revoke" a released version, setting the status as revoked. This stops access to the version from Vagrant, but maintains the history of the version.
func (*Version) Set ¶
UPDATE A VERSION
Version (required) The version number, typically incrementing a previous version. We validate this version string based on Semantic Versioning. We only require that the string matches a pattern that could be semver, and don't validate that the version comes after your previous versions, and so on. DescriptionMarkdown Markdown text used as a full-length and in-depth description of the version, typically for denoting changes introduced. Markdown is parsed according to GitHub Flavored Markdown. There is no maximum length.
You cannot modify the status attribute directly, so their are seperate endpoints to revoke and release versions.
type VersionStatus ¶
type VersionStatus string
const ( VersionUnreleased VersionStatus = "unreleased" VersionActive VersionStatus = "active" VersionRevoked VersionStatus = "revoked" )