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