github.com/minio/console@v1.4.1/models/notification_endpoint.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  // NotificationEndpoint notification endpoint
    35  //
    36  // swagger:model notificationEndpoint
    37  type NotificationEndpoint struct {
    38  
    39  	// account id
    40  	// Required: true
    41  	AccountID *string `json:"account_id"`
    42  
    43  	// properties
    44  	// Required: true
    45  	Properties map[string]string `json:"properties"`
    46  
    47  	// service
    48  	// Required: true
    49  	Service *NofiticationService `json:"service"`
    50  }
    51  
    52  // Validate validates this notification endpoint
    53  func (m *NotificationEndpoint) Validate(formats strfmt.Registry) error {
    54  	var res []error
    55  
    56  	if err := m.validateAccountID(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validateProperties(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if err := m.validateService(formats); err != nil {
    65  		res = append(res, err)
    66  	}
    67  
    68  	if len(res) > 0 {
    69  		return errors.CompositeValidationError(res...)
    70  	}
    71  	return nil
    72  }
    73  
    74  func (m *NotificationEndpoint) validateAccountID(formats strfmt.Registry) error {
    75  
    76  	if err := validate.Required("account_id", "body", m.AccountID); err != nil {
    77  		return err
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  func (m *NotificationEndpoint) validateProperties(formats strfmt.Registry) error {
    84  
    85  	if err := validate.Required("properties", "body", m.Properties); err != nil {
    86  		return err
    87  	}
    88  
    89  	return nil
    90  }
    91  
    92  func (m *NotificationEndpoint) validateService(formats strfmt.Registry) error {
    93  
    94  	if err := validate.Required("service", "body", m.Service); err != nil {
    95  		return err
    96  	}
    97  
    98  	if err := validate.Required("service", "body", m.Service); err != nil {
    99  		return err
   100  	}
   101  
   102  	if m.Service != nil {
   103  		if err := m.Service.Validate(formats); err != nil {
   104  			if ve, ok := err.(*errors.Validation); ok {
   105  				return ve.ValidateName("service")
   106  			} else if ce, ok := err.(*errors.CompositeError); ok {
   107  				return ce.ValidateName("service")
   108  			}
   109  			return err
   110  		}
   111  	}
   112  
   113  	return nil
   114  }
   115  
   116  // ContextValidate validate this notification endpoint based on the context it is used
   117  func (m *NotificationEndpoint) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   118  	var res []error
   119  
   120  	if err := m.contextValidateService(ctx, formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if len(res) > 0 {
   125  		return errors.CompositeValidationError(res...)
   126  	}
   127  	return nil
   128  }
   129  
   130  func (m *NotificationEndpoint) contextValidateService(ctx context.Context, formats strfmt.Registry) error {
   131  
   132  	if m.Service != nil {
   133  
   134  		if err := m.Service.ContextValidate(ctx, formats); err != nil {
   135  			if ve, ok := err.(*errors.Validation); ok {
   136  				return ve.ValidateName("service")
   137  			} else if ce, ok := err.(*errors.CompositeError); ok {
   138  				return ce.ValidateName("service")
   139  			}
   140  			return err
   141  		}
   142  	}
   143  
   144  	return nil
   145  }
   146  
   147  // MarshalBinary interface implementation
   148  func (m *NotificationEndpoint) MarshalBinary() ([]byte, error) {
   149  	if m == nil {
   150  		return nil, nil
   151  	}
   152  	return swag.WriteJSON(m)
   153  }
   154  
   155  // UnmarshalBinary interface implementation
   156  func (m *NotificationEndpoint) UnmarshalBinary(b []byte) error {
   157  	var res NotificationEndpoint
   158  	if err := swag.ReadJSON(b, &res); err != nil {
   159  		return err
   160  	}
   161  	*m = res
   162  	return nil
   163  }