• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang cfcurl.Curl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/krujos/cfcurl.Curl函数的典型用法代码示例。如果您正苦于以下问题:Golang Curl函数的具体用法?Golang Curl怎么用?Golang Curl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: GetOrgs

//GetOrgs returns a struct that represents critical fields in the JSON
func (api *APIHelper) GetOrgs(cli plugin.CliConnection) ([]Organization, error) {
	orgsJSON, err := cfcurl.Curl(cli, "/v2/organizations")
	if nil != err {
		return nil, err
	}
	pages := int(orgsJSON["total_pages"].(float64))
	orgs := []Organization{}
	for i := 1; i <= pages; i++ {
		if 1 != i {
			orgsJSON, err = cfcurl.Curl(cli, "/v2/organizations?page="+strconv.Itoa(i))
		}
		for _, o := range orgsJSON["resources"].([]interface{}) {
			theOrg := o.(map[string]interface{})
			entity := theOrg["entity"].(map[string]interface{})
			metadata := theOrg["metadata"].(map[string]interface{})
			orgs = append(orgs,
				Organization{
					Name:      entity["name"].(string),
					URL:       metadata["url"].(string),
					QuotaURL:  entity["quota_definition_url"].(string),
					SpacesURL: entity["spaces_url"].(string),
				})
		}
	}
	return orgs, nil
}
开发者ID:dave-malone,项目名称:usagereport-plugin,代码行数:27,代码来源:apihelper.go


示例2: GetOrgMemoryUsage

//GetOrgMemoryUsage returns the amount of memory (in MB) that the org is consuming
func (api *APIHelper) GetOrgMemoryUsage(cli plugin.CliConnection, org Organization) (float64, error) {
	usageJSON, err := cfcurl.Curl(cli, org.URL+"/memory_usage")
	if nil != err {
		return 0, err
	}
	return usageJSON["memory_usage_in_mb"].(float64), nil
}
开发者ID:dave-malone,项目名称:usagereport-plugin,代码行数:8,代码来源:apihelper.go


示例3: GetQuotaMemoryLimit

//GetQuotaMemoryLimit retruns the amount of memory (in MB) that the org is allowed
func (api *APIHelper) GetQuotaMemoryLimit(cli plugin.CliConnection, quotaURL string) (float64, error) {
	quotaJSON, err := cfcurl.Curl(cli, quotaURL)
	if nil != err {
		return 0, err
	}
	return quotaJSON["entity"].(map[string]interface{})["memory_limit"].(float64), nil
}
开发者ID:dave-malone,项目名称:usagereport-plugin,代码行数:8,代码来源:apihelper.go


示例4: Run

//Run a command
func (cmd *TestCmd) Run(cliConnection plugin.CliConnection, args []string) {
	out, _ := cfcurl.Curl(cliConnection, "/v2/apps")
	fmt.Println(out)

	out, _ = cfcurl.CurlDepricated(cliConnection, "/v2/domains")
	fmt.Println(out)
}
开发者ID:krujos,项目名称:cfcurl-testplugin,代码行数:8,代码来源:main.go


示例5: processPagedResults

//Base method to process paged results from API calls
func processPagedResults(cli plugin.CliConnection, url string, fn process) ([]interface{}, error) {

	theJSON, err := cfcurl.Curl(cli, url)
	if nil != err {
		return nil, err
	}

	pages := int(theJSON["total_pages"].(float64))
	var objects []interface{}
	for i := 1; i <= pages; i++ {
		if 1 != i {
			theJSON, err = cfcurl.Curl(cli, url+"?page="+strconv.Itoa(i))
		}
		for _, o := range theJSON["resources"].([]interface{}) {
			theObj := o.(map[string]interface{})
			entity := theObj["entity"].(map[string]interface{})
			metadata := theObj["metadata"].(map[string]interface{})
			objects = append(objects, fn(metadata, entity))
		}

	}

	return objects, nil
}
开发者ID:cdelashmutt-pivotal,项目名称:service-use,代码行数:25,代码来源:apihelper.go


示例6: GetOrganization

//GetSpace returns a struct that represents critical fields in the JSON
func (api *APIHelper) GetOrganization(cli plugin.CliConnection, organizationURL string) (Organization, error) {
	theJSON, err := cfcurl.Curl(cli, organizationURL)
	if nil != err {
		return Organization{}, err
	}

	entity := theJSON["entity"].(map[string]interface{})
	metadata := theJSON["metadata"].(map[string]interface{})

	organization := Organization{
		Name: entity["name"].(string),
		URL:  metadata["url"].(string),
	}

	return organization, nil
}
开发者ID:cdelashmutt-pivotal,项目名称:service-use,代码行数:17,代码来源:apihelper.go


示例7: GetOrgSpaces

//GetOrgSpaces returns the spaces in an org.
func (api *APIHelper) GetOrgSpaces(cli plugin.CliConnection, spacesURL string) ([]Space, error) {
	spacesJSON, err := cfcurl.Curl(cli, spacesURL)
	if nil != err {
		return nil, err
	}
	spaces := []Space{}
	for _, s := range spacesJSON["resources"].([]interface{}) {
		theSpace := s.(map[string]interface{})
		entity := theSpace["entity"].(map[string]interface{})
		spaces = append(spaces,
			Space{
				AppsURL: entity["apps_url"].(string),
				Name:    entity["name"].(string),
			})
	}
	return spaces, nil
}
开发者ID:dave-malone,项目名称:usagereport-plugin,代码行数:18,代码来源:apihelper.go


示例8: GetSpaceApps

//GetSpaceApps returns the apps in a space
func (api *APIHelper) GetSpaceApps(cli plugin.CliConnection, appsURL string) ([]App, error) {
	appsJSON, err := cfcurl.Curl(cli, appsURL)
	if nil != err {
		return nil, err
	}
	apps := []App{}
	for _, a := range appsJSON["resources"].([]interface{}) {
		theApp := a.(map[string]interface{})
		entity := theApp["entity"].(map[string]interface{})
		apps = append(apps,
			App{
				Instances: entity["instances"].(float64),
				RAM:       entity["memory"].(float64),
			})
	}
	return apps, nil
}
开发者ID:ECSTeam,项目名称:usagereport-plugin,代码行数:18,代码来源:apihelper.go


示例9: GetSpace

//GetSpace returns a struct that represents critical fields in the JSON
func (api *APIHelper) GetSpace(cli plugin.CliConnection, spaceURL string) (Space, error) {
	theJSON, err := cfcurl.Curl(cli, spaceURL)
	if nil != err {
		return Space{}, err
	}

	entity := theJSON["entity"].(map[string]interface{})
	metadata := theJSON["metadata"].(map[string]interface{})

	space := Space{
		Name:            entity["name"].(string),
		URL:             metadata["url"].(string),
		OrganizationURL: entity["organization_url"].(string),
	}

	return space, nil
}
开发者ID:cdelashmutt-pivotal,项目名称:service-use,代码行数:18,代码来源:apihelper.go


示例10: GetOrg

//GetOrg returns a struct that represents critical fields in the JSON
func (api *APIHelper) GetOrg(name string) (Organization, error) {
	query := fmt.Sprintf("name:%s", name)
	path := fmt.Sprintf("/v2/organizations?q=%s&inline-relations-depth=1", url.QueryEscape(query))
	orgsJSON, err := cfcurl.Curl(api.cli, path)
	if nil != err {
		return Organization{}, err
	}

	results := int(orgsJSON["total_results"].(float64))
	if results == 0 {
		return Organization{}, ErrOrgNotFound
	}

	orgResource := orgsJSON["resources"].([]interface{})[0]
	org := api.orgResourceToOrg(orgResource)

	return org, nil
}
开发者ID:krujos,项目名称:usagereport-plugin,代码行数:19,代码来源:apihelper.go


示例11: GetOrgs

//GetOrgs returns a struct that represents critical fields in the JSON
func (api *APIHelper) GetOrgs(cli plugin.CliConnection) ([]Organization, error) {
	orgsJSON, err := cfcurl.Curl(cli, "/v2/organizations")
	if nil != err {
		return nil, err
	}

	orgs := []Organization{}
	for _, o := range orgsJSON["resources"].([]interface{}) {
		theOrg := o.(map[string]interface{})
		entity := theOrg["entity"].(map[string]interface{})
		metadata := theOrg["metadata"].(map[string]interface{})
		orgs = append(orgs,
			Organization{
				Name:      entity["name"].(string),
				URL:       metadata["url"].(string),
				QuotaURL:  entity["quota_definition_url"].(string),
				SpacesURL: entity["spaces_url"].(string),
			})
	}
	return orgs, nil
}
开发者ID:jeaniejung,项目名称:usagereport-plugin,代码行数:22,代码来源:apihelper.go


示例12: GetSpaceApps

//GetSpaceApps returns the apps in a space
func (api *APIHelper) GetSpaceApps(cli plugin.CliConnection, appsURL string) ([]App, error) {
	appsJSON, err := cfcurl.Curl(cli, appsURL)
	if nil != err {
		return nil, err
	}

	apps := []App{}
	for _, a := range appsJSON["resources"].([]interface{}) {
		theApp := a.(map[string]interface{})
		entity := theApp["entity"].(map[string]interface{})

		bp := " "
		bpd := " "

		if entity["buildpack"] == nil {
			bp = "Not detected"
		} else {
			bp = entity["buildpack"].(string)
		}

		if entity["detected_buildpack"] == nil {
			bpd = "Not detected"
		} else {
			bpd = entity["detected_buildpack"].(string)
		}

		apps = append(apps,
			App{
				Instances:         entity["instances"].(float64),
				RAM:               entity["memory"].(float64),
				Running:           "STARTED" == entity["state"].(string),
				Name:              entity["name"].(string),
				Buildpack:         bp,
				BuildpackDetected: bpd,
			})
	}
	return apps, nil
}
开发者ID:ahahtyler,项目名称:usagereport-plugin,代码行数:39,代码来源:apihelper.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang aws.NewRequest函数代码示例发布时间:2022-05-23
下一篇:
Golang dhcp4.Packet类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap