diff --git a/HACKING b/HACKING index a825f544..cbf0bb04 100644 --- a/HACKING +++ b/HACKING @@ -149,6 +149,8 @@ Here's a tree of the folders in this repo with descriptions of what each is for │   │ │ other types in lib. │   │ │ DefaultFieldsHaver interface defined and tested-for here │   │ │ (required for table & list output types) +│   │   ├── morestrings - extra string manipulation functions used by multiple +│   │ │ packages │   │   └── prettyprint - PrettyPrinter interface and a helper function for │ │ writing PrettyPrinters │   │ All the types in lib/billing, lib/brain and lib/spp @@ -240,4 +242,4 @@ To generate the hash, use the following command. find . -type d \! -path './.*' \! -path './vendor/*' | sort | shasum -a 256 -# sha256sum: 993688b7f02276dcbd79d543b41f9994be2776ca163c8c40b6cc346435f834ce +# sha256sum: 14ec7f63021ea2d5f870bb638e911e540294fee5247a4e90f0b4020baf70071a diff --git a/cmd/bytemark/commands/add/api_key.go b/cmd/bytemark/commands/add/api_key.go new file mode 100644 index 00000000..8050fdd7 --- /dev/null +++ b/cmd/bytemark/commands/add/api_key.go @@ -0,0 +1,298 @@ +package add + +import ( + "errors" + "fmt" + "strings" + + "github.com/BytemarkHosting/bytemark-client/cmd/bytemark/app" + "github.com/BytemarkHosting/bytemark-client/cmd/bytemark/app/args" + "github.com/BytemarkHosting/bytemark-client/cmd/bytemark/app/flags" + "github.com/BytemarkHosting/bytemark-client/cmd/bytemark/app/with" + "github.com/BytemarkHosting/bytemark-client/lib/brain" + "github.com/BytemarkHosting/bytemark-client/lib/output/morestrings" + "github.com/BytemarkHosting/bytemark-client/lib/output/prettyprint" + brainRequests "github.com/BytemarkHosting/bytemark-client/lib/requests/brain" + "github.com/urfave/cli" +) + +func init() { + Commands = append(Commands, cli.Command{ + Name: "api key", + Aliases: []string{"apikey"}, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "expires-at", + Usage: "Date the API key should expire. Leave unset for keys that never expire", + }, + cli.GenericFlag{ + Name: "account-admin", + Usage: "Account to grant the API key administrative privilege over", + Value: &flags.AccountNameSliceFlag{}, + }, + cli.GenericFlag{ + Name: "group", + Usage: "Group to grant the API key administrative privilege over", + Value: &flags.GroupNameSliceFlag{}, + }, + cli.StringFlag{ + Name: "label", + Usage: "user-friendly label for the API key", + }, + cli.GenericFlag{ + Name: "server", + Usage: "Server to grant the API key administrative privilege over", + Value: &flags.VirtualMachineNameSliceFlag{}, + }, + cli.StringFlag{ + Name: "user", + Usage: "User the API key will be attached to. Defaults to the user you log in as", + }, + }, + Usage: "add an API key to your Bytemark Cloud Servers user", + UsageText: "add api key [--server ]... [--group ]... [--account-admin ]... [--user ]