Skip to content

Commit

Permalink
Onboard new APIs to apigeecli (#335)
Browse files Browse the repository at this point in the history
* WIP: onboard APIs for the developer portal #333

* feat: onboard new APIs to apigeecli

* chore: fix arg descriptions

* feat: adds create sec actions support

* chore: fix arg descriptions

* chore: fix arg descriptions

* feat: add security reports api

* feat: update org create parameters

* feat: adds security reports api

* feat: adds security profiles api

* feat: adds security reports api

* feat: updates org provisioning

* feat: adds get security incidents

* chore: fix linting issues

* chore: fix linting issues

* feat: onboard sec profile create

* chore: update desc to rename name to uuid

* bug: fixes the json format of update apidocs

* Changes for issues found testing newapis

* Changes to param names to make datastores and securityprofiles work

* feat: support export of sec profiles

* feat: support export of sec profiles

* chore: fix linting issues

* chore: fix param description

---------

Co-authored-by: Kurt Kanaskie <kurtkanaskie@google.com>
  • Loading branch information
srinandan and kurtkanaskie authored Dec 1, 2023
1 parent f7fa956 commit 9d3ff8b
Show file tree
Hide file tree
Showing 62 changed files with 3,449 additions and 88 deletions.
43 changes: 43 additions & 0 deletions cmd/apicategories/apicategories.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apicategories

import (
"github.com/spf13/cobra"
)

// Cmd to manage api catalog items
var Cmd = &cobra.Command{
Use: "apicategories",
Short: "Manage Apigee API categories that are tagged on catalog items",
Long: "Manage Apigee API categories that are tagged on catalog items",
}

var org, siteid, id string

func init() {
Cmd.PersistentFlags().StringVarP(&org, "org", "o",
"", "Apigee organization name")
Cmd.PersistentFlags().StringVarP(&siteid, "siteid", "s",
"", "Name or siteid of the portal")

Cmd.AddCommand(ListCmd)
Cmd.AddCommand(GetCmd)
Cmd.AddCommand(DelCmd)
Cmd.AddCommand(CreateCmd)

_ = Cmd.MarkFlagRequired("org")
_ = Cmd.MarkFlagRequired("siteid")
}
45 changes: 45 additions & 0 deletions cmd/apicategories/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apicategories

import (
"internal/apiclient"

"internal/client/apicategories"

"github.com/spf13/cobra"
)

// CreateCmd to get a catalog items
var CreateCmd = &cobra.Command{
Use: "create",
Short: "Creates a new API category",
Long: "Creates a new API category",
Args: func(cmd *cobra.Command, args []string) (err error) {
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = apicategories.Create(siteid, name)
return
},
}

var name string

func init() {
CreateCmd.Flags().StringVarP(&name, "name", "n",
"", "API Category name")
_ = CreateCmd.MarkFlagRequired("name")
}
42 changes: 42 additions & 0 deletions cmd/apicategories/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apicategories

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

"github.com/spf13/cobra"
)

// DelCmd to get a catalog items
var DelCmd = &cobra.Command{
Use: "delete",
Short: "Deletes an API Category by ID",
Long: "Deletes an API Category by ID",
Args: func(cmd *cobra.Command, args []string) (err error) {
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = apicategories.Delete(siteid, id)
return
},
}

func init() {
DelCmd.Flags().StringVarP(&id, "id", "i",
"", "API Category ID")
_ = DelCmd.MarkFlagRequired("id")
}
43 changes: 43 additions & 0 deletions cmd/apicategories/get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apicategories

import (
"internal/apiclient"

"internal/client/apicategories"

"github.com/spf13/cobra"
)

// GetCmd to get a catalog items
var GetCmd = &cobra.Command{
Use: "get",
Short: "Gets an API Category by ID",
Long: "Gets an API Category by ID",
Args: func(cmd *cobra.Command, args []string) (err error) {
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = apicategories.Get(siteid, id)
return
},
}

func init() {
GetCmd.Flags().StringVarP(&id, "id", "i",
"", "API Category ID")
_ = GetCmd.MarkFlagRequired("id")
}
36 changes: 36 additions & 0 deletions cmd/apicategories/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apicategories

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

"github.com/spf13/cobra"
)

