jkawamoto/roadie

View on GitHub
cloud/azure/compute/models/create_option.go

Summary

Maintainability
B
4 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/errors"
    "github.com/go-openapi/validate"
)

// CreateOption The create option.
// swagger:model CreateOption
type CreateOption string

const (
    // CreateOptionFromImage captures enum value "fromImage"
    CreateOptionFromImage CreateOption = "fromImage"
    // CreateOptionEmpty captures enum value "empty"
    CreateOptionEmpty CreateOption = "empty"
    // CreateOptionAttach captures enum value "attach"
    CreateOptionAttach CreateOption = "attach"
)

// for schema
var createOptionEnum []interface{}

func init() {
    var res []CreateOption
    if err := json.Unmarshal([]byte(`["fromImage","empty","attach"]`), &res); err != nil {
        panic(err)
    }
    for _, v := range res {
        createOptionEnum = append(createOptionEnum, v)
    }
}

func (m CreateOption) validateCreateOptionEnum(path, location string, value CreateOption) error {
    if err := validate.Enum(path, location, value, createOptionEnum); err != nil {
        return err
    }
    return nil
}

// Validate validates this create option
func (m CreateOption) Validate(formats strfmt.Registry) error {
    var res []error

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

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