github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/generated/restapi/operations/user/update_user_urlbuilder.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package user 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the generate command 7 8 import ( 9 "errors" 10 "net/url" 11 golangswaggerpaths "path" 12 "strings" 13 ) 14 15 // UpdateUserURL generates an URL for the update user operation 16 type UpdateUserURL struct { 17 Username string 18 19 _basePath string 20 // avoid unkeyed usage 21 _ struct{} 22 } 23 24 // WithBasePath sets the base path for this url builder, only required when it's different from the 25 // base path specified in the swagger spec. 26 // When the value of the base path is an empty string 27 func (o *UpdateUserURL) WithBasePath(bp string) *UpdateUserURL { 28 o.SetBasePath(bp) 29 return o 30 } 31 32 // SetBasePath sets the base path for this url builder, only required when it's different from the 33 // base path specified in the swagger spec. 34 // When the value of the base path is an empty string 35 func (o *UpdateUserURL) SetBasePath(bp string) { 36 o._basePath = bp 37 } 38 39 // Build a url path and query string 40 func (o *UpdateUserURL) Build() (*url.URL, error) { 41 var _result url.URL 42 43 var _path = "/users/{username}" 44 45 username := o.Username 46 if username != "" { 47 _path = strings.Replace(_path, "{username}", username, -1) 48 } else { 49 return nil, errors.New("username is required on UpdateUserURL") 50 } 51 52 _basePath := o._basePath 53 if _basePath == "" { 54 _basePath = "/v2" 55 } 56 _result.Path = golangswaggerpaths.Join(_basePath, _path) 57 58 return &_result, nil 59 } 60 61 // Must is a helper function to panic when the url builder returns an error 62 func (o *UpdateUserURL) Must(u *url.URL, err error) *url.URL { 63 if err != nil { 64 panic(err) 65 } 66 if u == nil { 67 panic("url can't be nil") 68 } 69 return u 70 } 71 72 // String returns the string representation of the path with query string 73 func (o *UpdateUserURL) String() string { 74 return o.Must(o.Build()).String() 75 } 76 77 // BuildFull builds a full url with scheme, host, path and query string 78 func (o *UpdateUserURL) BuildFull(scheme, host string) (*url.URL, error) { 79 if scheme == "" { 80 return nil, errors.New("scheme is required for a full url on UpdateUserURL") 81 } 82 if host == "" { 83 return nil, errors.New("host is required for a full url on UpdateUserURL") 84 } 85 86 base, err := o.Build() 87 if err != nil { 88 return nil, err 89 } 90 91 base.Scheme = scheme 92 base.Host = host 93 return base, nil 94 } 95 96 // StringFull returns the string representation of a complete url 97 func (o *UpdateUserURL) StringFull(scheme, host string) string { 98 return o.Must(o.BuildFull(scheme, host)).String() 99 }