github.com/minio/console@v1.4.1/api/operations/bucket/enable_bucket_encryption_urlbuilder.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 bucket
    21  
    22  // This file was generated by the swagger tool.
    23  // Editing this file might prove futile when you re-run the generate command
    24  
    25  import (
    26  	"errors"
    27  	"net/url"
    28  	golangswaggerpaths "path"
    29  	"strings"
    30  )
    31  
    32  // EnableBucketEncryptionURL generates an URL for the enable bucket encryption operation
    33  type EnableBucketEncryptionURL struct {
    34  	BucketName string
    35  
    36  	_basePath string
    37  	// avoid unkeyed usage
    38  	_ struct{}
    39  }
    40  
    41  // WithBasePath sets the base path for this url builder, only required when it's different from the
    42  // base path specified in the swagger spec.
    43  // When the value of the base path is an empty string
    44  func (o *EnableBucketEncryptionURL) WithBasePath(bp string) *EnableBucketEncryptionURL {
    45  	o.SetBasePath(bp)
    46  	return o
    47  }
    48  
    49  // SetBasePath sets the base path for this url builder, only required when it's different from the
    50  // base path specified in the swagger spec.
    51  // When the value of the base path is an empty string
    52  func (o *EnableBucketEncryptionURL) SetBasePath(bp string) {
    53  	o._basePath = bp
    54  }
    55  
    56  // Build a url path and query string
    57  func (o *EnableBucketEncryptionURL) Build() (*url.URL, error) {
    58  	var _result url.URL
    59  
    60  	var _path = "/buckets/{bucket_name}/encryption/enable"
    61  
    62  	bucketName := o.BucketName
    63  	if bucketName != "" {
    64  		_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
    65  	} else {
    66  		return nil, errors.New("bucketName is required on EnableBucketEncryptionURL")
    67  	}
    68  
    69  	_basePath := o._basePath
    70  	if _basePath == "" {
    71  		_basePath = "/api/v1"
    72  	}
    73  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    74  
    75  	return &_result, nil
    76  }
    77  
    78  // Must is a helper function to panic when the url builder returns an error
    79  func (o *EnableBucketEncryptionURL) Must(u *url.URL, err error) *url.URL {
    80  	if err != nil {
    81  		panic(err)
    82  	}
    83  	if u == nil {
    84  		panic("url can't be nil")
    85  	}
    86  	return u
    87  }
    88  
    89  // String returns the string representation of the path with query string
    90  func (o *EnableBucketEncryptionURL) String() string {
    91  	return o.Must(o.Build()).String()
    92  }
    93  
    94  // BuildFull builds a full url with scheme, host, path and query string
    95  func (o *EnableBucketEncryptionURL) BuildFull(scheme, host string) (*url.URL, error) {
    96  	if scheme == "" {
    97  		return nil, errors.New("scheme is required for a full url on EnableBucketEncryptionURL")
    98  	}
    99  	if host == "" {
   100  		return nil, errors.New("host is required for a full url on EnableBucketEncryptionURL")
   101  	}
   102  
   103  	base, err := o.Build()
   104  	if err != nil {
   105  		return nil, err
   106  	}
   107  
   108  	base.Scheme = scheme
   109  	base.Host = host
   110  	return base, nil
   111  }
   112  
   113  // StringFull returns the string representation of a complete url
   114  func (o *EnableBucketEncryptionURL) StringFull(scheme, host string) string {
   115  	return o.Must(o.BuildFull(scheme, host)).String()
   116  }