From fbaf93fb4c617f99ca8e487aa17d3a23230c3535 Mon Sep 17 00:00:00 2001 From: srinandan <13950006+srinandan@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:08:04 -0800 Subject: [PATCH] bug: adds validation for siteid #349 --- cmd/apicategories/create.go | 4 ++++ cmd/apicategories/delete.go | 4 ++++ cmd/apicategories/get.go | 4 ++++ cmd/apicategories/list.go | 4 ++++ cmd/apidocs/create.go | 4 +++- cmd/apidocs/delete.go | 4 ++++ cmd/apidocs/get.go | 4 ++++ cmd/apidocs/getdocs.go | 4 ++++ cmd/apidocs/list.go | 4 ++++ cmd/apidocs/update.go | 4 +++- 10 files changed, 38 insertions(+), 2 deletions(-) diff --git a/cmd/apicategories/create.go b/cmd/apicategories/create.go index b756d1ce8..134f012a4 100644 --- a/cmd/apicategories/create.go +++ b/cmd/apicategories/create.go @@ -15,6 +15,7 @@ package apicategories import ( + "fmt" "internal/apiclient" "internal/client/apicategories" @@ -31,6 +32,9 @@ var CreateCmd = &cobra.Command{ return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } _, err = apicategories.Create(siteid, name) return }, diff --git a/cmd/apicategories/delete.go b/cmd/apicategories/delete.go index 4f50432cf..e9987cf9d 100644 --- a/cmd/apicategories/delete.go +++ b/cmd/apicategories/delete.go @@ -15,6 +15,7 @@ package apicategories import ( + "fmt" "internal/apiclient" "internal/client/apicategories" @@ -30,6 +31,9 @@ var DelCmd = &cobra.Command{ return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } _, err = apicategories.Delete(siteid, id) return }, diff --git a/cmd/apicategories/get.go b/cmd/apicategories/get.go index 8fa3e2cdc..b097ddf62 100644 --- a/cmd/apicategories/get.go +++ b/cmd/apicategories/get.go @@ -15,6 +15,7 @@ package apicategories import ( + "fmt" "internal/apiclient" "internal/client/apicategories" @@ -31,6 +32,9 @@ var GetCmd = &cobra.Command{ return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } _, err = apicategories.Get(siteid, id) return }, diff --git a/cmd/apicategories/list.go b/cmd/apicategories/list.go index ffa185611..8966d9278 100644 --- a/cmd/apicategories/list.go +++ b/cmd/apicategories/list.go @@ -15,6 +15,7 @@ package apicategories import ( + "fmt" "internal/apiclient" "internal/client/apicategories" @@ -27,6 +28,9 @@ var ListCmd = &cobra.Command{ Short: "Returns the API categories associated with a portal", Long: "Returns the API categories associated with a portal", Args: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/apidocs/create.go b/cmd/apidocs/create.go index 1a1cc19dc..1a41e370a 100644 --- a/cmd/apidocs/create.go +++ b/cmd/apidocs/create.go @@ -43,7 +43,9 @@ var CreateCmd = &cobra.Command{ if err != nil { return fmt.Errorf("require-callback-url must be a boolean value: %v", err) } - + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/apidocs/delete.go b/cmd/apidocs/delete.go index 9edafbc4b..746d5fab2 100644 --- a/cmd/apidocs/delete.go +++ b/cmd/apidocs/delete.go @@ -15,6 +15,7 @@ package apidocs import ( + "fmt" "internal/apiclient" "internal/client/apidocs" @@ -27,6 +28,9 @@ var DelCmd = &cobra.Command{ Short: "Deletes a catalog item", Long: "Deletes a catalog item", Args: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/apidocs/get.go b/cmd/apidocs/get.go index 73ef3cd27..b55c59d7a 100644 --- a/cmd/apidocs/get.go +++ b/cmd/apidocs/get.go @@ -15,6 +15,7 @@ package apidocs import ( + "fmt" "internal/apiclient" "internal/client/apidocs" @@ -27,6 +28,9 @@ var GetCmd = &cobra.Command{ Short: "Gets a catalog item", Long: "Gets a catalog item", Args: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/apidocs/getdocs.go b/cmd/apidocs/getdocs.go index 49ed51e98..9e3a930ae 100644 --- a/cmd/apidocs/getdocs.go +++ b/cmd/apidocs/getdocs.go @@ -15,6 +15,7 @@ package apidocs import ( + "fmt" "internal/apiclient" "internal/client/apidocs" @@ -27,6 +28,9 @@ var GetDocCmd = &cobra.Command{ Short: "Gets the documentation for the specified catalog item", Long: "Gets the documentation for the specified catalog item", Args: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/apidocs/list.go b/cmd/apidocs/list.go index 38a7f5284..f046d417d 100644 --- a/cmd/apidocs/list.go +++ b/cmd/apidocs/list.go @@ -15,6 +15,7 @@ package apidocs import ( + "fmt" "internal/apiclient" "internal/client/apidocs" @@ -27,6 +28,9 @@ var ListCmd = &cobra.Command{ Short: "Returns the catalog items associated with a portal", Long: "Returns the catalog items associated with a portal", Args: func(cmd *cobra.Command, args []string) (err error) { + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/apidocs/update.go b/cmd/apidocs/update.go index 6c37fe3eb..1e0fcd254 100644 --- a/cmd/apidocs/update.go +++ b/cmd/apidocs/update.go @@ -44,7 +44,9 @@ var UpdateCmd = &cobra.Command{ if err != nil { return fmt.Errorf("require-callback-url must be a boolean value: %v", err) } - + if siteid == "" { + return fmt.Errorf("siteid is a mandatory parameter") + } return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) {