env

package
v1.113.6-beta Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArchiveCmd = &cobra.Command{
	Use:   "archives",
	Short: "Manage archive deployments for the environment",
	Long:  "Manage archive deployments for the environment",
}

Cmd to manage tracing of apis

View Source
var Cmd = &cobra.Command{
	Use:     "environments",
	Aliases: []string{"envs"},
	Short:   "Manage Apigee environments",
	Long:    "Manage Apigee environments",
}

Cmd to manage envs

View Source
var CreateArchiveCmd = &cobra.Command{
	Use:   "create",
	Short: "Create a new revision of archive in the environment",
	Long:  "Create a new revision of archive in the environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		if zipfile != "" && folder != "" {
			return fmt.Errorf("Both zipfile and folder path cannot be passed")
		}
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {

		if folder != "" {
			zipfile = name + ".zip"
			if err = proxybundle.GenerateArchiveBundle(folder, zipfile); err != nil {
				return err
			}
		}

		respBody, err := env.CreateArchive(name, zipfile)
		if wait {
			archiveResponse := op{}
			if err = json.Unmarshal(respBody, &archiveResponse); err != nil {
				return
			}

			s := strings.Split(archiveResponse.Name, "/")
			operationId := s[len(s)-1]

			fmt.Printf("Deployment operation id is %s\n", operationId)
			fmt.Printf("Checking deployment status in %d seconds\n", interval)

			apiclient.SetPrintOutput(false)

			stop := apiclient.Every(interval*time.Second, func(time.Time) bool {
				var respOpsBody []byte
				respMap := op{}
				if respOpsBody, err = operations.Get(operationId); err != nil {
					return true
				}

				if err = json.Unmarshal(respOpsBody, &respMap); err != nil {
					return true
				}

				if respMap.Metadata.State == "IN_PROGRESS" {
					fmt.Printf("Archive deployment status is: %s. Waiting %d seconds.\n", respMap.Metadata.State, interval)
					return true
				} else if respMap.Metadata.State == "FINISHED" {
					if respMap.Error == (operationError{}) {
						fmt.Println("Archive deployment completed with status: ", respMap.Metadata.State)
					} else {
						fmt.Printf("Archive deployment failed with status: %s", respMap.Error.Message)
					}
					return false
				} else {
					fmt.Printf("Unknown state %s", respMap.Metadata.State)
					return false
				}
			})

			<-stop

		}
		return
	},
}

CreateArchiveCmd to create env archive

View Source
var CreateCmd = &cobra.Command{
	Use:   "create",
	Short: "Create a new environment",
	Long:  "Create a new environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = env.Create(deploymentType, apiProxyType)
		return
	},
}

Cmd to get env details

View Source
var CrtTraceOverridesCmd = &cobra.Command{
	Use:   "create",
	Short: "Create a new Distributed Trace config override",
	Long:  "Create a new Distributed Trace config override",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.CreateTraceOverrides(apiProxy, exporter, endpoint, sampler, sample_rate)
		return
	},
}

CrtTraceOverridesCmd to manage tracing of apis

View Source
var DebugCmd = &cobra.Command{
	Use:   "debugmask",
	Short: "Manage debugmasks for the environment",
	Long:  "Manage debugmasks for the environment",
}

Cmd to manage tracing of apis

View Source
var DelArchiveCmd = &cobra.Command{
	Use:   "delete",
	Short: "Delete Apigee Archive from the environment",
	Long:  "Delete Apigee Archive from the environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = env.DeleteArchive(name)
		return
	},
}

DelArchiveCmd to list envs

View Source
var DelCmd = &cobra.Command{
	Use:   "delete",
	Short: "Delete an environment",
	Long:  "Delete an environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = env.Delete()
		return
	},
}

DelCmd to delete env

View Source
var DeployCmd = &cobra.Command{
	Use:   "deployments",
	Short: "Manage deployments for the environment",
	Long:  "Manage deployments for the environment",
}

DeployCmd to manage api deployments for an environment

View Source
var DisableTraceConfigCmd = &cobra.Command{
	Use:   "disable",
	Short: "Disable Distributed Trace config for the environment",
	Long:  "Disable Distributed Trace config for the environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.DisableTraceConfig()
		return
	},
}

