github.com/minio/console@v1.3.0/models/set_bucket_policy_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  // SetBucketPolicyRequest set bucket policy request
    35  //
    36  // swagger:model setBucketPolicyRequest
    37  type SetBucketPolicyRequest struct {
    38  
    39  	// access
    40  	// Required: true
    41  	Access *BucketAccess `json:"access"`
    42  
    43  	// definition
    44  	Definition string `json:"definition,omitempty"`
    45  }
    46  
    47  // Validate validates this set bucket policy request
    48  func (m *SetBucketPolicyRequest) Validate(formats strfmt.Registry) error {
    49  	var res []error
    50  
    51  	if err := m.validateAccess(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if len(res) > 0 {
    56  		return errors.CompositeValidationError(res...)
    57  	}
    58  	return nil
    59  }
    60  
    61  func (m *SetBucketPolicyRequest) validateAccess(formats strfmt.Registry) error {
    62  
    63  	if err := validate.Required("access", "body", m.Access); err != nil {
    64  		return err
    65  	}
    66  
    67  	if err := validate.Required("access", "body", m.Access); err != nil {
    68  		return err
    69  	}
    70  
    71  	if m.Access != nil {
    72  		if err := m.Access.Validate(formats); err != nil {
    73  			if ve, ok := err.(*errors.Validation); ok {
    74  				return ve.ValidateName("access")
    75  			} else if ce, ok := err.(*errors.CompositeError); ok {
    76  				return ce.ValidateName("access")
    77  			}
    78  			return err
    79  		}
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  // ContextValidate validate this set bucket policy request based on the context it is used
    86  func (m *SetBucketPolicyRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    87  	var res []error
    88  
    89  	if err := m.contextValidateAccess(ctx, formats); err != nil {
    90  		res = append(res, err)
    91  	}
    92  
    93  	if len(res) > 0 {
    94  		return errors.CompositeValidationError(res...)
    95  	}
    96  	return nil
    97  }
    98  
    99  func (m *SetBucketPolicyRequest) contextValidateAccess(ctx context.Context, formats strfmt.Registry) error {
   100  
   101  	if m.Access != nil {
   102  
   103  		if err := m.Access.ContextValidate(ctx, formats); err != nil {
   104  			if ve, ok := err.(*errors.Validation); ok {
   105  				return ve.ValidateName("access")
   106  			} else if ce, ok := err.(*errors.CompositeError); ok {
   107  				return ce.ValidateName("access")
   108  			}
   109  			return err
   110  		}
   111  	}
   112  
   113  	return nil
   114  }
   115  
   116  // MarshalBinary interface implementation
   117  func (m *SetBucketPolicyRequest) MarshalBinary() ([]byte, error) {
   118  	if m == nil {
   119  		return nil, nil
   120  	}
   121  	return swag.WriteJSON(m)
   122  }
   123  
   124  // UnmarshalBinary interface implementation
   125  func (m *SetBucketPolicyRequest) UnmarshalBinary(b []byte) error {
   126  	var res SetBucketPolicyRequest
   127  	if err := swag.ReadJSON(b, &res); err != nil {
   128  		return err
   129  	}
   130  	*m = res
   131  	return nil
   132  }