jkawamoto/roadie

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

Summary

Maintainability
A
2 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 (
    strfmt "github.com/go-openapi/strfmt"
    "github.com/go-openapi/swag"

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

// PoolPatchParameter The set of changes to be made to a pool.
// swagger:model PoolPatchParameter
type PoolPatchParameter struct {

    // A list of application packages to be installed on each compute node in the pool.
    //
    // Changes to application package references affect all new compute nodes joining the pool, but do not affect compute nodes that are already in the pool until they are rebooted or reimaged. If this element is present, it replaces any existing application package references. If you specify an empty collection, then all application package references are removed from the pool. If omitted, any existing application package references are left unchanged.
    ApplicationPackageReferences []*ApplicationPackageReference `json:"applicationPackageReferences"`

    // A list of certificates to be installed on each compute node in the pool.
    //
    // If omitted, any existing certificate references are left unchanged. For Windows compute nodes, the Batch service installs the certificates to the specified certificate store and location. For Linux compute nodes, the certificates are stored in a directory inside the task working directory and an environment variable AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this location. For certificates with visibility of remoteuser, a certs directory is created in the user's home directory (e.g., /home/<user-name>/certs) where certificates are placed.
    CertificateReferences []*CertificateReference `json:"certificateReferences"`

    // A list of name-value pairs associated with the pool as metadata.
    //
    // If this element is present, it replaces any existing metadata configured on the pool. If you specify an empty collection, any metadata is removed from the pool. If omitted, any existing metadata is left unchanged.
    Metadata []*MetadataItem `json:"metadata"`

    // A task to run on each compute node as it joins the pool. The task runs when the node is added to the pool or when the node is restarted.
    //
    // If omitted, any existing start task is left unchanged.
    StartTask *StartTask `json:"startTask,omitempty"`
}

// Validate validates this pool patch parameter
func (m *PoolPatchParameter) Validate(formats strfmt.Registry) error {
    var res []error

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

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

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

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

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

func (m *PoolPatchParameter) validateApplicationPackageReferences(formats strfmt.Registry) error {

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

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

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

        if m.ApplicationPackageReferences[i] != nil {

            if err := m.ApplicationPackageReferences[i].Validate(formats); err != nil {
                return err
            }
        }

    }

    return nil
}

func (m *PoolPatchParameter) validateCertificateReferences(formats strfmt.Registry) error {

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

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

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

        if m.CertificateReferences[i] != nil {

            if err := m.CertificateReferences[i].Validate(formats); err != nil {
                return err
            }
        }

    }

    return nil
}

func (m *PoolPatchParameter) validateMetadata(formats strfmt.Registry) error {

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

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

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

        if m.Metadata[i] != nil {

            if err := m.Metadata[i].Validate(formats); err != nil {
                return err
            }
        }

    }

    return nil
}

func (m *PoolPatchParameter) validateStartTask(formats strfmt.Registry) error {

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

    if m.StartTask != nil {

        if err := m.StartTask.Validate(formats); err != nil {
            return err
        }
    }

    return nil
}