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

Golang middleware.GetDOClient函数代码示例

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

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



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

示例1: enableDropletIPv6

func enableDropletIPv6(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	return doResourceAction(c, client.DropletActions.EnableIPv6)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:7,代码来源:droplet_actions.go


示例2: enableDropletPrivateNetworking

func enableDropletPrivateNetworking(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	return doResourceAction(c, client.DropletActions.EnablePrivateNetworking)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:7,代码来源:droplet_actions.go


示例3: listDropletBackups

func listDropletBackups(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	return listDropletImages(c, client.Droplets.Backups)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:7,代码来源:droplets.go


示例4: disableDropletBackups

func disableDropletBackups(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	return doResourceAction(c, client.DropletActions.DisableBackups)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:7,代码来源:droplet_actions.go


示例5: powerOnDroplet

func powerOnDroplet(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	return doResourceAction(c, client.DropletActions.PowerOn)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:7,代码来源:droplet_actions.go


示例6: listDropletKernels

func listDropletKernels(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	list := []godo.Kernel{}
	opt := &godo.ListOptions{}
	for {
		kernels, resp, err := client.Droplets.Kernels(id, opt)
		if err != nil {
			return Error(err)
		}
		list = append(list, kernels...)
		if resp.Links == nil || resp.Links.IsLastPage() {
			break
		}
		page, err := resp.Links.CurrentPage()
		if err != nil {
			return Error(err)
		}
		opt.Page = page + 1
	}
	return Respond(c, list, nil)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:28,代码来源:droplets.go


示例7: listDroplets

func listDroplets(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	list, er := paginateDroplets(client.Droplets.List)
	return Respond(c, list, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:8,代码来源:droplets.go


示例8: deleteDroplet

func deleteDroplet(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	_, er := client.Droplets.Delete(id)
	return RespondNoContent(c, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:12,代码来源:droplets.go


示例9: showAction

func showAction(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	action, _, er := client.Actions.Get(id)
	return Respond(c, action, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:12,代码来源:actions.go


示例10: showImage

func showImage(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	image, _, er := client.Images.GetByID(id)
	return Respond(c, image, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:12,代码来源:images.go


示例11: convertImage

func convertImage(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	transferReq := godo.ActionRequest{"type": "convert"}
	action, _, er := client.ImageActions.Transfer(id, &transferReq)
	return Respond(c, action, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:13,代码来源:image_actions.go


示例12: listDropletActions

func listDropletActions(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	list, er := paginateActions(func(opt *godo.ListOptions) ([]godo.Action, *godo.Response, error) {
		return client.Droplets.Actions(id, opt)
	})
	return Respond(c, list, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:14,代码来源:droplets.go


示例13: createKey

func createKey(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	req := godo.KeyCreateRequest{}
	if err = c.Bind(&req); err != nil {
		return err
	}
	key, _, er := client.Keys.Create(&req)
	if er == nil {
		c.Response.Header().Set("Location", keyHref(key.ID))
	}
	return RespondNoContent(c, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:15,代码来源:keys.go


示例14: createDroplet

func createDroplet(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	req := godo.DropletCreateRequest{}
	if err = c.Bind(&req); err != nil {
		return err
	}
	root, _, er := client.Droplets.Create(&req)
	if er == nil {
		c.Response.Header().Set("Location", dropletHref(root.Droplet.ID))
	}
	return RespondNoContent(c, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:15,代码来源:droplets.go


示例15: showKey

func showKey(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	key, _, er := client.Keys.GetByID(id)
	if er != nil {
		return Error(er)
	}
	return Respond(c, key, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:15,代码来源:keys.go


示例16: updateKey

func updateKey(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	req := godo.KeyUpdateRequest{}
	if err = c.Bind(&req); err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	_, _, er := client.Keys.UpdateByID(id, &req)
	return RespondNoContent(c, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:16,代码来源:keys.go


示例17: restoreDroplet

func restoreDroplet(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	req := struct {
		ImageID int `json:"imageID"`
	}{}
	err = c.Bind(&req)
	if err != nil {
		return err
	}
	return doResourceAction(c, func(id int) (*godo.Action, *godo.Response, error) {
		return client.DropletActions.Restore(id, req.ImageID)
	})
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:16,代码来源:droplet_actions.go


示例18: snapshotDroplet

func snapshotDroplet(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	req := struct {
		Name string `json:"name"`
	}{}
	err = c.Bind(&req)
	if err != nil {
		return err
	}
	return doResourceAction(c, func(id int) (*godo.Action, *godo.Response, error) {
		return client.DropletActions.Snapshot(id, req.Name)
	})
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:16,代码来源:droplet_actions.go


示例19: showDroplet

func showDroplet(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	id, err := getIDParam(c)
	if err != nil {
		return err
	}
	root, _, er := client.Droplets.Get(id)
	var droplet *Droplet
	if err == nil {
		droplet = DropletFromApi(root.Droplet)
	}
	return Respond(c, droplet, er)
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:16,代码来源:droplets.go


示例20: changeDropletKernel

func changeDropletKernel(c *echo.Context) *echo.HTTPError {
	client, err := middleware.GetDOClient(c)
	if err != nil {
		return err
	}
	req := struct {
		KernelID int `json:"kernelID"`
	}{}
	err = c.Bind(&req)
	if err != nil {
		return err
	}
	return doResourceAction(c, func(id int) (*godo.Action, *godo.Response, error) {
		return client.DropletActions.ChangeKernel(id, req.KernelID)
	})
}
开发者ID:cdwilhelm,项目名称:self-service-plugins,代码行数:16,代码来源:droplet_actions.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang cm15.Api类代码示例发布时间:2022-05-28
下一篇:
Golang siegreader.Buffer类代码示例发布时间: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