github.com/minio/console@v1.4.1/models/notification_endpoint_item.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  )
    32  
    33  // NotificationEndpointItem notification endpoint item
    34  //
    35  // swagger:model notificationEndpointItem
    36  type NotificationEndpointItem struct {
    37  
    38  	// account id
    39  	AccountID string `json:"account_id,omitempty"`
    40  
    41  	// service
    42  	Service NofiticationService `json:"service,omitempty"`
    43  
    44  	// status
    45  	Status string `json:"status,omitempty"`
    46  }
    47  
    48  // Validate validates this notification endpoint item
    49  func (m *NotificationEndpointItem) Validate(formats strfmt.Registry) error {
    50  	var res []error
    51  
    52  	if err := m.validateService(formats); err != nil {
    53  		res = append(res, err)
    54  	}
    55  
    56  	if len(res) > 0 {
    57  		return errors.CompositeValidationError(res...)
    58  	}
    59  	return nil
    60  }
    61  
    62  func (m *NotificationEndpointItem) validateService(formats strfmt.Registry) error {
    63  	if swag.IsZero(m.Service) { // not required
    64  		return nil
    65  	}
    66  
    67  	if err := m.Service.Validate(formats); err != nil {
    68  		if ve, ok := err.(*errors.Validation); ok {
    69  			return ve.ValidateName("service")
    70  		} else if ce, ok := err.(*errors.CompositeError); ok {
    71  			return ce.ValidateName("service")
    72  		}
    73  		return err
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  // ContextValidate validate this notification endpoint item based on the context it is used
    80  func (m *NotificationEndpointItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    81  	var res []error
    82  
    83  	if err := m.contextValidateService(ctx, formats); err != nil {
    84  		res = append(res, err)
    85  	}
    86  
    87  	if len(res) > 0 {
    88  		return errors.CompositeValidationError(res...)
    89  	}
    90  	return nil
    91  }
    92  
    93  func (m *NotificationEndpointItem) contextValidateService(ctx context.Context, formats strfmt.Registry) error {
    94  
    95  	if swag.IsZero(m.Service) { // not required
    96  		return nil
    97  	}
    98  
    99  	if err := m.Service.ContextValidate(ctx, formats); err != nil {
   100  		if ve, ok := err.(*errors.Validation); ok {
   101  			return ve.ValidateName("service")
   102  		} else if ce, ok := err.(*errors.CompositeError); ok {
   103  			return ce.ValidateName("service")
   104  		}
   105  		return err
   106  	}
   107  
   108  	return nil
   109  }
   110  
   111  // MarshalBinary interface implementation
   112  func (m *NotificationEndpointItem) MarshalBinary() ([]byte, error) {
   113  	if m == nil {
   114  		return nil, nil
   115  	}
   116  	return swag.WriteJSON(m)
   117  }
   118  
   119  // UnmarshalBinary interface implementation
   120  func (m *NotificationEndpointItem) UnmarshalBinary(b []byte) error {
   121  	var res NotificationEndpointItem
   122  	if err := swag.ReadJSON(b, &res); err != nil {
   123  		return err
   124  	}
   125  	*m = res
   126  	return nil
   127  }