-
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.
feat: export and import apicategories (#353)
* feat: export apicategories #352 * chore: fix vscode settings * feat: aads support to import apicategories #352 * feat: include import cmd for categories #352
- Loading branch information
Showing
7 changed files
with
202 additions
and
2 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
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
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,52 @@ | ||
// 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 ( | ||
"os" | ||
|
||
"internal/apiclient" | ||
|
||
"internal/client/apicategories" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// ExpCmd to export apidocs | ||
var ExpCmd = &cobra.Command{ | ||
Use: "export", | ||
Short: "Export API Categories across all sites", | ||
Long: "Export API Categories across all sites", | ||
Args: func(cmd *cobra.Command, args []string) (err error) { | ||
return apiclient.SetApigeeOrg(org) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
if folder == "" { | ||
folder, _ = os.Getwd() | ||
} | ||
if err = apiclient.FolderExists(folder); err != nil { | ||
return err | ||
} | ||
apiclient.DisableCmdPrintHttpResponse() | ||
return apicategories.Export(folder) | ||
}, | ||
} | ||
|
||
var folder string | ||
|
||
func init() { | ||
ExpCmd.Flags().StringVarP(&folder, "folder", "f", | ||
"", "folder to export API Docs") | ||
} |
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,50 @@ | ||
// 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 ( | ||
"fmt" | ||
|
||
"internal/apiclient" | ||
|
||
"internal/client/apicategories" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// ImpCmd to import products | ||
var ImpCmd = &cobra.Command{ | ||
Use: "import", | ||
Short: "Import from a folder containing apicategories", | ||
Long: "Import from a folder containing apicategories", | ||
Args: func(cmd *cobra.Command, args []string) (err error) { | ||
return apiclient.SetApigeeOrg(org) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if siteid == "" { | ||
return fmt.Errorf("siteid is a mandatory parameter") | ||
} | ||
return apicategories.Import(siteid, apicategoryFile) | ||
}, | ||
} | ||
|
||
var apicategoryFile string | ||
|
||
func init() { | ||
ImpCmd.Flags().StringVarP(&apicategoryFile, "file", "f", | ||
"", "A file containing apicategories") | ||
|
||
_ = ImpCmd.MarkFlagRequired("file") | ||
} |
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
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
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