func (c *Client) Create(ptr IObject) error {
	xtype := typename(ptr)
	url := fmt.Sprintf("%s://%s:%d/%ss", c.scheme, c.server, c.port, xtype)
	objJson, err := json.Marshal(ptr)
	if err != nil {
		return err
	}
	var rawJson json.RawMessage = objJson
	msg := map[string]*json.RawMessage{
		xtype: &rawJson,
	}
	data, err := json.Marshal(msg)
	resp, err := c.httpPost(url, "application/json", bytes.NewReader(data))
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("%s: %s", resp.Status, body)
	}
	ptr.SetClient(c)
	var m map[string]json.RawMessage
	err = json.Unmarshal(body, &m)
	if err != nil {
		return err
	}
	return json.Unmarshal(m[xtype], ptr)
}
Create an object in the OpenContrail API server.

The object must have been initialized with a name.
package contrail
import (
	"bytes"
	"crypto/tls"
	"crypto/x509"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"reflect"
	"strings"
	"unicode"
)
type TypeMap map[string]reflect.Type
type objectInterface interface {
	GetField(IObject, string) error
	UpdateReference(*ReferenceUpdateMsg) error
}
type Authenticator interface {
	AddAuthentication(*http.Request) error
}
type NopAuthenticator struct {
}
func (*NopAuthenticator) AddAuthentication(*http.Request) error {
	return nil
}
type Encryptor interface {
	AddEncryption(caFile string, keyFile string, certFile string, insecure bool) error
}
type NopEncryptor struct {
}
func (*NopEncryptor) AddEncryption(caFile string, keyFile string, certFile string, insecure bool) error {
	return nil
}
func (c *Client) AddEncryption(caFile string, keyFile string, certFile string, insecure bool) error {
	c.scheme = "https"
	tlsConfig := &tls.Config{}
	if insecure {
		tlsConfig.InsecureSkipVerify = true
	} else if caFile != "" {
		caCert, err := ioutil.ReadFile(caFile)
		if err != nil {
			return nil
		}
		caCertPool := x509.NewCertPool()
		caCertPool.AppendCertsFromPEM(caCert)
		tlsConfig.RootCAs = caCertPool
		if certFile != "" && keyFile != "" {
			cert, err := tls.LoadX509KeyPair(certFile, keyFile)
			if err != nil {
				return nil
			}
			tlsConfig.Certificates = []tls.Certificate{cert}
		} else {
			tlsConfig.InsecureSkipVerify = true
		}
	}
	transport := &http.Transport{
		TLSClientConfig: tlsConfig,
	}
	c.httpClient.Transport = transport
	return nil
}
type ApiClient interface {
	Create(ptr IObject) error
	Update(ptr IObject) error
	DeleteByUuid(typename, uuid string) error
	Delete(ptr IObject) error
	FindByUuid(typename string, uuid string) (IObject, error)
	UuidByName(typename string, fqn string) (string, error)
	FQNameByUuid(uuid string) ([]string, error)
	FindByName(typename string, fqn string) (IObject, error)
	List(typename string) ([]ListResult, error)
	ListByParent(typename string, parentID string) ([]ListResult, error)
	ListDetail(typename string, fields []string) ([]IObject, error)
	ListDetailByParent(typename string, parentID string, fields []string) ([]IObject, error)
}
type Client struct {
	server     string
	scheme     string
	port       int
	httpClient *http.Client
	auth       Authenticator
	encrypt    Encryptor
}
type TlsConfig struct {
	ca   string
	key  string
	cert string
}
type ListResult struct {
	Fq_name []string
	Href    string
	Uuid    string
}
var (
	typeMap TypeMap
)
func NewClient(server string, port int) *Client {
	client := new(Client)
	client.server = server
	client.port = port
	client.scheme = "http"
	client.httpClient = &http.Client{}
	client.auth = new(NopAuthenticator)
	client.encrypt = new(NopEncryptor)
	return client
}
func (c *Client) GetServer() string {
	return c.server
}
func (c *Client) SetAuthenticator(auth Authenticator) {
	c.auth = auth
}
func (c *Client) SetEncryptor(encrypt Encryptor) {
	c.encrypt = encrypt
}
func typename(ptr IObject) string {
	name := reflect.TypeOf(ptr).Elem().Name()
	var buf []rune
	for i, c := range name {
		if unicode.IsUpper(c) {
			if i > 0 {
				buf = append(buf, '-')
			}
			buf = append(buf, unicode.ToLower(c))
		} else {
			buf = append(buf, c)
		}
	}
	return string(buf)
}
func (c *Client) httpPost(url string, bodyType string, body io.Reader) (
	*http.Response, error) {
	req, err := http.NewRequest("POST", url, body)
	if err != nil {
		return nil, err
	}
	req.Header.Set("Content-Type", bodyType)
	err = c.auth.AddAuthentication(req)
	if err != nil {
		return nil, err
	}
	return c.httpClient.Do(req)
}
func (c *Client) httpPut(url string, bodyType string, body io.Reader) (
	*http.Response, error) {
	req, err := http.NewRequest("PUT", url, body)
	if err != nil {
		return nil, err
	}
	req.Header.Set("Content-Type", bodyType)
	err = c.auth.AddAuthentication(req)
	if err != nil {
		return nil, err
	}
	return c.httpClient.Do(req)
}
func (c *Client) httpGet(url string) (*http.Response, error) {
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}
	err = c.auth.AddAuthentication(req)
	if err != nil {
		return nil, err
	}
	return c.httpClient.Do(req)
}
func (c *Client) httpDelete(url string) (*http.Response, error) {
	req, err := http.NewRequest("DELETE", url, nil)
	if err != nil {
		return nil, err
	}
	err = c.auth.AddAuthentication(req)
	if err != nil {
		return nil, err
	}
	return c.httpClient.Do(req)
}