client

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package client manages channels and releases through the Replicated Vendor API.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("Not found")

ErrNotFound represnets a 404 response from the API.

Functions

This section is empty.

Types

type BadRequest

type BadRequest struct {
	MessageCode string `json:"messageCode"`
	Message     string `json:"message"`
}

BadRequest represents a 400 response from the API.

func (*BadRequest) Error

func (br *BadRequest) Error() string

Error prints the MessageCode and Message returned from the API.

type Client

type Client interface {
	GetAppBySlug(slug string) (*apps.App, error)
	CreateApp(name string) (*apps.App, error)

	ListChannels(appID string) ([]channels.AppChannel, error)
	CreateChannel(appID, name, desc string) ([]channels.AppChannel, error)
	ArchiveChannel(appID, channelID string) error
	GetChannel(appID, channelID string) (*channels.AppChannel, []channels.ChannelRelease, error)

	ListReleases(appID string) ([]releases.AppReleaseInfo, error)
	CreateRelease(appID string) (*releases.AppReleaseInfo, error)
	UpdateRelease(appID string, sequence int64, yaml string) error
	GetRelease(appID string, sequence int64) (*releases.AppRelease, error)
	PromoteRelease(
		appID string,
		sequence int64,
		label string,
		notes string,
		required bool,
		channelIDs ...string) error
}

Client provides methods to manage apps, channels, and releases.

func New

func New(apiKey string) Client

New returns a new HTTP client.

Example
token := os.Getenv("REPLICATED_API_TOKEN")
appSlug := os.Getenv("REPLICATED_APP_SLUG")

api := New(token)

app, err := api.GetAppBySlug(appSlug)
if err != nil {
	log.Fatal(err)
}

channels, err := api.ListChannels(app.Id)
if err != nil {
	log.Fatal(err)
}
for _, c := range channels {
	if c.Name == "Stable" {
		fmt.Println("We have a Stable channel")
	}
}
Output:

We have a Stable channel

func NewHTTPClient

func NewHTTPClient(origin string, apiKey string) Client

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

An HTTPClient communicates with the Replicated Vendor HTTP API.

func (*HTTPClient) ArchiveChannel

func (c *HTTPClient) ArchiveChannel(appID, channelID string) error

ArchiveChannel archives a channel.

func (*HTTPClient) CreateApp

func (c *HTTPClient) CreateApp(name string) (*apps.App, error)

CreateApp creates a new app with the given name and returns it.

func (*HTTPClient) CreateChannel

func (c *HTTPClient) CreateChannel(appID, name, desc string) ([]channels.AppChannel, error)

CreateChannel adds a channel to an app.

func (*HTTPClient) CreateRelease

func (c *HTTPClient) CreateRelease(appID string) (*releases.AppReleaseInfo, error)

CreateRelease adds a release to an app.

func (*HTTPClient) DeleteApp

func (c *HTTPClient) DeleteApp(id string) error

DeleteApp deletes an app by id.

func (*HTTPClient) GetAppBySlug

func (c *HTTPClient) GetAppBySlug(slug string) (*apps.App, error)

GetAppBySlug resolves an app by slug.

func (*HTTPClient) GetChannel

func (c *HTTPClient) GetChannel(appID, channelID string) (*channels.AppChannel, []channels.ChannelRelease, error)

GetChannel returns channel details and release history

func (*HTTPClient) GetRelease

func (c *HTTPClient) GetRelease(appID string, sequence int64) (*releases.AppRelease, error)

GetRelease returns a release's properties.

func (*HTTPClient) ListApps

func (c *HTTPClient) ListApps() ([]apps.AppAndChannels, error)

ListApps returns all apps and their channels.

func (*HTTPClient) ListChannels

func (c *HTTPClient) ListChannels(appID string) ([]channels.AppChannel, error)

ListChannels returns all channels for an app.

func (*HTTPClient) ListReleases

func (c *HTTPClient) ListReleases(appID string) ([]releases.AppReleaseInfo, error)

ListReleases lists all releases for an app.

func (*HTTPClient) PromoteRelease

func (c *HTTPClient) PromoteRelease(appID string, sequence int64, label, notes string, required bool, channelIDs ...string) error

PromoteRelease points the specified channels at a release sequence.

func (*HTTPClient) UpdateRelease

func (c *HTTPClient) UpdateRelease(appID string, sequence int64, yaml string) error

UpdateRelease updates a release's yaml.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL