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

Golang cm15.Api类代码示例

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

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



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

示例1: serversRetrieve

func serversRetrieve(client *cm15.Api, serversLocator string) []Server {
	serverLocator := client.ServerLocator(serversLocator)
	servers, err := serverLocator.Index(rsapi.ApiParams{"view": "instance_detail"})
	if err != nil {
		fmt.Println("failed to find servers: %s", err)
	}
	var serverList = make([]Server, len(servers))
	for i := 0; i < len(servers); i++ {
		nextInstanceLocator := extractHref(servers[i].Links, "next_instance")
		currentInstanceLocator := extractHref(servers[i].Links, "current_instance")
		s := Server{Name: servers[i].Name, Locked: false}
		nextInstance := instanceRetrieve(client, nextInstanceLocator)
		templateLocator := extractHref(nextInstance.Links, "server_template")
		template := templateRetrieve(client, templateLocator)
		s.Template = template.Name
		templates[templateLocator] = template.Name
		alertSpecs := alertsRetrieve(client, extractHref(servers[i].Links, "alert_specs"))
		alerts = append(alerts, alertSpecs...)
		s.NextInstance = inputsRetrieve(client, extractHref(nextInstance.Links, "inputs"))
		if currentInstanceLocator != "" {
			templateLocator := instanceRetrieve(client, currentInstanceLocator)
			s.CurrentInstance = inputsRetrieve(client, extractHref(templateLocator.Links, "inputs"))
			s.Locked = templateLocator.Locked
			s.Volumes = extractVolumesInfo(client, currentInstanceLocator+"/volume_attachments")
			if len(s.Volumes) == 0 {
				s.Volumes = nil
			}
		}
		serverList[i] = s
	}
	return serverList
}
开发者ID:abhashyam,项目名称:deployment,代码行数:32,代码来源:deployment.go


示例2: serverArray

// Makes a GET call on the given server array and returns all its current instances.
func serverArray(client *cm15.Api, name string) []*cm15.Instance {
	serverArrayLocator := client.ServerArrayLocator("/api/server_arrays")
	serverArrays, err := serverArrayLocator.Index(rsapi.ApiParams{"view": "default", "filter": []string{"name==" + name}})
	if err != nil {
		fail("Failed to retrieve server array: %v\n", err.Error())
	}
	if len(serverArrays) == 0 {
		fail("Could not find server array with name: %v\n", name)
	} else if len(serverArrays) != 1 {
		fail("More than one server array found with name: %v\n", name)
	}
	array := serverArrays[0]
	var instancesHref string
	for _, l := range array.Links {
		if l["rel"] == "current_instances" {
			instancesHref = l["href"]
			break
		}
	}
	instanceLocator := client.InstanceLocator(instancesHref)
	instances, err := instanceLocator.Index(rsapi.ApiParams{})
	if err != nil {
		fail("Failed to retrieve current instances of the server array: %v\n", err.Error())
	}
	if len(instances) == 0 {
		fail("No instances found in server array: %v\n", name)
	}
	return instances
}
开发者ID:dylanmei,项目名称:rsc,代码行数:30,代码来源:main.go


示例3: instanceRetrieve

