...

Source file src/github.com/prometheus/alertmanager/api/v2/restapi/operations/alert/get_alerts_urlbuilder.go

Documentation: github.com/prometheus/alertmanager/api/v2/restapi/operations/alert

     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  
    17  package alert
    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  
    22  import (
    23  	"errors"
    24  	"net/url"
    25  	golangswaggerpaths "path"
    26  
    27  	"github.com/go-openapi/swag"
    28  )
    29  
    30  // GetAlertsURL generates an URL for the get alerts operation
    31  type GetAlertsURL struct {
    32  	Active      *bool
    33  	Filter      []string
    34  	Inhibited   *bool
    35  	Receiver    *string
    36  	Silenced    *bool
    37  	Unprocessed *bool
    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 *GetAlertsURL) WithBasePath(bp string) *GetAlertsURL {
    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 *GetAlertsURL) SetBasePath(bp string) {
    56  	o._basePath = bp
    57  }
    58  
    59  // Build a url path and query string
    60  func (o *GetAlertsURL) Build() (*url.URL, error) {
    61  	var _result url.URL
    62  
    63  	var _path = "/alerts"
    64  
    65  	_basePath := o._basePath
    66  	if _basePath == "" {
    67  		_basePath = "/api/v2/"
    68  	}
    69  	_result.Path = golangswaggerpaths.Join(_basePath, _path)
    70  
    71  	qs := make(url.Values)
    72  
    73  	var activeQ string
    74  	if o.Active != nil {
    75  		activeQ = swag.FormatBool(*o.Active)
    76  	}
    77  	if activeQ != "" {
    78  		qs.Set("active", activeQ)
    79  	}
    80  
    81  	var filterIR []string
    82  	for _, filterI := range o.Filter {
    83  		filterIS := filterI
    84  		if filterIS != "" {
    85  			filterIR = append(filterIR, filterIS)
    86  		}
    87  	}
    88  
    89  	filter := swag.JoinByFormat(filterIR, "multi")
    90  
    91  	for _, qsv := range filter {
    92  		qs.Add("filter", qsv)
    93  	}
    94  
    95  	var inhibitedQ string
    96  	if o.Inhibited != nil {
    97  		inhibitedQ = swag.FormatBool(*o.Inhibited)
    98  	}
    99  	if inhibitedQ != "" {
   100  		qs.Set("inhibited", inhibitedQ)
   101  	}
   102  
   103  	var receiverQ string
   104  	if o.Receiver != nil {
   105  		receiverQ = *o.Receiver
   106  	}
   107  	if receiverQ != "" {
   108  		qs.Set("receiver", receiverQ)
   109  	}
   110  
   111  	var silencedQ string
   112  	if o.Silenced != nil {
   113  		silencedQ = swag.FormatBool(*o.Silenced)
   114  	}
   115  	if silencedQ != "" {
   116  		qs.Set("silenced", silencedQ)
   117  	}
   118  
   119  	var unprocessedQ string
   120  	if o.Unprocessed != nil {
   121  		unprocessedQ = swag.FormatBool(*o.Unprocessed)
   122  	}
   123  	if unprocessedQ != "" {
   124  		qs.Set("unprocessed", unprocessedQ)
   125  	}
   126  
   127  	_result.RawQuery = qs.Encode()
   128  
   129  	return &_result, nil
   130  }
   131  
   132  // Must is a helper function to panic when the url builder returns an error
   133  func (o *GetAlertsURL) Must(u *url.URL, err error) *url.URL {
   134  	if err != nil {
   135  		panic(err)
   136  	}
   137  	if u == nil {
   138  		panic("url can't be nil")
   139  	}
   140  	return u
   141  }
   142  
   143  // String returns the string representation of the path with query string
   144  func (o *GetAlertsURL) String() string {
   145  	return o.Must(o.Build()).String()
   146  }
   147  
   148  // BuildFull builds a full url with scheme, host, path and query string
   149  func (o *GetAlertsURL) BuildFull(scheme, host string) (*url.URL, error) {
   150  	if scheme == "" {
   151  		return nil, errors.New("scheme is required for a full url on GetAlertsURL")
   152  	}
   153  	if host == "" {
   154  		return nil, errors.New("host is required for a full url on GetAlertsURL")
   155  	}
   156  
   157  	base, err := o.Build()
   158  	if err != nil {
   159  		return nil, err
   160  	}
   161  
   162  	base.Scheme = scheme
   163  	base.Host = host
   164  	return base, nil
   165  }
   166  
   167  // StringFull returns the string representation of a complete url
   168  func (o *GetAlertsURL) StringFull(scheme, host string) string {
   169  	return o.Must(o.BuildFull(scheme, host)).String()
   170  }
   171  

View as plain text