github.com/minio/console@v1.4.1/models/set_bucket_quota.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  	"encoding/json"
    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  // SetBucketQuota set bucket quota
    36  //
    37  // swagger:model setBucketQuota
    38  type SetBucketQuota struct {
    39  
    40  	// amount
    41  	Amount int64 `json:"amount,omitempty"`
    42  
    43  	// enabled
    44  	// Required: true
    45  	Enabled *bool `json:"enabled"`
    46  
    47  	// quota type
    48  	// Enum: [hard]
    49  	QuotaType string `json:"quota_type,omitempty"`
    50  }
    51  
    52  // Validate validates this set bucket quota
    53  func (m *SetBucketQuota) Validate(formats strfmt.Registry) error {
    54  	var res []error
    55  
    56  	if err := m.validateEnabled(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validateQuotaType(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if len(res) > 0 {
    65  		return errors.CompositeValidationError(res...)
    66  	}
    67  	return nil
    68  }
    69  
    70  func (m *SetBucketQuota) validateEnabled(formats strfmt.Registry) error {
    71  
    72  	if err := validate.Required("enabled", "body", m.Enabled); err != nil {
    73  		return err
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  var setBucketQuotaTypeQuotaTypePropEnum []interface{}
    80  
    81  func init() {
    82  	var res []string
    83  	if err := json.Unmarshal([]byte(`["hard"]`), &res); err != nil {
    84  		panic(err)
    85  	}
    86  	for _, v := range res {
    87  		setBucketQuotaTypeQuotaTypePropEnum = append(setBucketQuotaTypeQuotaTypePropEnum, v)
    88  	}
    89  }
    90  
    91  const (
    92  
    93  	// SetBucketQuotaQuotaTypeHard captures enum value "hard"
    94  	SetBucketQuotaQuotaTypeHard string = "hard"
    95  )
    96  
    97  // prop value enum
    98  func (m *SetBucketQuota) validateQuotaTypeEnum(path, location string, value string) error {
    99  	if err := validate.EnumCase(path, location, value, setBucketQuotaTypeQuotaTypePropEnum, true); err != nil {
   100  		return err
   101  	}
   102  	return nil
   103  }
   104  
   105  func (m *SetBucketQuota) validateQuotaType(formats strfmt.Registry) error {
   106  	if swag.IsZero(m.QuotaType) { // not required
   107  		return nil
   108  	}
   109  
   110  	// value enum
   111  	if err := m.validateQuotaTypeEnum("quota_type", "body", m.QuotaType); err != nil {
   112  		return err
   113  	}
   114  
   115  	return nil
   116  }
   117  
   118  // ContextValidate validates this set bucket quota based on context it is used
   119  func (m *SetBucketQuota) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   120  	return nil
   121  }
   122  
   123  // MarshalBinary interface implementation
   124  func (m *SetBucketQuota) MarshalBinary() ([]byte, error) {
   125  	if m == nil {
   126  		return nil, nil
   127  	}
   128  	return swag.WriteJSON(m)
   129  }
   130  
   131  // UnmarshalBinary interface implementation
   132  func (m *SetBucketQuota) UnmarshalBinary(b []byte) error {
   133  	var res SetBucketQuota
   134  	if err := swag.ReadJSON(b, &res); err != nil {
   135  		return err
   136  	}
   137  	*m = res
   138  	return nil
   139  }