brev_api

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// namespace used to set/get values from the keychain.
	SecretsNamespace = "auth0-cli"
)

Variables

View Source
var (
	DEFAULT_APPLICATION_ID = "92f59a4yf"
	DEFAULT_APPLICATION    = Application{
		ID:           "92f59a4yf",
		Name:         "VSCode",
		Port:         22778,
		StartCommand: "",
		Version:      "1.57.1",
	}
)
View Source
var DEFAULT_APPLICATION_LIST = []Application{DEFAULT_APPLICATION}

Functions

func GetCachedWorkspaceNames added in v0.2.0

func GetCachedWorkspaceNames() []string

func GetOrgNames added in v0.2.0

func GetOrgNames() []string

func HandleNewClientErrors added in v0.1.6

func HandleNewClientErrors(err error) error

func IsInProjectDirectory

func IsInProjectDirectory() (bool, error)

func Login

func Login(prompt bool) error

func Logout

func Logout() error

func OpenBrowser

func OpenBrowser(url string) error

open opens the specified URL in the default browser of the user.

func RefreshWorkspaceCacheForActiveOrg

func RefreshWorkspaceCacheForActiveOrg() error

func RequiredScopes

func RequiredScopes() []string

RequiredScopes returns the scopes used for login.

func RequiredScopesMin

func RequiredScopesMin() []string

RequiredScopesMin returns minimum scopes used for login in integration tests.

func StringInList

func StringInList(a string, list []string) bool

func WriteCaches

func WriteCaches() error

func WriteIndividualWorkspaceCache

func WriteIndividualWorkspaceCache(orgID string, wss []Workspace) error

func WriteOrgCache added in v0.2.0

func WriteOrgCache(orgs []Organization) error

func WriteTokenToBrevConfigFile

func WriteTokenToBrevConfigFile(token *Credentials) error

Types

type Application added in v0.2.0

type Application struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Port         int    `json:"port"`
	StartCommand string `json:"startCommand"`
	Version      string `json:"version"`
}

type Authenticator

type Authenticator struct {
	Audience           string
	ClientID           string
	DeviceCodeEndpoint string
	OauthTokenEndpoint string
}

func (*Authenticator) Start

func (a *Authenticator) Start(ctx context.Context) (State, error)

Start kicks-off the device authentication flow by requesting a device code from Auth0, The returned state contains the URI for the next step of the flow.

func (*Authenticator) Wait

func (a *Authenticator) Wait(ctx context.Context, state State) (Result, error)

Wait waits until the user is logged in on the browser.

type CacheableWorkspace

type CacheableWorkspace struct {
	OrgID      string      `json:"orgID"`
	Workspaces []Workspace `json:"workspaces"`
}

func GetWsCacheData

func GetWsCacheData() ([]CacheableWorkspace, error)

type Client

type Client struct {
	Key *OauthToken
}

func NewClient

func NewClient() (*Client, error)

func NewCommandClient added in v0.1.6

func NewCommandClient() (*Client, error)

func (*Client) CreateWorkspace

func (a *Client) CreateWorkspace(orgID string, name string, gitrepo string) (*Workspace, error)

func (*Client) DeleteWorkspace added in v0.2.0

func (a *Client) DeleteWorkspace(wsID string) (*Workspace, error)

func (*Client) GetMe

func (a *Client) GetMe() (*User, error)

func (*Client) GetMeKeys

func (a *Client) GetMeKeys() (*UserKeys, error)

func (*Client) GetMyWorkspaces added in v0.1.5

func (a *Client) GetMyWorkspaces(orgID string) ([]Workspace, error)

Note: this is the "projects" view

func (*Client) GetOrgs

func (a *Client) GetOrgs() ([]Organization, error)

func (*Client) GetWorkspace

func (a *Client) GetWorkspace(wsID string) (*Workspace, error)

func (*Client) GetWorkspaceMetaData

func (a *Client) GetWorkspaceMetaData(wsID string) (*WorkspaceMetaData, error)

func (*Client) GetWorkspaces

func (a *Client) GetWorkspaces(orgID string) ([]Workspace, error)

func (*Client) ResetWorkspace added in v0.2.0

func (a *Client) ResetWorkspace(wsID string) (*Workspace, error)

