当前位置: 首页>>代码示例>>Golang>>正文


Golang godo.NewClient函数代码示例

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


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


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