Skip to content

Commit

Permalink
bug: undo delete by appname #338
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Dec 4, 2023
1 parent ef6c758 commit ee26840
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions cmd/apps/delapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
package apps

import (
"encoding/json"
"fmt"

"internal/apiclient"

"internal/client/apps"
Expand All @@ -34,34 +31,18 @@ var DelCmd = &cobra.Command{
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
var respBody []byte
var id string

apiclient.DisableCmdPrintHttpResponse()
if respBody, err = apps.SearchApp(name); err != nil {
return err
}

if id, err = getDeveloperID(respBody); err != nil {
return err
}
apiclient.EnableCmdPrintHttpResponse()
_, err = apps.Delete(name, id)
return
},
}

var id string

func init() {
DelCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the developer app")

DelCmd.Flags().StringVarP(&id, "id", "i",
"", "Developer Id")
_ = DelCmd.MarkFlagRequired("name")
}

func getDeveloperID(respBody []byte) (id string, err error) {
var respMap map[string]interface{}
if err = json.Unmarshal(respBody, &respMap); err != nil {
return "", err
}
return fmt.Sprintf("%v", respMap["developerId"]), nil
_ = DelCmd.MarkFlagRequired("id")
}

0 comments on commit ee26840

Please sign in to comment.