...

Source file src/github.com/prometheus/alertmanager/api/v2/restapi/operations/alert/get_alerts_parameters.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 swagger generate command
    21  
    22  import (
    23  	"net/http"
    24  
    25  	"github.com/go-openapi/errors"
    26  	"github.com/go-openapi/runtime"
    27  	"github.com/go-openapi/runtime/middleware"
    28  	"github.com/go-openapi/strfmt"
    29  	"github.com/go-openapi/swag"
    30  )
    31  
    32  // NewGetAlertsParams creates a new GetAlertsParams object
    33  // with the default values initialized.
    34  func NewGetAlertsParams() GetAlertsParams {
    35  
    36  	var (
    37  		// initialize parameters with default values
    38  
    39  		activeDefault = bool(true)
    40  
    41  		inhibitedDefault = bool(true)
    42  
    43  		silencedDefault    = bool(true)
    44  		unprocessedDefault = bool(true)
    45  	)
    46  
    47  	return GetAlertsParams{
    48  		Active: &activeDefault,
    49  
    50  		Inhibited: &inhibitedDefault,
    51  
    52  		Silenced: &silencedDefault,
    53  
    54  		Unprocessed: &unprocessedDefault,
    55  	}
    56  }
    57  
    58  // GetAlertsParams contains all the bound params for the get alerts operation
    59  // typically these are obtained from a http.Request
    60  //
    61  // swagger:parameters getAlerts
    62  type GetAlertsParams struct {
    63  
    64  	// HTTP Request Object
    65  	HTTPRequest *http.Request `json:"-"`
    66  
    67  	/*Show active alerts
    68  	  In: query
    69  	  Default: true
    70  	*/
    71  	Active *bool
    72  	/*A list of matchers to filter alerts by
    73  	  In: query
    74  	  Collection Format: multi
    75  	*/
    76  	Filter []string
    77  	/*Show inhibited alerts
    78  	  In: query
    79  	  Default: true
    80  	*/
    81  	Inhibited *bool
    82  	/*A regex matching receivers to filter alerts by
    83  	  In: query
    84  	*/
    85  	Receiver *string
    86  	/*Show silenced alerts
    87  	  In: query
    88  	  Default: true
    89  	*/
    90  	Silenced *bool
    91  	/*Show unprocessed alerts
    92  	  In: query
    93  	  Default: true
    94  	*/
    95  	Unprocessed *bool
    96  }
    97  
    98  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    99  // for simple values it will use straight method calls.
   100  //
   101  // To ensure default values, the struct must have been initialized with NewGetAlertsParams() beforehand.
   102  func (o *GetAlertsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
   103  	var res []error
   104  
   105  	o.HTTPRequest = r
   106  
   107  	qs := runtime.Values(r.URL.Query())
   108  
   109  	qActive, qhkActive, _ := qs.GetOK("active")
   110  	if err := o.bindActive(qActive, qhkActive, route.Formats); err != nil {
   111  		res = append(res, err)
   112  	}
   113  
   114  	qFilter, qhkFilter, _ := qs.GetOK("filter")
   115  	if err := o.bindFilter(qFilter, qhkFilter, route.Formats); err != nil {
   116  		res = append(res, err)
   117  	}
   118  
   119  	qInhibited, qhkInhibited, _ := qs.GetOK("inhibited")
   120  	if err := o.bindInhibited(qInhibited, qhkInhibited, route.Formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	qReceiver, qhkReceiver, _ := qs.GetOK("receiver")
   125  	if err := o.bindReceiver(qReceiver, qhkReceiver, route.Formats); err != nil {
   126  		res = append(res, err)
   127  	}
   128  
   129  	qSilenced, qhkSilenced, _ := qs.GetOK("silenced")
   130  	if err := o.bindSilenced(qSilenced, qhkSilenced, route.Formats); err != nil {
   131  		res = append(res, err)
   132  	}
   133  
   134  	qUnprocessed, qhkUnprocessed, _ := qs.GetOK("unprocessed")
   135  	if err := o.bindUnprocessed(qUnprocessed, qhkUnprocessed, route.Formats); err != nil {
   136  		res = append(res, err)
   137  	}
   138  	if len(res) > 0 {
   139  		return errors.CompositeValidationError(res...)
   140  	}
   141  	return nil
   142  }
   143  
   144  // bindActive binds and validates parameter Active from query.
   145  func (o *GetAlertsParams) bindActive(rawData []string, hasKey bool, formats strfmt.Registry) error {
   146  	var raw string
   147  	if len(rawData) > 0 {
   148  		raw = rawData[len(rawData)-1]
   149  	}
   150  
   151  	// Required: false
   152  	// AllowEmptyValue: false
   153  
   154  	if raw == "" { // empty values pass all other validations
   155  		// Default values have been previously initialized by NewGetAlertsParams()
   156  		return nil
   157  	}
   158  
   159  	value, err := swag.ConvertBool(raw)
   160  	if err != nil {
   161  		return errors.InvalidType("active", "query", "bool", raw)
   162  	}
   163  	o.Active = &value
   164  
   165  	return nil
   166  }
   167  
   168  // bindFilter binds and validates array parameter Filter from query.
   169  //
   170  // Arrays are parsed according to CollectionFormat: "multi" (defaults to "csv" when empty).
   171  func (o *GetAlertsParams) bindFilter(rawData []string, hasKey bool, formats strfmt.Registry) error {
   172  	// CollectionFormat: multi
   173  	filterIC := rawData
   174  	if len(filterIC) == 0 {
   175  		return nil
   176  	}
   177  
   178  	var filterIR []string
   179  	for _, filterIV := range filterIC {
   180  		filterI := filterIV
   181  
   182  		filterIR = append(filterIR, filterI)
   183  	}
   184  
   185  	o.Filter = filterIR
   186  
   187  	return nil
   188  }
   189  
   190  // bindInhibited binds and validates parameter Inhibited from query.
   191  func (o *GetAlertsParams) bindInhibited(rawData []string, hasKey bool, formats strfmt.Registry) error {
   192  	var raw string
   193  	if len(rawData) > 0 {
   194  		raw = rawData[len(rawData)-1]
   195  	}
   196  
   197  	// Required: false
   198  	// AllowEmptyValue: false
   199  
   200  	if raw == "" { // empty values pass all other validations
   201  		// Default values have been previously initialized by NewGetAlertsParams()
   202  		return nil
   203  	}
   204  
   205  	value, err := swag.ConvertBool(raw)
   206  	if err != nil {
   207  		return errors.InvalidType("inhibited", "query", "bool", raw)
   208  	}
   209  	o.Inhibited = &value
   210  
   211  	return nil
   212  }
   213  
   214  // bindReceiver binds and validates parameter Receiver from query.
   215  func (o *GetAlertsParams) bindReceiver(rawData []string, hasKey bool, formats strfmt.Registry) error {
   216  	var raw string
   217  	if len(rawData) > 0 {
   218  		raw = rawData[len(rawData)-1]
   219  	}
   220  
   221  	// Required: false
   222  	// AllowEmptyValue: false
   223  
   224  	if raw == "" { // empty values pass all other validations
   225  		return nil
   226  	}
   227  	o.Receiver = &raw
   228  
   229  	return nil
   230  }
   231  
   232  // bindSilenced binds and validates parameter Silenced from query.
   233  func (o *GetAlertsParams) bindSilenced(rawData []string, hasKey bool, formats strfmt.Registry) error {
   234  	var raw string
   235  	if len(rawData) > 0 {
   236  		raw = rawData[len(rawData)-1]
   237  	}
   238  
   239  	// Required: false
   240  	// AllowEmptyValue: false
   241  
   242  	if raw == "" { // empty values pass all other validations
   243  		// Default values have been previously initialized by NewGetAlertsParams()
   244  		return nil
   245  	}
   246  
   247  	value, err := swag.ConvertBool(raw)
   248  	if err != nil {
   249  		return errors.InvalidType("silenced", "query", "bool", raw)
   250  	}
   251  	o.Silenced = &value
   252  
   253  	return nil
   254  }
   255  
   256  // bindUnprocessed binds and validates parameter Unprocessed from query.
   257  func (o *GetAlertsParams) bindUnprocessed(rawData []string, hasKey bool, formats strfmt.Registry) error {
   258  	var raw string
   259  	if len(rawData) > 0 {
   260  		raw = rawData[len(rawData)-1]
   261  	}
   262  
   263  	// Required: false
   264  	// AllowEmptyValue: false
   265  
   266  	if raw == "" { // empty values pass all other validations
   267  		// Default values have been previously initialized by NewGetAlertsParams()
   268  		return nil
   269  	}
   270  
   271  	value, err := swag.ConvertBool(raw)
   272  	if err != nil {
   273  		return errors.InvalidType("unprocessed", "query", "bool", raw)
   274  	}
   275  	o.Unprocessed = &value
   276  
   277  	return nil
   278  }
   279  

View as plain text