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