// TLFNameExpanded returns a TLF name with a reset suffix if it exists.
// This version can be used in requests to lookup the TLF.
511787
func (m MessageSummary) TLFNameExpanded(finalizeInfo *ConversationFinalizeInfo) string {
	return ExpandTLFName(m.TlfName, finalizeInfo)
}
30483
func nameFromString(name string) (string, error) {
	l := len(name)
	if l > 0 && l <= 128 && nameRe.MatchString(name) {
		return name, nil
	}

	return "", ErrMalformed
}
1027794
func (pm *VolumePluginMgr) FindExpandablePluginByName(name string) (ExpandableVolumePlugin, error) {
	volumePlugin, err := pm.FindPluginByName(name)
	if err != nil {
		return nil, err
	}

	if expandableVolumePlugin, ok := volumePlugin.(ExpandableVolumePlugin); ok {
		return expandableVolumePlugin, nil
	}
	return nil, nil
}
710258
func rewriteToExpand(s string) string {
	// Pretty dumb at the moment, every { will get a $ prefixed.
	// Also wasteful as we build the string with +=. This is OKish
	// as we do this during config parsing.

	copy := ""

	for _, c := range s {
		if c == '{' {
			copy += "$"
		}
		copy += string(c)
	}

	return copy
}
413285
func ParseDurationExtended(s string) (d time.Duration, err error) {
	p := strings.Index(s, "d")
	if p == -1 {
		// no "d" suffix
		return time.ParseDuration(s)
	}

	var days int
	if days, err = strconv.Atoi(s[:p]); err != nil {
		return time.Duration(0), err
	}
	d = time.Duration(days) * 24 * time.Hour

	if p < len(s)-1 {
		var dur time.Duration
		if dur, err = time.ParseDuration(s[p+1:]); err != nil {
			return time.Duration(0), err
		}
		d += dur
	}

	return d, nil
}
164468
func MakeSimpleName(name string) string {
	name = strings.ToLower(name)
	name = invalidServiceChars.ReplaceAllString(name, "")
	name = strings.TrimFunc(name, func(r rune) bool { return r == '-' })
	if len(name) > kuval.DNS1035LabelMaxLength {
		name = name[:kuval.DNS1035LabelMaxLength]
	}
	return name
}
532180
func (t TokenBuilder) LtOrEqNamed(names ...string) Cmp {
	return t.cmp(leq, names)
}
875746
func (l *Logger) normalizeName() {
	length := len(l.Name)

	// name is ok as it is
	if length == maxnamelen || length == curnamelen {
		return
	}

	// name is too short, add some spaces
	if length < curnamelen {
		l.normalizeNameLen()
		return
	}

	// name is too long
	// do best to normalize it

	var (
		normalized string
		parts      []string
		separator  byte
	)

	// try split long name using different separators
	// this first one which can split name into smaller parts will be used
	for _, sep := range separators {
		parts = strings.Split(l.Name, string(sep))
		if len(parts) > 1 {
			separator = sep
			break
		}
	}

	// if we sucesufully splitted string into multiple parts
	if len(parts) > 1 {
		appendSeparator := true

		for i, str := range parts {
			// if part length is bigger than zero
			switch len(str) {
			case 0:
				appendSeparator = false
				break
			case 1:
				normalized += str[:1]
				break
			case 2:
				normalized += str[:2]
				break
			default:
				normalized += str[:3]
				break
			}

			if appendSeparator && (i != (len(parts) - 1)) {
				normalized += string(separator)
			}
		}

		// if still to long
		if len(normalized) > maxnamelen {
			normalized = normalized[:maxnamelen]
		}
	} else {
		length := len(l.Name)
		if length > maxnamelen {
			normalized = l.Name[:maxnamelen]
		} else {
			normalized = l.Name[0:length]
		}
	}

	l.Name = normalized
	if len(normalized) >= curnamelen {
		curnamelen = len(normalized)
	} else {
		l.normalizeNameLen()
	}
}
125161
func SplitAndNormalizeTLFName(g *libkb.GlobalContext, name string, public bool) (
	writerNames, readerNames []string,
	extensionSuffix string, err error) {

	names := strings.SplitN(name, TlfHandleExtensionSep, 2)
	if len(names) > 2 {
		return nil, nil, "", BadTLFNameError{name}
	}
	if len(names) > 1 {
		extensionSuffix = names[1]
	}

	splitNames := strings.SplitN(names[0], ReaderSep, 3)
	if len(splitNames) > 2 {
		return nil, nil, "", BadTLFNameError{name}
	}
	writerNames = strings.Split(splitNames[0], ",")
	if len(splitNames) > 1 {
		readerNames = strings.Split(splitNames[1], ",")
	}

	hasPublic := len(readerNames) == 0

	if public && !hasPublic {
		// No public folder exists for this folder.
		return nil, nil, "", NoSuchNameError{Name: name}
	}

	normalizedName, err := NormalizeNamesInTLF(g,
		writerNames, readerNames, extensionSuffix)
	if err != nil {
		return nil, nil, "", err
	}
	if normalizedName != name {
		return nil, nil, "", NameNotCanonical{name, normalizedName}
	}

	return writerNames, readerNames, strings.ToLower(extensionSuffix), nil
}
590533
func (s *Artifact) SetExtension(v string) *Artifact {
	s.Extension = &v
	return s
}
1271885
func (r Dns_Domain_Registration) GetExtendedAttributes(domainName *string) (resp []datatypes.Container_Dns_Domain_Registration_ExtendedAttribute, err error) {
	params := []interface{}{
		domainName,
	}
	err = r.Session.DoRequest("SoftLayer_Dns_Domain_Registration", "getExtendedAttributes", params, &r.Options, &resp)
	return
}
1261997
func NewNamedUlimitOpt(name string, ref *map[string]*units.Ulimit) *NamedUlimitOpt {
	if ref == nil {
		ref = &map[string]*units.Ulimit{}
	}
	return &NamedUlimitOpt{
		name:      name,
		UlimitOpt: *NewUlimitOpt(ref),
	}
}
265604
func (tlf *TLF) Rename(ctx context.Context, req *fuse.RenameRequest,
	newDir fs.Node) error {
	dir, err := tlf.loadDir(ctx)
	if err != nil {
		return err
	}
	return dir.Rename(ctx, req, newDir)
}
32939
func (q *SimpleQueryStringQuery) LowercaseExpandedTerms(lowercaseExpandedTerms bool) *SimpleQueryStringQuery {
	q.lowercaseExpandedTerms = &lowercaseExpandedTerms
	return q
}
984897
func (a *API) renameExportable() {
	for name, op := range a.Operations {
		newName := a.ExportableName(name)
		if newName != name {
			delete(a.Operations, name)
			a.Operations[newName] = op
		}
		op.ExportedName = newName
	}

	for k, s := range a.Shapes {
		// FIXME SNS has lower and uppercased shape names with the same name,
		// except the lowercased variant is used exclusively for string and
		// other primitive types. Renaming both would cause a collision.
		// We work around this by only renaming the structure shapes.
		if s.Type == "string" {
			continue
		}

		for mName, member := range s.MemberRefs {
			ref := s.MemberRefs[mName]
			ref.OrigShapeName = mName
			s.MemberRefs[mName] = ref

			newName := a.ExportableName(mName)
			if newName != mName {
				delete(s.MemberRefs, mName)
				s.MemberRefs[newName] = member

				// also apply locationName trait so we keep the old one
				// but only if there's no locationName trait on ref or shape
				if member.LocationName == "" && member.Shape.LocationName == "" {
					member.LocationName = mName
				}
			}

			if newName == "_" {
				panic("Shape " + s.ShapeName + " uses reserved member name '_'")
			}
		}

		newName := a.ExportableName(k)
		if newName != s.ShapeName {
			s.Rename(newName)
		}

		s.Payload = a.ExportableName(s.Payload)

		// fix required trait names
		for i, n := range s.Required {
			s.Required[i] = a.ExportableName(n)
		}
	}

	for _, s := range a.Shapes {
		// fix enum names
		if s.IsEnum() {
			s.EnumConsts = make([]string, len(s.Enum))
			for i := range s.Enum {
				shape := s.ShapeName
				shape = strings.ToUpper(shape[0:1]) + shape[1:]
				s.EnumConsts[i] = shape + s.EnumName(i)
			}
		}
	}
}
25559
func (f field) EscapedName() string {
	name := f.Name
	if _, ok := nimKeywords[name]; !ok {
		return name
	}
	return "`" + name + "`"
}
732482
func (c *Client) GetExpandedFormation(appID, releaseID string) (*ct.ExpandedFormation, error) {
	formation := &ct.ExpandedFormation{}
	return formation, c.Get(fmt.Sprintf("/apps/%s/formations/%s?expand=true", appID, releaseID), formation)
}