func (*Client) StartWorkspace added in v0.2.0

func (a *Client) StartWorkspace(wsID string) (*Workspace, error)

func (*Client) StopWorkspace added in v0.2.0

func (a *Client) StopWorkspace(wsID string) (*Workspace, error)

type Credentials

type Credentials struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	IDToken      string `json:"id_token"`
	RefreshToken string `json:"refresh_token"`
}

type OauthToken

type OauthToken struct {
	AccessToken  string `json:"access_token"`
	AuthMethod   string `json:"auth_method"`
	ExpiresIn    int    `json:"expires_in"`
	IDToken      string `json:"id_token"`
	RefreshToken string `json:"refresh_token"`
}

func GetToken

func GetToken() (*OauthToken, error)

GetToken reads the previously-persisted token from the filesystem, returning nil for a token if it does not exist

type Organization

type Organization struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

func GetActiveOrgContext

func GetActiveOrgContext(fs afero.Fs) (*Organization, error)

func GetOrgCacheData

func GetOrgCacheData() ([]Organization, error)

func GetOrgFromName added in v0.2.0

func GetOrgFromName(name string) (*Organization, error)

type RequestCreateWorkspace

type RequestCreateWorkspace struct {
	Name                 string        `json:"name"`
	WorkspaceGroupID     string        `json:"workspaceGroupId"`
	WorkspaceClassID     string        `json:"workspaceClassId"`
	GitRepo              string        `json:"gitRepo"`
	IsStoppable          bool          `json:"isStoppable"`
	WorkspaceTemplateID  string        `json:"workspaceTemplateId"`
	PrimaryApplicationId string        `json:"primaryApplicationId"`
	Applications         []Application `json:"applications"`
}

type Result

type Result struct {
	Tenant       string
	Domain       string
	RefreshToken string
	AccessToken  string
	ExpiresIn    int64
}

type SecretStore

type SecretStore interface {
	// Get gets the secret
	Get(namespace, key string) (string, error)
	// Delete removes the secret
	Delete(namespace, key string) error
}

SecretStore provides access to stored sensitive data.

type State

type State struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri_complete"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
}

func (*State) IntervalDuration

func (s *State) IntervalDuration() time.Duration

type User

type User struct {
	Id string `json:"id"`
}

type UserKeys

type UserKeys struct {
	PrivateKey      string               `json:"privateKey"`
	PublicKey       string               `json:"publicKey"`
	WorkspaceGroups []WorkspaceGroupKeys `json:"workspaceGroups"`
}

func (UserKeys) GetWorkspaceGroupKeysByGroupID

func (u UserKeys) GetWorkspaceGroupKeysByGroupID(groupID string) (*WorkspaceGroupKeys, error)

type Workspace

type Workspace struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	WorkspaceGroupID string `json:"workspaceGroupId"`
	OrganizationID   string `json:"organizationId"`
	WorkspaceClassID string `json:"workspaceClassId"`
	CreatedByUserID  string `json:"createdByUserId"`
	DNS              string `json:"dns"`
	Status           string `json:"status"`
	Password         string `json:"password"`
	GitRepo          string `json:"gitRepo"`
}

func GetWorkspaceFromName added in v0.2.0

func GetWorkspaceFromName(name string) (*Workspace, error)

func (Workspace) GetID added in v0.2.0

func (w Workspace) GetID() string

type WorkspaceGroupKeys

type WorkspaceGroupKeys struct {
	GroupID string `json:"groupId"`
	Cert    string `json:"cert"`
	CA      string `json:"ca"`
	APIURL  string `json:"apiUrl"`
}

type WorkspaceMetaData

type WorkspaceMetaData struct {
	PodName       string `json:"podName"`
	NamespaceName string `json:"namespaceName"`
}

func (WorkspaceMetaData) GetNamespaceName

func (w WorkspaceMetaData) GetNamespaceName() string

func (WorkspaceMetaData) GetPodName

func (w WorkspaceMetaData) GetPodName() string

type WorkspaceWithMeta added in v0.2.0

type WorkspaceWithMeta struct {
	WorkspaceMetaData
	Workspace
}

Jump to

Keyboard shortcuts

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