github.com/minio/console@v1.4.1/models/bucket.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  // Bucket bucket
    36  //
    37  // swagger:model bucket
    38  type Bucket struct {
    39  
    40  	// access
    41  	Access *BucketAccess `json:"access,omitempty"`
    42  
    43  	// creation date
    44  	CreationDate string `json:"creation_date,omitempty"`
    45  
    46  	// definition
    47  	Definition string `json:"definition,omitempty"`
    48  
    49  	// details
    50  	Details *BucketDetails `json:"details,omitempty"`
    51  
    52  	// name
    53  	// Required: true
    54  	// Min Length: 3
    55  	Name *string `json:"name"`
    56  
    57  	// objects
    58  	Objects int64 `json:"objects,omitempty"`
    59  
    60  	// rw access
    61  	RwAccess *BucketRwAccess `json:"rw_access,omitempty"`
    62  
    63  	// size
    64  	Size int64 `json:"size,omitempty"`
    65  }
    66  
    67  // Validate validates this bucket
    68  func (m *Bucket) Validate(formats strfmt.Registry) error {
    69  	var res []error
    70  
    71  	if err := m.validateAccess(formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if err := m.validateDetails(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if err := m.validateName(formats); err != nil {
    80  		res = append(res, err)
    81  	}
    82  
    83  	if err := m.validateRwAccess(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 *Bucket) validateAccess(formats strfmt.Registry) error {
    94  	if swag.IsZero(m.Access) { // not required
    95  		return nil
    96  	}
    97  
    98  	if m.Access != nil {
    99  		if err := m.Access.Validate(formats); err != nil {
   100  			if ve, ok := err.(*errors.Validation); ok {
   101  				return ve.ValidateName("access")
   102  			} else if ce, ok := err.(*errors.CompositeError); ok {
   103  				return ce.ValidateName("access")
   104  			}
   105  			return err
   106  		}
   107  	}
   108  
   109  	return nil
   110  }
   111  
   112  func (m *Bucket) validateDetails(formats strfmt.Registry) error {
   113  	if swag.IsZero(m.Details) { // not required
   114  		return nil
   115  	}
   116  
   117  	if m.Details != nil {
   118  		if err := m.Details.Validate(formats); err != nil {
   119  			if ve, ok := err.(*errors.Validation); ok {
   120  				return ve.ValidateName("details")
   121  			} else if ce, ok := err.(*errors.CompositeError); ok {
   122  				return ce.ValidateName("details")
   123  			}
   124  			return err
   125  		}
   126  	}
   127  
   128  	return nil
   129  }
   130  
   131  func (m *Bucket) validateName(formats strfmt.Registry) error {
   132  
   133  	if err := validate.Required("name", "body", m.Name); err != nil {
   134  		return err
   135  	}
   136  
   137  	if err := validate.MinLength("name", "body", *m.Name, 3); err != nil {
   138  		return err
   139  	}
   140  
   141  	return nil
   142  }
   143  
   144  func (m *Bucket) validateRwAccess(formats strfmt.Registry) error {
   145  	if swag.IsZero(m.RwAccess) { // not required
   146  		return nil
   147  	}
   148  
   149  	if m.RwAccess != nil {
   150  		if err := m.RwAccess.Validate(formats); err != nil {
   151  			if ve, ok := err.(*errors.Validation); ok {
   152  				return ve.ValidateName("rw_access")
   153  			} else if ce, ok := err.(*errors.CompositeError); ok {
   154  				return ce.ValidateName("rw_access")
   155  			}
   156  			return err
   157  		}
   158  	}
   159  
   160  	return nil
   161  }
   162  
   163  // ContextValidate validate this bucket based on the context it is used
   164  func (m *Bucket) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   165  	var res []error
   166  
   167  	if err := m.contextValidateAccess(ctx, formats); err != nil {
   168  		res = append(res, err)
   169  	}
   170  
   171  	if err := m.contextValidateDetails(ctx, formats); err != nil {
   172  		res = append(res, err)
   173  	}
   174  
   175  	if err := m.contextValidateRwAccess(ctx, formats); err != nil {
   176  		res = append(res, err)
   177  	}
   178  
   179  	if len(res) > 0 {
   180  		return errors.CompositeValidationError(res...)
   181  	}
   182  	return nil
   183  }
   184  
   185  func (m *Bucket) contextValidateAccess(ctx context.Context, formats strfmt.Registry) error {
   186  
   187  	if m.Access != nil {
   188  
   189  		if swag.IsZero(m.Access) { // not required
   190  			return nil
   191  		}
   192  
   193  		if err := m.Access.ContextValidate(ctx, formats); err != nil {
   194  			if ve, ok := err.(*errors.Validation); ok {
   195  				return ve.ValidateName("access")
   196  			} else if ce, ok := err.(*errors.CompositeError); ok {
   197  				return ce.ValidateName("access")
   198  			}
   199  			return err
   200  		}
   201  	}
   202  
   203  	return nil
   204  }
   205  
   206  func (m *Bucket) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error {
   207  
   208  	if m.Details != nil {
   209  
   210  		if swag.IsZero(m.Details) { // not required
   211  			return nil
   212  		}
   213  
   214  		if err := m.Details.ContextValidate(ctx, formats); err != nil {
   215  			if ve, ok := err.(*errors.Validation); ok {
   216  				return ve.ValidateName("details")
   217  			} else if ce, ok := err.(*errors.CompositeError); ok {
   218  				return ce.ValidateName("details")
   219  			}
   220  			return err
   221  		}
   222  	}
   223  
   224  	return nil
   225  }
   226  
   227  func (m *Bucket) contextValidateRwAccess(ctx context.Context, formats strfmt.Registry) error {
   228  
   229  	if m.RwAccess != nil {
   230  
   231  		if swag.IsZero(m.RwAccess) { // not required
   232  			return nil
   233  		}
   234  
   235  		if err := m.RwAccess.ContextValidate(ctx, formats); err != nil {
   236  			if ve, ok := err.(*errors.Validation); ok {
   237  				return ve.ValidateName("rw_access")
   238  			} else if ce, ok := err.(*errors.CompositeError); ok {
   239  				return ce.ValidateName("rw_access")
   240  			}
   241  			return err
   242  		}
   243  	}
   244  
   245  	return nil
   246  }
   247  
   248  // MarshalBinary interface implementation
   249  func (m *Bucket) MarshalBinary() ([]byte, error) {
   250  	if m == nil {
   251  		return nil, nil
   252  	}
   253  	return swag.WriteJSON(m)
   254  }
   255  
   256  // UnmarshalBinary interface implementation
   257  func (m *Bucket) UnmarshalBinary(b []byte) error {
   258  	var res Bucket
   259  	if err := swag.ReadJSON(b, &res); err != nil {
   260  		return err
   261  	}
   262  	*m = res
   263  	return nil
   264  }
   265  
   266  // BucketDetails bucket details
   267  //
   268  // swagger:model BucketDetails
   269  type BucketDetails struct {
   270  
   271  	// locking
   272  	Locking bool `json:"locking,omitempty"`
   273  
   274  	// quota
   275  	Quota *BucketDetailsQuota `json:"quota,omitempty"`
   276  
   277  	// replication
   278  	Replication bool `json:"replication,omitempty"`
   279  
   280  	// tags
   281  	Tags map[string]string `json:"tags,omitempty"`
   282  
   283  	// versioning
   284  	Versioning bool `json:"versioning,omitempty"`
   285  
   286  	// versioning suspended
   287  	VersioningSuspended bool `json:"versioningSuspended,omitempty"`
   288  }
   289  
   290  // Validate validates this bucket details
   291  func (m *BucketDetails) Validate(formats strfmt.Registry) error {
   292  	var res []error
   293  
   294  	if err := m.validateQuota(formats); err != nil {
   295  		res = append(res, err)
   296  	}
   297  
   298  	if len(res) > 0 {
   299  		return errors.CompositeValidationError(res...)
   300  	}
   301  	return nil
   302  }
   303  
   304  func (m *BucketDetails) validateQuota(formats strfmt.Registry) error {
   305  	if swag.IsZero(m.Quota) { // not required
   306  		return nil
   307  	}
   308  
   309  	if m.Quota != nil {
   310  		if err := m.Quota.Validate(formats); err != nil {
   311  			if ve, ok := err.(*errors.Validation); ok {
   312  				return ve.ValidateName("details" + "." + "quota")
   313  			} else if ce, ok := err.(*errors.CompositeError); ok {
   314  				return ce.ValidateName("details" + "." + "quota")
   315  			}
   316  			return err
   317  		}
   318  	}
   319  
   320  	return nil
   321  }
   322  
   323  // ContextValidate validate this bucket details based on the context it is used
   324  func (m *BucketDetails) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   325  	var res []error
   326  
   327  	if err := m.contextValidateQuota(ctx, formats); err != nil {
   328  		res = append(res, err)
   329  	}
   330  
   331  	if len(res) > 0 {
   332  		return errors.CompositeValidationError(res...)
   333  	}
   334  	return nil
   335  }
   336  
   337  func (m *BucketDetails) contextValidateQuota(ctx context.Context, formats strfmt.Registry) error {
   338  
   339  	if m.Quota != nil {
   340  
   341  		if swag.IsZero(m.Quota) { // not required
   342  			return nil
   343  		}
   344  
   345  		if err := m.Quota.ContextValidate(ctx, formats); err != nil {
   346  			if ve, ok := err.(*errors.Validation); ok {
   347  				return ve.ValidateName("details" + "." + "quota")
   348  			} else if ce, ok := err.(*errors.CompositeError); ok {
   349  				return ce.ValidateName("details" + "." + "quota")
   350  			}
   351  			return err
   352  		}
   353  	}
   354  
   355  	return nil
   356  }
   357  
   358  // MarshalBinary interface implementation
   359  func (m *BucketDetails) MarshalBinary() ([]byte, error) {
   360  	if m == nil {
   361  		return nil, nil
   362  	}
   363  	return swag.WriteJSON(m)
   364  }
   365  
   366  // UnmarshalBinary interface implementation
   367  func (m *BucketDetails) UnmarshalBinary(b []byte) error {
   368  	var res BucketDetails
   369  	if err := swag.ReadJSON(b, &res); err != nil {
   370  		return err
   371  	}
   372  	*m = res
   373  	return nil
   374  }
   375  
   376  // BucketDetailsQuota bucket details quota
   377  //
   378  // swagger:model BucketDetailsQuota
   379  type BucketDetailsQuota struct {
   380  
   381  	// quota
   382  	Quota int64 `json:"quota,omitempty"`
   383  
   384  	// type
   385  	// Enum: [hard]
   386  	Type string `json:"type,omitempty"`
   387  }
   388  
   389  // Validate validates this bucket details quota
   390  func (m *BucketDetailsQuota) Validate(formats strfmt.Registry) error {
   391  	var res []error
   392  
   393  	if err := m.validateType(formats); err != nil {
   394  		res = append(res, err)
   395  	}
   396  
   397  	if len(res) > 0 {
   398  		return errors.CompositeValidationError(res...)
   399  	}
   400  	return nil
   401  }
   402  
   403  var bucketDetailsQuotaTypeTypePropEnum []interface{}
   404  
   405  func init() {
   406  	var res []string
   407  	if err := json.Unmarshal([]byte(`["hard"]`), &res); err != nil {
   408  		panic(err)
   409  	}
   410  	for _, v := range res {
   411  		bucketDetailsQuotaTypeTypePropEnum = append(bucketDetailsQuotaTypeTypePropEnum, v)
   412  	}
   413  }
   414  
   415  const (
   416  
   417  	// BucketDetailsQuotaTypeHard captures enum value "hard"
   418  	BucketDetailsQuotaTypeHard string = "hard"
   419  )
   420  
   421  // prop value enum
   422  func (m *BucketDetailsQuota) validateTypeEnum(path, location string, value string) error {
   423  	if err := validate.EnumCase(path, location, value, bucketDetailsQuotaTypeTypePropEnum, true); err != nil {
   424  		return err
   425  	}
   426  	return nil
   427  }
   428  
   429  func (m *BucketDetailsQuota) validateType(formats strfmt.Registry) error {
   430  	if swag.IsZero(m.Type) { // not required
   431  		return nil
   432  	}
   433  
   434  	// value enum
   435  	if err := m.validateTypeEnum("details"+"."+"quota"+"."+"type", "body", m.Type); err != nil {
   436  		return err
   437  	}
   438  
   439  	return nil
   440  }
   441  
   442  // ContextValidate validates this bucket details quota based on context it is used
   443  func (m *BucketDetailsQuota) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   444  	return nil
   445  }
   446  
   447  // MarshalBinary interface implementation
   448  func (m *BucketDetailsQuota) MarshalBinary() ([]byte, error) {
   449  	if m == nil {
   450  		return nil, nil
   451  	}
   452  	return swag.WriteJSON(m)
   453  }
   454  
   455  // UnmarshalBinary interface implementation
   456  func (m *BucketDetailsQuota) UnmarshalBinary(b []byte) error {
   457  	var res BucketDetailsQuota
   458  	if err := swag.ReadJSON(b, &res); err != nil {
   459  		return err
   460  	}
   461  	*m = res
   462  	return nil
   463  }
   464  
   465  // BucketRwAccess bucket rw access
   466  //
   467  // swagger:model BucketRwAccess
   468  type BucketRwAccess struct {
   469  
   470  	// read
   471  	Read bool `json:"read,omitempty"`
   472  
   473  	// write
   474  	Write bool `json:"write,omitempty"`
   475  }
   476  
   477  // Validate validates this bucket rw access
   478  func (m *BucketRwAccess) Validate(formats strfmt.Registry) error {
   479  	return nil
   480  }
   481  
   482  // ContextValidate validates this bucket rw access based on context it is used
   483  func (m *BucketRwAccess) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   484  	return nil
   485  }
   486  
   487  // MarshalBinary interface implementation
   488  func (m *BucketRwAccess) MarshalBinary() ([]byte, error) {
   489  	if m == nil {
   490  		return nil, nil
   491  	}
   492  	return swag.WriteJSON(m)
   493  }
   494  
   495  // UnmarshalBinary interface implementation
   496  func (m *BucketRwAccess) UnmarshalBinary(b []byte) error {
   497  	var res BucketRwAccess
   498  	if err := swag.ReadJSON(b, &res); err != nil {
   499  		return err
   500  	}
   501  	*m = res
   502  	return nil
   503  }