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