当前位置: 首页>>代码示例>>Golang>>正文


Golang CliConnection.ApiEndpoint方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin.CliConnection.ApiEndpoint方法的典型用法代码示例。如果您正苦于以下问题:Golang CliConnection.ApiEndpoint方法的具体用法?Golang CliConnection.ApiEndpoint怎么用?Golang CliConnection.ApiEndpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/cli/plugin.CliConnection的用法示例。


在下文中一共展示了CliConnection.ApiEndpoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Run

func (c *DemoCmd) Run(cliConnection plugin.CliConnection, args []string) {
	switch args[0] {
	case "list-apps":
		fc, err := parseArguments(args)
		if err != nil {
			exit1(err.Error())
		}

		endpoint, err := cliConnection.ApiEndpoint()
		if err != nil {
			exit1("Error getting targeted endpoint: " + err.Error())
		}
		fmt.Printf("Listing apps @ endpoint %s/v2/apps...\n\n", endpoint)

		allApps, err := getAllApps(cliConnection)
		if err != nil {
			exit1("Error curling v2/apps: " + err.Error())
		}

		for _, app := range allApps.Resources {
			if (fc.IsSet("started") && app.Entity.State == "STARTED") ||
				(fc.IsSet("stopped") && app.Entity.State == "STOPPED") ||
				(!fc.IsSet("stopped") && !fc.IsSet("started")) {
				fmt.Println(app.Entity.Name)
			}
		}

	case "CLI-MESSAGE-UNINSTALL":
		fmt.Println("Thanks for using this demo")
	}
}
开发者ID:Reejoshi,项目名称:cli,代码行数:31,代码来源:test_rpc_server_example.go

示例2: Run

func (c *Test1) Run(cliConnection plugin.CliConnection, args []string) {
	if args[0] == "new-api" {
		token, _ := cliConnection.AccessToken()
		fmt.Println("Access Token:", token)
		fmt.Println("")

		app, err := cliConnection.GetApp("test_app")
		fmt.Println("err for test_app", err)
		fmt.Println("test_app is: ", app)

		hasOrg, _ := cliConnection.HasOrganization()
		fmt.Println("Has Organization Targeted:", hasOrg)
		currentOrg, _ := cliConnection.GetCurrentOrg()
		fmt.Println("Current Org:", currentOrg)
		org, _ := cliConnection.GetOrg(currentOrg.Name)
		fmt.Println(currentOrg.Name, " Org:", org)
		orgs, _ := cliConnection.GetOrgs()
		fmt.Println("Orgs:", orgs)
		hasSpace, _ := cliConnection.HasSpace()
		fmt.Println("Has Space Targeted:", hasSpace)
		currentSpace, _ := cliConnection.GetCurrentSpace()
		fmt.Println("Current space:", currentSpace)
		space, _ := cliConnection.GetSpace(currentSpace.Name)
		fmt.Println("Space:", space)
		spaces, _ := cliConnection.GetSpaces()
		fmt.Println("Spaces:", spaces)
		loggregator, _ := cliConnection.LoggregatorEndpoint()
		fmt.Println("Loggregator Endpoint:", loggregator)
		dopplerEndpoint, _ := cliConnection.DopplerEndpoint()
		fmt.Println("Doppler Endpoint:", dopplerEndpoint)

		user, _ := cliConnection.Username()
		fmt.Println("Current user:", user)
		userGUID, _ := cliConnection.UserGuid()
		fmt.Println("Current user guid:", userGUID)
		email, _ := cliConnection.UserEmail()
		fmt.Println("Current user email:", email)

		hasAPI, _ := cliConnection.HasAPIEndpoint()
		fmt.Println("Has API Endpoint:", hasAPI)
		api, _ := cliConnection.ApiEndpoint()
		fmt.Println("Current api:", api)
		version, _ := cliConnection.ApiVersion()
		fmt.Println("Current api version:", version)

		loggedIn, _ := cliConnection.IsLoggedIn()
		fmt.Println("Is Logged In:", loggedIn)
		isSSLDisabled, _ := cliConnection.IsSSLDisabled()
		fmt.Println("Is SSL Disabled:", isSSLDisabled)
	} else if args[0] == "test_1_cmd1" {
		theFirstCmd()
	} else if args[0] == "test_1_cmd2" {
		theSecondCmd()
	} else if args[0] == "CLI-MESSAGE-UNINSTALL" {
		uninstalling()
	}
}
开发者ID:Reejoshi,项目名称:cli,代码行数:57,代码来源:test_1.go


注:本文中的github.com/cloudfoundry/cli/plugin.CliConnection.ApiEndpoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。