func instanceRetrieve(client *cm15.Api, instanceLocator string) *cm15.Instance {
	locator := client.InstanceLocator(instanceLocator)
	instance, err := locator.Show(rsapi.ApiParams{})
	if err != nil {
		fmt.Println("failed to find instance: %s", err)
	}
	return instance
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例4: runnableBindingsRetrieve

func runnableBindingsRetrieve(client *cm15.Api, runnableBindingLocator string) []*cm15.RunnableBinding {
	locator := client.RunnableBindingLocator(runnableBindingLocator)
	runnableBindings, err := locator.Index(rsapi.ApiParams{})
	if err != nil {
		fmt.Printf("failed to find runnable bindings: %s", err)
	}
	return runnableBindings
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例5: cookbookAttachmentsRetrieve

func cookbookAttachmentsRetrieve(client *cm15.Api, cookbookAttachmentsLocator string) []*cm15.CookbookAttachment {
	locator := client.CookbookAttachmentLocator(cookbookAttachmentsLocator)
	cookbookAttachments, err := locator.Index(rsapi.ApiParams{})
	if err != nil {
		fmt.Println("failed to find cookbook attachments: %s", err)
	}
	return cookbookAttachments
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例6: alertsRetrieve

func alertsRetrieve(client *cm15.Api, alertsLocator string) []*cm15.AlertSpec {
	locator := client.AlertSpecLocator(alertsLocator)
	alertSpec, err := locator.Index(rsapi.ApiParams{"with_inherited": "false"})
	if err != nil {
		fmt.Println("failed to find alertspec: %s", err)
	}
	return alertSpec
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例7: volumeRetrieve

func volumeRetrieve(client *cm15.Api, volumeLocator string) *cm15.Volume {
	locator := client.VolumeLocator(volumeLocator)
	volume, err := locator.Show(rsapi.ApiParams{})
	if err != nil {
		fmt.Println("failed to find volume: %s", err)
	}
	return volume
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例8: volumeAttachmentsRetrive

func volumeAttachmentsRetrive(client *cm15.Api, volumeAttachmentsLocator string) []*cm15.VolumeAttachment {
	locator := client.VolumeAttachmentLocator(volumeAttachmentsLocator)
	volumeAttachments, err := locator.Index(rsapi.ApiParams{})
	if err != nil {
		fmt.Println("failed to find volume attachments: %s", err)
	}
	return volumeAttachments
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例9: cookbooksRetrieve

func cookbooksRetrieve(client *cm15.Api, cookbookLocator string) *cm15.Cookbook {
	locator := client.CookbookLocator(cookbookLocator)
	cookbook, err := locator.Show(rsapi.ApiParams{})
	if err != nil {
		fmt.Println("failed to find cookbook: %s", err)
	}
	return cookbook
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例10: templateRetrieve

func templateRetrieve(client *cm15.Api, templateLocator string) *cm15.ServerTemplate {
	locator := client.ServerTemplateLocator(templateLocator)
	template, err := locator.Show(rsapi.ApiParams{})
	if err != nil {
		fmt.Println("failed to find server template: %s", err)
	}
	return template
}
开发者ID:abhashyam,项目名称:deployment,代码行数:8,代码来源:deployment.go


示例11: inputsRetrieve

func inputsRetrieve(client *cm15.Api, inputsLocator string) []Input {
	locator := client.InputLocator(inputsLocator)
	inputs, err := locator.Index(rsapi.ApiParams{})
	if err != nil {
		fmt.Println("failed to find inputs: %s", err)
	}
	var inputsRetrieved = make([]Input, len(inputs))
	for index, input := range inputs {
		inputsRetrieved[index] = Input{Name: input.Name, Value: input.Value}
	}
	return inputsRetrieved
}
开发者ID:abhashyam,项目名称:deployment,代码行数:12,代码来源:deployment.go


示例12: server

// Makes a GET call on the given server and returns the current instance of the server.
func server(client *cm15.Api, name string) *cm15.Instance {
	serverLocator := client.ServerLocator("/api/servers")
	servers, err := serverLocator.Index(rsapi.ApiParams{"view": "instance_detail", "filter": []string{"name==" + name}})
	if err != nil {
		fail("Failed to retrieve server: %v\n", err.Error())
	}
	if len(servers) == 0 {
		fail("Could not find server with name: %v\n", name)
	} else if len(servers) != 1 {
		fail("More than one server found with name: %v\n", name)
	}
	return servers[0].CurrentInstance
}
开发者ID:dylanmei,项目名称:rsc,代码行数:14,代码来源:main.go


示例13: fetchAuditEntries

// Make an API call and fetch the audit entries matching specified criteria
func fetchAuditEntries(client *cm15.Api, filterEmail string) ([]*cm15.AuditEntry, error) {
	auditLocator := client.AuditEntryLocator("/api/audit_entries")
	var apiParams = rsapi.ApiParams{"filter": []string{"user_email==" + filterEmail}}
	auditEntries, err := auditLocator.Index(
		tomorrow(),  // End date
		"100",       // Limit
		yesterday(), // Start date
		apiParams,
	)
	if err != nil {
		return auditEntries, err
	}
	return auditEntries, nil
}
开发者ID:dylanmei,项目名称:rsc,代码行数:15,代码来源:main.go


示例14: extractRightScript

func extractRightScript(client *cm15.Api, rightscriptLocator string) RightScript {
	var rs RightScript
	locator := client.RightScriptLocator(rightscriptLocator)
	rightScript, err := locator.Show()
	if err != nil {
		fmt.Println("failed to find right script: %s", err)
	} else {
		rs = RightScript{
			Name:      rightScript.Name,
			Revision:  rightScript.Revision,
			UpdatedAt: rightScript.UpdatedAt,
		}
	}
	return rs
}
开发者ID:abhashyam,项目名称:deployment,代码行数:15,代码来源:deployment.go


示例15: serverArraysRetrieve

func serverArraysRetrieve(client *cm15.Api, serverArraysLocator string) []ServerArray {
	arrayLocator := client.ServerArrayLocator(serverArraysLocator)
	serverArrays, err := arrayLocator.Index(rsapi.ApiParams{"view": "instance_detail"})
	if err != nil {
		fmt.Println("failed to find servers: %s", err)
	}
	var serverArrayList = make([]ServerArray, len(serverArrays))
	for i := 0; i < len(serverArrays); i++ {
		nextInstanceLocator := extractHref(serverArrays[i].Links, "next_instance")
		currentInstancesLocator := extractHref(serverArrays[i].Links, "current_instances")
		var volumes []Volume
		sa := ServerArray{Name: serverArrays[i].Name, Locked: false}
		nextInstance := instanceRetrieve(client, nextInstanceLocator)
		templateLocator := extractHref(nextInstance.Links, "server_template")
		template := templateRetrieve(client, templateLocator)
		sa.Template = template.Name
		templates[templateLocator] = template.Name
		alertSpecs := alertsRetrieve(client, extractHref(serverArrays[i].Links, "alert_specs"))
		alerts = append(alerts, alertSpecs...)
		sa.NextInstance = inputsRetrieve(client, extractHref(nextInstance.Links, "inputs"))
		instanceLocator := client.InstanceLocator(currentInstancesLocator)
		instances, err := instanceLocator.Index(rsapi.ApiParams{})
		if err != nil {
			fmt.Println("failed to find instances: %s", err)
		}
		if len(instances) != 0 {
			currentInstanceLocator := extractHref(instances[0].Links, "self")
			currentInstance := instanceRetrieve(client, currentInstanceLocator)
			sa.CurrentInstance = inputsRetrieve(client, extractHref(currentInstance.Links, "inputs"))
			sa.Locked = currentInstance.Locked
		}
		for _, instance := range instances {
			v := extractVolumesInfo(client, extractHref(instance.Links, "self")+"/volume_attachments")
			volumes = append(volumes, v...)
		}
		if len(volumes) != 0 {
			sa.Volumes = volumes
		}
		serverArrayList[i] = sa
	}
	return serverArrayList
}
开发者ID:abhashyam,项目名称:deployment,代码行数:42,代码来源:deployment.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang metadata.Action类代码示例发布时间:2022-05-28
下一篇:
Golang middleware.GetDOClient函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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