//
// Allocation functions
//
// realiseAttributeGroups decides which Attributes are going
// to be stored in which groups
493354
func (inst *DenseInstances) realiseAttributeGroups() error {
	for a := range inst.tmpAttrAgMap {
		// Generate a default AttributeGroup name
		ag := inst.tmpAttrAgMap[a]

		// Augment with some additional information
		// Find out whether this attribute is also a class
		classAttribute := false
		for _, c := range inst.allClassAttributes() {
			if c.Equals(a) {
				classAttribute = true
			}
		}

		// This might result in multiple ClassAttribute groups
		// but hopefully nothing too crazy
		if classAttribute {
			// ag = fmt.Sprintf("CLASS_%s", ag)
		}

		// Create the ag if it doesn't exist
		if agId, ok := inst.agMap[ag]; !ok {
			_, generatingBinClass := inst.ags[agId].(*BinaryAttributeGroup)
			if !generatingBinClass {
				inst.createAttributeGroup(ag, 8)
			} else {
				inst.createAttributeGroup(ag, 0)
			}
		}
		id := inst.agMap[ag]
		p := inst.ags[id]
		err := p.AddAttribute(a)
		if err != nil {
			return err
		}
	}
	return nil
}
1046202
func (f *FixedAttributeGroup) AddAttribute(a Attribute) error {
	f.attributes = append(f.attributes, a)
	return nil
}
329759
func (s *Endpoint) SetAttributes(v map[string]*string) *Endpoint {
	s.Attributes = v
	return s
}
602066
func (a *attributes) GetAPIGroup() string {
	if a.event.ObjectRef == nil {
		return ""
	}
	return a.event.ObjectRef.APIGroup
}
1326101
func (fs *flushFS) fooAttributes() fuseops.InodeAttributes {
	return fuseops.InodeAttributes{
		Nlink: 1,
		Mode:  0777,
		Size:  uint64(len(fs.fooContents)),
	}
}
743908
func hasAttributes(v interface{}, a map[string]interface{}) (interface{}, error) {
	switch v.(type) {
	case []interface{}:
		// run through all entries looking one with matching attributes
		for _, vv := range v.([]interface{}) {
			if vvv, vvverr := hasAttributes(vv, a); vvverr == nil {
				return vvv, nil
			}
		}
		return nil, errors.New("no list member with matching attributes")
	case map[string]interface{}:
		// do all attribute name:value pairs match?
		nv := v.(map[string]interface{})
		for key, val := range a {
			if vv, ok := nv[key]; !ok {
				return nil, errors.New("no attribute with name: " + key[1:])
			} else if val != vv {
				return nil, errors.New("no attribute key:value pair: " + fmt.Sprintf("%s:%v", key[1:], val))
			}
		}
		// they all match; so return value associated with "#text" key.
		if vv, ok := nv["#text"]; ok {
			return vv, nil
		} else {
			// this happens when another element is value of tag rather than just a string value
			return nv, nil
		}
	}
	return nil, errors.New("no match for attributes")
}
35657
func (s *DistributionConfig) SetOriginGroups(v *OriginGroups) *DistributionConfig {
	s.OriginGroups = v
	return s
}
938321
func EqualAttributes(e, em Markup) bool {
	oldAttrs := em.Attributes()

	if len(oldAttrs) <= 0 {
		if len(e.Attributes()) <= 0 {
			return true
		}
		return false
	}

	//set to equal as the logic will try to assert its falsiness
	var equal = true

	for _, oa := range oldAttrs {
		//lets get the attribute type from the element, if it exists then check the value if its equal
		// continue the loop and check the rest, else we found a contention point, attribute of old markup
		// does not exists in new markup, so we break and mark as different,letting the new markup keep its hash
		// but if the loop finishes and all are equal then we swap the hashes
		if ta, err := GetAttr(e, oa.Name); err == nil {
			if ta.Value == oa.Value {
				continue
			}

			equal = false
			break
		} else {
			equal = false
			break
		}
	}

	return equal
}
621179
func (b *BinaryAttributeGroup) AddAttribute(a Attribute) error {
	b.attributes = append(b.attributes, a)
	return nil
}
1040722
func (b *BinaryAttributeGroup) Attributes() []Attribute {
	ret := make([]Attribute, len(b.attributes))
	for i, a := range b.attributes {
		ret[i] = a
	}
	return ret
}
298860
func DecompoundedAttributesEqual(o1, o2 *DecompoundedAttributesOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
1145610
func (fs *cachingFS) GetInodeAttributes(
	ctx context.Context,
	op *fuseops.GetInodeAttributesOp) (err error) {
	fs.mu.Lock()
	defer fs.mu.Unlock()

	// Figure out which inode the request is for.
	var attrs fuseops.InodeAttributes

	switch {
	case op.Inode == fuseops.RootInodeID:
		attrs = fs.rootAttrs()

	case op.Inode%numInodes == fooOffset:
		attrs = fs.fooAttrs()

	case op.Inode%numInodes == dirOffset:
		attrs = fs.dirAttrs()

	case op.Inode%numInodes == barOffset:
		attrs = fs.barAttrs()
	}

	// Fill in the response.
	op.Attributes = attrs
	op.AttributesExpiration = time.Now().Add(fs.getattrTimeout)

	return
}
41367
func (client *Client) SetLoadBalancerUDPListenerAttribute(args *SetLoadBalancerUDPListenerAttributeArgs) (err error) {
	response := &CommonLoadBalancerListenerResponse{}
	err = client.Invoke("SetLoadBalancerUDPListenerAttribute", args, response)
	return err
}
653290
func (s *UpdateTableInput) SetAttributeDefinitions(v []*AttributeDefinition) *UpdateTableInput {
	s.AttributeDefinitions = v
	return s
}
472363
func (f *FixedAttributeGroup) Attributes() []Attribute {
	ret := make([]Attribute, len(f.attributes))
	// Add Attributes
	for i, a := range f.attributes {
		ret[i] = a
	}
	return ret
}
1109495
func MarshalAttributes(attrs []Attribute) ([]byte, error) {
	// Count how many bytes we should allocate to store each attribute's contents.
	var c int
	for _, a := range attrs {
		c += nlaHeaderLen + nlaAlign(len(a.Data))
	}

	// Advance through b with idx to place attribute data at the correct offset.
	var idx int
	b := make([]byte, c)
	for _, a := range attrs {
		// Infer the length of attribute if zero.
		if a.Length == 0 {
			a.Length = uint16(nlaHeaderLen + len(a.Data))
		}

		// Marshal a into b and advance idx to show many bytes are occupied.
		n, err := a.marshal(b[idx:])
		if err != nil {
			return nil, err
		}
		idx += n
	}

	return b, nil
}
1108049
func (o *SAMLConnectorV2) GetAttributes() []string {
	var out []string
	for _, mapping := range o.Spec.AttributesToRoles {
		out = append(out, mapping.Name)
	}
	return utils.Deduplicate(out)
}