apitypes

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BadRequestError     = "bad_request"
	UnauthorizedError   = "unauthorized"
	NotFoundError       = "not_found"
	RequestTimeoutError = "request_timeout"
	InternalServerError = "internal_server"
	NotImplementedError = "not_implemented"
	UnknownError        = "unknown_error"
)

These are the possible error types.

Variables

View Source
var ErrClaimCycleFound = errors.New("Cycle detected in signed claims")

ErrClaimCycleFound is returned when a cycle is found within the claims. this *should* be impossible, as they are signed.

View Source
var ErrIncorrectWorklogIDLen = errors.New("Incorrect worklog ID length")

ErrIncorrectWorklogIDLen is returned when a base32 encoded worklog id is the wrong length.

Functions

func FormatError added in v0.16.0

func FormatError(err error) error

FormatError updates an error to contain more context

func IsNotFoundError added in v0.12.0

func IsNotFoundError(err error) bool

IsNotFoundError returns whether or not an error is a 404 result from the api.

func IsUnauthorizedError added in v0.21.0

func IsUnauthorizedError(err error) bool

IsUnauthorizedError returns whether or not an error is a 401 result from the api.

Types

type BaseCredential added in v0.11.0

type BaseCredential struct {
	Name      string           `json:"name"`
	OrgID     *identity.ID     `json:"org_id"`
	PathExp   *pathexp.PathExp `json:"pathexp"`
	ProjectID *identity.ID     `json:"project_id"`
	Value     *CredentialValue `json:"value"`
}

BaseCredential is the body of an unencrypted Credential

func (*BaseCredential) GetName added in v0.11.0

func (c *BaseCredential) GetName() string

GetName returns the name

func (*BaseCredential) GetOrgID added in v0.11.0

func (c *BaseCredential) GetOrgID() *identity.ID

GetOrgID returns the org id

func (*BaseCredential) GetPathExp added in v0.11.0

func (c *BaseCredential) GetPathExp() *pathexp.PathExp

GetPathExp returns the pathexp

func (*BaseCredential) GetProjectID added in v0.11.0

func (c *BaseCredential) GetProjectID() *identity.ID

GetProjectID returns the project id

func (*BaseCredential) GetValue added in v0.11.0

func (c *BaseCredential) GetValue() *CredentialValue

GetValue returns the value object, unless unset then returns nil

type Credential

type Credential interface {
	GetName() string
	GetOrgID() *identity.ID
	GetPathExp() *pathexp.PathExp
	GetProjectID() *identity.ID
	GetValue() *CredentialValue
}

Credential interface is either a v1 or v2 credential object

type CredentialEnvelope

type CredentialEnvelope struct {
	ID      *identity.ID `json:"id"`
	Version uint8        `json:"version"`
	Body    *Credential  `json:"body"`
}

CredentialEnvelope is an unencrypted credential object with a deserialized body

type CredentialResp added in v0.11.0

type CredentialResp struct {
	ID      *identity.ID    `json:"id"`
	Version uint8           `json:"version"`
	Body    json.RawMessage `json:"body"`
}

CredentialResp is used to facilitate unmarshalling of versioned objects

type CredentialV2 added in v0.11.0

type CredentialV2 struct {
	BaseCredential
	State string `json:"state"`
}

CredentialV2 is the body of an unencrypted Credential

func (*CredentialV2) GetValue added in v0.11.0

func (c *CredentialV2) GetValue() *CredentialValue

GetValue returns the value object, unless unset then returns nil

type CredentialValue

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

CredentialValue is the raw value of a credential.

func NewFloatCredentialValue added in v0.8.0

func NewFloatCredentialValue(f float64) *CredentialValue

NewFloatCredentialValue creates a CredentialValue with a float value.

func NewIntCredentialValue added in v0.8.0

func NewIntCredentialValue(i int) *CredentialValue

NewIntCredentialValue creates a CredentialValue with an int value.

func NewStringCredentialValue added in v0.8.0

func NewStringCredentialValue(s string) *CredentialValue

NewStringCredentialValue creates a CredentialValue with a string value.

func NewUndecryptedCredentialValue added in v0.28.0

func NewUndecryptedCredentialValue() *CredentialValue

NewUndecryptedCredentialValue creates a CredentialValue with an undecrypted value

