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