func (m *ApiClient) DeleteByUuid(typename string, id string) error {
	obj, err := m.db.GetByUUID(uuid.Parse(id))
	if err != nil {
		return err
	}
	return m.db.Delete(obj)
}
DeleteByUuid removes the object identified by the specified uuid.
package mocks
import (
	"fmt"
	"strings"
	"github.com/Juniper/contrail-go-api"
	"github.com/Juniper/contrail-go-api/types"
	"github.com/pborman/uuid"
)
type TypeInterceptor interface {
	Get(contrail.IObject)
	Put(contrail.IObject)
}
type ApiClient struct {
	IDAssignMap    map[string]string
	InterceptorMap map[string]TypeInterceptor
	db             Database
	updater        *objectUpdater
}
func (m *ApiClient) Init() {
	m.db = NewInMemDatabase()
	m.updater = NewObjectUpdater(m.db)
	domain := new(types.Domain)
	domain.SetName("default-domain")
	err := m.Create(domain)
	if err != nil {
		panic(err.Error())
	}
	project := new(types.Project)
	project.SetFQName("domain", []string{"default-domain", "default-project"})
	err = m.Create(project)
	if err != nil {
		panic(err.Error())
	}
	ipam := new(types.NetworkIpam)
	ipam.SetFQName("project", []string{"default-domain", "default-project", "default-network-ipam"})
	err = m.Create(ipam)
	if err != nil {
		panic(err.Error())
	}
}
func objName(ptr contrail.IObject) string {
	return ptr.GetType() + ":" + strings.Join(ptr.GetFQName(), ":")
}
func (m *ApiClient) AddInterceptor(typename string, interceptor TypeInterceptor) {
	if m.InterceptorMap == nil {
		m.InterceptorMap = make(map[string]TypeInterceptor)
	}
	m.InterceptorMap[typename] = interceptor
}
func (m *ApiClient) interceptPut(ptr contrail.IObject) {
	if m.InterceptorMap == nil {
		return
	}
	if interceptor, ok := m.InterceptorMap[ptr.GetType()]; ok {
		interceptor.Put(ptr)
	}
}
func (m *ApiClient) interceptGet(ptr contrail.IObject) {
	if m.InterceptorMap == nil {
		return
	}
	if interceptor, ok := m.InterceptorMap[ptr.GetType()]; ok {
		interceptor.Get(ptr)
	}
}
func (m *ApiClient) getParent(obj contrail.IObject) (contrail.IObject, error) {
	typename := obj.GetParentType()
	if len(typename) == 0 || typename == "config-root" {
		return nil, nil
	}
	fqn := obj.GetFQName()
	parentName := fqn[:len(fqn)-1]
	return m.db.GetByName(typename, strings.Join(parentName, ":"))
}
func (m *ApiClient) Create(ptr contrail.IObject) error {
	if ptr.GetUuid() == "" {
		isSet := false
		if m.IDAssignMap != nil {
			if id, ok := m.IDAssignMap[objName(ptr)]; ok {
				ptr.SetUuid(id)
				isSet = true
			}
		}
		if !isSet {
			ptr.SetUuid(uuid.New())
		}
	}
	parent, err := m.getParent(ptr)
	if err != nil {
		return err
	}
	m.interceptPut(ptr)
	refList := getReferenceList(ptr)
	m.db.Put(ptr, parent, refList)
	ptr.SetClient(m.updater)
	return nil
}
func (m *ApiClient) Update(ptr contrail.IObject) error {
	refList := getReferenceList(ptr)
	m.db.Update(ptr, refList)
	return nil
}