jkawamoto/roadie

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

Summary

Maintainability
A
2 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"
)

// SubtaskInformation Information about an Azure Batch subtask.
// swagger:model SubtaskInformation
type SubtaskInformation struct {

    // The time at which the subtask completed.
    //
    // This property is set only if the subtask is in the Completed state.
    EndTime strfmt.DateTime `json:"endTime,omitempty"`

    // The exit code of the program specified on the subtask command line.
    //
    // This property is set only if the subtask is in the completed state. In general, the exit code for a process reflects the specific convention implemented by the application developer for that process. If you use the exit code value to make decisions in your code, be sure that you know the exit code convention used by the application process. However, if the Batch service terminates the subtask (due to timeout, or user termination via the API) you may see an operating system-defined exit code.
    ExitCode int32 `json:"exitCode,omitempty"`

    // The ID of the subtask.
    ID int32 `json:"id,omitempty"`

    // Information about the compute node on which the subtask ran.
    NodeInfo *ComputeNodeInformation `json:"nodeInfo,omitempty"`

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

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

    // Details of any error encountered scheduling the subtask.
    SchedulingError *TaskSchedulingError `json:"schedulingError,omitempty"`

    // The time at which the subtask started running. If the subtask has been restarted or retried, this is the most recent time at which the subtask started running.
    StartTime strfmt.DateTime `json:"startTime,omitempty"`

    // The current state of the subtask.
    State string `json:"state,omitempty"`

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

// Validate validates this subtask information
func (m *SubtaskInformation) Validate(formats strfmt.Registry) error {
    var res []error

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

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

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

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

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

func (m *SubtaskInformation) validateNodeInfo(formats strfmt.Registry) error {

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

    if m.NodeInfo != nil {

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

    return nil
}

var subtaskInformationTypePreviousStatePropEnum []interface{}

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

const (
    // SubtaskInformationPreviousStateActive captures enum value "active"
    SubtaskInformationPreviousStateActive string = "active"
    // SubtaskInformationPreviousStatePreparing captures enum value "preparing"
    SubtaskInformationPreviousStatePreparing string = "preparing"
    // SubtaskInformationPreviousStateRunning captures enum value "running"
    SubtaskInformationPreviousStateRunning string = "running"
    // SubtaskInformationPreviousStateCompleted captures enum value "completed"
    SubtaskInformationPreviousStateCompleted string = "completed"
)

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

func (m *SubtaskInformation) 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
}

func (m *SubtaskInformation) validateSchedulingError(formats strfmt.Registry) error {

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

    if m.SchedulingError != nil {

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

    return nil
}

var subtaskInformationTypeStatePropEnum []interface{}

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

const (
    // SubtaskInformationStateActive captures enum value "active"
    SubtaskInformationStateActive string = "active"
    // SubtaskInformationStatePreparing captures enum value "preparing"
    SubtaskInformationStatePreparing string = "preparing"
    // SubtaskInformationStateRunning captures enum value "running"
    SubtaskInformationStateRunning string = "running"
    // SubtaskInformationStateCompleted captures enum value "completed"
    SubtaskInformationStateCompleted string = "completed"
)

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

func (m *SubtaskInformation) 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
}