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