api

package
v0.19.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2016 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package api provides the daemon API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Orgs         *OrgsClient
	Users        *UsersClient
	Machines     *MachinesClient
	Profiles     *ProfilesClient
	Teams        *TeamsClient
	Memberships  *MembershipsClient
	Invites      *InvitesClient
	Keypairs     *KeypairsClient
	Session      *SessionClient
	Services     *ServicesClient
	Policies     *PoliciesClient
	Environments *EnvironmentsClient
	Projects     *ProjectsClient
	Credentials  *CredentialsClient
	Worklog      *WorklogClient
	Version      *VersionClient
	// contains filtered or unexported fields
}

Client exposes the daemon API.

func NewClient

func NewClient(cfg *config.Config) *Client

NewClient returns a new Client.

func (*Client) Do

func (c *Client) Do(ctx context.Context, r *http.Request, v interface{}, reqID *string, progress *ProgressFunc) (*http.Response, error)

Do executes an http.Request, populating v with the JSON response on success.

If the request errors with a JSON formatted response body, it will be unmarshaled into the returned error.

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, query *url.Values, body interface{}, proxied bool) (*http.Request, string, error)

NewRequest constructs a new http.Request, with a body containing the json representation of body, if provided.

type CredentialsClient

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

CredentialsClient provides access to unencrypted credentials for viewing, and encrypts credentials when setting.

func (*CredentialsClient) Create added in v0.8.0

Create creates the given credential

func (*CredentialsClient) Get

Get returns all credentials at the given path.

func (*CredentialsClient) Search added in v0.13.0

Search returns all credentials at the given pathexp.

type EnvironmentResult

type EnvironmentResult struct {
	ID      *identity.ID           `json:"id"`
	Version uint8                  `json:"version"`
	Body    *primitive.Environment `json:"body"`
}

EnvironmentResult is the payload returned for a env object

type EnvironmentsClient

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

EnvironmentsClient makes proxied requests to the registry's envs endpoints

func (*EnvironmentsClient) Create

func (e *EnvironmentsClient) Create(ctx context.Context, orgID, projectID *identity.ID, name string) error

Create generates a new env object for an org/project ID

func (*EnvironmentsClient) List

func (e *EnvironmentsClient) List(ctx context.Context, orgIDs, projectIDs *[]*identity.ID, names *[]string) ([]EnvironmentResult, error)

List retrieves relevant envs by name and/or orgID and/or projectID

type Event

type Event struct {
	ID          string `json:"id"`
	MessageType string
	Message     string `json:"message"`
	Completed   int    `json:"completed"`
	Total       int    `json:"total"`
}

Event contains the properties of a server sent event

type InviteResult

type InviteResult struct {
	ID      *identity.ID         `json:"id"`
	Version uint8                `json:"version"`
	Body    *primitive.OrgInvite `json:"body"`
}

InviteResult is the payload returned for a team object

type InvitesClient

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

InvitesClient makes proxied requests to the registry's invites endpoints

func (*InvitesClient) Accept

func (i *InvitesClient) Accept(ctx context.Context, org, email, code string) error

Accept executes the accept invite request

func (*InvitesClient) Approve

func (i *InvitesClient) Approve(ctx context.Context, inviteID identity.ID, output *ProgressFunc) error

Approve executes the approve invite request

func (*InvitesClient) Associate

func (i *InvitesClient) Associate(ctx context.Context, org, email, code string) (*InviteResult, error)

Associate executes the associate invite request

func (*InvitesClient) List

func (i *InvitesClient) List(ctx context.Context, orgID *identity.ID, states []string) ([]InviteResult, error)

List all invites for a given org

func (*InvitesClient) Send

func (i *InvitesClient) Send(ctx context.Context, email string, orgID, inviterID identity.ID, teamIDs []identity.ID) error

Send creates a new org invitation

type KeypairResult

type KeypairResult struct {
	PublicKey *struct {
		ID   *identity.ID         `json:"id"`
		Body *primitive.PublicKey `json:"body"`
	} `json:"public_key"`
	PrivateKey *struct {
		ID   *identity.ID         `json:"id"`
		Body *primitive.PublicKey `json:"body"`
	} `json:"private_key"`
	Claims []struct {
		ID   *identity.ID     `json:"id"`
		Body *primitive.Claim `json:"claims"`
	}
}

KeypairResult is the payload returned for a keypair object

func (*KeypairResult) Revoked added in v0.18.0

func (k *KeypairResult) Revoked() bool

Revoked returns a bool indicating if any revocation claims exist against this KeypairResult's keypair.

