Skip to content

Commit

Permalink
bug: adds validation for siteid #349 (#350)
Browse files Browse the repository at this point in the history
* bug: adds validation for siteid #349

* chore: fix linting issues #349
  • Loading branch information
srinandan authored Dec 12, 2023
1 parent 42d0e76 commit 40cac48
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions cmd/apicategories/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apicategories

import (
"fmt"

"internal/apiclient"

"internal/client/apicategories"
Expand All @@ -31,6 +33,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
},
Expand Down
5 changes: 5 additions & 0 deletions cmd/apicategories/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apicategories

import (
"fmt"

"internal/apiclient"
"internal/client/apicategories"

Expand All @@ -30,6 +32,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
},
Expand Down
5 changes: 5 additions & 0 deletions cmd/apicategories/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apicategories

import (
"fmt"

"internal/apiclient"

"internal/client/apicategories"
Expand All @@ -31,6 +33,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
},
Expand Down
5 changes: 5 additions & 0 deletions cmd/apicategories/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apicategories

import (
"fmt"

"internal/apiclient"
"internal/client/apicategories"

Expand All @@ -27,6 +29,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) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/apidocs/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions cmd/apidocs/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apidocs

import (
"fmt"

"internal/apiclient"
"internal/client/apidocs"

Expand All @@ -27,6 +29,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) {
Expand Down
5 changes: 5 additions & 0 deletions cmd/apidocs/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apidocs

import (
"fmt"

"internal/apiclient"
"internal/client/apidocs"

Expand All @@ -27,6 +29,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) {
Expand Down
5 changes: 5 additions & 0 deletions cmd/apidocs/getdocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apidocs

import (
"fmt"

"internal/apiclient"
"internal/client/apidocs"

Expand All @@ -27,6 +29,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) {
Expand Down
5 changes: 5 additions & 0 deletions cmd/apidocs/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package apidocs

import (
"fmt"

"internal/apiclient"
"internal/client/apidocs"

Expand All @@ -27,6 +29,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) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/apidocs/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 40cac48

Please sign in to comment.