func NewUnsetCredentialValue added in v0.8.0

func NewUnsetCredentialValue() *CredentialValue

NewUnsetCredentialValue creates a CredentialValue with an unset value.

func (*CredentialValue) IsUndecrypted added in v0.28.0

func (c *CredentialValue) IsUndecrypted() bool

IsUndecrypted returns if this credential has not been decrypted

func (*CredentialValue) IsUnset

func (c *CredentialValue) IsUnset() bool

IsUnset returns if this credential has been unset (deleted)

func (*CredentialValue) MarshalJSON added in v0.8.0

func (c *CredentialValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*CredentialValue) Raw added in v0.17.0

func (c *CredentialValue) Raw() (interface{}, error)

Raw returns the underlying typed value for this Credential.

func (*CredentialValue) String

func (c *CredentialValue) String() string

String returns the string representation of this credential. It panics if the credential was deleted.

func (*CredentialValue) UnmarshalJSON

func (c *CredentialValue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Error

type Error struct {
	Type ErrorType `json:"type"`
	Err  []string  `json:"error"`
}

Error represents standard formatted API errors from the daemon or registry.

func NewUnverifiedError added in v0.16.0

func NewUnverifiedError() *Error

NewUnverifiedError returns a message telling the user to verify their account before continuing

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface for formatted API errors.

func (*Error) StatusCode

func (e *Error) StatusCode() int

StatusCode returns the http status code associated with the underlying error type

type ErrorType

type ErrorType string

ErrorType represents the string error types that the daemon and registry can return.

func LookupErrorType added in v0.30.0

func LookupErrorType(code int) ErrorType

LookupErrorType returns the ErrorType for the given HTTP StatusCode, UnknownError is returned if the error type could not be found.

type InviteAccept

type InviteAccept struct {
	Org   string `json:"org"`
	Email string `json:"email"`
	Code  string `json:"code"`
}

InviteAccept contains data required to accept org invite

type InviteApproveWorklogDetails added in v0.23.0

type InviteApproveWorklogDetails struct {
	InviteID *identity.ID `json:"invite_id"`
	Email    string       `json:"email"`
	Username string       `json:"username"`
	Name     string       `json:"name"`
	Org      string       `json:"org"`
	Teams    []string     `json:"teams"`
}

InviteApproveWorklogDetails holds WorklogItem details for the InviteApproveWorklogType.

func (*InviteApproveWorklogDetails) Subject added in v0.23.0

func (i *InviteApproveWorklogDetails) Subject() string

Subject returns the human readable subject of this WorklogItem.

func (*InviteApproveWorklogDetails) Summary added in v0.23.0

func (i *InviteApproveWorklogDetails) Summary() string

Summary returns the human readable summary of this WorklogItem.

type KeyringMembersWorklogDetails added in v0.23.0

type KeyringMembersWorklogDetails struct {
	EntityID *identity.ID      `json:"entity_id"`
	Name     string            `json:"name"`
	Type     string            `json:"type"`
	OwnerIDs []identity.ID     `json:"owner_ids"`
	Keyrings []pathexp.PathExp `json:"keyrings"`
}

KeyringMembersWorklogDetails holds WorklogItem details for the KeyringMembersWorklogType.

func (*KeyringMembersWorklogDetails) Subject added in v0.23.0

func (k *KeyringMembersWorklogDetails) Subject() string

Subject returns the human readable subject of this WorklogItem.

func (*KeyringMembersWorklogDetails) Summary added in v0.23.0

func (k *KeyringMembersWorklogDetails) Summary() string

Summary returns the human readable summary of this WorklogItem.

type Login

type Login struct {
	Type        SessionType     `json:"type"`
	Credentials json.RawMessage `json:"credentials"`
}

Login is a wrapper around a login request from the CLI to the Daemon

type LoginCredential added in v0.15.0

type LoginCredential interface {
	Type() SessionType
	Valid() bool
	Passphrase() []byte
	Identifier() string
}

LoginCredential represents an login credentials for a user or machine

type MachineLogin added in v0.15.0

type MachineLogin struct {
	TokenID *identity.ID  `json:"token_id"`
	Secret  *base64.Value `json:"secret"`
}

MachineLogin contains the required details for logging into the api and daemon as a machine.

func (*MachineLogin) Identifier added in v0.15.0

func (m *MachineLogin) Identifier() string

Identifier returns the identifying piece of information of the request

func (*MachineLogin) Passphrase added in v0.15.0

func (m *MachineLogin) Passphrase() []byte

Passphrase returns the "secret" component of the request

func (MachineLogin) Type added in v0.15.0

func (MachineLogin) Type() SessionType

Type returns the type of the login request

func (*MachineLogin) Valid added in v0.15.0

func (m *MachineLogin) Valid() bool

Valid returns whether or not this is a valid machine login request

type MachineSegment added in v0.15.0

type MachineSegment struct {
	Machine     *envelope.Machine     `json:"machine"`
	Memberships []envelope.Membership `json:"memberships"`
	Tokens      []struct {
		Token    *envelope.MachineToken `json:"token"`
		Keypairs []PublicKeySegment     `json:"keypairs"`
	} `json:"tokens"`
}

MachineSegment represents a machine, its tokens, and their connected keypairs

type MachinesCreateRequest added in v0.15.0

type MachinesCreateRequest struct {
	Name   string        `json:"name"`
	OrgID  *identity.ID  `json:"org_id"`
	TeamID *identity.ID  `json:"team_id"`
	Secret *base64.Value `json:"secret"`
}

MachinesCreateRequest represents a request by a client to create a machine for a specific org, team using the given name and secret.

type MissingKeypairsWorklogDetails added in v0.23.0

type MissingKeypairsWorklogDetails struct {
	Org               string `json:"org"`
	EncryptionMissing bool   `json:"encryption_missing"`
	SigningMissing    bool   `json:"signing_missing"`
}

MissingKeypairsWorklogDetails holds WorklogItem details for the MissingKeypairsWorklogType..

func (*MissingKeypairsWorklogDetails) Subject added in v0.23.0

Subject returns the human readable subject of this WorklogItem.

func (*MissingKeypairsWorklogDetails) Summary added in v0.23.0

Summary returns the human readable summary of this WorklogItem.

type Profile

type Profile struct {
	ID   *identity.ID `json:"id"`
	Body *struct {
		Name     string `json:"name"`
		Username string `json:"username"`
	} `json:"body"`
}

Profile contains the fields in the response for the profiles endpoint

type ProfileUpdate added in v0.17.0

type ProfileUpdate struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

ProfileUpdate contains the fields a user can change on their user object

type PublicKeySegment added in v0.15.0

type PublicKeySegment struct {
	PublicKey *envelope.PublicKey `json:"public_key"`
	Claims    []envelope.Claim    `json:"claims"`
}

PublicKeySegment represents a sub section of a claimtree targeting a specific public key and it's claims.

func (*PublicKeySegment) HeadClaim added in v0.21.0

func (pks *PublicKeySegment) HeadClaim() (*envelope.Claim, error)

HeadClaim returns the most recent Claim made against this PublicKey

func (*PublicKeySegment) Revoked added in v0.18.0

func (pks *PublicKeySegment) Revoked() bool

Revoked returns a bool indicating if any revocation claims exist against this PublicKey

type SecretRotateWorklogDetails added in v0.23.0

type SecretRotateWorklogDetails struct {
	PathExp *pathexp.PathExp            `json:"pathexp"`
	Name    string                      `json:"name"`
	Reasons []SecretRotateWorklogReason `json:"reasons"`
}

SecretRotateWorklogDetails holds WorklogItem details for the SecretRotateWorklogType.

func (*SecretRotateWorklogDetails) Subject added in v0.23.0

func (s *SecretRotateWorklogDetails) Subject() string

Subject returns the human readable subject of this WorklogItem.

func (*SecretRotateWorklogDetails) Summary added in v0.23.0

func (s *SecretRotateWorklogDetails) Summary() string

Summary returns the human readable summary of this WorklogItem.

type SecretRotateWorklogReason added in v0.23.0

type SecretRotateWorklogReason struct {
	Username string                                `json:"username"`
	Type     primitive.KeyringMemberRevocationType `json:"type"`
}

SecretRotateWorklogReason holds the username and claim revocation type for a secret rotation reason.

type Self added in v0.15.0

type Self struct {
	Type SessionType `json:"type"`

	// XXX: create an ident/auth interface
	Identity envelope.Envelope `json:"identity"`
	Auth     envelope.Envelope `json:"auth"`
}

Self represents the current identity and auth combination for this session

type SessionStatus

type SessionStatus struct {
	Token      bool `json:"token"`
	Passphrase bool `json:"passphrase"`
}

SessionStatus contains details about the user's daemon session.

type SessionType added in v0.22.0

type SessionType string

SessionType is the enumerated string type of sessions.

const (
	MachineSession SessionType = "machine"
	UserSession    SessionType = "user"
	NotLoggedIn    SessionType = "no_session"
)

A session can represent either a machine or a user

type Signup

type Signup struct {
	Name       string
	Username   string
	Email      string
	Passphrase string
	InviteCode string
	OrgName    string
	OrgInvite  bool
}

Signup contains information required for registering an account

type UpdateInfo added in v0.23.0

type UpdateInfo struct {
	NeedsUpdate bool   `json:"needs_update"`
	Version     string `json:"version"`
}

UpdateInfo contains info about the latest version of Torus available for download and if that version is higher than the local running one.

type UserLogin added in v0.15.0

type UserLogin struct {
	Email    string `json:"email"`
	Password string `json:"passphrase"`
}

UserLogin contains the required details for logging in to the api and daemon as a user.

func (*UserLogin) Identifier added in v0.15.0

func (u *UserLogin) Identifier() string

Identifier returns the identifying piece of information of the request

func (*UserLogin) Passphrase added in v0.15.0

func (u *UserLogin) Passphrase() []byte

Passphrase returns the "secret" or "password" component of the request

func (UserLogin) Type added in v0.15.0

func (UserLogin) Type() SessionType

Type returns the type of login request

func (*UserLogin) Valid added in v0.15.0

func (u *UserLogin) Valid() bool

Valid returns whether or not this is a valid login request

type VerifyEmail added in v0.8.0

type VerifyEmail struct {
	Code string `json:"code"`
}

VerifyEmail contains email verification code

type Version

type Version struct {
	Version string `json:"version"`
}

Version contains the release version of the daemon.

type WorklogDetails added in v0.23.0

type WorklogDetails interface {
	Subject() string
	Summary() string
}

WorklogDetails is the common interface exposed by worklog item types.

type WorklogID added in v0.12.0

type WorklogID [worklogIDLen]byte

WorklogID is the unique content-based identifier for worklog entries

func DecodeWorklogIDFromString added in v0.12.0

func DecodeWorklogIDFromString(raw string) (WorklogID, error)

DecodeWorklogIDFromString decodes a WorklogID from the given base32 encoded representation.

func (WorklogID) String added in v0.12.0

func (id WorklogID) String() string

func (WorklogID) Type added in v0.20.0

func (id WorklogID) Type() WorklogType

Type returns this id's type

type WorklogItem added in v0.12.0

type WorklogItem struct {
	ID *WorklogID `json:"id"`

	Details WorklogDetails `json:"details"`
}

WorklogItem is an item that the daemon has identified as needing to be done to ensure system correctness, or security in the face of stale secrets.

func (*WorklogItem) CreateID added in v0.12.0

func (w *WorklogItem) CreateID(worklogType WorklogType)

CreateID creates and populates a WorklogID for the WorklogItem based on the given type and its subject.

func (*WorklogItem) Subject added in v0.12.0

func (w *WorklogItem) Subject() string

Subject returns the human readable subject of this WorklogItem.

func (*WorklogItem) Summary added in v0.12.0

func (w *WorklogItem) Summary() string

Summary returns the human readable summary of this WorklogItem.

func (*WorklogItem) Type added in v0.12.0

func (w *WorklogItem) Type() WorklogType

Type returns this item's type

type WorklogType added in v0.12.0

type WorklogType byte

WorklogType is the enumerated byte type of WorklogItems

const (
	SecretRotateWorklogType WorklogType = 1 << iota
	MissingKeypairsWorklogType
	InviteApproveWorklogType
	UserKeyringMembersWorklogType
	MachineKeyringMembersWorklogType

	AnyWorklogType WorklogType = 0xff
)

The enumberated byte types of WorklogItems

func (WorklogType) String added in v0.12.0

func (t WorklogType) String() string

String returns a human reable string for this worklog item type.

Jump to

Keyboard shortcuts

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