github.com/minio/console@v1.4.1/api/operations/object/put_object_legal_hold_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 object
    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  // PutObjectLegalHoldURL generates an URL for the put object legal hold operation
    33  type PutObjectLegalHoldURL struct {
    34  	BucketName string
    35  
    36  	Prefix    string
    37  	VersionID string
    38  
    39  	_basePath string
    40  	// avoid unkeyed usage
    41  	_ struct{}
    42  }
    43  
    44  // WithBasePath sets the base path for this url builder, only required when it's different from the
    45  // base path specified in the swagger spec.
    46  // When the value of the base path is an empty string
    47  func (o *PutObjectLegalHoldURL) WithBasePath(bp string) *PutObjectLegalHoldURL {
    48  	o.SetBasePath(bp)
    49  	return o
    50  }
    51  
    52  // SetBasePath sets the base path for this url builder, only required when it's different from the
    53  // base path specified in the swagger spec.
    54  // When the value of the base path is an empty string
    55  func (o *PutObjectLegalHoldURL) SetBasePath(bp string) {
    56  	o._basePath = bp
    57  }
    58  
    59  // Build a url path and query string
    60  func (o *PutObjectLegalHoldURL) Build() (*url.URL, error) {
    61  	var _result url.URL
    62  
    63  	var _path = "/buckets/{bucket_name}/objects/legalhold"
    64  
    65  	bucketName := o.BucketName
    66  	if bucketName != "" {
    67  		_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
    68  	} else {
    69  		return nil, errors.New("bucketName is required on PutObjectLegalHoldURL")
    70  	}
    71  
    72  	_basePath := o._basePath
    73  	if _basePath == "" {
    74  		_basePath = "/api/v1"
    75  	}
    76  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    77  
    78  	qs := make(url.Values)
    79  
    80  	prefixQ := o.Prefix
    81  	if prefixQ != "" {
    82  		qs.Set("prefix", prefixQ)
    83  	}
    84  
    85  	versionIDQ := o.VersionID
    86  	if versionIDQ != "" {
    87  		qs.Set("version_id", versionIDQ)
    88  	}
    89  
    90  	_result.RawQuery = qs.Encode()
    91  
    92  	return &_result, nil
    93  }
    94  
    95  // Must is a helper function to panic when the url builder returns an error
    96  func (o *PutObjectLegalHoldURL) Must(u *url.URL, err error) *url.URL {
    97  	if err != nil {
    98  		panic(err)
    99  	}
   100  	if u == nil {
   101  		panic("url can't be nil")
   102  	}
   103  	return u
   104  }
   105  
   106  // String returns the string representation of the path with query string
   107  func (o *PutObjectLegalHoldURL) String() string {
   108  	return o.Must(o.Build()).String()
   109  }
   110  
   111  // BuildFull builds a full url with scheme, host, path and query string
   112  func (o *PutObjectLegalHoldURL) BuildFull(scheme, host string) (*url.URL, error) {
   113  	if scheme == "" {
   114  		return nil, errors.New("scheme is required for a full url on PutObjectLegalHoldURL")
   115  	}
   116  	if host == "" {
   117  		return nil, errors.New("host is required for a full url on PutObjectLegalHoldURL")
   118  	}
   119  
   120  	base, err := o.Build()
   121  	if err != nil {
   122  		return nil, err
   123  	}
   124  
   125  	base.Scheme = scheme
   126  	base.Host = host
   127  	return base, nil
   128  }
   129  
   130  // StringFull returns the string representation of a complete url
   131  func (o *PutObjectLegalHoldURL) StringFull(scheme, host string) string {
   132  	return o.Must(o.BuildFull(scheme, host)).String()
   133  }