jkawamoto/roadie

View on GitHub
cloud/azure/compute/models/virtual_machine_identity.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"
)

// VirtualMachineIdentity Identity for the virtual machine.
// swagger:model VirtualMachineIdentity
type VirtualMachineIdentity struct {

    // The principal id of virtual machine identity.
    // Read Only: true
    PrincipalID string `json:"principalId,omitempty"`

    // The tenant id associated with the virtual machine.
    // Read Only: true
    TenantID string `json:"tenantId,omitempty"`

    // The type of identity used for the virtual machine. Currently, the only supported type is 'SystemAssigned', which implicitly creates an identity.
    Type string `json:"type,omitempty"`
}

// Validate validates this virtual machine identity
func (m *VirtualMachineIdentity) Validate(formats strfmt.Registry) error {
    var res []error

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

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

var virtualMachineIdentityTypeTypePropEnum []interface{}

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

const (
    // VirtualMachineIdentityTypeSystemAssigned captures enum value "SystemAssigned"
    VirtualMachineIdentityTypeSystemAssigned string = "SystemAssigned"
)

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

func (m *VirtualMachineIdentity) validateType(formats strfmt.Registry) error {

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

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

    return nil
}