Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AcCmd = &cobra.Command{ Use: "enable-apigee-connect", Short: "Enable Apigee Connect for an Apigee Org", Long: "Enable Apigee Connect for 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) { return orgs.SetOrgProperty("features.mart.apigee.connect.enabled", "true") }, }
Cmd to set mart endpoint
View Source
var Cmd = &cobra.Command{ Use: "organizations", Aliases: []string{"orgs"}, Short: "Manage Apigee Orgs", Long: "Manage Apigee Orgs", }
Cmd to manage orgs
View Source
var CreateCmd = &cobra.Command{ Use: "create", Short: "Create a new Apigee Org", Long: "Create a new Apigee Org", Args: func(cmd *cobra.Command, args []string) (err error) { if runtimeType != "HYBRID" && runtimeType != "CLOUD" { return fmt.Errorf("runtime type must be CLOUD or HYBRID") } if billingType != "SUBSCRIPTION" && billingType != "EVALUATION" { return fmt.Errorf("Billing type must be SUBSCRIPTION or EVALUATION") } if runtimeType == "CLOUD" { if network == "" { return fmt.Errorf("authorized network must be supplied") } if databaseKey == "" { return fmt.Errorf("runtime database encryption key must be supplied") } } apiclient.SetProjectID(projectID) return apiclient.SetApigeeOrg(projectID) }, RunE: func(cmd *cobra.Command, args []string) (err error) { _, err = orgs.Create(region, network, runtimeType, databaseKey, billingType, disablePortal) return }, }
Cmd to get org details
View Source
var DelCmd = &cobra.Command{ Use: "delete", Short: "Delete an Apigee Org", Long: "Delete 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 = orgs.Delete(retension) return }, }
DelCmd to get org details
View Source
var ExportCmd = &cobra.Command{ Use: "export", Short: "Export Apigee Configuration", Long: "Export Apigee Configuration", Args: func(cmd *cobra.Command, args []string) (err error) { return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { var productResponse, appsResponse, targetServerResponse, referencesResponse [][]byte var respBody, listKVMBytes []byte runtimeType, _ := orgs.GetOrgField("runtimeType") if err = createFolders(); proceedOnError(err) != nil { return err } clilog.Warning.Println("Calls to Apigee APIs have a quota of 6000 per min. Running this tool against large list of entities can exhaust that quota and impact the usage of the platform.") fmt.Println("Exporting API Proxies...") if err = apis.ExportProxies(conn, proxiesFolderName, allRevisions); proceedOnError(err) != nil { return err } fmt.Println("Exporting Sharedflows...") if err = sharedflows.Export(conn, sharedFlowsFolderName, allRevisions); proceedOnError(err) != nil { return err } fmt.Println("Exporting API Products...") if productResponse, err = products.Export(conn); proceedOnError(err) != nil { return err } if err = apiclient.WriteArrayByteArrayToFile(productsFileName, false, productResponse); proceedOnError(err) != nil { return err } fmt.Printf("\tExporting KV Map names for org %s\n", org) if listKVMBytes, err = kvm.List(""); proceedOnError(err) != nil { return err } if err = apiclient.WriteByteArrayToFile(org+"_"+kVMFileName, false, listKVMBytes); proceedOnError(err) != nil { return err } if err = exportKVMEntries("org", "", listKVMBytes); proceedOnError(err) != nil { return err } fmt.Println("Exporting Developers...") if respBody, err = developers.Export(); proceedOnError(err) != nil { return err } if err = apiclient.WriteByteArrayToFile(developersFileName, false, respBody); proceedOnError(err) != nil { return err } fmt.Println("Exporting Developer Apps...") if appsResponse, err = apps.Export(conn); proceedOnError(err) != nil { return err } if err = apiclient.WriteArrayByteArrayToFile(appsFileName, false, appsResponse); proceedOnError(err) != nil { return err } fmt.Println("Exporting Environment Group Configuration...") apiclient.SetPrintOutput(false) if respBody, err = envgroups.List(); proceedOnError(err) != nil { return err } if err = apiclient.WriteByteArrayToFile(envGroupsFileName, false, respBody); proceedOnError(err) != nil { return err } fmt.Println("Exporting Data collectors Configuration...") if respBody, err = datacollectors.List(); proceedOnError(err) != nil { return err } if err = apiclient.WriteByteArrayToFile(dataCollFileName, false, respBody); proceedOnError(err) != nil { return err } if runtimeType == "HYBRID" { fmt.Println("Exporting Sync Authorization Identities...") if respBody, err = sync.Get(); err != nil { return err } if err = apiclient.WriteByteArrayToFile(syncAuthFileName, false, respBody); proceedOnError(err) != nil { return err } } var envRespBody []byte if envRespBody, err = env.List(); proceedOnError(err) != nil { return err } environments := []string{} if err = json.Unmarshal(envRespBody, &environments); proceedOnError(err) != nil { return err } for _, environment := range environments { fmt.Println("Exporting configuration for environment " + environment) apiclient.SetApigeeEnv(environment) apiclient.SetPrintOutput(false) fmt.Println("\tExporting Target servers...") if targetServerResponse, err = targetservers.Export(conn); proceedOnError(err) != nil { return err } if err = apiclient.WriteArrayByteArrayToFile(environment+"_"+targetServerFileName, false, targetServerResponse); proceedOnError(err) != nil { return err } fmt.Printf("\tExporting KV Map names for environment %s...\n", environment) if listKVMBytes, err = kvm.List(""); err != nil { return err } if err = apiclient.WriteByteArrayToFile(environment+"_"+kVMFileName, false, listKVMBytes); proceedOnError(err) != nil { return err } if err = exportKVMEntries("env", environment, listKVMBytes); proceedOnError(err) != nil { return err } fmt.Println("\tExporting Key store names...") if respBody, err = keystores.List(); proceedOnError(err) != nil { return err } if err = apiclient.WriteByteArrayToFile(environment+"_"+keyStoresFileName, false, respBody); proceedOnError(err) != nil { return err } fmt.Println("\tExporting debugmask configuration...") if respBody, err = env.GetDebug(); err != nil { return err } if err = apiclient.WriteByteArrayToFile(environment+debugmaskFileName, false, respBody); proceedOnError(err) != nil { return err } fmt.Println("\tExporting traceconfig...") if respBody, err = env.GetTraceConfig(); err != nil { return err } if err = apiclient.WriteByteArrayToFile(environment+tracecfgFileName, false, respBody); proceedOnError(err) != nil { return err } fmt.Println("\tExporting references...") if referencesResponse, err = references.Export(conn); proceedOnError(err) != nil { return err } if err = apiclient.WriteArrayByteArrayToFile(environment+"_"+referencesFileName, false, referencesResponse); proceedOnError(err) != nil { return err } } return }, }
ExportCmd to get org details
View Source
var GetCmd = &cobra.Command{ Use: "get", Short: "Show details of an Apigee Org", Long: "Show details of 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 = orgs.Get() return }, }
Cmd to get org details
View Source
var ImportCmd = &cobra.Command{ Use: "import", Short: "Import Apigee Configuration", Long: "Import Apigee Configuration", Args: func(cmd *cobra.Command, args []string) (err error) { return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { var kvmList []string clilog.Warning.Println("Calls to Apigee APIs have a quota of 6000 per min. Running this tool against large list of entities can exhaust that quota and impact the usage of the platform.") fmt.Println("Importing API Proxies...") if err = apis.ImportProxies(conn, path.Join(folder, proxiesFolderName)); err != nil { return err } fmt.Println("Importing Sharedflows...") if err = sharedflows.Import(conn, path.Join(folder, sharedFlowsFolderName)); err != nil { return err } fmt.Println("Check for files with KVM Entries") orgKVMFileList, envKVMFileList, _, _ := listKVMFiles() if isFileExists(path.Join(folder, org+"_"+kVMFileName)) { fmt.Println("Importing Org scoped KVMs...") if kvmList, err = readEntityFile(path.Join(folder, org+"_"+kVMFileName)); err != nil { return err } for _, kvmName := range kvmList { if _, err = kvm.Create("", kvmName, true); err != nil { return err } if orgKVMFileList[kvmName] != "" { if err = kvm.ImportEntries("", kvmName, conn, orgKVMFileList[kvmName]); err != nil { return err } } } } if isFileExists(path.Join(folder, productsFileName)) { fmt.Println("Importing Products...") if err = products.Import(conn, path.Join(folder, productsFileName), false); err != nil { return err } } if isFileExists(path.Join(folder, developersFileName)) { fmt.Println("Importing Developers...") if err = developers.Import(conn, path.Join(folder, developersFileName)); err != nil { return err } fmt.Println("Importing Apps...") if err = apps.Import(conn, path.Join(folder, appsFileName), path.Join(folder, developersFileName)); err != nil { return err } } if isFileExists(path.Join(folder, envGroupsFileName)) { fmt.Println("Importing Environment Group Configuration...") if err = envgroups.Import(path.Join(folder, envGroupsFileName)); err != nil { return err } } if isFileExists(path.Join(folder, dataCollFileName)) { fmt.Println("Importing Data Collectors Configuration...") if err = datacollectors.Import(path.Join(folder, dataCollFileName)); err != nil { return err } } apiclient.SetPrintOutput(false) var envRespBody []byte if envRespBody, err = env.List(); err != nil { return err } environments := []string{} if envRespBody != nil { if err = json.Unmarshal(envRespBody, &environments); err != nil { return err } } for _, environment := range environments { fmt.Println("Importing configuration for environment " + environment) apiclient.SetApigeeEnv(environment) if isFileExists(path.Join(folder, environment+"_"+keyStoresFileName)) { fmt.Println("\tImporting Keystore names...") if err = keystores.Import(conn, path.Join(folder, environment+"_"+keyStoresFileName)); err != nil { return err } } if isFileExists(path.Join(folder, environment+"_"+targetServerFileName)) { fmt.Println("\tImporting Target servers...") if err = targetservers.Import(conn, path.Join(folder, environment+"_"+targetServerFileName)); err != nil { return err } } if isFileExists(path.Join(folder, environment+"_"+referencesFileName)) { fmt.Println("\tImporting References...") if err = references.Import(conn, path.Join(folder, environment+"_"+referencesFileName)); err != nil { return err } } if isFileExists(path.Join(folder, kVMFileName)) { fmt.Println("\tImporting KVM Names only...") if kvmList, err = readEntityFile(path.Join(folder, environment+"_"+kVMFileName)); err != nil { return err } for _, kvmName := range kvmList { if _, err = kvm.Create("", kvmName, true); err != nil { return err } if envKVMFileList[kvmName] != "" { if err = kvm.ImportEntries("", kvmName, conn, envKVMFileList[kvmName]); err != nil { return err } } } } if importDebugmask { if isFileExists(path.Join(folder, environment+debugmaskFileName)) { fmt.Println("\tImporting Debug Mask configuration...") debugMask, _ := readEntityFileAsString(path.Join(folder, environment+debugmaskFileName)) if _, err = env.SetDebug(debugMask); err != nil { return err } } } if importTrace { if isFileExists(path.Join(folder, environment+tracecfgFileName)) { fmt.Println("\tImporting Trace configuration...") traceCfg, _ := readEntityFileAsString(path.Join(folder, environment+tracecfgFileName)) if _, err = env.ImportTraceConfig(traceCfg); err != nil { return err } } } } return err }, }
ImportCmd to get org details
View Source
var IngressCmd = &cobra.Command{ Use: "ingressconfig", Short: "Show details of the Ingress configuration for an Apigee Org", Long: "Show details of the Ingress configuration for 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 = orgs.GetDeployedIngressConfig(view) return }, }
IngressCmd to get org details
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List the Apigee organizations", Long: "List the Apigee organizations, and the related projects that a user has permissions for", Args: func(cmd *cobra.Command, args []string) (err error) { return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { _, err = orgs.List() return }, }
Cmd to list orgs
View Source
var MartCmd = &cobra.Command{ Use: "setmart", Short: "Set MART endpoint for an Apigee Org", Long: "Set MART endpoint for 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) { return orgs.SetOrgProperty("features.mart.server.endpoint", mart) }, }
Cmd to set mart endpoint
View Source
var MonthlyCmd = &cobra.Command{ Use: "monthly", Short: "Report monthly usage for an Apigee Org", Long: "Report monthly usage for 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) { var apiCalls int if _, err = time.Parse("1/2006", fmt.Sprintf("%d/%d", month, year)); err != nil { return } if envDetails { w := tabwriter.NewWriter(os.Stdout, 26, 4, 0, ' ', 0) fmt.Fprintln(w, "ENVIRONMENT\tMONTH\tAPI CALLS") fmt.Fprintln(w) w.Flush() } if apiCalls, err = orgs.TotalAPICallsInMonth(month, year, envDetails, conn); err != nil { return } if envDetails { fmt.Printf("\nSummary\n\n") } w := tabwriter.NewWriter(os.Stdout, 26, 4, 0, ' ', 0) fmt.Fprintln(w, "ORGANIATION\tMONTH\tAPI CALLS") fmt.Fprintf(w, "%s\t%d/%d\t%d\n", apiclient.GetApigeeOrg(), month, year, apiCalls) fmt.Fprintln(w) w.Flush() return }, }
MonthlyCmd to get monthly usage
View Source
var ObCmd = &cobra.Command{ Use: "enable-ax-obfuscation", Short: "Obfuscate analytics fields", Long: "Obfuscate analytics fields before sending to control plane", Args: func(cmd *cobra.Command, args []string) (err error) { return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { return orgs.SetOrgProperty("features.analytics.data.obfuscation.enabled", "true") }, }
Cmd to enable AX obfuscation
View Source
var PropCmd = &cobra.Command{ Use: "set", Short: "Set organization property", Long: "Set organization property", Args: func(cmd *cobra.Command, args []string) (err error) { return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { return orgs.SetOrgProperty(propName, propValue) }, }
Cmd to set mart endpoint
View Source
var ReportCmd = &cobra.Command{ Use: "reports", Aliases: []string{"orgs"}, Short: "Report Apigee Org Usage", Long: "Report Apigee Org Usage", }
ReportCmd to manage org reprots
View Source
var SetAddonCmd = &cobra.Command{ Use: "setaddons", Short: "Enable addons for an Apigee organization", Long: "Enable addons for an Apigee organization", Args: func(cmd *cobra.Command, args []string) (err error) { return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) (err error) { _, err = orgs.SetAddons(advancedApiOpsConfig, integrationConfig, monetizationConfig, connectorsConfig, apiSecurityConfig) return }, }
Cmd to set mart endpoint
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Short: "Update settings of an Apigee Org", Long: "Update settings of an Apigee Org", Args: func(cmd *cobra.Command, args []string) (err error) { if runtimeType != "HYBRID" && runtimeType != "CLOUD" { return fmt.Errorf("runtime type must be CLOUD or HYBRID") } if runtimeType == "CLOUD" { if network == "" { return fmt.Errorf("authorized network must be supplied") } if databaseKey == "" { return fmt.Errorf("runtime database encryption key must be supplied") } } apiclient.SetProjectID(projectID) return apiclient.SetApigeeOrg(projectID) }, RunE: func(cmd *cobra.Command, args []string) (err error) { _, err = orgs.Update(description, "", region, network, runtimeType, databaseKey) return }, }
UpdateCmd to get org details
View Source
var YearlyCmd = &cobra.Command{ Use: "yearly", Short: "Report yearly usage for an Apigee Org", Long: "Report yearly usage for 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) { var apiCalls int if _, err = time.Parse("2006", fmt.Sprintf("%d", year)); err != nil { return } if envDetails { w := tabwriter.NewWriter(os.Stdout, 26, 4, 0, ' ', 0) fmt.Fprintln(w, "ENVIRONMENT\tMONTH\tAPI CALLS") w.Flush() } if apiCalls, err = orgs.TotalAPICallsInYear(year, envDetails, conn); err != nil { return } if envDetails { fmt.Printf("\nSummary\n\n") } w := tabwriter.NewWriter(os.Stdout, 26, 4, 0, ' ', 0) fmt.Fprintln(w, "ORGANIZATION\tYEAR\tAPI CALLS") fmt.Fprintf(w, "%s\t%d\t%d\n", apiclient.GetApigeeOrg(), year, apiCalls) fmt.Fprintln(w) w.Flush() return }, }
YearlyCmd to get monthly usage
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.