Documentation ¶
Overview ¶
Package datum is our cobra cli implementation
Index ¶
- Constants
- Variables
- func Execute()
- func GetInviteStatusEnum(status string) (enums.InviteStatus, error)
- func GetKeyring() (keyring.Keyring, error)
- func GetRoleEnum(role string) (enums.Role, error)
- func GetTokenFromKeyring(ctx context.Context) (*oauth2.Token, string, error)
- func JSONPrint(s []byte) error
- func ParseBytes(v []byte) (map[string]interface{}, error)
- func ParseJSON(v string) (map[string]interface{}, error)
- func SetupClient(ctx context.Context) (*datumclient.DatumClient, error)
- func SetupClientWithAuth(ctx context.Context) (*datumclient.DatumClient, error)
- func StoreSession(session string) error
- func StoreSessionCookies(client *datumclient.DatumClient)
- func StoreToken(token *oauth2.Token) error
- type RequiredFieldMissingError
Constants ¶
const ( TableOutput = "table" JSONOutput = "json" )
Variables ¶
var ( // ErrTokenRequired is returned when no authentication token is provided ErrTokenRequired = errors.New("DATUM_ACCESS_TOKEN not set") // ErrInvalidRole is returned when an invalid role is provided for a member ErrInvalidRole = errors.New("invalid role, only member and admin are allowed") // ErrInvalidInviteStatus is returned when an invalid status is provided for an invite ErrInvalidInviteStatus = errors.New("invalid status, only sent, required, accepted, expired are allowed") // ErrUnsupportedProvider is returned when an invalid provider is specified during login ErrUnsupportedProvider = errors.New("invalid provider, only Github and Google are supported") // ErrNotFound is returned when a resource is not found ErrNotFound = errors.New("resource not found") // ErrSessionNotFound is returned when a session is not found ErrSessionNotFound = errors.New("session not found") )
var ( OutputFormat string InputFile string Logger *zap.SugaredLogger Config *koanf.Koanf )
var ( // DatumHost contains the root url for the Datum API DatumHost string // GraphAPIHost contains the url for the Datum graph api GraphAPIHost string )
var RootCmd = &cobra.Command{ Use: appName, Short: "the datum cli", PersistentPreRun: func(cmd *cobra.Command, args []string) { initConfiguration(cmd) }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func GetInviteStatusEnum ¶ added in v0.2.6
func GetInviteStatusEnum(status string) (enums.InviteStatus, error)
GetInviteStatusEnum returns the invitation status if valid, otherwise returns an error
func GetKeyring ¶
GetKeyring will return the already loaded keyring so that we don't prompt users for passwords multiple times
func GetRoleEnum ¶ added in v0.2.5
GetRoleEnum returns the Role if valid, otherwise returns an error
func GetTokenFromKeyring ¶
GetTokenFromKeyring will return the oauth token from the keyring if the token is expired, but the refresh token is still valid, the token will be refreshed
func ParseBytes ¶ added in v0.5.0
ParseBytes parses buffered bytes into a map
func SetupClient ¶ added in v0.6.0
func SetupClient(ctx context.Context) (*datumclient.DatumClient, error)
SetupClient will setup the datum client without the Authorization header this is used for endpoints that do not require authentication, e.g. `v1/login`
func SetupClientWithAuth ¶ added in v0.6.0
func SetupClientWithAuth(ctx context.Context) (*datumclient.DatumClient, error)
SetupClientWithAuth will setup the datum client with the the bearer token passed in the Authorization header and the session cookie passed in the Cookie header. If the token is expired, it will be refreshed. The token and session will be stored in the keyring for future requests
func StoreSession ¶ added in v0.2.5
StoreSession in local keyring
func StoreSessionCookies ¶ added in v0.2.5
func StoreSessionCookies(client *datumclient.DatumClient)
StoreSessionCookies gets the session cookie from the cookie jar and stores it in the keychain for future requests
Types ¶
type RequiredFieldMissingError ¶
type RequiredFieldMissingError struct { // Field contains the required field that was missing from the input Field string }
RequiredFieldMissingError is returned when a field is required but not provided
func NewRequiredFieldMissingError ¶
func NewRequiredFieldMissingError(f string) *RequiredFieldMissingError
NewRequiredFieldMissingError returns an error for a missing required field
func (*RequiredFieldMissingError) Error ¶
func (e *RequiredFieldMissingError) Error() string
Error returns the RequiredFieldMissingError in string format
Directories ¶
Path | Synopsis |
---|---|
Package datumapitokens is our cobra cli for api token endpoints
|
Package datumapitokens is our cobra cli for api token endpoints |
Package datumgroup is our cobra cli for group endpoints
|
Package datumgroup is our cobra cli for group endpoints |
Package datumgroupmembers is our cobra cli for group member endpoints
|
Package datumgroupmembers is our cobra cli for group member endpoints |
Package datumgroupsetting provides commands for managing group settings
|
Package datumgroupsetting provides commands for managing group settings |
Package datuminvite creates invitation emails + tokens for external users to join a Datum organization
|
Package datuminvite creates invitation emails + tokens for external users to join a Datum organization |
Package datumlogin is our cobra cli for authentication endpoints
|
Package datumlogin is our cobra cli for authentication endpoints |
Package datumorg is our cobra cli for organization endpoints
|
Package datumorg is our cobra cli for organization endpoints |
Package datumorgmembers is our cobra cli for org member endpoints
|
Package datumorgmembers is our cobra cli for org member endpoints |
Package datumorgsetting provides commands for managing organization settings
|
Package datumorgsetting provides commands for managing organization settings |
Package datumtokens is our cobra cli for token endpoints
|
Package datumtokens is our cobra cli for token endpoints |
Package register allows user registration
|
Package register allows user registration |
Package reset allows user password reset
|
Package reset allows user password reset |
Package datumsearch is our cobra cli for search endpoint
|
Package datumsearch is our cobra cli for search endpoint |
Package datumsubscribers is our cobra cli for subscriber endpoints
|
Package datumsubscribers is our cobra cli for subscriber endpoints |
Package datumswitch provides a basic interface to switch between oragnization contexts
|
Package datumswitch provides a basic interface to switch between oragnization contexts |
Package datumuser is our cobra cli for user endpoints
|
Package datumuser is our cobra cli for user endpoints |
Package datumusersetting is our cobra cli for user setting endpoints
|
Package datumusersetting is our cobra cli for user setting endpoints |
Package version contains the version information for the CLI
|
Package version contains the version information for the CLI |