github.com/emreu/go-swagger@v0.22.1/examples/task-tracker/restapi/operations/tasks/get_task_comments_urlbuilder.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package tasks 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 "github.com/go-openapi/strfmt" 15 "github.com/go-openapi/swag" 16 ) 17 18 // GetTaskCommentsURL generates an URL for the get task comments operation 19 type GetTaskCommentsURL struct { 20 ID int64 21 22 PageSize *int32 23 Since *strfmt.DateTime 24 25 _basePath string 26 // avoid unkeyed usage 27 _ struct{} 28 } 29 30 // WithBasePath sets the base path for this url builder, only required when it's different from the 31 // base path specified in the swagger spec. 32 // When the value of the base path is an empty string 33 func (o *GetTaskCommentsURL) WithBasePath(bp string) *GetTaskCommentsURL { 34 o.SetBasePath(bp) 35 return o 36 } 37 38 // SetBasePath sets the base path for this url builder, only required when it's different from the 39 // base path specified in the swagger spec. 40 // When the value of the base path is an empty string 41 func (o *GetTaskCommentsURL) SetBasePath(bp string) { 42 o._basePath = bp 43 } 44 45 // Build a url path and query string 46 func (o *GetTaskCommentsURL) Build() (*url.URL, error) { 47 var _result url.URL 48 49 var _path = "/tasks/{id}/comments" 50 51 id := swag.FormatInt64(o.ID) 52 if id != "" { 53 _path = strings.Replace(_path, "{id}", id, -1) 54 } else { 55 return nil, errors.New("id is required on GetTaskCommentsURL") 56 } 57 58 _basePath := o._basePath 59 if _basePath == "" { 60 _basePath = "/api" 61 } 62 _result.Path = golangswaggerpaths.Join(_basePath, _path) 63 64 qs := make(url.Values) 65 66 var pageSizeQ string 67 if o.PageSize != nil { 68 pageSizeQ = swag.FormatInt32(*o.PageSize) 69 } 70 if pageSizeQ != "" { 71 qs.Set("pageSize", pageSizeQ) 72 } 73 74 var sinceQ string 75 if o.Since != nil { 76 sinceQ = o.Since.String() 77 } 78 if sinceQ != "" { 79 qs.Set("since", sinceQ) 80 } 81 82 _result.RawQuery = qs.Encode() 83 84 return &_result, nil 85 } 86 87 // Must is a helper function to panic when the url builder returns an error 88 func (o *GetTaskCommentsURL) Must(u *url.URL, err error) *url.URL { 89 if err != nil { 90 panic(err) 91 } 92 if u == nil { 93 panic("url can't be nil") 94 } 95 return u 96 } 97 98 // String returns the string representation of the path with query string 99 func (o *GetTaskCommentsURL) String() string { 100 return o.Must(o.Build()).String() 101 } 102 103 // BuildFull builds a full url with scheme, host, path and query string 104 func (o *GetTaskCommentsURL) BuildFull(scheme, host string) (*url.URL, error) { 105 if scheme == "" { 106 return nil, errors.New("scheme is required for a full url on GetTaskCommentsURL") 107 } 108 if host == "" { 109 return nil, errors.New("host is required for a full url on GetTaskCommentsURL") 110 } 111 112 base, err := o.Build() 113 if err != nil { 114 return nil, err 115 } 116 117 base.Scheme = scheme 118 base.Host = host 119 return base, nil 120 } 121 122 // StringFull returns the string representation of a complete url 123 func (o *GetTaskCommentsURL) StringFull(scheme, host string) string { 124 return o.Must(o.BuildFull(scheme, host)).String() 125 }