當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。