type KeypairsClient

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

KeypairsClient makes proxied requests to the registry's keypairs endpoints

func (*KeypairsClient) Generate

func (k *KeypairsClient) Generate(ctx context.Context, orgID *identity.ID,
	output *ProgressFunc) error

Generate generates new keypairs for the user in the given org.

func (*KeypairsClient) List

func (k *KeypairsClient) List(ctx context.Context, orgID *identity.ID) ([]KeypairResult, error)

List retrieves relevant keypairs by orgID

type MachinesClient added in v0.15.0

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

MachinesClient makes requests to the Daemon on behalf of the user to manipulate Machine resources.

func (*MachinesClient) Create added in v0.15.0

func (m *MachinesClient) Create(ctx context.Context, orgID, teamID *identity.ID,
	name string, output *ProgressFunc) (*apitypes.MachineSegment, *base64.Value, error)

Create a new machine in the given org

func (*MachinesClient) Destroy added in v0.15.0

func (m *MachinesClient) Destroy(ctx context.Context, machineID *identity.ID) error

Destroy machine by ID

func (*MachinesClient) Get added in v0.15.0

func (m *MachinesClient) Get(ctx context.Context, machineID *identity.ID) (*apitypes.MachineSegment, error)

Get machine by ID

func (*MachinesClient) List added in v0.15.0

func (m *MachinesClient) List(ctx context.Context, orgID *identity.ID, state *string, name *string, teamID *identity.ID) ([]*apitypes.MachineSegment, error)

List machines in the given org and state

type MembershipResult

type MembershipResult struct {
	ID      *identity.ID
	Version uint8
	Body    *primitive.Membership
}

MembershipResult is the payload returned for team membership association.

type MembershipsClient

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

MembershipsClient makes proxied requests to the registry's team memberships endpoints.

func (*MembershipsClient) Create added in v0.8.0

func (m *MembershipsClient) Create(ctx context.Context, userID, orgID, teamID *identity.ID) error

Create requests addition of a user to a team

func (*MembershipsClient) Delete

func (m *MembershipsClient) Delete(ctx context.Context, membership *identity.ID) error

Delete requests deletion of a specific membership row by ID

func (*MembershipsClient) List

func (m *MembershipsClient) List(ctx context.Context, org, user, team *identity.ID) ([]MembershipResult, error)

List returns all team membership associations for the given user id within the given org id.

type OrgResult

type OrgResult struct {
	ID      *identity.ID   `json:"id"`
	Version uint8          `json:"version"`
	Body    *primitive.Org `json:"body"`
}

OrgResult is the payload returned for an org object

type OrgTreeSegment added in v0.15.0

type OrgTreeSegment struct {
	Org      *primitive.Org      `json:"org"`
	Policies []*primitive.Policy `json:"policies"`
	Profiles []*apitypes.Profile `json:"profiles"`
	Teams    []*struct {
		Team              *apitypes.Team             `json:"team"`
		Memberships       *[]*apitypes.Membership    `json:"memberships"`
		PolicyAttachments *[]*PolicyAttachmentResult `json:"policy_attachments"`
	} `json:"teams"`
}

OrgTreeSegment is the payload returns for an org tree

type OrgsClient

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

OrgsClient makes proxied requests to the registry's orgs endpoints

func (*OrgsClient) Create

func (o *OrgsClient) Create(ctx context.Context, name string) (*OrgResult, error)

Create creates a new org with the given name. It returns the newly-created org.

func (*OrgsClient) GetByName

func (o *OrgsClient) GetByName(ctx context.Context, name string) (*OrgResult, error)

GetByName retrieves an org by its named

func (*OrgsClient) GetTree added in v0.15.0

func (o *OrgsClient) GetTree(ctx context.Context, orgID identity.ID) ([]OrgTreeSegment, error)

GetTree returns an org tree

func (*OrgsClient) List

func (o *OrgsClient) List(ctx context.Context) ([]OrgResult, error)

List returns all organizations that the signed-in user has access to

func (*OrgsClient) RemoveMember added in v0.12.0

func (o *OrgsClient) RemoveMember(ctx context.Context, orgID identity.ID,
	userID identity.ID) error

RemoveMember removes a user from an org

type PoliciesClient

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

PoliciesClient makes proxied requests to the registry's policies endpoints

func (*PoliciesClient) Attach added in v0.8.0

func (p *PoliciesClient) Attach(ctx context.Context, org, policy, team *identity.ID) error

Attach attaches a policy to a team

func (*PoliciesClient) AttachmentsList

