jkawamoto/roadie

View on GitHub
cloud/azure/resource/models/resource_group.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 (
    strfmt "github.com/go-openapi/strfmt"

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

// ResourceGroup Resource group information.
// swagger:model ResourceGroup
type ResourceGroup struct {

    // The ID of the resource group.
    // Read Only: true
    ID string `json:"id,omitempty"`

    // The location of the resource group. It cannot be changed after the resource group has been created. It muct be one of the supported Azure locations.
    // Required: true
    Location *string `json:"location"`

    // The ID of the resource that manages this resource group.
    ManagedBy string `json:"managedBy,omitempty"`

    // The name of the resource group.
    Name string `json:"name,omitempty"`

    // properties
    Properties *ResourceGroupProperties `json:"properties,omitempty"`

    // The tags attached to the resource group.
    Tags map[string]string `json:"tags,omitempty"`
}

// Validate validates this resource group
func (m *ResourceGroup) Validate(formats strfmt.Registry) error {
    var res []error

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

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

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

func (m *ResourceGroup) validateLocation(formats strfmt.Registry) error {

    if err := validate.Required("location", "body", m.Location); err != nil {
        return err
    }

    return nil
}

func (m *ResourceGroup) validateProperties(formats strfmt.Registry) error {

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

    if m.Properties != nil {

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

    return nil
}