apidocs

package
v1.125.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "apidocs",
	Short: "Manage Apigee API catalog item through ApiDoc",
	Long:  "Manage Apigee API catalog item through ApiDoc",
}

Cmd to manage apis

View Source
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)
		}
		if siteid == "" {
			return fmt.Errorf("siteid is a mandatory parameter")
		}
		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
	},
}

CreateCmd to create a catalog items

View Source
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) {
		if siteid == "" {
			return fmt.Errorf("siteid is a mandatory parameter")
		}
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = apidocs.Delete(siteid, id)
		return
	},
}

DelCmd to get a catalog items

View Source
var DocCmd = &cobra.Command{
	Use:   "documentation",
	Short: "Manage the documentation for the specified catalog item",
	Long:  "Manage the documentation for the specified catalog item",
}

DocCmd to manage apis

View Source
var ExpCmd = &cobra.Command{
	Use:   "export",
	Short: "Export API Docs to a file",
	Long:  "Export API Docs to a file",
	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 apidocs.Export(folder)
	},
}

ExpCmd to export apidocs

View Source
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) {
		if siteid == "" {
			return fmt.Errorf("siteid is a mandatory parameter")
		}
		if name == "" && id == "" {
			return fmt.Errorf("title or id must be set as a parameter")
		}
		if name != "" && id != "" {
			return fmt.Errorf("title and id cannot be set as a parameter")
		}
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		if name != "" {
			var payload []byte
			if payload, err = apidocs.GetByTitle(siteid, name); err != nil {
				return err
			}
			return apiclient.PrettyPrint("application/json", payload)
		}
		_, err = apidocs.Get(siteid, id)
		return
	},
}

GetCmd to get a catalog items

View Source
var GetDocCmd = &cobra.Command{
	Use:   "get",
	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) {
		_, err = apidocs.GetDocumentation(siteid, id)
		return
	},
}

GetDocCmd to get a catalog items

View Source
var ImpCmd = &cobra.Command{
	Use:   "import",
	Short: "Import from a folder containing apidocs",
	Long:  "Import from a folder containing apidocs",
	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) error {
		return apidocs.Import(siteid, useSrcSiteID, folder)
	},
}

ImpCmd to import products

View Source
var ListCmd = &cobra.Command{
	Use:   "list",
	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) {
		_, err = apidocs.List(siteid, pageSize, pageToken)
		return
	},
}

ListCmd to list catalog items

View Source
var UpdateCmd = &cobra.Command{
	Use:   "update",
	Short: "Update an existing catalog item",
	Long:  "Update an existing 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)
		}
		if siteid == "" {
			return fmt.Errorf("siteid is a mandatory parameter")
		}
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = apidocs.Update(siteid, id, title, description, published,
			anonAllowed, apiProductName, requireCallbackUrl, imageUrl, categoryIds)
		return
	},
}

UpdateCmd to create a catalog items

View Source
var UpdateDocCmd = &cobra.Command{
	Use:   "update",
	Short: "Updates the documentation for the specified catalog item",
	Long:  "Updates the documentation for the specified catalog item",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		if openAPIPath == "" && graphQLPath == "" {
			return fmt.Errorf("The flags openapi and grapql cannot both be empty")
		}
		if openAPIPath != "" && graphQLPath != "" {
			return fmt.Errorf("The flags openapi and grapql cannot both be set")
		}
		if graphQLPath != "" && endpointUri == "" {
			return fmt.Errorf("The flags graphQLPath and endpointUri must be set together")
		}
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		var openAPIDoc, graphQLDoc []byte
		var openAPI, graphQL string

		if openAPIPath != "" {
			if openAPIDoc, err = utils.ReadFile(openAPIPath); err != nil {
				return err
			}
			if openAPIDoc, err = json.Marshal(openAPIDoc); err != nil {
				return err
			}
			openAPI = string(openAPIDoc)
		}

		if graphQLPath != "" {
			graphQLDoc, err = utils.ReadFile(graphQLPath)
			if err != nil {
				return err
			}
			if graphQLDoc, err = json.Marshal(graphQLDoc); err != nil {
				return err
			}
			graphQL = string(graphQLDoc)
		}

		_, err = apidocs.UpdateDocumentation(siteid, id, name, openAPI, graphQL, endpointUri)
		return
	},
}

UpdateDocCmd to get a catalog items

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL