Esempio n. 1
0
// Client() returns a new client for accessing RightScale.
func (c *Config) Client() (*cm15.API, error) {
	auth := rsapi.NewOAuthAuthenticator(c.RefreshToken, c.AccountID)
	client := cm15.New("us-3.rightscale.com", auth)

	log.Printf("[INFO] RightScale Client configured for account: %s", c.AccountID)

	return client, nil
}
Esempio n. 2
0
func (account *Account) Client16() (*cm16.API, error) {
	if account.client16 == nil {
		if err := account.validate(); err != nil {
			return nil, err
		}
		auth := rsapi.NewOAuthAuthenticator(account.RefreshToken, account.Id)
		account.client16 = cm16.New(account.Host, auth)
	}
	return account.client16, nil
}
Esempio n. 3
0
func NewClient(apiHost, ssHost string, account int, token string) (*Client, error) {
	apiAuth := rsapi.NewOAuthAuthenticator(token, account)
	apiAuth.SetHost(apiHost)

	if err := apiAuth.CanAuthenticate(apiHost); err != nil {
		return nil, fmt.Errorf("invalid credentials: %s\n", err)
	}

	ssAuth := rsapi.NewSSAuthenticator(apiAuth, account)
	return &Client{
		account:  account,
		designer: ssd.New(ssHost, ssAuth),
		manager:  ssm.New(ssHost, ssAuth),
	}, nil
}