// Parent returns the `parent` Key of this Key.
//   NewKey("/Comedy/MontyPython/Actor:JohnCleese").Parent()
//   NewKey("/Comedy/MontyPython")
516635
func (k Key) Parent() Key {
	n := k.List()
	if len(n) == 1 {
		return RawKey("/")
	}
	return NewKey(strings.Join(n[:len(n)-1], "/"))
}
1257260
func (r *ResourceDefinition) Parent() *ResourceDefinition {
	if r.ParentName != "" {
		if parent, ok := Design.Resources[r.ParentName]; ok {
			return parent
		}
	}
	return nil
}
751215
func getParentName(pod *v1.Pod) string {
	parent, _ := getParentNameAndOrdinal(pod)
	return parent
}
1328006
func (s *IndexService) Parent(parent string) *IndexService {
	s.parent = parent
	return s
}
574345
func (s *TasksCancelService) ParentTaskId(parentTaskId string) *TasksCancelService {
	s.parentTaskId = parentTaskId
	return s
}
852531
func (a *Driver) isParent(id, parent string) bool {
	parents, _ := getParentIDs(a.rootPath(), id)
	if parent == "" && len(parents) > 0 {
		return false
	}
	return !(len(parents) > 0 && parent != parents[0])
}
744126
func (s *Source) Key() string {
	var k string
	if s.Parent != nil {
		k = s.Parent.Key() + "/"
	}
	if s.URL != "" {
		k += s.URL
	} else if s.ExtractFromArchive != "" {
		k += s.ExtractFromArchive
	} else {
		glog.Fatalf("expected either URL or ExtractFromArchive to be set")
	}
	return k
}
1162169
func (s *TasksListService) ParentTaskId(parentTaskId string) *TasksListService {
	s.parentTaskId = parentTaskId
	return s
}
287477
func getParentFromKey(spec *swspec.Swagger, key string) (string, string, interface{}, error) {
	// unescape chars in key, e.g. "{}" from path params
	pth, _ := internal.PathUnescape(key[1:])

	parent, entry := slashpath.Dir(pth), slashpath.Base(pth)
	debugLog("getting schema holder at: %s, with entry: %s", parent, entry)

	pptr, err := jsonpointer.New(parent)
	if err != nil {
		return "", "", nil, err
	}
	pvalue, _, err := pptr.Get(spec)
	if err != nil {
		return "", "", nil, fmt.Errorf("can't get parent for %s: %v", parent, err)
	}
	return parent, entry, pvalue, nil
}
1339757
func AddParent(errobj ErrorObject, parent ErrorObject) error {
	if errobj == nil || parent == nil {
		return nil
	}

	// set parent if not exist
	if errobj.Parent() == nil {
		errobj.SetParent(parent)
		return nil
	}

	// find oldest parent to set
	base := errobj
	if err := WalkErrors(base.Parent(), func(errcomp ErrorObject) (stop bool, walkerr error) {
		// already in parent tree
		if errcomp == parent {
			base = nil
			return true, nil
		}
		base = errcomp
		return false, nil
	}); err != nil {
		return err
	}

	if base != nil {
		base.SetParent(parent)
	}

	return nil
}
1183233
func (p Path) ParentID() uuid.UUID {
	if len(p) > 1 {
		return p[len(p)-2]
	}
	return uuid.Nil
}
115846
func getParentNameAndOrdinal(pod *v1.Pod) (string, int) {
	parent := ""
	ordinal := -1
	subMatches := statefulPodRegex.FindStringSubmatch(pod.Name)
	if len(subMatches) < 3 {
		return parent, ordinal
	}
	parent = subMatches[1]
	if i, err := strconv.ParseInt(subMatches[2], 10, 32); err == nil {
		ordinal = int(i)
	}
	return parent, ordinal
}
1273260
func (s *MultiTermvectorItem) Parent(parent string) *MultiTermvectorItem {
	s.parent = parent
	return s
}
407854
func (k Key) Child(k2 Key) Key {
	switch {
	case k.string == "/":
		return k2
	case k2.string == "/":
		return k
	default:
		return RawKey(k.string + k2.string)
	}
}
885637
func (bldr *iisQueryBuilder) Ancestor(parentKey *datastore.Key) *iisQueryBuilder {
	bldr.q = bldr.q.Ancestor(parentKey)
	if bldr.plugin != nil {
		bldr.plugin.Ancestor(parentKey)
	}
	return bldr
}
470689
func (r *BulkIndexRequest) Parent(parent string) *BulkIndexRequest {
	r.parent = parent
	r.source = nil
	return r
}
1113417
func (s *Svc) Parent() *api.Service {
	if len(s.Parents) > 0 {
		return s.Parents[0].Service
	}
	return nil
}