func (j *AuroraJob) AddLabel(key string, value string) Job {
	if _, ok := j.metadata[key]; !ok {
		j.metadata[key] = &aurora.Metadata{Key: key}
		j.jobConfig.TaskConfig.Metadata = append(j.jobConfig.TaskConfig.Metadata, j.metadata[key])
	}
	j.metadata[key].Value = value
	return j
}
AddLabel adds a Mesos label to the job. Note that Aurora will add the
prefix "org.apache.aurora.metadata." to the beginning of each key.
package realis
import (
	"strconv"
	"github.com/paypal/gorealis/gen-go/apache/aurora"
)
type Job interface {
	Environment(env string) Job
	Role(role string) Job
	Name(name string) Job
	CronSchedule(cron string) Job
	CronCollisionPolicy(policy aurora.CronCollisionPolicy) Job
	CPU(cpus float64) Job
	Disk(disk int64) Job
	RAM(ram int64) Job
	GPU(gpu int64) Job
	ExecutorName(name string) Job
	ExecutorData(data string) Job
	AddPorts(num int) Job
	AddLabel(key string, value string) Job
	AddNamedPorts(names ...string) Job
	AddLimitConstraint(name string, limit int32) Job
	AddValueConstraint(name string, negated bool, values ...string) Job
	AddDedicatedConstraint(role, name string) Job
	AddURIs(extract bool, cache bool, values ...string) Job
	JobKey() *aurora.JobKey
	JobConfig() *aurora.JobConfiguration
	TaskConfig() *aurora.TaskConfig
	IsService(isService bool) Job
	InstanceCount(instCount int32) Job
	GetInstanceCount() int32
	MaxFailure(maxFail int32) Job
	Container(container Container) Job
	PartitionPolicy(policy *aurora.PartitionPolicy) Job
	Tier(tier string) Job
	SlaPolicy(policy *aurora.SlaPolicy) Job
}
type resourceType int
const (
	CPU resourceType = iota
	RAM
	DISK
	GPU
)
const portNamePrefix = "org.apache.aurora.port."
type AuroraJob struct {
	jobConfig   *aurora.JobConfiguration
	resources   map[resourceType]*aurora.Resource
	metadata    map[string]*aurora.Metadata
	constraints map[string]*aurora.Constraint
	portCount   int
}
func NewJob() Job {
	jobConfig := aurora.NewJobConfiguration()
	taskConfig := aurora.NewTaskConfig()
	jobKey := aurora.NewJobKey()
	jobConfig.Key = jobKey
	jobConfig.TaskConfig = taskConfig
	taskConfig.Job = jobKey
	taskConfig.Container = aurora.NewContainer()
	taskConfig.Container.Mesos = aurora.NewMesosContainer()
	numCpus := aurora.NewResource()
	ramMb := aurora.NewResource()
	diskMb := aurora.NewResource()
	resources := map[resourceType]*aurora.Resource{CPU: numCpus, RAM: ramMb, DISK: diskMb}
	taskConfig.Resources = []*aurora.Resource{numCpus, ramMb, diskMb}
	numCpus.NumCpus = new(float64)
	ramMb.RamMb = new(int64)
	diskMb.DiskMb = new(int64)
	return &AuroraJob{
		jobConfig:   jobConfig,
		resources:   resources,
		metadata:    make(map[string]*aurora.Metadata),
		constraints: make(map[string]*aurora.Constraint),
		portCount:   0,
	}
}
func (j *AuroraJob) Environment(env string) Job {
	j.jobConfig.Key.Environment = env
	return j
}
func (j *AuroraJob) Role(role string) Job {
	j.jobConfig.Key.Role = role
	identity := &aurora.Identity{User: role}
	j.jobConfig.Owner = identity
	j.jobConfig.TaskConfig.Owner = identity
	return j
}
func (j *AuroraJob) Name(name string) Job {
	j.jobConfig.Key.Name = name
	return j
}
func (j *AuroraJob) ExecutorName(name string) Job {
	if j.jobConfig.TaskConfig.ExecutorConfig == nil {
		j.jobConfig.TaskConfig.ExecutorConfig = aurora.NewExecutorConfig()
	}
	j.jobConfig.TaskConfig.ExecutorConfig.Name = name
	return j
}
func (j *AuroraJob) ExecutorData(data string) Job {
	if j.jobConfig.TaskConfig.ExecutorConfig == nil {
		j.jobConfig.TaskConfig.ExecutorConfig = aurora.NewExecutorConfig()
	}
	j.jobConfig.TaskConfig.ExecutorConfig.Data = data
	return j
}
func (j *AuroraJob) CPU(cpus float64) Job {
	*j.resources[CPU].NumCpus = cpus
	return j
}
func (j *AuroraJob) RAM(ram int64) Job {
	*j.resources[RAM].RamMb = ram
	return j
}
func (j *AuroraJob) Disk(disk int64) Job {
	*j.resources[DISK].DiskMb = disk
	return j
}
func (j *AuroraJob) GPU(gpu int64) Job {
	if _, ok := j.resources[GPU]; !ok {
		j.resources[GPU] = &aurora.Resource{}
		j.JobConfig().GetTaskConfig().Resources = append(
			j.JobConfig().GetTaskConfig().Resources,
			j.resources[GPU])
	}
	j.resources[GPU].NumGpus = &gpu
	return j
}
func (j *AuroraJob) MaxFailure(maxFail int32) Job {
	j.jobConfig.TaskConfig.MaxTaskFailures = maxFail
	return j
}
func (j *AuroraJob) InstanceCount(instCount int32) Job {
	j.jobConfig.InstanceCount = instCount
	return j
}
func (j *AuroraJob) CronSchedule(cron string) Job {
	j.jobConfig.CronSchedule = &cron
	return j
}
func (j *AuroraJob) CronCollisionPolicy(policy aurora.CronCollisionPolicy) Job {
	j.jobConfig.CronCollisionPolicy = policy
	return j
}
func (j *AuroraJob) GetInstanceCount() int32 {
	return j.jobConfig.InstanceCount
}
func (j *AuroraJob) IsService(isService bool) Job {
	j.jobConfig.TaskConfig.IsService = isService
	return j
}
func (j *AuroraJob) JobKey() *aurora.JobKey {
	return j.jobConfig.Key
}
func (j *AuroraJob) JobConfig() *aurora.JobConfiguration {
	return j.jobConfig
}
func (j *AuroraJob) TaskConfig() *aurora.TaskConfig {
	return j.jobConfig.TaskConfig
}
func (j *AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job {
	for _, value := range values {
		j.jobConfig.TaskConfig.MesosFetcherUris = append(j.jobConfig.TaskConfig.MesosFetcherUris,
			&aurora.MesosFetcherURI{Value: value, Extract: &extract, Cache: &cache})
	}
	return j
}