...

Source file src/github.com/prometheus/alertmanager/api/v2/client/alert/get_alerts_parameters.go

Documentation: github.com/prometheus/alertmanager/api/v2/client/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  	"context"
    24  	"net/http"
    25  	"time"
    26  
    27  	"github.com/go-openapi/errors"
    28  	"github.com/go-openapi/runtime"
    29  	cr "github.com/go-openapi/runtime/client"
    30  	"github.com/go-openapi/strfmt"
    31  	"github.com/go-openapi/swag"
    32  )
    33  
    34  // NewGetAlertsParams creates a new GetAlertsParams object,
    35  // with the default timeout for this client.
    36  //
    37  // Default values are not hydrated, since defaults are normally applied by the API server side.
    38  //
    39  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    40  func NewGetAlertsParams() *GetAlertsParams {
    41  	return &GetAlertsParams{
    42  		timeout: cr.DefaultTimeout,
    43  	}
    44  }
    45  
    46  // NewGetAlertsParamsWithTimeout creates a new GetAlertsParams object
    47  // with the ability to set a timeout on a request.
    48  func NewGetAlertsParamsWithTimeout(timeout time.Duration) *GetAlertsParams {
    49  	return &GetAlertsParams{
    50  		timeout: timeout,
    51  	}
    52  }
    53  
    54  // NewGetAlertsParamsWithContext creates a new GetAlertsParams object
    55  // with the ability to set a context for a request.
    56  func NewGetAlertsParamsWithContext(ctx context.Context) *GetAlertsParams {
    57  	return &GetAlertsParams{
    58  		Context: ctx,
    59  	}
    60  }
    61  
    62  // NewGetAlertsParamsWithHTTPClient creates a new GetAlertsParams object
    63  // with the ability to set a custom HTTPClient for a request.
    64  func NewGetAlertsParamsWithHTTPClient(client *http.Client) *GetAlertsParams {
    65  	return &GetAlertsParams{
    66  		HTTPClient: client,
    67  	}
    68  }
    69  
    70  /*
    71  GetAlertsParams contains all the parameters to send to the API endpoint
    72  
    73  	for the get alerts operation.
    74  
    75  	Typically these are written to a http.Request.
    76  */
    77  type GetAlertsParams struct {
    78  
    79  	/* Active.
    80  
    81  	   Show active alerts
    82  
    83  	   Default: true
    84  	*/
    85  	Active *bool
    86  
    87  	/* Filter.
    88  
    89  	   A list of matchers to filter alerts by
    90  	*/
    91  	Filter []string
    92  
    93  	/* Inhibited.
    94  
    95  	   Show inhibited alerts
    96  
    97  	   Default: true
    98  	*/
    99  	Inhibited *bool
   100  
   101  	/* Receiver.
   102  
   103  	   A regex matching receivers to filter alerts by
   104  	*/
   105  	Receiver *string
   106  
   107  	/* Silenced.
   108  
   109  	   Show silenced alerts
   110  
   111  	   Default: true
   112  	*/
   113  	Silenced *bool
   114  
   115  	/* Unprocessed.
   116  
   117  	   Show unprocessed alerts
   118  
   119  	   Default: true
   120  	*/
   121  	Unprocessed *bool
   122  
   123  	timeout    time.Duration
   124  	Context    context.Context
   125  	HTTPClient *http.Client
   126  }
   127  
   128  // WithDefaults hydrates default values in the get alerts params (not the query body).
   129  //
   130  // All values with no default are reset to their zero value.
   131  func (o *GetAlertsParams) WithDefaults() *GetAlertsParams {
   132  	o.SetDefaults()
   133  	return o
   134  }
   135  
   136  // SetDefaults hydrates default values in the get alerts params (not the query body).
   137  //
   138  // All values with no default are reset to their zero value.
   139  func (o *GetAlertsParams) SetDefaults() {
   140  	var (
   141  		activeDefault = bool(true)
   142  
   143  		inhibitedDefault = bool(true)
   144  
   145  		silencedDefault = bool(true)
   146  
   147  		unprocessedDefault = bool(true)
   148  	)
   149  
   150  	val := GetAlertsParams{
   151  		Active:      &activeDefault,
   152  		Inhibited:   &inhibitedDefault,
   153  		Silenced:    &silencedDefault,
   154  		Unprocessed: &unprocessedDefault,
   155  	}
   156  
   157  	val.timeout = o.timeout
   158  	val.Context = o.Context
   159  	val.HTTPClient = o.HTTPClient
   160  	*o = val
   161  }
   162  
   163  // WithTimeout adds the timeout to the get alerts params
   164  func (o *GetAlertsParams) WithTimeout(timeout time.Duration) *GetAlertsParams {
   165  	o.SetTimeout(timeout)
   166  	return o
   167  }
   168  
   169  // SetTimeout adds the timeout to the get alerts params
   170  func (o *GetAlertsParams) SetTimeout(timeout time.Duration) {
   171  	o.timeout = timeout
   172  }
   173  
   174  // WithContext adds the context to the get alerts params
   175  func (o *GetAlertsParams) WithContext(ctx context.Context) *GetAlertsParams {
   176  	o.SetContext(ctx)
   177  	return o
   178  }
   179  
   180  // SetContext adds the context to the get alerts params
   181  func (o *GetAlertsParams) SetContext(ctx context.Context) {
   182  	o.Context = ctx
   183  }
   184  
   185  // WithHTTPClient adds the HTTPClient to the get alerts params
   186  func (o *GetAlertsParams) WithHTTPClient(client *http.Client) *GetAlertsParams {
   187  	o.SetHTTPClient(client)
   188  	return o
   189  }
   190  
   191  // SetHTTPClient adds the HTTPClient to the get alerts params
   192  func (o *GetAlertsParams) SetHTTPClient(client *http.Client) {
   193  	o.HTTPClient = client
   194  }
   195  
   196  // WithActive adds the active to the get alerts params
   197  func (o *GetAlertsParams) WithActive(active *bool) *GetAlertsParams {
   198  	o.SetActive(active)
   199  	return o
   200  }
   201  
   202  // SetActive adds the active to the get alerts params
   203  func (o *GetAlertsParams) SetActive(active *bool) {
   204  	o.Active = active
   205  }
   206  
   207  // WithFilter adds the filter to the get alerts params
   208  func (o *GetAlertsParams) WithFilter(filter []string) *GetAlertsParams {
   209  	o.SetFilter(filter)
   210  	return o
   211  }
   212  
   213  // SetFilter adds the filter to the get alerts params
   214  func (o *GetAlertsParams) SetFilter(filter []string) {
   215  	o.Filter = filter
   216  }
   217  
   218  // WithInhibited adds the inhibited to the get alerts params
   219  func (o *GetAlertsParams) WithInhibited(inhibited *bool) *GetAlertsParams {
   220  	o.SetInhibited(inhibited)
   221  	return o
   222  }
   223  
   224  // SetInhibited adds the inhibited to the get alerts params
   225  func (o *GetAlertsParams) SetInhibited(inhibited *bool) {
   226  	o.Inhibited = inhibited
   227  }
   228  
   229  // WithReceiver adds the receiver to the get alerts params
   230  func (o *GetAlertsParams) WithReceiver(receiver *string) *GetAlertsParams {
   231  	o.SetReceiver(receiver)
   232  	return o
   233  }
   234  
   235  // SetReceiver adds the receiver to the get alerts params
   236  func (o *GetAlertsParams) SetReceiver(receiver *string) {
   237  	o.Receiver = receiver
   238  }
   239  
   240  // WithSilenced adds the silenced to the get alerts params
   241  func (o *GetAlertsParams) WithSilenced(silenced *bool) *GetAlertsParams {
   242  	o.SetSilenced(silenced)
   243  	return o
   244  }
   245  
   246  // SetSilenced adds the silenced to the get alerts params
   247  func (o *GetAlertsParams) SetSilenced(silenced *bool) {
   248  	o.Silenced = silenced
   249  }
   250  
   251  // WithUnprocessed adds the unprocessed to the get alerts params
   252  func (o *GetAlertsParams) WithUnprocessed(unprocessed *bool) *GetAlertsParams {
   253  	o.SetUnprocessed(unprocessed)
   254  	return o
   255  }
   256  
   257  // SetUnprocessed adds the unprocessed to the get alerts params
   258  func (o *GetAlertsParams) SetUnprocessed(unprocessed *bool) {
   259  	o.Unprocessed = unprocessed
   260  }
   261  
   262  // WriteToRequest writes these params to a swagger request
   263  func (o *GetAlertsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   264  
   265  	if err := r.SetTimeout(o.timeout); err != nil {
   266  		return err
   267  	}
   268  	var res []error
   269  
   270  	if o.Active != nil {
   271  
   272  		// query param active
   273  		var qrActive bool
   274  
   275  		if o.Active != nil {
   276  			qrActive = *o.Active
   277  		}
   278  		qActive := swag.FormatBool(qrActive)
   279  		if qActive != "" {
   280  
   281  			if err := r.SetQueryParam("active", qActive); err != nil {
   282  				return err
   283  			}
   284  		}
   285  	}
   286  
   287  	if o.Filter != nil {
   288  
   289  		// binding items for filter
   290  		joinedFilter := o.bindParamFilter(reg)
   291  
   292  		// query array param filter
   293  		if err := r.SetQueryParam("filter", joinedFilter...); err != nil {
   294  			return err
   295  		}
   296  	}
   297  
   298  	if o.Inhibited != nil {
   299  
   300  		// query param inhibited
   301  		var qrInhibited bool
   302  
   303  		if o.Inhibited != nil {
   304  			qrInhibited = *o.Inhibited
   305  		}
   306  		qInhibited := swag.FormatBool(qrInhibited)
   307  		if qInhibited != "" {
   308  
   309  			if err := r.SetQueryParam("inhibited", qInhibited); err != nil {
   310  				return err
   311  			}
   312  		}
   313  	}
   314  
   315  	if o.Receiver != nil {
   316  
   317  		// query param receiver
   318  		var qrReceiver string
   319  
   320  		if o.Receiver != nil {
   321  			qrReceiver = *o.Receiver
   322  		}
   323  		qReceiver := qrReceiver
   324  		if qReceiver != "" {
   325  
   326  			if err := r.SetQueryParam("receiver", qReceiver); err != nil {
   327  				return err
   328  			}
   329  		}
   330  	}
   331  
   332  	if o.Silenced != nil {
   333  
   334  		// query param silenced
   335  		var qrSilenced bool
   336  
   337  		if o.Silenced != nil {
   338  			qrSilenced = *o.Silenced
   339  		}
   340  		qSilenced := swag.FormatBool(qrSilenced)
   341  		if qSilenced != "" {
   342  
   343  			if err := r.SetQueryParam("silenced", qSilenced); err != nil {
   344  				return err
   345  			}
   346  		}
   347  	}
   348  
   349  	if o.Unprocessed != nil {
   350  
   351  		// query param unprocessed
   352  		var qrUnprocessed bool
   353  
   354  		if o.Unprocessed != nil {
   355  			qrUnprocessed = *o.Unprocessed
   356  		}
   357  		qUnprocessed := swag.FormatBool(qrUnprocessed)
   358  		if qUnprocessed != "" {
   359  
   360  			if err := r.SetQueryParam("unprocessed", qUnprocessed); err != nil {
   361  				return err
   362  			}
   363  		}
   364  	}
   365  
   366  	if len(res) > 0 {
   367  		return errors.CompositeValidationError(res...)
   368  	}
   369  	return nil
   370  }
   371  
   372  // bindParamGetAlerts binds the parameter filter
   373  func (o *GetAlertsParams) bindParamFilter(formats strfmt.Registry) []string {
   374  	filterIR := o.Filter
   375  
   376  	var filterIC []string
   377  	for _, filterIIR := range filterIR { // explode []string
   378  
   379  		filterIIV := filterIIR // string as string
   380  		filterIC = append(filterIC, filterIIV)
   381  	}
   382  
   383  	// items.CollectionFormat: "multi"
   384  	filterIS := swag.JoinByFormat(filterIC, "multi")
   385  
   386  	return filterIS
   387  }
   388  

View as plain text