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

Golang godo.NewClient函数代码示例

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

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



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

示例1: VerifyCredential

// VerifyCredential verifies whether the users DO credentials (access token) is
// valid or not
func (s *Stack) VerifyCredential(c *stack.Credential) error {
	cred := c.Credential.(*Credential)

	if err := cred.Valid(); err != nil {
		return err
	}

	oauthClient := oauth2.NewClient(
		oauth2.NoContext,
		oauth2.StaticTokenSource(&oauth2.Token{AccessToken: cred.AccessToken}),
	)

	client := godo.NewClient(oauthClient)

	// let's retrieve our Account information. If it's successful, we're good
	// to go
	_, _, err := client.Account.Get()
	if err != nil {
		return &stack.Error{
			Err: err,
		}
	}

	return nil
}
开发者ID:koding,项目名称:koding,代码行数:27,代码来源:stack.go


示例2: GetClient

func GetClient() *godo.Client {
	token := &oauth2.Token{AccessToken: token}
	t := oauth2.StaticTokenSource(token)

	oauthClient := oauth2.NewClient(oauth2.NoContext, t)
	return godo.NewClient(oauthClient)
}
开发者ID:carriercomm,项目名称:doenv,代码行数:7,代码来源:lib.go


示例3: getClient

func (d *Driver) getClient() *godo.Client {
	token := &oauth2.Token{AccessToken: d.AccessToken}
	tokenSource := oauth2.StaticTokenSource(token)
	client := oauth2.NewClient(oauth2.NoContext, tokenSource)

	return godo.NewClient(client)
}
开发者ID:mschygulla,项目名称:machine,代码行数:7,代码来源:digitalocean.go


示例4: GetClient

// GetClient returns a godo client.
func GetClient(token string) *godo.Client {
	tokenSource := &TokenSource{AccessToken: token}
	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	client := godo.NewClient(oauthClient)
	client.BaseURL = GodoBase
	return client
}
开发者ID:andrewsomething,项目名称:floatctl,代码行数:8,代码来源:util.go


示例5: New

// New returns a new instance of DoImages
func New(conf *DoConfig) (*DoImages, error) {
	if conf.Token == "" {
		return nil, errors.New("Access Token is not set. Please check your configuration.")
	}

	// increase the timeout
	timeout := time.Second * 30
	client := &http.Client{
		Transport: &http.Transport{TLSHandshakeTimeout: timeout},
		Timeout:   timeout,
	}

	// we need to pass the client with the context itself
	ctx := context.WithValue(oauth2.NoContext, oauth2.HTTPClient, client)

	oauthClient := oauth2.NewClient(ctx, &tokenSource{
		AccessToken: conf.Token,
	})

	godoClient := godo.NewClient(oauthClient)

	return &DoImages{
		client: godoClient,
		images: make([]godo.Image, 0),
	}, nil
}
开发者ID:hanscj1,项目名称:images,代码行数:27,代码来源:do.go


示例6: getClient

func (d *Driver) getClient() *godo.Client {
	t := &oauth.Transport{
		Token: &oauth.Token{AccessToken: d.AccessToken},
	}

	return godo.NewClient(t.Client())
}
开发者ID:robebeye,项目名称:machine,代码行数:7,代码来源:digitalocean.go


示例7: clientFromToken

func clientFromToken(pat string) *godo.Client {
	tokenSrc := &tokenSource{
		AccessToken: pat,
	}

	return godo.NewClient(oauth2.NewClient(oauth2.NoContext, tokenSrc))
}
开发者ID:franciscod,项目名称:dokernel,代码行数:7,代码来源:client_setup.go


示例8: loadDoClient

func loadDoClient() {
	tokenSource := &TokenSource{
		AccessToken: globalConfig.APIToken,
	}

	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	doClient = godo.NewClient(oauthClient)
}
开发者ID:1lann,项目名称:dynamicserver,代码行数:8,代码来源:do_client.go


示例9: GetClientHandle

func (dm *DoDropletMarshaller) GetClientHandle(token string) *godo.Client {
	tokenSource := &TokenSource{
		AccessToken: token,
	}
	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	client := godo.NewClient(oauthClient)
	return client
}
开发者ID:packetassailant,项目名称:D2Deploy,代码行数:8,代码来源:d2deploy.go


示例10: getClinet

