github.com/minio/console@v1.4.1/api/operations/inspect/inspect_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 inspect 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 30 "github.com/go-openapi/swag" 31 ) 32 33 // InspectURL generates an URL for the inspect operation 34 type InspectURL struct { 35 Encrypt *bool 36 File string 37 Volume 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 *InspectURL) WithBasePath(bp string) *InspectURL { 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 *InspectURL) SetBasePath(bp string) { 56 o._basePath = bp 57 } 58 59 // Build a url path and query string 60 func (o *InspectURL) Build() (*url.URL, error) { 61 var _result url.URL 62 63 var _path = "/admin/inspect" 64 65 _basePath := o._basePath 66 if _basePath == "" { 67 _basePath = "/api/v1" 68 } 69 _result.Path = golangswaggerpaths.Join(_basePath, _path) 70 71 qs := make(url.Values) 72 73 var encryptQ string 74 if o.Encrypt != nil { 75 encryptQ = swag.FormatBool(*o.Encrypt) 76 } 77 if encryptQ != "" { 78 qs.Set("encrypt", encryptQ) 79 } 80 81 fileQ := o.File 82 if fileQ != "" { 83 qs.Set("file", fileQ) 84 } 85 86 volumeQ := o.Volume 87 if volumeQ != "" { 88 qs.Set("volume", volumeQ) 89 } 90 91 _result.RawQuery = qs.Encode() 92 93 return &_result, nil 94 } 95 96 // Must is a helper function to panic when the url builder returns an error 97 func (o *InspectURL) Must(u *url.URL, err error) *url.URL { 98 if err != nil { 99 panic(err) 100 } 101 if u == nil { 102 panic("url can't be nil") 103 } 104 return u 105 } 106 107 // String returns the string representation of the path with query string 108 func (o *InspectURL) String() string { 109 return o.Must(o.Build()).String() 110 } 111 112 // BuildFull builds a full url with scheme, host, path and query string 113 func (o *InspectURL) BuildFull(scheme, host string) (*url.URL, error) { 114 if scheme == "" { 115 return nil, errors.New("scheme is required for a full url on InspectURL") 116 } 117 if host == "" { 118 return nil, errors.New("host is required for a full url on InspectURL") 119 } 120 121 base, err := o.Build() 122 if err != nil { 123 return nil, err 124 } 125 126 base.Scheme = scheme 127 base.Host = host 128 return base, nil 129 } 130 131 // StringFull returns the string representation of a complete url 132 func (o *InspectURL) StringFull(scheme, host string) string { 133 return o.Must(o.BuildFull(scheme, host)).String() 134 }