DisableTraceConfigCmd to manage tracing of apis

View Source
var GetArchiveCmd = &cobra.Command{
	Use:   "get",
	Short: "Get archive details",
	Long:  "Get archive details",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = env.GetArchive(name)
		return
	},
}

GetArchiveCmd to list envs

View Source
var GetCmd = &cobra.Command{
	Use:   "get",
	Short: "Get properties of an environment",
	Long:  "Get properties of an environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = env.Get(config)
		return
	},
}

Cmd to get env details

View Source
var GetConfigCmd = &cobra.Command{
	Use:   "config",
	Short: "Get deployment configuration for an Environment",
	Long:  "Get deployment configuration for an Environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.GetDeployedConfig()
		return
	},
}

GetConfigCmd to get deployed apis in an env

View Source
var GetDebugCmd = &cobra.Command{
	Use:   "get",
	Short: "Get debugmasks for an Environment",
	Long:  "Get debugmasks for an Environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.GetDebug()
		return
	},
}

Cmd to manage tracing of apis

View Source
var GetDeployCmd = &cobra.Command{
	Use:   "get",
	Short: "Get deployments for an Environment",
	Long:  "Get deployments for an Environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		if all {
			_, err = environments.GetAllDeployments()
		} else {
			_, err = environments.GetDeployments(sharedflows)
		}
		return
	},
}

DeployCmd to get deployed apis in an env

View Source
var GetIamCmd = &cobra.Command{
	Use:   "get",
	Short: "Gets the IAM policy on an Environment",
	Long:  "Gets the IAM policy on an Environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.GetIAM()
		return
	},
}

Cmd to manage tracing of apis

View Source
var GetTraceConfigCmd = &cobra.Command{
	Use:   "get",
	Short: "Get Distributed Trace config for the environment",
	Long:  "Get Distributed Trace config for the environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.GetTraceConfig()
		return
	},
}

GetTraceConfigCmd to manage tracing of apis

View Source
var GetTraceOverridesCmd = &cobra.Command{
	Use:   "get",
	Short: "Get Distributed Trace config overrides",
	Long:  "Get Distributed Trace config overrides",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.GetTraceOverrides(configName)
		return
	},
}

GetTraceOverridesCmd to manage tracing of apis

View Source
var IamCmd = &cobra.Command{
	Use:   "iam",
	Short: "Manage IAM permissions for the environment",
	Long:  "Manage IAM permissions for the environment",
}

Cmd to manage tracing of apis

View Source
var ListArchiveCmd = &cobra.Command{
	Use:   "list",
	Short: "List archives deployed to the environment",
	Long:  "List archives deployed to the environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = env.ListArchives()
		return
	},
}

Cmd to list envs

View Source
var ListCmd = &cobra.Command{
	Use:   "list",
	Short: "List environments in an Apigee Org",
	Long:  "List environments in an Apigee Org",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = env.List()
		return
	},
}

Cmd to list envs

View Source
var ListTraceOverridesCmd = &cobra.Command{
	Use:   "list",
	Short: "List Distributed Trace config overrides",
	Long:  "List Distributed Trace config overrides",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.ListTraceOverrides()
		return
	},
}

ListTraceOverridesCmd to manage tracing of apis

View Source
var ObCmd = &cobra.Command{
	Use:   "ax-obfuscation",
	Short: "Obfuscate analytics fields",
	Long:  "Obfuscate analytics fields before sending to control plane",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		return env.SetEnvProperty("features.analytics.data.obfuscation.enabled", strconv.FormatBool(enable))
	},
}

Cmd to enable AX obfuscation

View Source
var PropCmd = &cobra.Command{
	Use:   "set",
	Short: "Set environment property",
	Long:  "Set environment property",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		return env.SetEnvProperty(propName, propValue)
	},
}

Cmd to set mart endpoint

View Source
var RemoveRoleCmd = &cobra.Command{
	Use:   "removerole",
	Short: "Remove a member or SA from a role for an environment",
	Long:  "Remove a member or SA from a role for an environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		err = environments.RemoveIAM(memberName, role)
		if err != nil {
			return err
		}
		fmt.Printf("Member %s removed access to role %s\n", memberName, role)
		return nil
	},
}

