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