jkawamoto/roadie

View on GitHub
cloud/azure/batch/models/job_add_parameter.go

Summary

Maintainability
B
5 hrs
Test Coverage
package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
    "encoding/json"

    strfmt "github.com/go-openapi/strfmt"
    "github.com/go-openapi/swag"

    "github.com/go-openapi/errors"
    "github.com/go-openapi/validate"
)

// JobAddParameter An Azure Batch job to add.
// swagger:model JobAddParameter
type JobAddParameter struct {

    // The list of common environment variable settings. These environment variables are set for all tasks in the job (including the Job Manager, Job Preparation and Job Release tasks).
    CommonEnvironmentSettings []*EnvironmentSetting `json:"commonEnvironmentSettings"`

    // The execution constraints for the job.
    Constraints *JobConstraints `json:"constraints,omitempty"`

    // The display name for the job.
    //
    // The display name need not be unique and can contain any Unicode characters up to a maximum length of 1024.
    DisplayName string `json:"displayName,omitempty"`

    // A string that uniquely identifies the job within the account.
    //
    // The ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters. It is common to use a GUID for the id.
    // Required: true
    ID *string `json:"id"`

    // Details of a Job Manager task to be launched when the job is started.
    //
    // If the job does not specify a Job Manager task, the user must explicitly add tasks to the job. If the job does specify a Job Manager task, the Batch service creates the Job Manager task when the job is created, and will try to schedule the Job Manager task before scheduling other tasks in the job. The Job Manager task's typical purpose is to control and/or monitor job execution, for example by deciding what additional tasks to run, determining when the work is complete, etc. (However, a Job Manager task is not restricted to these activities – it is a fully-fledged task in the system and perform whatever actions are required for the job.) For example, a Job Manager task might download a file specified as a parameter, analyze the contents of that file and submit additional tasks based on those contents.
    JobManagerTask *JobManagerTask `json:"jobManagerTask,omitempty"`

    // The Job Preparation task.
    //
    // If a job has a Job Preparation task, the Batch service will run the Job Preparation task on a compute node before starting any tasks of that job on that compute node.
    JobPreparationTask *JobPreparationTask `json:"jobPreparationTask,omitempty"`

    // The Job Release task.
    //
    // A Job Release task cannot be specified without also specifying a Job Preparation task for the job. The Batch service runs the Job Release task on the compute nodes that have run the Job Preparation task. The primary purpose of the Job Release task is to undo changes to compute nodes made by the Job Preparation task. Example activities include deleting local files, or shutting down services that were started as part of job preparation.
    JobReleaseTask *JobReleaseTask `json:"jobReleaseTask,omitempty"`

    // A list of name-value pairs associated with the job as metadata.
    //
    // The Batch service does not assign any meaning to metadata; it is solely for the use of user code.
    Metadata []*MetadataItem `json:"metadata"`

    // The action the Batch service should take when all tasks in the job are in the completed state.
    //
    // Note that if a job contains no tasks, then all tasks are considered complete. This option is therefore most commonly used with a job manager task; if you want to use automatic job termination without a job manager, you should initially set onAllTasksComplete to noaction and update the job properties to set onAllTasksComplete to terminatejob once you have finished adding tasks. Permitted values are: noaction – do nothing. The job remains active unless terminated or disabled by some other means. terminatejob – terminate the job. The job’s terminateReason is set to 'AllTasksComplete'. The default is noaction.
    OnAllTasksComplete string `json:"onAllTasksComplete,omitempty"`

    // The action the Batch service should take when any task in the job fails. A task is considered to have failed if it completes with a non-zero exit code and has exhausted its retry count, or if it had a scheduling error.
    //
    // Permitted values are: noaction – do nothing. performexitoptionsjobaction – take the action associated with the task exit condition in the task's exitConditions collection. (This may still result in no action being taken, if that is what the task specifies.) The default is noaction.
    OnTaskFailure string `json:"onTaskFailure,omitempty"`

    // The pool on which the Batch service runs the job's tasks.
    // Required: true
    PoolInfo *PoolInformation `json:"poolInfo"`

    // The priority of the job.
    //
    //  Priority values can range from -1000 to 1000, with -1000 being the lowest priority and 1000 being the highest priority. The default value is 0.
    Priority int32 `json:"priority,omitempty"`

    // The flag that determines if this job will use tasks with dependencies.
    UsesTaskDependencies bool `json:"usesTaskDependencies,omitempty"`
}