RemoveRoleCmd to a member from a role

View Source
var SetAxCmd = &cobra.Command{
	Use:   "setax",
	Short: "Set Analytics Agent role for a member on an environment",
	Long:  "Set Analytics Agent role for a member an Environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		if role != "analyticsAgent" && role != "analyticsViewer" {
			return fmt.Errorf("invalid memberRole. Member role must be analyticsViewer or analyticsAgent")
		}
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		err = environments.SetIAM(memberName, role, memberType)
		if err != nil {
			return err
		}
		fmt.Printf("Member %s granted access to %s role\n", memberName, role)
		return nil
	},
}

Cmd to manage tracing of apis

View Source
var SetCustCmd = &cobra.Command{
	Use:   "setcustom",
	Short: "Set a custom role for a member on an environment",
	Long:  "Set a custom role for a member on an environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		re := regexp.MustCompile(`projects\/([a-zA-Z0-9_-]+)\/roles\/([a-zA-Z0-9_-]+)`)
		result := re.FindString(role)
		if result == "" {
			return fmt.Errorf("custom role must be of the format projects/{project-id}/roles/{role-name}")
		}
		err = environments.SetIAM(memberName, role, memberType)
		if err != nil {
			return err
		}
		fmt.Printf("Member %s, granted access to %s\n", memberName, role)
		return nil
	},
}

SetCustCmd to manage custom roles for an env

View Source
var SetDebugCmd = &cobra.Command{
	Use:   "set",
	Short: "Set debugmasks for an Environment",
	Long:  "Set debugmasks for an Environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.SetDebug(payload)
		return
	},
}

Cmd to manage tracing of apis

View Source
var SetDepCmd = &cobra.Command{
	Use:   "setdeploy",
	Short: "Set Apigee Deployer role for a member on an environment",
	Long:  "Set Apigee Deployer role for a member on an environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		err = environments.SetIAM(memberName, "deploy", memberType)
		if err != nil {
			return err
		}
		fmt.Printf("Member %s granted access to Apigee Deployer role\n", memberName)
		return nil
	},
}

Cmd to manage tracing of apis

View Source
var SetSyncCmd = &cobra.Command{
	Use:   "setsync",
	Short: "Set Synchronization Manager role for a member on an environment",
	Long:  "Set Synchronization Manager role for a member on an environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		err = environments.SetIAM(memberName, "sync", memberType)
		if err != nil {
			return err
		}
		fmt.Printf("Member %s granted access to Apigee Synchronizer Manager role\n", memberName)
		return nil
	},
}

Cmd to manage tracing of apis

View Source
var TestIamCmd = &cobra.Command{
	Use:   "test",
	Short: "Test IAM policy for an Environment",
	Long:  "Test IAM policy for an Environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.TestIAM(resource, verb)
		return
	},
}

Cmd to manage tracing of apis

View Source
var TraceConfigCmd = &cobra.Command{
	Use:   "traceconfig",
	Short: "Manage Distributed Trace config for the environment",
	Long:  "Manage Distributed Trace config for the environment",
}

Cmd to manage tracing of apis

View Source
var TraceOverridesCmd = &cobra.Command{
	Use:   "overrides",
	Short: "Manage Distributed Trace config overrides for the environment",
	Long:  "Manage Distributed Trace config overrides for the environment",
}

Cmd to manage tracing of apis

View Source
var UpdateTraceConfigCmd = &cobra.Command{
	Use:   "update",
	Short: "Update Distributed Trace config for the environment",
	Long:  "Update Distributed Trace config for the environment",
	Args: func(cmd *cobra.Command, args []string) (err error) {
		apiclient.SetApigeeEnv(environment)
		return apiclient.SetApigeeOrg(org)
	},
	RunE: func(cmd *cobra.Command, args []string) (err error) {
		_, err = environments.UpdateTraceConfig(exporter, endpoint, sampler, sample_rate)
		return
	},
}

UpdateTraceConfigCmd to manage tracing of apis

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