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