...

Source file src/github.com/prometheus/alertmanager/api/v2/client/alertgroup/get_alert_groups_parameters.go

Documentation: github.com/prometheus/alertmanager/api/v2/client/alertgroup

     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 alertgroup
    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  // NewGetAlertGroupsParams creates a new GetAlertGroupsParams 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 NewGetAlertGroupsParams() *GetAlertGroupsParams {
    41  	return &GetAlertGroupsParams{
    42  		timeout: cr.DefaultTimeout,
    43  	}
    44  }
    45  
    46  // NewGetAlertGroupsParamsWithTimeout creates a new GetAlertGroupsParams object
    47  // with the ability to set a timeout on a request.
    48  func NewGetAlertGroupsParamsWithTimeout(timeout time.Duration) *GetAlertGroupsParams {
    49  	return &GetAlertGroupsParams{
    50  		timeout: timeout,
    51  	}
    52  }
    53  
    54  // NewGetAlertGroupsParamsWithContext creates a new GetAlertGroupsParams object
    55  // with the ability to set a context for a request.
    56  func NewGetAlertGroupsParamsWithContext(ctx context.Context) *GetAlertGroupsParams {
    57  	return &GetAlertGroupsParams{
    58  		Context: ctx,
    59  	}
    60  }
    61  
    62  // NewGetAlertGroupsParamsWithHTTPClient creates a new GetAlertGroupsParams object
    63  // with the ability to set a custom HTTPClient for a request.
    64  func NewGetAlertGroupsParamsWithHTTPClient(client *http.Client) *GetAlertGroupsParams {
    65  	return &GetAlertGroupsParams{
    66  		HTTPClient: client,
    67  	}
    68  }
    69  
    70  /*
    71  GetAlertGroupsParams contains all the parameters to send to the API endpoint
    72  
    73  	for the get alert groups operation.
    74  
    75  	Typically these are written to a http.Request.
    76  */
    77  type GetAlertGroupsParams 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  	timeout    time.Duration
   116  	Context    context.Context
   117  	HTTPClient *http.Client
   118  }
   119  
   120  // WithDefaults hydrates default values in the get alert groups params (not the query body).
   121  //
   122  // All values with no default are reset to their zero value.
   123  func (o *GetAlertGroupsParams) WithDefaults() *GetAlertGroupsParams {
   124  	o.SetDefaults()
   125  	return o
   126  }
   127  
   128  // SetDefaults hydrates default values in the get alert groups params (not the query body).
   129  //
   130  // All values with no default are reset to their zero value.
   131  func (o *GetAlertGroupsParams) SetDefaults() {
   132  	var (
   133  		activeDefault = bool(true)
   134  
   135  		inhibitedDefault = bool(true)
   136  
   137  		silencedDefault = bool(true)
   138  	)
   139  
   140  	val := GetAlertGroupsParams{
   141  		Active:    &activeDefault,
   142  		Inhibited: &inhibitedDefault,
   143  		Silenced:  &silencedDefault,
   144  	}
   145  
   146  	val.timeout = o.timeout
   147  	val.Context = o.Context
   148  	val.HTTPClient = o.HTTPClient
   149  	*o = val
   150  }
   151  
   152  // WithTimeout adds the timeout to the get alert groups params
   153  func (o *GetAlertGroupsParams) WithTimeout(timeout time.Duration) *GetAlertGroupsParams {
   154  	o.SetTimeout(timeout)
   155  	return o
   156  }
   157  
   158  // SetTimeout adds the timeout to the get alert groups params
   159  func (o *GetAlertGroupsParams) SetTimeout(timeout time.Duration) {
   160  	o.timeout = timeout
   161  }
   162  
   163  // WithContext adds the context to the get alert groups params
   164  func (o *GetAlertGroupsParams) WithContext(ctx context.Context) *GetAlertGroupsParams {
   165  	o.SetContext(ctx)
   166  	return o
   167  }
   168  
   169  // SetContext adds the context to the get alert groups params
   170  func (o *GetAlertGroupsParams) SetContext(ctx context.Context) {
   171  	o.Context = ctx
   172  }
   173  
   174  // WithHTTPClient adds the HTTPClient to the get alert groups params
   175  func (o *GetAlertGroupsParams) WithHTTPClient(client *http.Client) *GetAlertGroupsParams {
   176  	o.SetHTTPClient(client)
   177  	return o
   178  }
   179  
   180  // SetHTTPClient adds the HTTPClient to the get alert groups params
   181  func (o *GetAlertGroupsParams) SetHTTPClient(client *http.Client) {
   182  	o.HTTPClient = client
   183  }
   184  
   185  // WithActive adds the active to the get alert groups params
   186  func (o *GetAlertGroupsParams) WithActive(active *bool) *GetAlertGroupsParams {
   187  	o.SetActive(active)
   188  	return o
   189  }
   190  
   191  // SetActive adds the active to the get alert groups params
   192  func (o *GetAlertGroupsParams) SetActive(active *bool) {
   193  	o.Active = active
   194  }
   195  
   196  // WithFilter adds the filter to the get alert groups params
   197  func (o *GetAlertGroupsParams) WithFilter(filter []string) *GetAlertGroupsParams {
   198  	o.SetFilter(filter)
   199  	return o
   200  }
   201  
   202  // SetFilter adds the filter to the get alert groups params
   203  func (o *GetAlertGroupsParams) SetFilter(filter []string) {
   204  	o.Filter = filter
   205  }
   206  
   207  // WithInhibited adds the inhibited to the get alert groups params
   208  func (o *GetAlertGroupsParams) WithInhibited(inhibited *bool) *GetAlertGroupsParams {
   209  	o.SetInhibited(inhibited)
   210  	return o
   211  }
   212  
   213  // SetInhibited adds the inhibited to the get alert groups params
   214  func (o *GetAlertGroupsParams) SetInhibited(inhibited *bool) {
   215  	o.Inhibited = inhibited
   216  }
   217  
   218  // WithReceiver adds the receiver to the get alert groups params
   219  func (o *GetAlertGroupsParams) WithReceiver(receiver *string) *GetAlertGroupsParams {
   220  	o.SetReceiver(receiver)
   221  	return o
   222  }
   223  
   224  // SetReceiver adds the receiver to the get alert groups params
   225  func (o *GetAlertGroupsParams) SetReceiver(receiver *string) {
   226  	o.Receiver = receiver
   227  }
   228  
   229  // WithSilenced adds the silenced to the get alert groups params
   230  func (o *GetAlertGroupsParams) WithSilenced(silenced *bool) *GetAlertGroupsParams {
   231  	o.SetSilenced(silenced)
   232  	return o
   233  }
   234  
   235  // SetSilenced adds the silenced to the get alert groups params
   236  func (o *GetAlertGroupsParams) SetSilenced(silenced *bool) {
   237  	o.Silenced = silenced
   238  }
   239  
   240  // WriteToRequest writes these params to a swagger request
   241  func (o *GetAlertGroupsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   242  
   243  	if err := r.SetTimeout(o.timeout); err != nil {
   244  		return err
   245  	}
   246  	var res []error
   247  
   248  	if o.Active != nil {
   249  
   250  		// query param active
   251  		var qrActive bool
   252  
   253  		if o.Active != nil {
   254  			qrActive = *o.Active
   255  		}
   256  		qActive := swag.FormatBool(qrActive)
   257  		if qActive != "" {
   258  
   259  			if err := r.SetQueryParam("active", qActive); err != nil {
   260  				return err
   261  			}
   262  		}
   263  	}
   264  
   265  	if o.Filter != nil {
   266  
   267  		// binding items for filter
   268  		joinedFilter := o.bindParamFilter(reg)
   269  
   270  		// query array param filter
   271  		if err := r.SetQueryParam("filter", joinedFilter...); err != nil {
   272  			return err
   273  		}
   274  	}
   275  
   276  	if o.Inhibited != nil {
   277  
   278  		// query param inhibited
   279  		var qrInhibited bool
   280  
   281  		if o.Inhibited != nil {
   282  			qrInhibited = *o.Inhibited
   283  		}
   284  		qInhibited := swag.FormatBool(qrInhibited)
   285  		if qInhibited != "" {
   286  
   287  			if err := r.SetQueryParam("inhibited", qInhibited); err != nil {
   288  				return err
   289  			}
   290  		}
   291  	}
   292  
   293  	if o.Receiver != nil {
   294  
   295  		// query param receiver
   296  		var qrReceiver string
   297  
   298  		if o.Receiver != nil {
   299  			qrReceiver = *o.Receiver
   300  		}
   301  		qReceiver := qrReceiver
   302  		if qReceiver != "" {
   303  
   304  			if err := r.SetQueryParam("receiver", qReceiver); err != nil {
   305  				return err
   306  			}
   307  		}
   308  	}
   309  
   310  	if o.Silenced != nil {
   311  
   312  		// query param silenced
   313  		var qrSilenced bool
   314  
   315  		if o.Silenced != nil {
   316  			qrSilenced = *o.Silenced
   317  		}
   318  		qSilenced := swag.FormatBool(qrSilenced)
   319  		if qSilenced != "" {
   320  
   321  			if err := r.SetQueryParam("silenced", qSilenced); err != nil {
   322  				return err
   323  			}
   324  		}
   325  	}
   326  
   327  	if len(res) > 0 {
   328  		return errors.CompositeValidationError(res...)
   329  	}
   330  	return nil
   331  }
   332  
   333  // bindParamGetAlertGroups binds the parameter filter
   334  func (o *GetAlertGroupsParams) bindParamFilter(formats strfmt.Registry) []string {
   335  	filterIR := o.Filter
   336  
   337  	var filterIC []string
   338  	for _, filterIIR := range filterIR { // explode []string
   339  
   340  		filterIIV := filterIIR // string as string
   341  		filterIC = append(filterIC, filterIIV)
   342  	}
   343  
   344  	// items.CollectionFormat: "multi"
   345  	filterIS := swag.JoinByFormat(filterIC, "multi")
   346  
   347  	return filterIS
   348  }
   349  

View as plain text