// NewUsProductType returns returns an 'enum' value of type usProductType given its
// string representation
427906
func NewUsProductType(s string) (usProductType, error) {
	var e usProductType
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
802642
func (apiDef *APIDefinition) createType(name string, tip interface{},
	inputProps map[interface{}]interface{}) bool {

	created := false
	// check that there is no type with this name
	if _, exist := apiDef.Types[name]; exist {
		return created
	}

	// convert the inputProps to properties
	props := make(map[string]interface{})

	for k, p := range inputProps {
		name, ok := k.(string)
		if !ok {
			panic(fmt.Errorf("property key:%v need to be a string", k))
		}
		props[name] = p
	}

	t := Type{
		Name:       name,
		Type:       tip,
		Properties: props,
	}
	apiDef.Types[name] = t
	created = true
	return created
}
1361293
func NewOptBuyType(s string) (optBuyType, error) {
	var e optBuyType
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
81276
func NewGroupAddExternalIdType(Description string) *GroupAddExternalIdType {
	s := new(GroupAddExternalIdType)
	s.Description = Description
	return s
}
1013851
func NewProductBuilder(name string, client speed.Client) *ProductBuilder {
	completed, err := speed.NewPCPCounter(0, "products."+name+".count")
	if err != nil {
		log.Fatal("Could not create completed, error: ", err)
	}

	totalTime, err := speed.NewPCPGauge(0, "products."+name+".time")
	if err != nil {
		log.Fatal("Could not create totalTime, error: ", err)
	}

	client.MustRegister(completed)
	client.MustRegister(totalTime)

	return &ProductBuilder{
		name:      name,
		bound:     500,
		completed: completed,
		totalTime: totalTime,
	}
}
1124032
func NewBaseType(init ...interface{}) BaseType {
	if len(init) == 1 {
		switch v := init[0].(type) {
		case BaseType:
			return v
		case int:
			return BaseType(v)
		case int32:
			return BaseType(v)
		case string:
			for i, s := range namesBaseType {
				if s == v {
					return BaseType(i)
				}
			}
		default:
			panic("Bad init value for BaseType enum")
		}
	}
	return BaseType(0) //default to the first enum value
}
1073250
func NewRelType(s string) (relType, error) {
	var e relType
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
157628
func NewPaperDocUnresolveCommentType(Description string) *PaperDocUnresolveCommentType {
	s := new(PaperDocUnresolveCommentType)
	s.Description = Description
	return s
}
644484
func NewHolderType(s string) (holderType, error) {
	var e holderType
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
627915
func NewAcctType(s string) (acctType, error) {
	var e acctType
	err := e.FromString(s)
	if err != nil {
		return 0, err
	}
	return e, nil
}
1237006
func NewPaperDocEditType(Description string) *PaperDocEditType {
	s := new(PaperDocEditType)
	s.Description = Description
	return s
}
33606
func newEnum(structName string, prop raml.Property, pkg string, fromStruct bool) *enum {
	e := enum{
		Name: strings.Title(structName) + strings.Title(prop.Name),
		Type: convertToGoType(prop.TypeString(), prop.Items.Type),
		Pkg:  pkg,
	}
	if !fromStruct {
		e.Name = "Enum" + e.Name
	}
	for _, v := range prop.Enum.([]interface{}) {
		e.Fields = append(e.Fields, newEnumField(v, e))
	}
	return &e
}
1142062
func NewGroupDescriptionUpdatedType(Description string) *GroupDescriptionUpdatedType {
	s := new(GroupDescriptionUpdatedType)
	s.Description = Description
	return s
}
568108
func (s *Scheme) NewObject(kind unversioned.GroupVersionKind) (interface{}, error) {
	if t, exists := s.gvkToType[kind]; exists {
		return reflect.New(t).Interface(), nil
	}

	return nil, &notRegisteredErr{gvk: kind}
}
795918
func NewEmmRefreshAuthTokenType(Description string) *EmmRefreshAuthTokenType {
	s := new(EmmRefreshAuthTokenType)
	s.Description = Description
	return s
}
1006378
func NewPaperDocDownloadType(Description string) *PaperDocDownloadType {
	s := new(PaperDocDownloadType)
	s.Description = Description
	return s
}
144078
func NewEmmChangePolicyType(Description string) *EmmChangePolicyType {
	s := new(EmmChangePolicyType)
	s.Description = Description
	return s
}