1// Code generated by go-swagger; DO NOT EDIT. 2 3// Copyright Prometheus Team 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17package silence 18 19// This file was generated by the swagger tool. 20// Editing this file might prove futile when you re-run the generate command 21 22import ( 23 "errors" 24 "net/url" 25 golangswaggerpaths "path" 26 27 "github.com/go-openapi/swag" 28) 29 30// GetSilencesURL generates an URL for the get silences operation 31type GetSilencesURL struct { 32 Filter []string 33 34 _basePath string 35 // avoid unkeyed usage 36 _ struct{} 37} 38 39// WithBasePath sets the base path for this url builder, only required when it's different from the 40// base path specified in the swagger spec. 41// When the value of the base path is an empty string 42func (o *GetSilencesURL) WithBasePath(bp string) *GetSilencesURL { 43 o.SetBasePath(bp) 44 return o 45} 46 47// SetBasePath sets the base path for this url builder, only required when it's different from the 48// base path specified in the swagger spec. 49// When the value of the base path is an empty string 50func (o *GetSilencesURL) SetBasePath(bp string) { 51 o._basePath = bp 52} 53 54// Build a url path and query string 55func (o *GetSilencesURL) Build() (*url.URL, error) { 56 var _result url.URL 57 58 var _path = "/silences" 59 60 _basePath := o._basePath 61 if _basePath == "" { 62 _basePath = "/api/v2/" 63 } 64 _result.Path = golangswaggerpaths.Join(_basePath, _path) 65 66 qs := make(url.Values) 67 68 var filterIR []string 69 for _, filterI := range o.Filter { 70 filterIS := filterI 71 if filterIS != "" { 72 filterIR = append(filterIR, filterIS) 73 } 74 } 75 76 filter := swag.JoinByFormat(filterIR, "multi") 77 78 for _, qsv := range filter { 79 qs.Add("filter", qsv) 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 88func (o *GetSilencesURL) 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 99func (o *GetSilencesURL) String() string { 100 return o.Must(o.Build()).String() 101} 102 103// BuildFull builds a full url with scheme, host, path and query string 104func (o *GetSilencesURL) BuildFull(scheme, host string) (*url.URL, error) { 105 if scheme == "" { 106 return nil, errors.New("scheme is required for a full url on GetSilencesURL") 107 } 108 if host == "" { 109 return nil, errors.New("host is required for a full url on GetSilencesURL") 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 123func (o *GetSilencesURL) StringFull(scheme, host string) string { 124 return o.Must(o.BuildFull(scheme, host)).String() 125} 126