// CreateElement returns an Element by collating the recorded, local and remote field values
512499
func (b *Factory) CreateElement(recorded, local, remote map[string]interface{}) (apply.Element, error) {
	// Create an Item from the 3 values.  Use empty name for field
	visitor := &ElementBuildingVisitor{b.Resources}

	gvk, err := getCommonGroupVersionKind(recorded, local, remote)
	if err != nil {
		return nil, err
	}

	// Get the openapi object metadata
	s := visitor.resources.LookupResource(gvk)
	oapiKind, err := getKind(s)
	if err != nil {
		return nil, err
	}

	data := apply.NewRawElementData(recorded, local, remote)
	fieldName := ""
	item, err := visitor.getItem(oapiKind, fieldName, data)
	if err != nil {
		return nil, err
	}

	// Collate each field of the item into a combined Element
	return item.CreateElement(visitor)
}
1373981
func (l *Client) CreateSegment(name, ql, slug string) (Segment, error) {
	res := ApiResp{}
	data := Segment{}

	payload := Segment{
		Name:     name,
		FilterQL: ql,
		SlugName: slug,
	}

	// make the request
	err := l.Post(segmentCreateEndpoint, nil, payload, &res, &data)
	if err != nil {
		return data, err
	}

	return data, nil
}
1356376
func (api *API) CreateField(ctx context.Context, indexName string, fieldName string, opts ...FieldOption) (*Field, error) {
	span, _ := tracing.StartSpanFromContext(ctx, "API.CreateField")
	defer span.Finish()

	if err := api.validate(apiCreateField); err != nil {
		return nil, errors.Wrap(err, "validating api method")
	}

	// Apply functional options.
	fo := FieldOptions{}
	for _, opt := range opts {
		err := opt(&fo)
		if err != nil {
			return nil, errors.Wrap(err, "applying option")
		}
	}

	// Find index.
	index := api.holder.Index(indexName)
	if index == nil {
		return nil, newNotFoundError(ErrIndexNotFound)
	}

	// Create field.
	field, err := index.CreateField(fieldName, opts...)
	if err != nil {
		return nil, errors.Wrap(err, "creating field")
	}

	// Send the create field message to all nodes.
	err = api.server.SendSync(
		&CreateFieldMessage{
			Index: indexName,
			Field: fieldName,
			Meta:  &fo,
		})
	if err != nil {
		api.server.logger.Printf("problem sending CreateField message: %s", err)
		return nil, errors.Wrap(err, "sending CreateField message")
	}
	api.holder.Stats.CountWithCustomTags("createField", 1, 1.0, []string{fmt.Sprintf("index:%s", indexName)})
	return field, nil
}
783081
func (a *AuthnContext) Element() *etree.Element {
	el := etree.NewElement("saml:AuthnContext")
	if a.AuthnContextClassRef != nil {
		el.AddChild(a.AuthnContextClassRef.Element())
	}
	return el
}
734656
func (a *AudienceRestriction) Element() *etree.Element {
	el := etree.NewElement("saml:AudienceRestriction")
	el.AddChild(a.Audience.Element())
	return el
}
277106
func (v ElementBuildingVisitor) CreateTypeElement(item *typeItem) (apply.Element, error) {
	meta, err := getFieldMeta(item.GetMeta(), item.Name)
	if err != nil {
		return nil, err
	}
	return v.typeElement(meta, item)
}
1184035
func NewHTMLElementFromSelectionNode(resp *Response, s *goquery.Selection, n *html.Node, idx int) *HTMLElement {
	return &HTMLElement{
		Name:       n.Data,
		Request:    resp.Request,
		Response:   resp,
		Text:       goquery.NewDocumentFromNode(n).Text(),
		DOM:        s,
		Index:      idx,
		attributes: n.Attr,
	}
}
1201264
func (s *StructInjector) InjectElem(destElem reflect.Value, ctx ...reflect.Value) {
	for _, f := range s.fields {
		f.Object.Assign(ctx, func(v reflect.Value) {
			destElem.FieldByIndex(f.FieldIndex).Set(v)
		})
	}
}
837692
func (s *StatusCode) Element() *etree.Element {
	el := etree.NewElement("samlp:StatusCode")
	el.CreateAttr("Value", s.Value)
	if s.StatusCode != nil {
		el.AddChild(s.StatusCode.Element())
	}
	return el
}
358722
func NewElementNotFound(msg string, a ...interface{}) ElementNotFound {
	msg = fmt.Sprintf(msg, a...)
	return ElementNotFound{
		error: errors.New(msg),
	}
}
784227
func (rl *List) RemoveElement(value string) error {
	conn := rl.pool.Get(rl.dbindex)
	_, err := conn.Do("LREM", rl.id, value)
	return err
}
979297
func appendElement(htmlDoc *htmlDocument, parent *tagElement, e element) {
	if parent != nil {
		parent.appendChild(e)
	} else {
		htmlDoc.append(e)
	}
}
620771
func setElement(e reflect.Value, v string) error {
	switch e.Interface().(type) {
	case int, int32, int64:
		return convertInt(e, v)
	case string:
		return convertString(e, v)
	case float32, float64:
		return convertFloat(e, v)
	case bool:
		return convertBool(e, v)
	case net.IP:
		return convertIP(e, v)
	case net.IPNet:
		return convertCIDR(e, v)
	case utilnet.PortRange:
		return convertPortRange(e, v)
	case time.Duration:
		return convertDuration(e, v)
	case []string:
		vals := strings.Split(v, ",")
		e.Set(reflect.ValueOf(vals))
	case map[string]string:
		return convertMap(e, v)
	default:
		// Last ditch attempt to convert anything based on its underlying kind.
		// This covers any types that are aliased to a native type
		return convertKind(e, v)
	}

	return nil
}
1270374
func (ce *CompoundElement) Add(children ...Element) *CompoundElement {
	ce.children = append(ce.children, children...)
	return ce
}
1020043
func NewXMLElementFromHTMLNode(resp *Response, s *html.Node) *XMLElement {
	return &XMLElement{
		Name:       s.Data,
		Request:    resp.Request,
		Response:   resp,
		Text:       htmlquery.InnerText(s),
		DOM:        s,
		attributes: s.Attr,
		isHTML:     true,
	}
}
441967
func (o *Enterprise) CreateL2DomainTemplate(child *L2DomainTemplate) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
172248
func (t *tree) Create(values ...interface{}) Changer {
	var path []nodeContent
	for _, value := range values {
		path = append(path, justValue{value})
	}
	n, err := t.container.root.create(path...)
	return &changer{n, err}
}