github.com/minio/console@v1.4.1/models/start_profiling_list.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  // StartProfilingList start profiling list
    35  //
    36  // swagger:model startProfilingList
    37  type StartProfilingList struct {
    38  
    39  	// start results
    40  	StartResults []*StartProfilingItem `json:"startResults"`
    41  
    42  	// number of start results
    43  	Total int64 `json:"total,omitempty"`
    44  }
    45  
    46  // Validate validates this start profiling list
    47  func (m *StartProfilingList) Validate(formats strfmt.Registry) error {
    48  	var res []error
    49  
    50  	if err := m.validateStartResults(formats); err != nil {
    51  		res = append(res, err)
    52  	}
    53  
    54  	if len(res) > 0 {
    55  		return errors.CompositeValidationError(res...)
    56  	}
    57  	return nil
    58  }
    59  
    60  func (m *StartProfilingList) validateStartResults(formats strfmt.Registry) error {
    61  	if swag.IsZero(m.StartResults) { // not required
    62  		return nil
    63  	}
    64  
    65  	for i := 0; i < len(m.StartResults); i++ {
    66  		if swag.IsZero(m.StartResults[i]) { // not required
    67  			continue
    68  		}
    69  
    70  		if m.StartResults[i] != nil {
    71  			if err := m.StartResults[i].Validate(formats); err != nil {
    72  				if ve, ok := err.(*errors.Validation); ok {
    73  					return ve.ValidateName("startResults" + "." + strconv.Itoa(i))
    74  				} else if ce, ok := err.(*errors.CompositeError); ok {
    75  					return ce.ValidateName("startResults" + "." + strconv.Itoa(i))
    76  				}
    77  				return err
    78  			}
    79  		}
    80  
    81  	}
    82  
    83  	return nil
    84  }
    85  
    86  // ContextValidate validate this start profiling list based on the context it is used
    87  func (m *StartProfilingList) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    88  	var res []error
    89  
    90  	if err := m.contextValidateStartResults(ctx, formats); err != nil {
    91  		res = append(res, err)
    92  	}
    93  
    94  	if len(res) > 0 {
    95  		return errors.CompositeValidationError(res...)
    96  	}
    97  	return nil
    98  }
    99  
   100  func (m *StartProfilingList) contextValidateStartResults(ctx context.Context, formats strfmt.Registry) error {
   101  
   102  	for i := 0; i < len(m.StartResults); i++ {
   103  
   104  		if m.StartResults[i] != nil {
   105  
   106  			if swag.IsZero(m.StartResults[i]) { // not required
   107  				return nil
   108  			}
   109  
   110  			if err := m.StartResults[i].ContextValidate(ctx, formats); err != nil {
   111  				if ve, ok := err.(*errors.Validation); ok {
   112  					return ve.ValidateName("startResults" + "." + strconv.Itoa(i))
   113  				} else if ce, ok := err.(*errors.CompositeError); ok {
   114  					return ce.ValidateName("startResults" + "." + strconv.Itoa(i))
   115  				}
   116  				return err
   117  			}
   118  		}
   119  
   120  	}
   121  
   122  	return nil
   123  }
   124  
   125  // MarshalBinary interface implementation
   126  func (m *StartProfilingList) MarshalBinary() ([]byte, error) {
   127  	if m == nil {
   128  		return nil, nil
   129  	}
   130  	return swag.WriteJSON(m)
   131  }
   132  
   133  // UnmarshalBinary interface implementation
   134  func (m *StartProfilingList) UnmarshalBinary(b []byte) error {
   135  	var res StartProfilingList
   136  	if err := swag.ReadJSON(b, &res); err != nil {
   137  		return err
   138  	}
   139  	*m = res
   140  	return nil
   141  }