github.com/minio/console@v1.3.0/models/put_bucket_retention_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  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/strfmt"
    30  	"github.com/go-openapi/swag"
    31  	"github.com/go-openapi/validate"
    32  )
    33  
    34  // PutBucketRetentionRequest put bucket retention request
    35  //
    36  // swagger:model putBucketRetentionRequest
    37  type PutBucketRetentionRequest struct {
    38  
    39  	// mode
    40  	// Required: true
    41  	Mode *ObjectRetentionMode `json:"mode"`
    42  
    43  	// unit
    44  	// Required: true
    45  	Unit *ObjectRetentionUnit `json:"unit"`
    46  
    47  	// validity
    48  	// Required: true
    49  	Validity *int32 `json:"validity"`
    50  }
    51  
    52  // Validate validates this put bucket retention request
    53  func (m *PutBucketRetentionRequest) Validate(formats strfmt.Registry) error {
    54  	var res []error
    55  
    56  	if err := m.validateMode(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validateUnit(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if err := m.validateValidity(formats); err != nil {
    65  		res = append(res, err)
    66  	}
    67  
    68  	if len(res) > 0 {
    69  		return errors.CompositeValidationError(res...)
    70  	}
    71  	return nil
    72  }
    73  
    74  func (m *PutBucketRetentionRequest) validateMode(formats strfmt.Registry) error {
    75  
    76  	if err := validate.Required("mode", "body", m.Mode); err != nil {
    77  		return err
    78  	}
    79  
    80  	if err := validate.Required("mode", "body", m.Mode); err != nil {
    81  		return err
    82  	}
    83  
    84  	if m.Mode != nil {
    85  		if err := m.Mode.Validate(formats); err != nil {
    86  			if ve, ok := err.(*errors.Validation); ok {
    87  				return ve.ValidateName("mode")
    88  			} else if ce, ok := err.(*errors.CompositeError); ok {
    89  				return ce.ValidateName("mode")
    90  			}
    91  			return err
    92  		}
    93  	}
    94  
    95  	return nil
    96  }
    97  
    98  func (m *PutBucketRetentionRequest) validateUnit(formats strfmt.Registry) error {
    99  
   100  	if err := validate.Required("unit", "body", m.Unit); err != nil {
   101  		return err
   102  	}
   103  
   104  	if err := validate.Required("unit", "body", m.Unit); err != nil {
   105  		return err
   106  	}
   107  
   108  	if m.Unit != nil {
   109  		if err := m.Unit.Validate(formats); err != nil {
   110  			if ve, ok := err.(*errors.Validation); ok {
   111  				return ve.ValidateName("unit")
   112  			} else if ce, ok := err.(*errors.CompositeError); ok {
   113  				return ce.ValidateName("unit")
   114  			}
   115  			return err
   116  		}
   117  	}
   118  
   119  	return nil
   120  }
   121  
   122  func (m *PutBucketRetentionRequest) validateValidity(formats strfmt.Registry) error {
   123  
   124  	if err := validate.Required("validity", "body", m.Validity); err != nil {
   125  		return err
   126  	}
   127  
   128  	return nil
   129  }
   130  
   131  // ContextValidate validate this put bucket retention request based on the context it is used
   132  func (m *PutBucketRetentionRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   133  	var res []error
   134  
   135  	if err := m.contextValidateMode(ctx, formats); err != nil {
   136  		res = append(res, err)
   137  	}
   138  
   139  	if err := m.contextValidateUnit(ctx, formats); err != nil {
   140  		res = append(res, err)
   141  	}
   142  
   143  	if len(res) > 0 {
   144  		return errors.CompositeValidationError(res...)
   145  	}
   146  	return nil
   147  }
   148  
   149  func (m *PutBucketRetentionRequest) contextValidateMode(ctx context.Context, formats strfmt.Registry) error {
   150  
   151  	if m.Mode != nil {
   152  
   153  		if err := m.Mode.ContextValidate(ctx, formats); err != nil {
   154  			if ve, ok := err.(*errors.Validation); ok {
   155  				return ve.ValidateName("mode")
   156  			} else if ce, ok := err.(*errors.CompositeError); ok {
   157  				return ce.ValidateName("mode")
   158  			}
   159  			return err
   160  		}
   161  	}
   162  
   163  	return nil
   164  }
   165  
   166  func (m *PutBucketRetentionRequest) contextValidateUnit(ctx context.Context, formats strfmt.Registry) error {
   167  
   168  	if m.Unit != nil {
   169  
   170  		if err := m.Unit.ContextValidate(ctx, formats); err != nil {
   171  			if ve, ok := err.(*errors.Validation); ok {
   172  				return ve.ValidateName("unit")
   173  			} else if ce, ok := err.(*errors.CompositeError); ok {
   174  				return ce.ValidateName("unit")
   175  			}
   176  			return err
   177  		}
   178  	}
   179  
   180  	return nil
   181  }
   182  
   183  // MarshalBinary interface implementation
   184  func (m *PutBucketRetentionRequest) MarshalBinary() ([]byte, error) {
   185  	if m == nil {
   186  		return nil, nil
   187  	}
   188  	return swag.WriteJSON(m)
   189  }
   190  
   191  // UnmarshalBinary interface implementation
   192  func (m *PutBucketRetentionRequest) UnmarshalBinary(b []byte) error {
   193  	var res PutBucketRetentionRequest
   194  	if err := swag.ReadJSON(b, &res); err != nil {
   195  		return err
   196  	}
   197  	*m = res
   198  	return nil
   199  }