github.com/minio/console@v1.4.1/models/site_replication_add_request.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // This file is part of MinIO Console Server
     4  // Copyright (c) 2023 MinIO, Inc.
     5  //
     6  // This program is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Affero General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // This program is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU Affero General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Affero General Public License
    17  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  //
    19  
    20  package models
    21  
    22  // This file was generated by the swagger tool.
    23  // Editing this file might prove futile when you re-run the swagger generate command
    24  
    25  import (
    26  	"context"
    27  	"strconv"
    28  
    29  	"github.com/go-openapi/errors"
    30  	"github.com/go-openapi/strfmt"
    31  	"github.com/go-openapi/swag"
    32  )
    33  
    34  // SiteReplicationAddRequest site replication add request
    35  //
    36  // swagger:model siteReplicationAddRequest
    37  type SiteReplicationAddRequest []*PeerSite
    38  
    39  // Validate validates this site replication add request
    40  func (m SiteReplicationAddRequest) Validate(formats strfmt.Registry) error {
    41  	var res []error
    42  
    43  	for i := 0; i < len(m); i++ {
    44  		if swag.IsZero(m[i]) { // not required
    45  			continue
    46  		}
    47  
    48  		if m[i] != nil {
    49  			if err := m[i].Validate(formats); err != nil {
    50  				if ve, ok := err.(*errors.Validation); ok {
    51  					return ve.ValidateName(strconv.Itoa(i))
    52  				} else if ce, ok := err.(*errors.CompositeError); ok {
    53  					return ce.ValidateName(strconv.Itoa(i))
    54  				}
    55  				return err
    56  			}
    57  		}
    58  
    59  	}
    60  
    61  	if len(res) > 0 {
    62  		return errors.CompositeValidationError(res...)
    63  	}
    64  	return nil
    65  }
    66  
    67  // ContextValidate validate this site replication add request based on the context it is used
    68  func (m SiteReplicationAddRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    69  	var res []error
    70  
    71  	for i := 0; i < len(m); i++ {
    72  
    73  		if m[i] != nil {
    74  
    75  			if swag.IsZero(m[i]) { // not required
    76  				return nil
    77  			}
    78  
    79  			if err := m[i].ContextValidate(ctx, formats); err != nil {
    80  				if ve, ok := err.(*errors.Validation); ok {
    81  					return ve.ValidateName(strconv.Itoa(i))
    82  				} else if ce, ok := err.(*errors.CompositeError); ok {
    83  					return ce.ValidateName(strconv.Itoa(i))
    84  				}
    85  				return err
    86  			}
    87  		}
    88  
    89  	}
    90  
    91  	if len(res) > 0 {
    92  		return errors.CompositeValidationError(res...)
    93  	}
    94  	return nil
    95  }