cm15/codegen_client.go
func (loc *Oauth2Locator) Create(grantType string, options rsapi.APIParams) (map[string]interface{}, error) {
	var res map[string]interface{}
	if grantType == "" {
		return res, fmt.Errorf("grantType is required")
	}
	var params rsapi.APIParams
	var p rsapi.APIParams
	p = rsapi.APIParams{
		"grant_type": grantType,
	}
	var accountIdOpt = options["account_id"]
	if accountIdOpt != nil {
		p["account_id"] = accountIdOpt
	}
	var clientIdOpt = options["client_id"]
	if clientIdOpt != nil {
		p["client_id"] = clientIdOpt
	}
	var clientSecretOpt = options["client_secret"]
	if clientSecretOpt != nil {
		p["client_secret"] = clientSecretOpt
	}
	var rsVersionOpt = options["r_s_version"]
	if rsVersionOpt != nil {
		p["r_s_version"] = rsVersionOpt
	}
	var refreshTokenOpt = options["refresh_token"]
	if refreshTokenOpt != nil {
		p["refresh_token"] = refreshTokenOpt
	}
	var rightLinkVersionOpt = options["right_link_version"]
	if rightLinkVersionOpt != nil {
		p["right_link_version"] = rightLinkVersionOpt
	}
	uri, err := loc.ActionPath("Oauth2", "create")
	if err != nil {
		return res, err
	}
	req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
	if err != nil {
		return res, err
	}
	resp, err := loc.api.PerformRequest(req)
	if err != nil {
		return res, err
	}
	defer resp.Body.Close()
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		respBody, _ := ioutil.ReadAll(resp.Body)
		sr := string(respBody)
		if sr != "" {
			sr = ": " + sr
		}
		return res, fmt.Errorf("invalid response %s%s", resp.Status, sr)
	}
	defer resp.Body.Close()
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return res, err
	}
	err = json.Unmarshal(respBody, &res)
	return res, err
}
func (loc *Oauth2Locator) Create(grantType string, options rsapi.APIParams) (map[string]interface{}, error) {
	var res map[string]interface{}
	if grantType == "" {
		return res, fmt.Errorf("grantType is required")
	}
	var params rsapi.APIParams
	var p rsapi.APIParams
	p = rsapi.APIParams{
		"grant_type": grantType,
	}
	var accountIdOpt = options["account_id"]
	if accountIdOpt != nil {
		p["account_id"] = accountIdOpt
	}
	var clientIdOpt = options["client_id"]
	if clientIdOpt != nil {
		p["client_id"] = clientIdOpt
	}
	var clientSecretOpt = options["client_secret"]
	if clientSecretOpt != nil {
		p["client_secret"] = clientSecretOpt
	}
	var rsVersionOpt = options["r_s_version"]
	if rsVersionOpt != nil {
		p["r_s_version"] = rsVersionOpt
	}
	var refreshTokenOpt = options["refresh_token"]
	if refreshTokenOpt != nil {
		p["refresh_token"] = refreshTokenOpt
	}
	var rightLinkVersionOpt = options["right_link_version"]
	if rightLinkVersionOpt != nil {
		p["right_link_version"] = rightLinkVersionOpt
	}
	uri, err := loc.ActionPath("Oauth2", "create")
	if err != nil {
		return res, err
	}
	req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
	if err != nil {
		return res, err
	}
	resp, err := loc.api.PerformRequest(req)
	if err != nil {
		return res, err
	}
	defer resp.Body.Close()
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		respBody, _ := ioutil.ReadAll(resp.Body)
		sr := string(respBody)
		if sr != "" {
			sr = ": " + sr
		}
		return res, fmt.Errorf("invalid response %s%s", resp.Status, sr)
	}
	defer resp.Body.Close()
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return res, err
	}
	err = json.Unmarshal(respBody, &res)
	return res, err
}
//===== Actions
// POST /api/oauth2/
//
// Perform an OAuth 2.0 token_refresh operation to obtain an access token that
// can be used in lieu of an API session cookie. (In other words, creates a
// session using OAuth 2.0).
// Note that an API-Version header is required with your request, and that the server
// may respond with a 301 Moved Permanently if you include an account_id parameter and
// your account is hosted in another RightScale cluster.
// The request parameters and response format are all as per the OAuth 2.0
// Internet Draft standard v23. In brief:
// - Successful responses include an access token, an expires-in timestamp, and a token type
// - The token type is always "bearer"
// - To use a bearer token, include header "Authorization: Bearer " with your API requests
// - The client must refresh the access token before it expires
// # Example Request using Curl (with prettified response):
// curl -i -H X-API-Version:1.5 -x POST https://my.rightscale.com/api/oauth2 -d "grant_type=refresh_token" -d "refresh_token=abcd1234deadbeef"
// {
// "access_token": "xyzzy",
// "expires_in":   3600,
// "token_type":   "bearer"
// }
// Required parameters:
// grant_type: Type of grant.
// Optional parameters:
// account_id: The client's account ID (only needed for instance agent clients).
// client_id: The client ID (only needed for confidential clients).
// client_secret: The client secret (only needed for confidential clients).
// r_s_version: The RightAgent protocol version the client conforms to (only needed for instance agent clients).
// refresh_token: The refresh token obtained from OAuth grant.
// right_link_version: The RightLink gem version the client conforms to (only needed for instance agent clients).