// NewTenant creates a new tenant using the given name and description. The
// third parameter is a flag that indicates if the tenant should be enabled or
// not.
NewTenant creates a new tenant using the given name and description. The
third parameter is a flag that indicates if the tenant should be enabled or
not.
// NewTenant creates a new tenant using the given name and description . The // third parameter is a flag that indicates if the tenant should be enabled or // not .
func (c *Client) NewTenant(name, description string, enabled bool) (*Tenant, error) {
	b := bytes.NewBufferString(fmt.Sprintf(`{"tenant": {"name": "%s", "description": "%s", "enabled": %t}}`, name, description, enabled))
	response, _ := c.do("POST", c.authUrl+"/tenants", b)
	defer response.Body.Close()
	result, _ := ioutil.ReadAll(response.Body)
	if response.StatusCode > 399 {
		return nil, fmt.Errorf("Error while performing request: %d, %s", response.StatusCode, string(result))
	}
	var data map[string]map[string]interface{}
	_ = json.Unmarshal(result, &data)
	tenant := Tenant{
		Id:          data["tenant"]["id"].(string),
		Name:        data["tenant"]["name"].(string),
		Description: data["tenant"]["description"].(string),
	}
	return &tenant, nil
}
func ( c * Client ) NewTenant ( name , description string , enabled bool ) ( * Tenant , error ) { b := bytes . NewBufferString ( fmt . Sprintf ( `{"tenant": {"name": "%s", "description": "%s", "enabled": %t}}` , name , description , enabled ) ) response , _ := c . do ( " " , c . authUrl + " " , b ) defer response . Body . Close ( ) result , _ := ioutil . ReadAll ( response . Body ) if response . StatusCode > 399 { return nil , fmt . Errorf ( " " , response . StatusCode , string ( result ) ) } var data map [ string ] map [ string ] interface { } _ = json . Unmarshal ( result , & data ) tenant := Tenant { Id : data [ " " ] [ " " ] . ( string ) , Name : data [ " " ] [ " " ] . ( string ) , Description : data [ " " ] [ " " ] . ( string ) , } return & tenant , nil }
NewTenant creates a new tenant using the given name and description.
NewTenant creates a new tenant using the given name and description .
// TODO (flaviamissi): when keystone url is passed with 5000 port, it returns 200 with no body!