jkawamoto/roadie

View on GitHub
cloud/azure/resource/models/tag_details.go

Summary

Maintainability
A
1 hr
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 (
    "strconv"

    strfmt "github.com/go-openapi/strfmt"

    "github.com/go-openapi/errors"
    "github.com/go-openapi/swag"
)

// TagDetails Tag details.
// swagger:model TagDetails
type TagDetails struct {

    // The total number of resources that use the resource tag. When a tag is initially created and has no associated resources, the value is 0.
    Count *TagCount `json:"count,omitempty"`

    // The tag ID.
    ID string `json:"id,omitempty"`

    // The tag name.
    TagName string `json:"tagName,omitempty"`

    // The list of tag values.
    Values []*TagValue `json:"values"`
}

// Validate validates this tag details
func (m *TagDetails) Validate(formats strfmt.Registry) error {
    var res []error

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

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

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

func (m *TagDetails) validateCount(formats strfmt.Registry) error {

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

    if m.Count != nil {

        if err := m.Count.Validate(formats); err != nil {
            if ve, ok := err.(*errors.Validation); ok {
                return ve.ValidateName("count")
            }
            return err
        }
    }

    return nil
}

func (m *TagDetails) validateValues(formats strfmt.Registry) error {

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

    for i := 0; i < len(m.Values); i++ {

        if swag.IsZero(m.Values[i]) { // not required
            continue
        }

        if m.Values[i] != nil {

            if err := m.Values[i].Validate(formats); err != nil {
                if ve, ok := err.(*errors.Validation); ok {
                    return ve.ValidateName("values" + "." + strconv.Itoa(i))
                }
                return err
            }
        }

    }

    return nil
}