From b16b04aa3f1d63f917f9ff4bc2ff24ba1a7cc5f8 Mon Sep 17 00:00:00 2001 From: Nandan Sridhar Date: Mon, 15 Jul 2019 22:30:43 -0700 Subject: [PATCH] crt and del developes --- cmd/developers/crtdev/crtdev.go | 48 +++++++++++++++++++++++++++++++++ cmd/developers/deldev/deldev.go | 29 ++++++++++++++++++++ cmd/developers/developers.go | 4 +++ 3 files changed, 81 insertions(+) create mode 100644 cmd/developers/crtdev/crtdev.go create mode 100644 cmd/developers/deldev/deldev.go diff --git a/cmd/developers/crtdev/crtdev.go b/cmd/developers/crtdev/crtdev.go new file mode 100644 index 00000000..91b2a882 --- /dev/null +++ b/cmd/developers/crtdev/crtdev.go @@ -0,0 +1,48 @@ +package crtdev + +import ( + "../../shared" + "github.com/spf13/cobra" + "net/url" + "path" + "strings" +) + +var Cmd = &cobra.Command{ + Use: "create", + Short: "Create a developer", + Long: "Create a developer", + Run: func(cmd *cobra.Command, args []string) { + u, _ := url.Parse(shared.BaseURL) + + developer := []string{} + + developer = append(developer, "\"email\":\""+email+"\"") + developer = append(developer, "\"firstName\":\""+firstName+"\"") + developer = append(developer, "\"lastName\":\""+lastName+"\"") + developer = append(developer, "\"userName\":\""+userName+"\"") + + payload := "{"+strings.Join(developer,",")+"}" + u.Path = path.Join(u.Path, shared.RootArgs.Org, "developers") + shared.HttpClient(u.String(), payload) + }, +} + +var email, lastName, firstName, userName string + +func init() { + + Cmd.Flags().StringVarP(&email, "email", "n", + "", "The developer's email") + Cmd.Flags().StringVarP(&firstName, "first", "f", + "", "The first name of the developer") + Cmd.Flags().StringVarP(&lastName, "last", "s", + "", "The last name of the developer") + Cmd.Flags().StringVarP(&userName, "user", "u", + "", "The username of the developer") + + Cmd.MarkFlagRequired("email") + Cmd.MarkFlagRequired("first") + Cmd.MarkFlagRequired("last") + Cmd.MarkFlagRequired("user") +} diff --git a/cmd/developers/deldev/deldev.go b/cmd/developers/deldev/deldev.go new file mode 100644 index 00000000..7f3a363b --- /dev/null +++ b/cmd/developers/deldev/deldev.go @@ -0,0 +1,29 @@ +package deldev + +import ( + "../../shared" + "github.com/spf13/cobra" + "net/url" + "path" +) + +var Cmd = &cobra.Command{ + Use: "delete", + Short: "Deletes an App Developer from an organization", + Long: "Deletes an App Developer from an organization", + Run: func(cmd *cobra.Command, args []string) { + u, _ := url.Parse(shared.BaseURL) + u.Path = path.Join(u.Path, shared.RootArgs.Org, "developers", name) + shared.HttpClient(u.String(),"","DELETE") + }, +} + +var name string + +func init() { + + Cmd.Flags().StringVarP(&name, "name", "n", + "", "Name of the developer") + + Cmd.MarkFlagRequired("name") +} diff --git a/cmd/developers/developers.go b/cmd/developers/developers.go index 04fabe4d..c9fe2313 100644 --- a/cmd/developers/developers.go +++ b/cmd/developers/developers.go @@ -4,6 +4,8 @@ import ( "../shared" "./getdev" "./listdev" + "./deldev" + "./crtdev" "github.com/spf13/cobra" ) @@ -25,4 +27,6 @@ func init() { Cmd.MarkPersistentFlagRequired("org") Cmd.AddCommand(listdev.Cmd) Cmd.AddCommand(getdev.Cmd) + Cmd.AddCommand(deldev.Cmd) + Cmd.AddCommand(crtdev.Cmd) }