-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: onboard APIs for the developer portal #333
- Loading branch information
Showing
17 changed files
with
919 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
_ = Cmd.MarkFlagRequired("org") | ||
_ = Cmd.MarkFlagRequired("siteid") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
Cmd.AddCommand(DelCmd) | ||
Cmd.AddCommand(DocCmd) | ||
|
||
_ = Cmd.MarkFlagRequired("org") | ||
_ = Cmd.MarkFlagRequired("siteid") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
"", "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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
Oops, something went wrong.