github.com/minio/console@v1.4.1/models/notification_delete_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  	"strconv"
    28  
    29  	"github.com/go-openapi/errors"
    30  	"github.com/go-openapi/strfmt"
    31  	"github.com/go-openapi/swag"
    32  	"github.com/go-openapi/validate"
    33  )
    34  
    35  // NotificationDeleteRequest notification delete request
    36  //
    37  // swagger:model notificationDeleteRequest
    38  type NotificationDeleteRequest struct {
    39  
    40  	// filter specific type of event. Defaults to all event (default: '[put,delete,get]')
    41  	// Required: true
    42  	Events []NotificationEventType `json:"events"`
    43  
    44  	// filter event associated to the specified prefix
    45  	// Required: true
    46  	Prefix *string `json:"prefix"`
    47  
    48  	// filter event associated to the specified suffix
    49  	// Required: true
    50  	Suffix *string `json:"suffix"`
    51  }
    52  
    53  // Validate validates this notification delete request
    54  func (m *NotificationDeleteRequest) Validate(formats strfmt.Registry) error {
    55  	var res []error
    56  
    57  	if err := m.validateEvents(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validatePrefix(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if err := m.validateSuffix(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if len(res) > 0 {
    70  		return errors.CompositeValidationError(res...)
    71  	}
    72  	return nil
    73  }
    74  
    75  func (m *NotificationDeleteRequest) validateEvents(formats strfmt.Registry) error {
    76  
    77  	if err := validate.Required("events", "body", m.Events); err != nil {
    78  		return err
    79  	}
    80  
    81  	for i := 0; i < len(m.Events); i++ {
    82  
    83  		if err := m.Events[i].Validate(formats); err != nil {
    84  			if ve, ok := err.(*errors.Validation); ok {
    85  				return ve.ValidateName("events" + "." + strconv.Itoa(i))
    86  			} else if ce, ok := err.(*errors.CompositeError); ok {
    87  				return ce.ValidateName("events" + "." + strconv.Itoa(i))
    88  			}
    89  			return err
    90  		}
    91  
    92  	}
    93  
    94  	return nil
    95  }
    96  
    97  func (m *NotificationDeleteRequest) validatePrefix(formats strfmt.Registry) error {
    98  
    99  	if err := validate.Required("prefix", "body", m.Prefix); err != nil {
   100  		return err
   101  	}
   102  
   103  	return nil
   104  }
   105  
   106  func (m *NotificationDeleteRequest) validateSuffix(formats strfmt.Registry) error {
   107  
   108  	if err := validate.Required("suffix", "body", m.Suffix); err != nil {
   109  		return err
   110  	}
   111  
   112  	return nil
   113  }
   114  
   115  // ContextValidate validate this notification delete request based on the context it is used
   116  func (m *NotificationDeleteRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   117  	var res []error
   118  
   119  	if err := m.contextValidateEvents(ctx, formats); err != nil {
   120  		res = append(res, err)
   121  	}
   122  
   123  	if len(res) > 0 {
   124  		return errors.CompositeValidationError(res...)
   125  	}
   126  	return nil
   127  }
   128  
   129  func (m *NotificationDeleteRequest) contextValidateEvents(ctx context.Context, formats strfmt.Registry) error {
   130  
   131  	for i := 0; i < len(m.Events); i++ {
   132  
   133  		if swag.IsZero(m.Events[i]) { // not required
   134  			return nil
   135  		}
   136  
   137  		if err := m.Events[i].ContextValidate(ctx, formats); err != nil {
   138  			if ve, ok := err.(*errors.Validation); ok {
   139  				return ve.ValidateName("events" + "." + strconv.Itoa(i))
   140  			} else if ce, ok := err.(*errors.CompositeError); ok {
   141  				return ce.ValidateName("events" + "." + strconv.Itoa(i))
   142  			}
   143  			return err
   144  		}
   145  
   146  	}
   147  
   148  	return nil
   149  }
   150  
   151  // MarshalBinary interface implementation
   152  func (m *NotificationDeleteRequest) MarshalBinary() ([]byte, error) {
   153  	if m == nil {
   154  		return nil, nil
   155  	}
   156  	return swag.WriteJSON(m)
   157  }
   158  
   159  // UnmarshalBinary interface implementation
   160  func (m *NotificationDeleteRequest) UnmarshalBinary(b []byte) error {
   161  	var res NotificationDeleteRequest
   162  	if err := swag.ReadJSON(b, &res); err != nil {
   163  		return err
   164  	}
   165  	*m = res
   166  	return nil
   167  }