func (p *PoliciesClient) AttachmentsList(ctx context.Context, orgID, ownerID, policyID *identity.ID) ([]PolicyAttachmentResult, error)

AttachmentsList retrieves all policy attachments for an org

func (*PoliciesClient) Create added in v0.8.0

func (p *PoliciesClient) Create(ctx context.Context, policy *primitive.Policy) (*PoliciesResult, error)

Create creates a new policy

func (*PoliciesClient) Detach added in v0.8.0

func (p *PoliciesClient) Detach(ctx context.Context, attachmentID *identity.ID) error

Detach deletes a specific attachment

func (*PoliciesClient) List

func (p *PoliciesClient) List(ctx context.Context, orgID *identity.ID, name string) ([]PoliciesResult, error)

List retrieves relevant policiies by orgID and/or name

type PoliciesResult

type PoliciesResult struct {
	ID      *identity.ID      `json:"id"`
	Version uint8             `json:"version"`
	Body    *primitive.Policy `json:"body"`
}

PoliciesResult is the payload returned for a policy object

type PolicyAttachmentResult

type PolicyAttachmentResult struct {
	ID      *identity.ID                `json:"id"`
	Version uint8                       `json:"version"`
	Body    *primitive.PolicyAttachment `json:"body"`
}

PolicyAttachmentResult is the payload returned for a policy_attachment object

type ProfilesClient

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

ProfilesClient makes proxied requests to the registry's profiles endpoints

func (*ProfilesClient) ListByID

func (p *ProfilesClient) ListByID(ctx context.Context, userIDs []identity.ID) (*[]apitypes.Profile, error)

ListByID returns profiles looked up by User ID

func (*ProfilesClient) ListByName

func (p *ProfilesClient) ListByName(ctx context.Context, name string) (*apitypes.Profile, error)

ListByName returns profiles looked up by username

type ProgressFunc

type ProgressFunc func(event *Event, err error)

ProgressFunc is used to output events

type ProjectResult

type ProjectResult struct {
	ID      *identity.ID       `json:"id"`
	Version uint8              `json:"version"`
	Body    *primitive.Project `json:"body"`
}

ProjectResult is the payload returned for a project object

type ProjectTreeSegment added in v0.19.0

type ProjectTreeSegment struct {
	Org      *OrgResult              `json:"org"`
	Envs     []*apitypes.Environment `json:"envs"`
	Services []*apitypes.Service     `json:"services"`
	Projects []*ProjectResult        `json:"projects"`
	Profiles []*apitypes.Profile     `json:"profiles"`
}

ProjectTreeSegment is the payload returned for a project tree

type ProjectsClient

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

ProjectsClient makes proxied requests to the registry's projects endpoints

func (*ProjectsClient) Create

func (p *ProjectsClient) Create(ctx context.Context, org *identity.ID, name string) (*ProjectResult, error)

Create creates a new project with the given name within the given org

func (*ProjectsClient) GetTree added in v0.19.0

func (p *ProjectsClient) GetTree(ctx context.Context, orgID *identity.ID) ([]ProjectTreeSegment, error)

GetTree returns a project tree

func (*ProjectsClient) List

func (p *ProjectsClient) List(ctx context.Context, orgIDs *[]*identity.ID, names *[]string) ([]ProjectResult, error)

List retrieves relevant projects by name and/or orgID

type ServiceResult

type ServiceResult struct {
	ID      *identity.ID       `json:"id"`
	Version uint8              `json:"version"`
	Body    *primitive.Service `json:"body"`
}

ServiceResult is the payload returned for a service object

type ServicesClient

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

ServicesClient makes proxied requests to the registry's services endpoints

func (*ServicesClient) Create

func (s *ServicesClient) Create(ctx context.Context, orgID, projectID *identity.ID, name string) error

Create performs a request to create a new service object

func (*ServicesClient) List

func (s *ServicesClient) List(ctx context.Context, orgIDs, projectIDs *[]*identity.ID, names *[]string) ([]ServiceResult, error)

List retrieves relevant services by name and/or orgID and/or projectID

type Session added in v0.15.0

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

Session represents the current logged in entities identity and authentication objects which could be a Machine or User

func NewSession added in v0.15.0

func NewSession(resp *apitypes.Self) (*Session, error)

NewSession returns a new session constructed from the payload of the current identity as returned from the Daemon

func (*Session) AuthID added in v0.15.0

func (s *Session) AuthID() *identity.ID

AuthID returns the auth id (e.g. user or machine token id)

func (*Session) Email added in v0.15.0

func (s *Session) Email() string

