github.com/minio/console@v1.3.0/models/bucket_access.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/validate"
    32  )
    33  
    34  // BucketAccess bucket access
    35  //
    36  // swagger:model bucketAccess
    37  type BucketAccess string
    38  
    39  func NewBucketAccess(value BucketAccess) *BucketAccess {
    40  	return &value
    41  }
    42  
    43  // Pointer returns a pointer to a freshly-allocated BucketAccess.
    44  func (m BucketAccess) Pointer() *BucketAccess {
    45  	return &m
    46  }
    47  
    48  const (
    49  
    50  	// BucketAccessPRIVATE captures enum value "PRIVATE"
    51  	BucketAccessPRIVATE BucketAccess = "PRIVATE"
    52  
    53  	// BucketAccessPUBLIC captures enum value "PUBLIC"
    54  	BucketAccessPUBLIC BucketAccess = "PUBLIC"
    55  
    56  	// BucketAccessCUSTOM captures enum value "CUSTOM"
    57  	BucketAccessCUSTOM BucketAccess = "CUSTOM"
    58  )
    59  
    60  // for schema
    61  var bucketAccessEnum []interface{}
    62  
    63  func init() {
    64  	var res []BucketAccess
    65  	if err := json.Unmarshal([]byte(`["PRIVATE","PUBLIC","CUSTOM"]`), &res); err != nil {
    66  		panic(err)
    67  	}
    68  	for _, v := range res {
    69  		bucketAccessEnum = append(bucketAccessEnum, v)
    70  	}
    71  }
    72  
    73  func (m BucketAccess) validateBucketAccessEnum(path, location string, value BucketAccess) error {
    74  	if err := validate.EnumCase(path, location, value, bucketAccessEnum, true); err != nil {
    75  		return err
    76  	}
    77  	return nil
    78  }
    79  
    80  // Validate validates this bucket access
    81  func (m BucketAccess) Validate(formats strfmt.Registry) error {
    82  	var res []error
    83  
    84  	// value enum
    85  	if err := m.validateBucketAccessEnum("", "body", m); err != nil {
    86  		return err
    87  	}
    88  
    89  	if len(res) > 0 {
    90  		return errors.CompositeValidationError(res...)
    91  	}
    92  	return nil
    93  }
    94  
    95  // ContextValidate validates this bucket access based on context it is used
    96  func (m BucketAccess) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    97  	return nil
    98  }