github.com/minio/console@v1.4.1/models/put_object_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  // PutObjectRetentionRequest put object retention request
    35  //
    36  // swagger:model putObjectRetentionRequest
    37  type PutObjectRetentionRequest struct {
    38  
    39  	// expires
    40  	// Required: true
    41  	Expires *string `json:"expires"`
    42  
    43  	// governance bypass
    44  	GovernanceBypass bool `json:"governance_bypass,omitempty"`
    45  
    46  	// mode
    47  	// Required: true
    48  	Mode *ObjectRetentionMode `json:"mode"`
    49  }
    50  
    51  // Validate validates this put object retention request
    52  func (m *PutObjectRetentionRequest) Validate(formats strfmt.Registry) error {
    53  	var res []error
    54  
    55  	if err := m.validateExpires(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if err := m.validateMode(formats); err != nil {
    60  		res = append(res, err)
    61  	}
    62  
    63  	if len(res) > 0 {
    64  		return errors.CompositeValidationError(res...)
    65  	}
    66  	return nil
    67  }
    68  
    69  func (m *PutObjectRetentionRequest) validateExpires(formats strfmt.Registry) error {
    70  
    71  	if err := validate.Required("expires", "body", m.Expires); err != nil {
    72  		return err
    73  	}
    74  
    75  	return nil
    76  }
    77  
    78  func (m *PutObjectRetentionRequest) validateMode(formats strfmt.Registry) error {
    79  
    80  	if err := validate.Required("mode", "body", m.Mode); err != nil {
    81  		return err
    82  	}
    83  
    84  	if err := validate.Required("mode", "body", m.Mode); err != nil {
    85  		return err
    86  	}
    87  
    88  	if m.Mode != nil {
    89  		if err := m.Mode.Validate(formats); err != nil {
    90  			if ve, ok := err.(*errors.Validation); ok {
    91  				return ve.ValidateName("mode")
    92  			} else if ce, ok := err.(*errors.CompositeError); ok {
    93  				return ce.ValidateName("mode")
    94  			}
    95  			return err
    96  		}
    97  	}
    98  
    99  	return nil
   100  }
   101  
   102  // ContextValidate validate this put object retention request based on the context it is used
   103  func (m *PutObjectRetentionRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   104  	var res []error
   105  
   106  	if err := m.contextValidateMode(ctx, formats); err != nil {
   107  		res = append(res, err)
   108  	}
   109  
   110  	if len(res) > 0 {
   111  		return errors.CompositeValidationError(res...)
   112  	}
   113  	return nil
   114  }
   115  
   116  func (m *PutObjectRetentionRequest) contextValidateMode(ctx context.Context, formats strfmt.Registry) error {
   117  
   118  	if m.Mode != nil {
   119  
   120  		if err := m.Mode.ContextValidate(ctx, formats); err != nil {
   121  			if ve, ok := err.(*errors.Validation); ok {
   122  				return ve.ValidateName("mode")
   123  			} else if ce, ok := err.(*errors.CompositeError); ok {
   124  				return ce.ValidateName("mode")
   125  			}
   126  			return err
   127  		}
   128  	}
   129  
   130  	return nil
   131  }
   132  
   133  // MarshalBinary interface implementation
   134  func (m *PutObjectRetentionRequest) MarshalBinary() ([]byte, error) {
   135  	if m == nil {
   136  		return nil, nil
   137  	}
   138  	return swag.WriteJSON(m)
   139  }
   140  
   141  // UnmarshalBinary interface implementation
   142  func (m *PutObjectRetentionRequest) UnmarshalBinary(b []byte) error {
   143  	var res PutObjectRetentionRequest
   144  	if err := swag.ReadJSON(b, &res); err != nil {
   145  		return err
   146  	}
   147  	*m = res
   148  	return nil
   149  }