datum

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package datum is our cobra/viper cli implementation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
var (
	// DatumHost contains the root url for the Datum API
	DatumHost string
	// GraphAPIHost contains the url for the Datum graph api
	GraphAPIHost string
)
View Source
var (
	Logger *zap.SugaredLogger
)
View Source
var RootCmd = &cobra.Command{
	Use:   appName,
	Short: "the datum cli",
}

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

func GetKeyring() (keyring.Keyring, error)

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

func GetRoleEnum(role string) (enums.Role, error)

GetRoleEnum returns the Role if valid, otherwise returns an error

func GetTokenFromKeyring

func GetTokenFromKeyring(ctx context.Context) (*oauth2.Token, string, error)

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 JSONPrint

func JSONPrint(s []byte) error

func StoreSession added in v0.2.5

func StoreSession(session string) error

StoreSession in local keyring

func StoreSessionCookies added in v0.2.5

func StoreSessionCookies(client *datumclient.Client)

StoreSessionCookies gets the session cookie from the cookie jar and stores it in the keychain for future requests

func StoreToken

func StoreToken(token *oauth2.Token) error

StoreToken in local keyring

func ViperBindFlag

func ViperBindFlag(name string, flag *pflag.Flag)

ViperBindFlag provides a wrapper around the viper bindings that panics if an error occurs

Types

type CLI

type CLI struct {
	Client      datumclient.DatumClient
	Interceptor clientv2.RequestInterceptor
	AccessToken string
}

func GetGraphClient added in v0.3.1

func GetGraphClient(ctx context.Context) (*CLI, error)

func GetRestClient added in v0.3.1

func GetRestClient(ctx context.Context) (*CLI, error)

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 datumgroup is our cobra/viper cli for group endpoints
Package datumgroup is our cobra/viper cli for group endpoints
Package datumgroupmembers is our cobra/viper cli for group member endpoints
Package datumgroupmembers is our cobra/viper 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/viper cli for authentication endpoints
Package datumlogin is our cobra/viper cli for authentication endpoints
Package datumorg is our cobra/viper cli for organization endpoints
Package datumorg is our cobra/viper cli for organization endpoints
Package datumorgmembers is our cobra/viper cli for org member endpoints
Package datumorgmembers is our cobra/viper cli for org member endpoints
Package datumorgsetting provides commands for managing organization settings
Package datumorgsetting provides commands for managing organization settings
Package register allows user registration
Package register allows user registration
Package reset allows user password reset
Package reset allows user password reset
Package datumsubscribers is our cobra/viper cli for subscriber endpoints
Package datumsubscribers is our cobra/viper cli for subscriber endpoints
Package datumtokens is our cobra/viper cli for token endpoints
Package datumtokens is our cobra/viper cli for token endpoints
Package datumuser is our cobra/viper cli for user endpoints
Package datumuser is our cobra/viper cli for user endpoints
Package datumusersetting is our cobra/viper cli for user setting endpoints
Package datumusersetting is our cobra/viper cli for user setting endpoints
Package version contains the version information for the CLI
Package version contains the version information for the CLI

Jump to

Keyboard shortcuts

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