Skip to content

Commit

Permalink
bug: adds validation for siteid #349
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Dec 4, 2023
1 parent 9d3ff8b commit fbaf93f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/apicategories/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package apicategories

import (
"fmt"

Check failure on line 18 in cmd/apicategories/create.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 18 in cmd/apicategories/create.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
"internal/apiclient"

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

import (
"fmt"

Check failure on line 18 in cmd/apicategories/delete.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 18 in cmd/apicategories/delete.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
"internal/apiclient"
"internal/client/apicategories"

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

import (
"fmt"

Check failure on line 18 in cmd/apicategories/get.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 18 in cmd/apicategories/get.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
"internal/apiclient"

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

import (
"fmt"
"internal/apiclient"
"internal/client/apicategories"

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

import (
"fmt"
"internal/apiclient"
"internal/client/apidocs"

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

import (
"fmt"
"internal/apiclient"
"internal/client/apidocs"

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

import (
"fmt"
"internal/apiclient"
"internal/client/apidocs"

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

import (
"fmt"
"internal/apiclient"
"internal/client/apidocs"

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

Please sign in to comment.