func getClinet(accessToken string) *godo.Client {

	t := &oauth.Transport{
		Token: &oauth.Token{AccessToken: accessToken},
	}
	return godo.NewClient(t.Client())

}
开发者ID:rodolfobandeira,项目名称:godo-cli,代码行数:8,代码来源:main.go


示例11: NewDOClient

func NewDOClient(token string) *godo.Client {
	tokenSource := &TokenSource{
		AccessToken: token,
	}
	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	client := godo.NewClient(oauthClient)
	return client
}
开发者ID:pulcy,项目名称:quark,代码行数:8,代码来源:client.go


示例12: NewClient

// NewClient creates creates a godo.Client givent a token.
func (cs *LiveConfig) NewClient(token string) *godo.Client {
	tokenSource := &TokenSource{
		AccessToken: token,
	}

	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	return godo.NewClient(oauthClient)
}
开发者ID:mattkanwisher,项目名称:doit,代码行数:9,代码来源:util.go


示例13: MakeDigitalOcean

func MakeDigitalOcean(token string) *DigitalOcean {
	do := new(DigitalOcean)
	tokenSource := &TokenSource{
		AccessToken: token,
	}
	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	do.client = godo.NewClient(oauthClient)
	return do
}
开发者ID:LunaNode,项目名称:cloug,代码行数:9,代码来源:digitalocean.go


示例14: getClient

func getClient(token string) *godo.Client {
	ts := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: token},
	)
	tc := oauth2.NewClient(oauth2.NoContext, ts)

	client := godo.NewClient(tc)

	return client
}
开发者ID:Tinker-Ware,项目名称:digital-ocean-service,代码行数:10,代码来源:keys.go


示例15: withClient

func withClient(handler http.Handler, fn func(client *godo.Client) error) error {
	server := httptest.NewServer(handler)
	defer server.Close()

	client := godo.NewClient(nil)
	url, _ := url.Parse(server.URL)
	client.BaseURL = url

	return fn(client)
}
开发者ID:koding,项目名称:koding,代码行数:10,代码来源:machine_test.go


示例16: MakeDigitalOcean

func MakeDigitalOcean(region string, token string) *DigitalOcean {
	this := new(DigitalOcean)
	this.region = region
	tokenSource := &TokenSource{
		AccessToken: token,
	}
	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	this.client = godo.NewClient(oauthClient)
	return this
}
开发者ID:yashodhank,项目名称:lobster,代码行数:10,代码来源:digitalocean.go


示例17: NewDropletHandler

func NewDropletHandler(settings Settings) *DropletHandler {
	retval := new(DropletHandler)
	retval.settings = settings

	// setup DO client
	tokenSource := &tokenSource{settings.ApiToken}
	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	retval.client = godo.NewClient(oauthClient)

	return retval
}
开发者ID:gtalent,项目名称:dospin,代码行数:11,代码来源:droplethandler.go


示例18: Client

// Client() returns a new client for accessing digital ocean.
func (c *Config) Client() (*godo.Client, error) {
	tokenSrc := oauth2.StaticTokenSource(&oauth2.Token{
		AccessToken: c.Token,
	})

	client := godo.NewClient(oauth2.NewClient(oauth2.NoContext, tokenSrc))

	log.Printf("[INFO] DigitalOcean Client configured for URL: %s", client.BaseURL.String())

	return client, nil
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:12,代码来源:config.go


示例19: Setup

func (p *digitalOceanProvider) Setup() error {
	readEnv()
	token := envSet.Var("DO_TOKEN").Value.Get().(string)
	if token == "" {
		return fmt.Errorf("DO_TOKEN required for Digital Ocean provider")
	}
	tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
	oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)
	p.client = godo.NewClient(oauthClient)
	_, _, err := p.client.Account.Get()
	return err
}
开发者ID:TheNathanBlack,项目名称:hostctl,代码行数:12,代码来源:provider.go


示例20: Setup

// Setup a new client with an access_token.
func (p *DOProvider) Setup() error {
	token := env.String("do_access_token", "", "digitalocean PAT token")
	if token == "" {
		return errors.New("access key required")
	}

	t := &oauth.Transport{
		Token: &oauth.Token{AccessToken: token},
	}

	p.client = godo.NewClient(t.Client())

	return nil
}
开发者ID:simplexlab,项目名称:remotectl,代码行数:15,代码来源:digitalocean.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang godo.DropletCreateSSHKey类代码示例发布时间:2022-05-23
下一篇:
Golang oauth2.NewClient函数代码示例发布时间: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