func (s *Scheme) New(versionName, typeName string) (Object, error) {
	obj, err := s.raw.NewObject(versionName, typeName)
	if err != nil {
		return nil, err
	}
	return obj.(Object), nil
}
New returns a new API object of the given version ("" for internal
representation) and name, or an error if it hasn't been registered.
package runtime
import (
	"fmt"
	"reflect"
	"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
)
type Scheme struct {
	raw *conversion.Scheme
}
func (self *Scheme) fromScope(s conversion.Scope) (inVersion, outVersion string, scheme *Scheme) {
	scheme = self
	inVersion = s.Meta().SrcVersion
	outVersion = s.Meta().DestVersion
	return inVersion, outVersion, scheme
}
type emptyPlugin struct {
	PluginBase `json:",inline"`
}
func (self *Scheme) embeddedObjectToRawExtension(in *EmbeddedObject, out *RawExtension, s conversion.Scope) error {
	if in.Object == nil {
		out.RawJSON = []byte("null")
		return nil
	}
	_, outVersion, scheme := self.fromScope(s)
	_, kind, err := scheme.raw.ObjectVersionAndKind(in.Object)
	if err != nil {
		return err
	}
	outObj, err := scheme.New(outVersion, kind)
	if err != nil {
		return err
	}
	err = s.Convert(in.Object, outObj, 0)
	if err != nil {
		return err
	}
	err = s.Convert(
		&emptyPlugin{PluginBase: PluginBase{Kind: kind}},
		outObj,
		conversion.SourceToDest|conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames,
	)
	if err != nil {
		return err
	}
	raw, err := scheme.EncodeToVersion(outObj, outVersion)
	if err != nil {
		return err
	}
	out.RawJSON = raw
	return nil
}
func (self *Scheme) rawExtensionToEmbeddedObject(in *RawExtension, out *EmbeddedObject, s conversion.Scope) error {
	if len(in.RawJSON) == 0 || (len(in.RawJSON) == 4 && string(in.RawJSON) == "null") {
		out.Object = nil
		return nil
	}
	inVersion, outVersion, scheme := self.fromScope(s)
	_, kind, err := scheme.raw.DataVersionAndKind(in.RawJSON)
	if err != nil {
		return err
	}
	inObj, err := scheme.New(inVersion, kind)
	if err != nil {
		return err
	}
	err = scheme.DecodeInto(in.RawJSON, inObj)
	if err != nil {
		return err
	}
	outObj, err := scheme.New(outVersion, kind)
	if err != nil {
		return err
	}
	err = scheme.Convert(inObj, outObj)
	if err != nil {
		return err
	}
	err = s.Convert(
		&emptyPlugin{PluginBase: PluginBase{Kind: ""}},
		outObj,
		conversion.SourceToDest|conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames,
	)
	if err != nil {
		return err
	}
	out.Object = outObj
	return nil
}
func (self *Scheme) runtimeObjectToRawExtensionArray(in *[]Object, out *[]RawExtension, s conversion.Scope) error {
	src := *in
	dest := make([]RawExtension, len(src))
	_, outVersion, scheme := self.fromScope(s)
	for i := range src {
		switch t := src[i].(type) {
		case *Unknown:
			dest[i].RawJSON = t.RawJSON
		default:
			data, err := scheme.EncodeToVersion(src[i], outVersion)
			if err != nil {
				return err
			}
			dest[i].RawJSON = data
		}
	}
	*out = dest
	return nil
}
func (self *Scheme) rawExtensionToRuntimeObjectArray(in *[]RawExtension, out *[]Object, s conversion.Scope) error {
	src := *in
	dest := make([]Object, len(src))
	_, _, scheme := self.fromScope(s)
	for i := range src {
		data := src[i].RawJSON
		obj, err := scheme.Decode(data)
		if err != nil {
			if !IsNotRegisteredError(err) {
				return err
			}
			version, kind, err := scheme.raw.DataVersionAndKind(data)
			if err != nil {
				return err
			}
			obj = &Unknown{
				TypeMeta: TypeMeta{
					APIVersion: version,
					Kind:       kind,
				},
				RawJSON: data,
			}
		}
		dest[i] = obj
	}
	*out = dest
	return nil
}
func NewScheme() *Scheme {
	s := &Scheme{conversion.NewScheme()}
	s.raw.InternalVersion = ""
	s.raw.MetaFactory = conversion.SimpleMetaFactory{BaseFields: []string{"TypeMeta"}, VersionField: "APIVersion", KindField: "Kind"}
	if err := s.raw.AddConversionFuncs(
		s.embeddedObjectToRawExtension,
		s.rawExtensionToEmbeddedObject,
		s.runtimeObjectToRawExtensionArray,
		s.rawExtensionToRuntimeObjectArray,
	); err != nil {
		panic(err)
	}
	return s
}
func (s *Scheme) AddKnownTypes(version string, types ...Object) {
	interfaces := make([]interface{}, len(types))
	for i := range types {
		interfaces[i] = types[i]
	}
	s.raw.AddKnownTypes(version, interfaces...)
}
func (s *Scheme) AddKnownTypeWithName(version, kind string, obj Object) {
	s.raw.AddKnownTypeWithName(version, kind, obj)
}
func (s *Scheme) KnownTypes(version string) map[string]reflect.Type {
	return s.raw.KnownTypes(version)
}
func (s *Scheme) DataVersionAndKind(data []byte) (version, kind string, err error) {
	return s.raw.DataVersionAndKind(data)
}
func (s *Scheme) ObjectVersionAndKind(obj Object) (version, kind string, err error) {
	return s.raw.ObjectVersionAndKind(obj)
}