...

Source file src/github.com/prometheus/alertmanager/api/v2/client/silence/get_silences_parameters.go

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

     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 silence
    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  // NewGetSilencesParams creates a new GetSilencesParams 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 NewGetSilencesParams() *GetSilencesParams {
    41  	return &GetSilencesParams{
    42  		timeout: cr.DefaultTimeout,
    43  	}
    44  }
    45  
    46  // NewGetSilencesParamsWithTimeout creates a new GetSilencesParams object
    47  // with the ability to set a timeout on a request.
    48  func NewGetSilencesParamsWithTimeout(timeout time.Duration) *GetSilencesParams {
    49  	return &GetSilencesParams{
    50  		timeout: timeout,
    51  	}
    52  }
    53  
    54  // NewGetSilencesParamsWithContext creates a new GetSilencesParams object
    55  // with the ability to set a context for a request.
    56  func NewGetSilencesParamsWithContext(ctx context.Context) *GetSilencesParams {
    57  	return &GetSilencesParams{
    58  		Context: ctx,
    59  	}
    60  }
    61  
    62  // NewGetSilencesParamsWithHTTPClient creates a new GetSilencesParams object
    63  // with the ability to set a custom HTTPClient for a request.
    64  func NewGetSilencesParamsWithHTTPClient(client *http.Client) *GetSilencesParams {
    65  	return &GetSilencesParams{
    66  		HTTPClient: client,
    67  	}
    68  }
    69  
    70  /*
    71  GetSilencesParams contains all the parameters to send to the API endpoint
    72  
    73  	for the get silences operation.
    74  
    75  	Typically these are written to a http.Request.
    76  */
    77  type GetSilencesParams struct {
    78  
    79  	/* Filter.
    80  
    81  	   A list of matchers to filter silences by
    82  	*/
    83  	Filter []string
    84  
    85  	timeout    time.Duration
    86  	Context    context.Context
    87  	HTTPClient *http.Client
    88  }
    89  
    90  // WithDefaults hydrates default values in the get silences params (not the query body).
    91  //
    92  // All values with no default are reset to their zero value.
    93  func (o *GetSilencesParams) WithDefaults() *GetSilencesParams {
    94  	o.SetDefaults()
    95  	return o
    96  }
    97  
    98  // SetDefaults hydrates default values in the get silences params (not the query body).
    99  //
   100  // All values with no default are reset to their zero value.
   101  func (o *GetSilencesParams) SetDefaults() {
   102  	// no default values defined for this parameter
   103  }
   104  
   105  // WithTimeout adds the timeout to the get silences params
   106  func (o *GetSilencesParams) WithTimeout(timeout time.Duration) *GetSilencesParams {
   107  	o.SetTimeout(timeout)
   108  	return o
   109  }
   110  
   111  // SetTimeout adds the timeout to the get silences params
   112  func (o *GetSilencesParams) SetTimeout(timeout time.Duration) {
   113  	o.timeout = timeout
   114  }
   115  
   116  // WithContext adds the context to the get silences params
   117  func (o *GetSilencesParams) WithContext(ctx context.Context) *GetSilencesParams {
   118  	o.SetContext(ctx)
   119  	return o
   120  }
   121  
   122  // SetContext adds the context to the get silences params
   123  func (o *GetSilencesParams) SetContext(ctx context.Context) {
   124  	o.Context = ctx
   125  }
   126  
   127  // WithHTTPClient adds the HTTPClient to the get silences params
   128  func (o *GetSilencesParams) WithHTTPClient(client *http.Client) *GetSilencesParams {
   129  	o.SetHTTPClient(client)
   130  	return o
   131  }
   132  
   133  // SetHTTPClient adds the HTTPClient to the get silences params
   134  func (o *GetSilencesParams) SetHTTPClient(client *http.Client) {
   135  	o.HTTPClient = client
   136  }
   137  
   138  // WithFilter adds the filter to the get silences params
   139  func (o *GetSilencesParams) WithFilter(filter []string) *GetSilencesParams {
   140  	o.SetFilter(filter)
   141  	return o
   142  }
   143  
   144  // SetFilter adds the filter to the get silences params
   145  func (o *GetSilencesParams) SetFilter(filter []string) {
   146  	o.Filter = filter
   147  }
   148  
   149  // WriteToRequest writes these params to a swagger request
   150  func (o *GetSilencesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   151  
   152  	if err := r.SetTimeout(o.timeout); err != nil {
   153  		return err
   154  	}
   155  	var res []error
   156  
   157  	if o.Filter != nil {
   158  
   159  		// binding items for filter
   160  		joinedFilter := o.bindParamFilter(reg)
   161  
   162  		// query array param filter
   163  		if err := r.SetQueryParam("filter", joinedFilter...); err != nil {
   164  			return err
   165  		}
   166  	}
   167  
   168  	if len(res) > 0 {
   169  		return errors.CompositeValidationError(res...)
   170  	}
   171  	return nil
   172  }
   173  
   174  // bindParamGetSilences binds the parameter filter
   175  func (o *GetSilencesParams) bindParamFilter(formats strfmt.Registry) []string {
   176  	filterIR := o.Filter
   177  
   178  	var filterIC []string
   179  	for _, filterIIR := range filterIR { // explode []string
   180  
   181  		filterIIV := filterIIR // string as string
   182  		filterIC = append(filterIC, filterIIV)
   183  	}
   184  
   185  	// items.CollectionFormat: "multi"
   186  	filterIS := swag.JoinByFormat(filterIC, "multi")
   187  
   188  	return filterIS
   189  }
   190  

View as plain text