Documentation
¶
Index ¶
- Constants
- Variables
- func CloudAPIsURL(slug string) *url.URL
- func CloudConsoleURL(prefix string) *url.URL
- func ContextWithClient(ctx context.Context) context.Context
- func ContextWithOptions(ctx context.Context, opts ...CommandHelperOption) context.Context
- func NewPublicOryProjectClient() *cloud.APIClient
- func ReadAndParseFiles(files []string) ([]json.RawMessage, error)
- func RegisterConfigFlag(f *pflag.FlagSet)
- func RegisterProjectFlag(f *pflag.FlagSet)
- func RegisterWorkspaceFlag(f *pflag.FlagSet)
- func RegisterYesFlag(f *pflag.FlagSet)
- type CommandHelper
- func (h *CommandHelper) Authenticate(ctx context.Context) error
- func (h *CommandHelper) ClearConfig() error
- func (h *CommandHelper) CreateEventStream(ctx context.Context, projectID string, body cloud.CreateEventStreamBody) (*cloud.EventStream, error)
- func (h *CommandHelper) CreateOrganization(ctx context.Context, projectID string, body cloud.OrganizationBody) (*cloud.Organization, error)
- func (h *CommandHelper) CreateProject(ctx context.Context, name, environment string, workspace *string, ...) (*client.Project, error)
- func (h *CommandHelper) CreateProjectAPIKey(ctx context.Context, projectID, name string, expiresIn time.Duration) (*cloud.ProjectApiKey, error)
- func (h *CommandHelper) CreateWorkspace(ctx context.Context, name string) (*cloud.Workspace, error)
- func (h *CommandHelper) CreateWorkspaceAPIKey(ctx context.Context, workspaceID, name string) (*cloud.WorkspaceApiKey, error)
- func (h *CommandHelper) DeleteEventStream(ctx context.Context, projectID, streamID string) error
- func (h *CommandHelper) DeleteOrganization(ctx context.Context, projectID, orgID string) error
- func (h *CommandHelper) DeleteProjectAPIKey(ctx context.Context, projectID, keyID string) error
- func (h *CommandHelper) DeleteWorkspaceAPIKey(ctx context.Context, workspaceID, keyID string) error
- func (h *CommandHelper) GetAuthenticatedConfig(ctx context.Context) (*Config, error)
- func (h *CommandHelper) GetProject(ctx context.Context, idOrSlug string, workspace *string) (*client.Project, error)
- func (h *CommandHelper) GetSelectedProject(ctx context.Context) (*client.ProjectMetadata, error)
- func (h *CommandHelper) GetWorkspace(ctx context.Context, id string) (*cloud.Workspace, error)
- func (h *CommandHelper) ListEventStreams(ctx context.Context, projectID string) (*cloud.ListEventStreams, error)
- func (h *CommandHelper) ListOrganizations(ctx context.Context, projectID string) (*cloud.ListOrganizationsResponse, error)
- func (h *CommandHelper) ListProjects(ctx context.Context, workspace *string) ([]client.ProjectMetadata, error)
- func (h *CommandHelper) ListWorkspaces(ctx context.Context) ([]cloud.Workspace, error)
- func (h *CommandHelper) OpenURL(uri string) error
- func (h *CommandHelper) PatchProject(ctx context.Context, id string, raw []json.RawMessage, ...) (*client.SuccessfulProjectUpdate, error)
- func (h *CommandHelper) PrintUpdateProjectWarnings(p *client.SuccessfulProjectUpdate) error
- func (h *CommandHelper) ProjectAuthToken(ctx context.Context) (oauth2.TokenSource, func(string) *url.URL, error)
- func (h *CommandHelper) ProjectID() (string, error)
- func (h *CommandHelper) SelectProject(id string) error
- func (h *CommandHelper) SelectWorkspace(id string) error
- func (h *CommandHelper) SignOut(ctx context.Context) error
- func (h *CommandHelper) TemporaryAPIKey(ctx context.Context, name string, expiresIn time.Duration) (apiKey string, cleanup func() error, err error)
- func (h *CommandHelper) UpdateConfig(c *Config) error
- func (h *CommandHelper) UpdateEventStream(ctx context.Context, projectID, streamID string, body cloud.SetEventStreamBody) (*cloud.EventStream, error)
- func (h *CommandHelper) UpdateOrganization(ctx context.Context, projectID, orgID string, body cloud.OrganizationBody) (*cloud.Organization, error)
- func (h *CommandHelper) UpdateProject(ctx context.Context, id string, name string, configs []json.RawMessage) (*client.SuccessfulProjectUpdate, error)
- func (h *CommandHelper) UserName(ctx context.Context) string
- func (h *CommandHelper) WorkspaceID() *string
- type CommandHelperOption
- func WithConfigLocation(location string) CommandHelperOption
- func WithNoConfirm(noConfirm bool) CommandHelperOption
- func WithOpenBrowserHook(openBrowser func(string) error) CommandHelperOption
- func WithProjectAPIKey(apiKey string) CommandHelperOption
- func WithProjectOverride(project string) CommandHelperOption
- func WithQuiet(isQuiet bool) CommandHelperOption
- func WithStdin(r io.Reader) CommandHelperOption
- func WithVerboseErrWriter(w io.Writer) CommandHelperOption
- func WithWorkspaceAPIKey(apiKey string) CommandHelperOption
- func WithWorkspaceOverride(workspace string) CommandHelperOption
- type Config
- type Identity
Constants ¶
const ( WorkspaceKey = "ORY_WORKSPACE" ProjectKey = "ORY_PROJECT" WorkspaceAPIKey = "ORY_WORKSPACE_API_KEY" ProjectAPIKey = "ORY_PROJECT_API_KEY" )
const ( ConfigFileName = ".ory-cloud.json" FlagConfig = "config" ConfigPathKey = "ORY_CONFIG_PATH" ConfigVersion = "v1" )
const ( FlagWorkspace = "workspace" FlagProject = "project" FlagYes = "yes" )
const ( RateLimitHeaderKey = "ORY_RATE_LIMIT_HEADER" ConsoleURLKey = "ORY_CONSOLE_URL" OryAPIsURLKey = "ORY_ORYAPIS_URL" )
Variables ¶
var ( ErrNoConfig = errors.New("no ory configuration file present") ErrNoConfigQuiet = errors.New("please authenticate the CLI or remove the `--quiet` flag") ErrNotAuthenticated = errors.New("you are not authenticated, please run `ory auth` to authenticate") ErrReauthenticate = errors.New("your session or key has expired or has otherwise become invalid, re-authenticate to continue") )
var ErrProjectNotSet = fmt.Errorf("no project was specified")
Functions ¶
func CloudAPIsURL ¶ added in v0.1.42
func CloudConsoleURL ¶ added in v0.1.42
func ContextWithOptions ¶ added in v1.0.0
func ContextWithOptions(ctx context.Context, opts ...CommandHelperOption) context.Context
func NewPublicOryProjectClient ¶ added in v1.0.0
func ReadAndParseFiles ¶ added in v1.0.0
func ReadAndParseFiles(files []string) ([]json.RawMessage, error)
ReadAndParseFiles reads and parses JSON/YAML files from the given sources.
func RegisterConfigFlag ¶
func RegisterProjectFlag ¶
func RegisterWorkspaceFlag ¶ added in v1.0.0
func RegisterYesFlag ¶
Types ¶
type CommandHelper ¶
type CommandHelper struct {
VerboseErrWriter io.Writer
Stdin *bufio.Reader
// contains filtered or unexported fields
}
func NewCobraCommandHelper ¶ added in v1.0.0
func NewCobraCommandHelper(cmd *cobra.Command, opts ...CommandHelperOption) (*CommandHelper, error)
NewCobraCommandHelper creates a new CommandHelper instance which handles cobra CLI commands.
func NewCommandHelper ¶
func NewCommandHelper(ctx context.Context, opts ...CommandHelperOption) (*CommandHelper, error)
func (*CommandHelper) Authenticate ¶
func (h *CommandHelper) Authenticate(ctx context.Context) error
func (*CommandHelper) ClearConfig ¶ added in v1.0.0
func (h *CommandHelper) ClearConfig() error
func (*CommandHelper) CreateEventStream ¶ added in v0.3.2
func (h *CommandHelper) CreateEventStream(ctx context.Context, projectID string, body cloud.CreateEventStreamBody) (*cloud.EventStream, error)
func (*CommandHelper) CreateOrganization ¶ added in v0.3.0
func (h *CommandHelper) CreateOrganization(ctx context.Context, projectID string, body cloud.OrganizationBody) (*cloud.Organization, error)
func (*CommandHelper) CreateProject ¶
func (*CommandHelper) CreateProjectAPIKey ¶ added in v1.0.0
func (h *CommandHelper) CreateProjectAPIKey(ctx context.Context, projectID, name string, expiresIn time.Duration) (*cloud.ProjectApiKey, error)
CreateProjectAPIKey creates a project API key. If expiresIn is greater than zero, the key is set to expire that duration from now so it is cleaned up automatically on the server side even if local cleanup fails. An expiresIn of zero creates a key without expiry; a negative value is rejected.
func (*CommandHelper) CreateWorkspace ¶ added in v1.0.0
func (*CommandHelper) CreateWorkspaceAPIKey ¶ added in v1.0.0
func (h *CommandHelper) CreateWorkspaceAPIKey(ctx context.Context, workspaceID, name string) (*cloud.WorkspaceApiKey, error)
func (*CommandHelper) DeleteEventStream ¶ added in v0.3.2
func (h *CommandHelper) DeleteEventStream(ctx context.Context, projectID, streamID string) error
func (*CommandHelper) DeleteOrganization ¶ added in v0.3.0
func (h *CommandHelper) DeleteOrganization(ctx context.Context, projectID, orgID string) error
func (*CommandHelper) DeleteProjectAPIKey ¶ added in v1.0.0
func (h *CommandHelper) DeleteProjectAPIKey(ctx context.Context, projectID, keyID string) error
func (*CommandHelper) DeleteWorkspaceAPIKey ¶ added in v1.0.0
func (h *CommandHelper) DeleteWorkspaceAPIKey(ctx context.Context, workspaceID, keyID string) error
func (*CommandHelper) GetAuthenticatedConfig ¶ added in v1.0.0
func (h *CommandHelper) GetAuthenticatedConfig(ctx context.Context) (*Config, error)
func (*CommandHelper) GetProject ¶
func (*CommandHelper) GetSelectedProject ¶ added in v1.0.0
func (h *CommandHelper) GetSelectedProject(ctx context.Context) (*client.ProjectMetadata, error)
func (*CommandHelper) GetWorkspace ¶ added in v1.1.0
func (*CommandHelper) ListEventStreams ¶ added in v0.3.2
func (h *CommandHelper) ListEventStreams(ctx context.Context, projectID string) (*cloud.ListEventStreams, error)
func (*CommandHelper) ListOrganizations ¶ added in v0.3.0
func (h *CommandHelper) ListOrganizations(ctx context.Context, projectID string) (*cloud.ListOrganizationsResponse, error)
func (*CommandHelper) ListProjects ¶
func (h *CommandHelper) ListProjects(ctx context.Context, workspace *string) ([]client.ProjectMetadata, error)
func (*CommandHelper) ListWorkspaces ¶ added in v1.0.0
func (*CommandHelper) OpenURL ¶ added in v1.0.0
func (h *CommandHelper) OpenURL(uri string) error
func (*CommandHelper) PatchProject ¶
func (h *CommandHelper) PatchProject(ctx context.Context, id string, raw []json.RawMessage, add, replace, del []string) (*client.SuccessfulProjectUpdate, error)
func (*CommandHelper) PrintUpdateProjectWarnings ¶
func (h *CommandHelper) PrintUpdateProjectWarnings(p *client.SuccessfulProjectUpdate) error
func (*CommandHelper) ProjectAuthToken ¶ added in v1.0.0
func (h *CommandHelper) ProjectAuthToken(ctx context.Context) (oauth2.TokenSource, func(string) *url.URL, error)
func (*CommandHelper) ProjectID ¶ added in v1.0.0
func (h *CommandHelper) ProjectID() (string, error)
func (*CommandHelper) SelectProject ¶ added in v1.0.0
func (h *CommandHelper) SelectProject(id string) error
func (*CommandHelper) SelectWorkspace ¶ added in v1.0.0
func (h *CommandHelper) SelectWorkspace(id string) error
func (*CommandHelper) TemporaryAPIKey ¶ added in v1.0.0
func (h *CommandHelper) TemporaryAPIKey(ctx context.Context, name string, expiresIn time.Duration) (apiKey string, cleanup func() error, err error)
TemporaryAPIKey creates a short-lived project API key that is deleted via the returned cleanup function. The key is additionally set to expire after expiresIn so that it is removed automatically should the cleanup fail. An expiresIn of zero creates a key without expiry.
func (*CommandHelper) UpdateConfig ¶ added in v1.0.0
func (h *CommandHelper) UpdateConfig(c *Config) error
func (*CommandHelper) UpdateEventStream ¶ added in v0.3.2
func (h *CommandHelper) UpdateEventStream(ctx context.Context, projectID, streamID string, body cloud.SetEventStreamBody) (*cloud.EventStream, error)
func (*CommandHelper) UpdateOrganization ¶ added in v0.3.0
func (h *CommandHelper) UpdateOrganization(ctx context.Context, projectID, orgID string, body cloud.OrganizationBody) (*cloud.Organization, error)
func (*CommandHelper) UpdateProject ¶
func (h *CommandHelper) UpdateProject(ctx context.Context, id string, name string, configs []json.RawMessage) (*client.SuccessfulProjectUpdate, error)
func (*CommandHelper) UserName ¶ added in v1.0.0
func (h *CommandHelper) UserName(ctx context.Context) string
func (*CommandHelper) WorkspaceID ¶ added in v1.0.0
func (h *CommandHelper) WorkspaceID() *string
type CommandHelperOption ¶ added in v1.0.0
type CommandHelperOption func(*CommandHelper)
func WithConfigLocation ¶ added in v1.0.0
func WithConfigLocation(location string) CommandHelperOption
func WithNoConfirm ¶ added in v1.0.0
func WithNoConfirm(noConfirm bool) CommandHelperOption
func WithOpenBrowserHook ¶ added in v1.0.0
func WithOpenBrowserHook(openBrowser func(string) error) CommandHelperOption
func WithProjectAPIKey ¶ added in v1.0.0
func WithProjectAPIKey(apiKey string) CommandHelperOption
func WithProjectOverride ¶ added in v1.0.0
func WithProjectOverride(project string) CommandHelperOption
func WithQuiet ¶ added in v1.0.0
func WithQuiet(isQuiet bool) CommandHelperOption
func WithStdin ¶ added in v1.0.0
func WithStdin(r io.Reader) CommandHelperOption
func WithVerboseErrWriter ¶ added in v1.0.0
func WithVerboseErrWriter(w io.Writer) CommandHelperOption
func WithWorkspaceAPIKey ¶ added in v1.0.0
func WithWorkspaceAPIKey(apiKey string) CommandHelperOption
func WithWorkspaceOverride ¶ added in v1.0.0
func WithWorkspaceOverride(workspace string) CommandHelperOption
type Config ¶ added in v1.0.0
type Config struct {
Version string `json:"version"`
AccessToken *oauth2.Token `json:"access_token"`
SelectedProject uuid.UUID `json:"selected_project"`
SelectedWorkspace uuid.UUID `json:"selected_workspace"`
IdentityTraits Identity `json:"session_identity_traits"`
// contains filtered or unexported fields
}
func (*Config) TokenSource ¶ added in v1.0.0
func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource