jkawamoto/roadie

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

Summary

Maintainability
B
6 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"
)

// ExitOptions How the Batch service should respond to a particular exit condition.
// swagger:model ExitOptions
type ExitOptions struct {

    // An action to take on the job containing the task, if the task completes with the given exit condition and the job’s onTaskFailed property is 'performexitoptionsjobaction'.
    //
    // The default is none for exit code 0 and terminate for all other exit conditions. It is an error to specify this if the job's onTaskFailed is noaction. The add task request fails with an invalid property value error; if you are calling the REST API directly, the HTTP status code is 400 (Bad Request).
    JobAction string `json:"jobAction,omitempty"`
}

// Validate validates this exit options
func (m *ExitOptions) Validate(formats strfmt.Registry) error {
    var res []error

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

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

var exitOptionsTypeJobActionPropEnum []interface{}

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

const (
    // ExitOptionsJobActionNone captures enum value "none"
    ExitOptionsJobActionNone string = "none"
    // ExitOptionsJobActionDisable captures enum value "disable"
    ExitOptionsJobActionDisable string = "disable"
    // ExitOptionsJobActionTerminate captures enum value "terminate"
    ExitOptionsJobActionTerminate string = "terminate"
)

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

func (m *ExitOptions) validateJobAction(formats strfmt.Registry) error {

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

    // value enum
    if err := m.validateJobActionEnum("jobAction", "body", m.JobAction); err != nil {
        return err
    }

    return nil
}