Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
crt and del developes
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jul 16, 2019
1 parent 9625731 commit b16b04a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cmd/developers/crtdev/crtdev.go
Original file line number Diff line number Diff line change
@@ -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")
}
29 changes: 29 additions & 0 deletions cmd/developers/deldev/deldev.go
Original file line number Diff line number Diff line change
@@ -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")
}
4 changes: 4 additions & 0 deletions cmd/developers/developers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"../shared"
"./getdev"
"./listdev"
"./deldev"
"./crtdev"
"github.com/spf13/cobra"
)

Expand All @@ -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)
}

0 comments on commit b16b04a

Please sign in to comment.