Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboard new APIs to apigeecli #335

Merged
merged 24 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
142e40d
WIP: onboard APIs for the developer portal #333
srinandan Nov 14, 2023
d295df7
feat: onboard new APIs to apigeecli
srinandan Nov 21, 2023
22b80bf
chore: fix arg descriptions
srinandan Nov 22, 2023
bff19ff
feat: adds create sec actions support
srinandan Nov 22, 2023
05f12c6
chore: fix arg descriptions
srinandan Nov 22, 2023
721e4cb
chore: fix arg descriptions
srinandan Nov 22, 2023
1202a67
feat: add security reports api
srinandan Nov 22, 2023
6059623
feat: update org create parameters
srinandan Nov 22, 2023
2bec7b6
feat: adds security reports api
srinandan Nov 24, 2023
8dc7627
feat: adds security profiles api
srinandan Nov 24, 2023
b467618
feat: adds security reports api
srinandan Nov 24, 2023
d2f7a2b
feat: updates org provisioning
srinandan Nov 24, 2023
37c5bf4
feat: adds get security incidents
srinandan Nov 24, 2023
285406a
chore: fix linting issues
srinandan Nov 24, 2023
05ceb19
chore: fix linting issues
srinandan Nov 24, 2023
319f2c0
feat: onboard sec profile create
srinandan Nov 27, 2023
5ca61a2
chore: update desc to rename name to uuid
srinandan Nov 27, 2023
cf9f72b
bug: fixes the json format of update apidocs
srinandan Nov 27, 2023
3241919
Changes for issues found testing newapis
kurtkanaskie Nov 28, 2023
c90226c
Changes to param names to make datastores and securityprofiles work
kurtkanaskie Dec 1, 2023
446f606
feat: support export of sec profiles
srinandan Dec 1, 2023
65e0463
feat: support export of sec profiles
srinandan Dec 1, 2023
def9726
chore: fix linting issues
srinandan Dec 1, 2023
6cb4803
chore: fix param description
srinandan Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions cmd/apicategories/apicategories.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 (
"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, 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)
srinandan marked this conversation as resolved.
Show resolved Hide resolved

_ = Cmd.MarkFlagRequired("org")
_ = Cmd.MarkFlagRequired("siteid")
}
43 changes: 43 additions & 0 deletions cmd/apicategories/create.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"
)

// 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
},
}

func init() {
CreateCmd.Flags().StringVarP(&name, "name", "n",
"", "Catalog 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 a catalog item",
Long: "Deletes a catalog item",
srinandan marked this conversation as resolved.
Show resolved Hide resolved
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, name)
return
},
}

func init() {
DelCmd.Flags().StringVarP(&name, "name", "n",
"", "Catalog name")
_ = DelCmd.MarkFlagRequired("name")
srinandan marked this conversation as resolved.
Show resolved Hide resolved
}
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 a catalog item",
Long: "Gets a catalog item",
srinandan marked this conversation as resolved.
Show resolved Hide resolved
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, name)
return
},
}

func init() {
GetCmd.Flags().StringVarP(&name, "name", "n",
"", "Catalog name")
_ = GetCmd.MarkFlagRequired("name")
srinandan marked this conversation as resolved.
Show resolved Hide resolved
}
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
},
}
43 changes: 43 additions & 0 deletions cmd/apidocs/apidocs.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 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, 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)
srinandan marked this conversation as resolved.
Show resolved Hide resolved
Cmd.AddCommand(DelCmd)
Cmd.AddCommand(DocCmd)

_ = 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", "t",
srinandan marked this conversation as resolved.
Show resolved Hide resolved
"", "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, name)
return
},
}

func init() {
DelCmd.Flags().StringVarP(&name, "name", "n",
"", "Catalog name")
_ = DelCmd.MarkFlagRequired("name")
srinandan marked this conversation as resolved.
Show resolved Hide resolved
}
Loading