// ListCmd to list apicategories
var ListCmd = &cobra.Command{
Use: "list",
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) {
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = apicategories.List(siteid)
return
},
}
45 changes: 45 additions & 0 deletions cmd/apidocs/apidocs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apidocs

import (
"github.com/spf13/cobra"
)

// Cmd to manage apis
var Cmd = &cobra.Command{
Use: "apidocs",
Short: "Manage Apigee API catalog item through ApiDoc",
Long: "Manage Apigee API catalog item through ApiDoc",
}

var org, siteid, id, name string

func init() {
Cmd.PersistentFlags().StringVarP(&org, "org", "o",
"", "Apigee organization name")
Cmd.PersistentFlags().StringVarP(&siteid, "siteid", "s",
"", "Name or siteid of the portal")

Cmd.AddCommand(ListCmd)
Cmd.AddCommand(GetCmd)
Cmd.AddCommand(DelCmd)
Cmd.AddCommand(DocCmd)
Cmd.AddCommand(CreateCmd)
Cmd.AddCommand(UpdateCmd)

_ = Cmd.MarkFlagRequired("org")
_ = Cmd.MarkFlagRequired("siteid")
}
84 changes: 84 additions & 0 deletions cmd/apidocs/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apidocs

import (
"fmt"
"strconv"

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

"github.com/spf13/cobra"
)

// CreateCmd to create a catalog items
var CreateCmd = &cobra.Command{
Use: "create",
Short: "Create a new catalog item",
Long: "Create a new catalog item",
Args: func(cmd *cobra.Command, args []string) (err error) {
_, err = strconv.ParseBool(published)
if err != nil {
return fmt.Errorf("published must be a boolean value: %v", err)
}
_, err = strconv.ParseBool(anonAllowed)
if err != nil {
return fmt.Errorf("allow-anon must be a boolean value: %v", err)
}

_, err = strconv.ParseBool(requireCallbackUrl)
if err != nil {
return fmt.Errorf("require-callback-url must be a boolean value: %v", err)
}

return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = apidocs.Create(siteid, title, description, published,
anonAllowed, apiProductName, requireCallbackUrl, imageUrl, categoryIds)
return
},
}

var (
title, description, published, anonAllowed, apiProductName string
requireCallbackUrl, imageUrl string
categoryIds []string
)

func init() {
CreateCmd.Flags().StringVarP(&title, "title", "l",
"", "The user-facing name of the catalog item")
CreateCmd.Flags().StringVarP(&description, "desc", "d",
"", "Description of the catalog item")
CreateCmd.Flags().StringVarP(&published, "published", "p",
"", "Denotes whether the catalog item is published to the portal or is in a draft state")
CreateCmd.Flags().StringVarP(&anonAllowed, "allow-anon", "",
"", "Boolean flag that manages user access to the catalog item")
CreateCmd.Flags().StringVarP(&apiProductName, "api-product", "",
"", "The name field of the associated API product")
CreateCmd.Flags().StringVarP(&requireCallbackUrl, "require-callback-url", "",
"", "Whether a callback URL is required when this catalog item's developer app is created")
CreateCmd.Flags().StringVarP(&imageUrl, "image-url", "",
"", "Location of the image used for the catalog item in the catalog")

CreateCmd.Flags().StringArrayVarP(&categoryIds, "category-ids", "",
nil, "The IDs of the API categories to which this catalog item belongs")

_ = CreateCmd.MarkFlagRequired("name")
_ = CreateCmd.MarkFlagRequired("title")
_ = CreateCmd.MarkFlagRequired("apiProductName")
}
42 changes: 42 additions & 0 deletions cmd/apidocs/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apidocs

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

"github.com/spf13/cobra"
)

// DelCmd to get a catalog items
var DelCmd = &cobra.Command{
Use: "delete",
Short: "Deletes a catalog item",
Long: "Deletes a catalog item",
Args: func(cmd *cobra.Command, args []string) (err error) {
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = apidocs.Delete(siteid, id)
return
},
}

func init() {
DelCmd.Flags().StringVarP(&id, "id", "i",
"", "Catalog ID")
_ = DelCmd.MarkFlagRequired("id")
}
Loading

0 comments on commit 9d3ff8b

Please sign in to comment.