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