本文整理匯總了Golang中github.com/rightscale/gdo/middleware.GetDOClient函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetDOClient函數的具體用法?Golang GetDOClient怎麽用?Golang GetDOClient使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetDOClient函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}