Email returns none for a machine or the users email address

func (*Session) ID added in v0.15.0

func (s *Session) ID() *identity.ID

ID returns the identity ID (e.g. user or machine id)

func (*Session) Name added in v0.15.0

func (s *Session) Name() string

Name returns the fullname of the user or the machine name

func (*Session) Type added in v0.15.0

func (s *Session) Type() string

Type returns the type of the session (machine or user)

func (*Session) Username added in v0.15.0

func (s *Session) Username() string

Username returns the username or machine name depending on the session type

type SessionClient

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

SessionClient provides access to the daemon's user session related endpoints, for logging in/out, and checking your session status.

func (*SessionClient) Get

Get returns the status of the user's session.

func (*SessionClient) Logout

func (s *SessionClient) Logout(ctx context.Context) error

Logout logs the user out of their session

func (*SessionClient) MachineLogin added in v0.15.0

func (s *SessionClient) MachineLogin(ctx context.Context, tokenID, tokenSecret string) error

MachineLogin logs the user in using the provided token id and secret

func (*SessionClient) UserLogin added in v0.15.0

func (s *SessionClient) UserLogin(ctx context.Context, email, passphrase string) error

UserLogin logs the user in using the provided email and passphrase

func (*SessionClient) Who added in v0.15.0

func (s *SessionClient) Who(ctx context.Context) (*Session, error)

Who returns the Session object for the current authenticated user or machine

type TeamResult

type TeamResult struct {
	ID      *identity.ID    `json:"id"`
	Version uint8           `json:"version"`
	Body    *primitive.Team `json:"body"`
}

TeamResult is the payload returned for a team object

type TeamsClient

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

TeamsClient makes proxied requests to the registry's teams endpoints

func (*TeamsClient) Create

func (t *TeamsClient) Create(
	ctx context.Context, orgID *identity.ID, name, teamType string) (*apitypes.Team, error)

Create performs a request to create a new team object

func (*TeamsClient) GetByName

func (t *TeamsClient) GetByName(ctx context.Context, orgID *identity.ID, name string) ([]TeamResult, error)

GetByName retrieves the team with the specified name

func (*TeamsClient) GetByOrg

func (t *TeamsClient) GetByOrg(ctx context.Context, orgID *identity.ID) ([]TeamResult, error)

GetByOrg retrieves all teams for an org id

func (*TeamsClient) List added in v0.15.0

func (t *TeamsClient) List(ctx context.Context, orgID *identity.ID, name, teamType string) ([]TeamResult, error)

List retrieves all teams for an org based on the filtered values

type UserResult

type UserResult struct {
	ID      *identity.ID    `json:"id"`
	Version uint8           `json:"version"`
	Body    *primitive.User `json:"body"`
}

UserResult is the payload returned for a user object

type UsersClient

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

UsersClient makes proxied requests to the registry's users endpoints

func (*UsersClient) Signup

func (u *UsersClient) Signup(ctx context.Context, signup *apitypes.Signup, output *ProgressFunc) (*UserResult, error)

Signup will have the daemon create a new user request

func (*UsersClient) Update added in v0.17.0

func (u *UsersClient) Update(ctx context.Context, delta apitypes.ProfileUpdate) (*UserResult, error)

Update performs a profile update to the user object

func (*UsersClient) VerifyEmail added in v0.8.0

func (u *UsersClient) VerifyEmail(ctx context.Context, verifyCode string) error

VerifyEmail will confirm the user's email with the registry

type VersionClient

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

VersionClient provides access to the daemon's /v1/version endpoint, for inspecting the daemon's release version.

func (*VersionClient) Get

Get returns the daemon's release version.

func (*VersionClient) GetRegistry

func (v *VersionClient) GetRegistry(ctx context.Context) (*apitypes.Version, error)

GetRegistry returns the registry's release version.

type WorklogClient added in v0.12.0

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

WorklogClient views and resolves worklog items in the daemon.

func (*WorklogClient) Get added in v0.12.0

Get returns the worklog item with the given id in the given org.

func (*WorklogClient) List added in v0.12.0

func (w *WorklogClient) List(ctx context.Context, orgID *identity.ID) ([]apitypes.WorklogItem, error)

List returns the list of all worklog items in the given org.

func (*WorklogClient) Resolve added in v0.12.0

func (w *WorklogClient) Resolve(ctx context.Context, orgID *identity.ID, ident *apitypes.WorklogID) (*apitypes.WorklogResult, error)

Resolve resolves the worklog item with the given id in the given org.

Jump to

Keyboard shortcuts

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