// Validate validates this job add parameter
func (m *JobAddParameter) Validate(formats strfmt.Registry) error {
    var res []error

    if err := m.validateCommonEnvironmentSettings(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateConstraints(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateID(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateJobManagerTask(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateJobPreparationTask(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateJobReleaseTask(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateMetadata(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateOnAllTasksComplete(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validateOnTaskFailure(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if err := m.validatePoolInfo(formats); err != nil {
        // prop
        res = append(res, err)
    }

    if len(res) > 0 {
        return errors.CompositeValidationError(res...)
    }
    return nil
}

func (m *JobAddParameter) validateCommonEnvironmentSettings(formats strfmt.Registry) error {

    if swag.IsZero(m.CommonEnvironmentSettings) { // not required
        return nil
    }

    for i := 0; i < len(m.CommonEnvironmentSettings); i++ {

        if swag.IsZero(m.CommonEnvironmentSettings[i]) { // not required
            continue
        }

        if m.CommonEnvironmentSettings[i] != nil {

            if err := m.CommonEnvironmentSettings[i].Validate(formats); err != nil {
                return err
            }
        }

    }

    return nil
}

func (m *JobAddParameter) validateConstraints(formats strfmt.Registry) error {

    if swag.IsZero(m.Constraints) { // not required
        return nil
    }

    if m.Constraints != nil {

        if err := m.Constraints.Validate(formats); err != nil {
            return err
        }
    }

    return nil
}

func (m *JobAddParameter) validateID(formats strfmt.Registry) error {

    if err := validate.Required("id", "body", m.ID); err != nil {
        return err
    }

    return nil
}

func (m *JobAddParameter) validateJobManagerTask(formats strfmt.Registry) error {

    if swag.IsZero(m.JobManagerTask) { // not required
        return nil
    }

    if m.JobManagerTask != nil {

        if err := m.JobManagerTask.Validate(formats); err != nil {
            return err
        }
    }

    return nil
}

func (m *JobAddParameter) validateJobPreparationTask(formats strfmt.Registry) error {

    if swag.IsZero(m.JobPreparationTask) { // not required
        return nil
    }

    if m.JobPreparationTask != nil {

        if err := m.JobPreparationTask.Validate(formats); err != nil {
            return err
        }
    }

    return nil
}

func (m *JobAddParameter) validateJobReleaseTask(formats strfmt.Registry) error {

    if swag.IsZero(m.JobReleaseTask) { // not required
        return nil
    }

    if m.JobReleaseTask != nil {

        if err := m.JobReleaseTask.Validate(formats); err != nil {
            return err
        }
    }

    return nil
}

func (m *JobAddParameter) validateMetadata(formats strfmt.Registry) error {

    if swag.IsZero(m.Metadata) { // not required
        return nil
    }

    for i := 0; i < len(m.Metadata); i++ {

        if swag.IsZero(m.Metadata[i]) { // not required
            continue
        }

        if m.Metadata[i] != nil {

            if err := m.Metadata[i].Validate(formats); err != nil {
                return err
            }
        }

    }

    return nil
}

var jobAddParameterTypeOnAllTasksCompletePropEnum []interface{}

func init() {
    var res []string
    if err := json.Unmarshal([]byte(`["noAction","terminateJob"]`), &res); err != nil {
        panic(err)
    }
    for _, v := range res {
        jobAddParameterTypeOnAllTasksCompletePropEnum = append(jobAddParameterTypeOnAllTasksCompletePropEnum, v)
    }
}

const (
    // JobAddParameterOnAllTasksCompleteNoAction captures enum value "noAction"
    JobAddParameterOnAllTasksCompleteNoAction string = "noAction"
    // JobAddParameterOnAllTasksCompleteTerminateJob captures enum value "terminateJob"
    JobAddParameterOnAllTasksCompleteTerminateJob string = "terminateJob"
)

// prop value enum
func (m *JobAddParameter) validateOnAllTasksCompleteEnum(path, location string, value string) error {
    if err := validate.Enum(path, location, value, jobAddParameterTypeOnAllTasksCompletePropEnum); err != nil {
        return err
    }
    return nil
}

func (m *JobAddParameter) validateOnAllTasksComplete(formats strfmt.Registry) error {

    if swag.IsZero(m.OnAllTasksComplete) { // not required
        return nil
    }

    // value enum
    if err := m.validateOnAllTasksCompleteEnum("onAllTasksComplete", "body", m.OnAllTasksComplete); err != nil {
        return err
    }

    return nil
}

var jobAddParameterTypeOnTaskFailurePropEnum []interface{}

func init() {
    var res []string
    if err := json.Unmarshal([]byte(`["noAction","performExitOptionsJobAction"]`), &res); err != nil {
        panic(err)
    }
    for _, v := range res {
        jobAddParameterTypeOnTaskFailurePropEnum = append(jobAddParameterTypeOnTaskFailurePropEnum, v)
    }
}

const (
    // JobAddParameterOnTaskFailureNoAction captures enum value "noAction"
    JobAddParameterOnTaskFailureNoAction string = "noAction"
    // JobAddParameterOnTaskFailurePerformExitOptionsJobAction captures enum value "performExitOptionsJobAction"
    JobAddParameterOnTaskFailurePerformExitOptionsJobAction string = "performExitOptionsJobAction"
)

// prop value enum
func (m *JobAddParameter) validateOnTaskFailureEnum(path, location string, value string) error {
    if err := validate.Enum(path, location, value, jobAddParameterTypeOnTaskFailurePropEnum); err != nil {
        return err
    }
    return nil
}

func (m *JobAddParameter) validateOnTaskFailure(formats strfmt.Registry) error {

    if swag.IsZero(m.OnTaskFailure) { // not required
        return nil
    }

    // value enum
    if err := m.validateOnTaskFailureEnum("onTaskFailure", "body", m.OnTaskFailure); err != nil {
        return err
    }

    return nil
}

func (m *JobAddParameter) validatePoolInfo(formats strfmt.Registry) error {

    if err := validate.Required("poolInfo", "body", m.PoolInfo); err != nil {
        return err
    }

    if m.PoolInfo != nil {

        if err := m.PoolInfo.Validate(formats); err != nil {
            return err
        }
    }

    return nil
}