users

package
v0.0.0-...-966d904 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = models.Command{
	Name:      "users",
	ShortHelp: "Manage users who have access to the given organization",
	LongHelp: "The <code>users</code> command allows you to manage who has access to your environment through the organization that owns the environment. " +
		"The users command can not be run directly but has three subcommands.",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.CommandLong(ListSubCmd.Name, ListSubCmd.ShortHelp, ListSubCmd.LongHelp, ListSubCmd.CmdFunc(settings))
			cmd.CommandLong(RmSubCmd.Name, RmSubCmd.ShortHelp, RmSubCmd.LongHelp, RmSubCmd.CmdFunc(settings))
		}
	},
}

Cmd is the contract between the user and the CLI. This specifies the command name, arguments, and required/optional arguments and flags for the command.

View Source
var ListSubCmd = models.Command{
	Name:      "list",
	ShortHelp: "List all users who have access to the given organization",
	LongHelp: "<code>users list</code> shows every user that belongs to your environment's organization. " +
		"Users who belong to your environment's organization may access to your environment's services and data depending on their role in the organization. " +
		"Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" users list\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdList(settings.UsersID, New(settings), invites.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
		}
	},
}
View Source
var RmSubCmd = models.Command{
	Name:      "rm",
	ShortHelp: "Revoke access to the given organization for the given user",
	LongHelp: "<code>users rm</code> revokes a users access to your environment's organization. " +
		"Revoking a user's access to your environment's organization will revoke their access to your organization's environments. " +
		"Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" users rm user@example.com\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			email := subCmd.StringArg("EMAIL", "", "The email address of the user to revoke access from for the given organization")
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdRm(*email, New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			subCmd.Spec = "EMAIL"
		}
	},
}

Functions

func CmdList

func CmdList(myUsersID string, iu IUsers, ii invites.IInvites) error

func CmdRm

func CmdRm(email string, iu IUsers) error

Types

type IUsers

type IUsers interface {
	List() (*[]models.OrgUser, error)
	Rm(usersID string) error
}

IUsers

func New

func New(settings *models.Settings) IUsers

New generates a new instance of IUsers

type SUsers

type SUsers struct {
	Settings *models.Settings
}

SUsers is a concrete implementation of IUsers

func (*SUsers) List

func (u *SUsers) List() (*[]models.OrgUser, error)

func (*SUsers) Rm

func (u *SUsers) Rm(usersID string) error

Jump to

Keyboard shortcuts

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