jkawamoto/roadie

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

Summary

Maintainability
C
7 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"
)

// CloudJob An Azure Batch job.
// swagger:model CloudJob
type CloudJob 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 creation time of the job.
    CreationTime strfmt.DateTime `json:"creationTime,omitempty"`

    // The display name for the job.
    DisplayName string `json:"displayName,omitempty"`

    // The ETag of the job.
    //
    // This is an opaque string. You can use it to detect whether the job has changed between requests. In particular, you can be pass the ETag when updating a job to specify that your changes should take effect only if nobody else has modified the job in the meantime.
    ETag string `json:"eTag,omitempty"`

    // The execution information for the job.
    ExecutionInfo *JobExecutionInformation `json:"executionInfo,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.
    ID string `json:"id,omitempty"`

    // Details of a Job Manager task to be launched when the job is started.
    JobManagerTask *JobManagerTask `json:"jobManagerTask,omitempty"`

    // The Job Preparation task.
    //
    // The Job Preparation task is a special task run on each node before any other task of the job.
    JobPreparationTask *JobPreparationTask `json:"jobPreparationTask,omitempty"`

    // The Job Release task.
    //
    // The Job Release task is a special task run at the end of the job on each node that has run any other task of the job.
    JobReleaseTask *JobReleaseTask `json:"jobReleaseTask,omitempty"`

    // The last modified time of the job.
    //
    // This is the last time at which the job level data, such as the job state or priority, changed. It does not factor in task-level changes such as adding new tasks or tasks changing state.
    LastModified strfmt.DateTime `json:"lastModified,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.
    //
    // 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 settings associated with the job.
    PoolInfo *PoolInformation `json:"poolInfo,omitempty"`

    // The previous state of the job.
    //
    // This property is not set if the job is in its initial Active state.
    PreviousState string `json:"previousState,omitempty"`

    // The time at which the job entered its previous state.
    //
    // This property is not set if the job is in its initial Active state.
    PreviousStateTransitionTime strfmt.DateTime `json:"previousStateTransitionTime,omitempty"`

    // 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 current state of the job.
    State string `json:"state,omitempty"`

    // The time at which the job entered its current state.
    StateTransitionTime strfmt.DateTime `json:"stateTransitionTime,omitempty"`

    // Resource usage statistics for the entire lifetime of the job.
    Stats *JobStatistics `json:"stats,omitempty"`

    // The URL of the job.
    URL string `json:"url,omitempty"`

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

// Validate validates this cloud job
func (m *CloudJob) 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.validateExecutionInfo(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 err := m.validatePreviousState(formats); err != nil {
        // prop
        res = append(res, err)
    }

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

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

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

func (m *CloudJob) 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 *CloudJob) 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 *CloudJob) validateExecutionInfo(formats strfmt.Registry) error {

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

    if m.ExecutionInfo != nil {

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

    return nil
}

func (m *CloudJob) 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 *CloudJob) 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 *CloudJob) 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 *CloudJob) 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 cloudJobTypeOnAllTasksCompletePropEnum []interface{}

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

const (
    // CloudJobOnAllTasksCompleteNoAction captures enum value "noAction"
    CloudJobOnAllTasksCompleteNoAction string = "noAction"
    // CloudJobOnAllTasksCompleteTerminateJob captures enum value "terminateJob"
    CloudJobOnAllTasksCompleteTerminateJob string = "terminateJob"
)

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

func (m *CloudJob) 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 cloudJobTypeOnTaskFailurePropEnum []interface{}

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

const (
    // CloudJobOnTaskFailureNoAction captures enum value "noAction"
    CloudJobOnTaskFailureNoAction string = "noAction"
    // CloudJobOnTaskFailurePerformExitOptionsJobAction captures enum value "performExitOptionsJobAction"
    CloudJobOnTaskFailurePerformExitOptionsJobAction string = "performExitOptionsJobAction"
)

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

func (m *CloudJob) 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 *CloudJob) validatePoolInfo(formats strfmt.Registry) error {

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

    if m.PoolInfo != nil {

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

    return nil
}

var cloudJobTypePreviousStatePropEnum []interface{}

func init() {
    var res []string
    if err := json.Unmarshal([]byte(`["active","disabling","disabled","enabling","terminating","completed","deleting"]`), &res); err != nil {
        panic(err)
    }
    for _, v := range res {
        cloudJobTypePreviousStatePropEnum = append(cloudJobTypePreviousStatePropEnum, v)
    }
}

const (
    // CloudJobPreviousStateActive captures enum value "active"
    CloudJobPreviousStateActive string = "active"
    // CloudJobPreviousStateDisabling captures enum value "disabling"
    CloudJobPreviousStateDisabling string = "disabling"
    // CloudJobPreviousStateDisabled captures enum value "disabled"
    CloudJobPreviousStateDisabled string = "disabled"
    // CloudJobPreviousStateEnabling captures enum value "enabling"
    CloudJobPreviousStateEnabling string = "enabling"
    // CloudJobPreviousStateTerminating captures enum value "terminating"
    CloudJobPreviousStateTerminating string = "terminating"
    // CloudJobPreviousStateCompleted captures enum value "completed"
    CloudJobPreviousStateCompleted string = "completed"
    // CloudJobPreviousStateDeleting captures enum value "deleting"
    CloudJobPreviousStateDeleting string = "deleting"
)

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

func (m *CloudJob) validatePreviousState(formats strfmt.Registry) error {

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

    // value enum
    if err := m.validatePreviousStateEnum("previousState", "body", m.PreviousState); err != nil {
        return err
    }

    return nil
}

var cloudJobTypeStatePropEnum []interface{}

func init() {
    var res []string
    if err := json.Unmarshal([]byte(`["active","disabling","disabled","enabling","terminating","completed","deleting"]`), &res); err != nil {
        panic(err)
    }
    for _, v := range res {
        cloudJobTypeStatePropEnum = append(cloudJobTypeStatePropEnum, v)
    }
}

const (
    // CloudJobStateActive captures enum value "active"
    CloudJobStateActive string = "active"
    // CloudJobStateDisabling captures enum value "disabling"
    CloudJobStateDisabling string = "disabling"
    // CloudJobStateDisabled captures enum value "disabled"
    CloudJobStateDisabled string = "disabled"
    // CloudJobStateEnabling captures enum value "enabling"
    CloudJobStateEnabling string = "enabling"
    // CloudJobStateTerminating captures enum value "terminating"
    CloudJobStateTerminating string = "terminating"
    // CloudJobStateCompleted captures enum value "completed"
    CloudJobStateCompleted string = "completed"
    // CloudJobStateDeleting captures enum value "deleting"
    CloudJobStateDeleting string = "deleting"
)

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

func (m *CloudJob) validateState(formats strfmt.Registry) error {

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

    // value enum
    if err := m.validateStateEnum("state", "body", m.State); err != nil {
        return err
    }

    return nil
}

func (m *CloudJob) validateStats(formats strfmt.Registry) error {

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

    if m.Stats != nil {

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

    return nil
}