// JobName returns name of this Job as defined its project's config.
//
// This is "<name>"" part extracted from "<project>/<name>" job ID.
337786
func (e *Job) JobName() string {
	chunks := strings.Split(e.JobID, "/")
	return chunks[1]
}
747411
func (s *TopicsDetectionJobProperties) SetJobName(v string) *TopicsDetectionJobProperties {
	s.JobName = &v
	return s
}
1060869
func (s *UpdateJobInput) SetJobName(v string) *UpdateJobInput {
	s.JobName = &v
	return s
}
1232789
func taskName(info *types.TaskInfo) string {
	name := strings.TrimSuffix(info.Name, "_Task")
	switch name {
	case "":
		return info.DescriptionId
	case "Destroy", "Rename":
		return info.Entity.Type + "." + name
	default:
		return name
	}
}
418284
func (p *ProjectOptions) GetName() string {
	if p == nil || p.Name == nil {
		return ""
	}
	return *p.Name
}
1217514
func (s *DominantLanguageDetectionJobFilter) SetJobName(v string) *DominantLanguageDetectionJobFilter {
	s.JobName = &v
	return s
}
512745
func (s *LookupService) Name(ctx context.Context, resource platform.ResourceType, id platform.ID) (string, error) {
	return s.NameFn(ctx, resource, id)
}
645658
func (c *jobs) Delete(name string, options *api.DeleteOptions) (err error) {
	if options == nil {
		return c.r.Delete().Namespace(c.ns).Resource("jobs").Name(name).Do().Error()
	}

	body, err := api.Scheme.EncodeToVersion(options, latest.GroupOrDie("").GroupVersion.String())
	if err != nil {
		return err
	}
	return c.r.Delete().Namespace(c.ns).Resource("jobs").Name(name).Body(body).Do().Error()
}
562952
func (s *CreateProjectInput) SetProjectName(v string) *CreateProjectInput {
	s.ProjectName = &v
	return s
}
342000
func (r Role) Name() string {
	if r < READER || r > ADMIN {
		return ""
	}
	return roleNames[r]
}
570825
func (st *BuildStruct) Name() string {
	// FooBar -> fooBar
	// IIS -> iis
	// AEData -> aeData

	name := st.SimpleName()

	if !st.Private {
		return name
	}
	if len(name) <= 1 {
		return strings.ToLower(name)
	}
	if name == strings.ToUpper(name) {
		return strings.ToLower(name)
	}

	runeNames := []rune(name)
	if unicode.IsLower(runeNames[0]) {
		return name
	} else if unicode.IsLower(runeNames[1]) {
		return string(unicode.ToLower(runeNames[0])) + string(runeNames[1:])
	}

	var idx int
	for idx = 0; idx < len(runeNames); idx++ {
		r := runeNames[idx]
		if unicode.IsLower(r) {
			break
		}
	}

	return strings.ToLower(string(runeNames[0:idx-1])) + string(runeNames[idx-1:])
}
492084
func (s *Condition) SetJobName(v string) *Condition {
	s.JobName = &v
	return s
}
654997
func (s *Build) SetProjectName(v string) *Build {
	s.ProjectName = &v
	return s
}
140064
func (s *CreateUserImportJobInput) SetJobName(v string) *CreateUserImportJobInput {
	s.JobName = &v
	return s
}
1115607
func AllocName(job, group string, idx uint) string {
	return fmt.Sprintf("%s.%s[%d]", job, group, idx)
}
280417
func (j *Jenkins) RenameJob(job string, name string) *Job {
	jobObj := Job{Jenkins: j, Raw: new(JobResponse), Base: "/job/" + job}
	jobObj.Rename(name)
	return &jobObj
}
282168
func jobNameFromConfigFileName(configFileName string) (string, error) {
	parts := strings.Split(configFileName, "/")
	if len(parts) < 2 {
		return "", fmt.Errorf("Job config file name expected to have at least one /: %s", configFileName)
	}
	if parts[len(parts)-1] != "config.xml" {
		return "", fmt.Errorf("Job config file name does not end in config.xml: %s", configFileName)
	}
	return parts[len(parts)-2], nil
}