當前位置: 首頁>>代碼示例>>Golang>>正文


Golang middleware.GetDOClient函數代碼示例

本文整理匯總了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)
}
開發者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


注:本文中的github.com/rightscale/gdo/middleware.GetDOClient函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。