...

Source file src/github.com/prometheus/alertmanager/api/v2/client/silence/post_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  
    32  	"github.com/prometheus/alertmanager/api/v2/models"
    33  )
    34  
    35  // NewPostSilencesParams creates a new PostSilencesParams object,
    36  // with the default timeout for this client.
    37  //
    38  // Default values are not hydrated, since defaults are normally applied by the API server side.
    39  //
    40  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    41  func NewPostSilencesParams() *PostSilencesParams {
    42  	return &PostSilencesParams{
    43  		timeout: cr.DefaultTimeout,
    44  	}
    45  }
    46  
    47  // NewPostSilencesParamsWithTimeout creates a new PostSilencesParams object
    48  // with the ability to set a timeout on a request.
    49  func NewPostSilencesParamsWithTimeout(timeout time.Duration) *PostSilencesParams {
    50  	return &PostSilencesParams{
    51  		timeout: timeout,
    52  	}
    53  }
    54  
    55  // NewPostSilencesParamsWithContext creates a new PostSilencesParams object
    56  // with the ability to set a context for a request.
    57  func NewPostSilencesParamsWithContext(ctx context.Context) *PostSilencesParams {
    58  	return &PostSilencesParams{
    59  		Context: ctx,
    60  	}
    61  }
    62  
    63  // NewPostSilencesParamsWithHTTPClient creates a new PostSilencesParams object
    64  // with the ability to set a custom HTTPClient for a request.
    65  func NewPostSilencesParamsWithHTTPClient(client *http.Client) *PostSilencesParams {
    66  	return &PostSilencesParams{
    67  		HTTPClient: client,
    68  	}
    69  }
    70  
    71  /*
    72  PostSilencesParams contains all the parameters to send to the API endpoint
    73  
    74  	for the post silences operation.
    75  
    76  	Typically these are written to a http.Request.
    77  */
    78  type PostSilencesParams struct {
    79  
    80  	/* Silence.
    81  
    82  	   The silence to create
    83  	*/
    84  	Silence *models.PostableSilence
    85  
    86  	timeout    time.Duration
    87  	Context    context.Context
    88  	HTTPClient *http.Client
    89  }
    90  
    91  // WithDefaults hydrates default values in the post silences params (not the query body).
    92  //
    93  // All values with no default are reset to their zero value.
    94  func (o *PostSilencesParams) WithDefaults() *PostSilencesParams {
    95  	o.SetDefaults()
    96  	return o
    97  }
    98  
    99  // SetDefaults hydrates default values in the post silences params (not the query body).
   100  //
   101  // All values with no default are reset to their zero value.
   102  func (o *PostSilencesParams) SetDefaults() {
   103  	// no default values defined for this parameter
   104  }
   105  
   106  // WithTimeout adds the timeout to the post silences params
   107  func (o *PostSilencesParams) WithTimeout(timeout time.Duration) *PostSilencesParams {
   108  	o.SetTimeout(timeout)
   109  	return o
   110  }
   111  
   112  // SetTimeout adds the timeout to the post silences params
   113  func (o *PostSilencesParams) SetTimeout(timeout time.Duration) {
   114  	o.timeout = timeout
   115  }
   116  
   117  // WithContext adds the context to the post silences params
   118  func (o *PostSilencesParams) WithContext(ctx context.Context) *PostSilencesParams {
   119  	o.SetContext(ctx)
   120  	return o
   121  }
   122  
   123  // SetContext adds the context to the post silences params
   124  func (o *PostSilencesParams) SetContext(ctx context.Context) {
   125  	o.Context = ctx
   126  }
   127  
   128  // WithHTTPClient adds the HTTPClient to the post silences params
   129  func (o *PostSilencesParams) WithHTTPClient(client *http.Client) *PostSilencesParams {
   130  	o.SetHTTPClient(client)
   131  	return o
   132  }
   133  
   134  // SetHTTPClient adds the HTTPClient to the post silences params
   135  func (o *PostSilencesParams) SetHTTPClient(client *http.Client) {
   136  	o.HTTPClient = client
   137  }
   138  
   139  // WithSilence adds the silence to the post silences params
   140  func (o *PostSilencesParams) WithSilence(silence *models.PostableSilence) *PostSilencesParams {
   141  	o.SetSilence(silence)
   142  	return o
   143  }
   144  
   145  // SetSilence adds the silence to the post silences params
   146  func (o *PostSilencesParams) SetSilence(silence *models.PostableSilence) {
   147  	o.Silence = silence
   148  }
   149  
   150  // WriteToRequest writes these params to a swagger request
   151  func (o *PostSilencesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   152  
   153  	if err := r.SetTimeout(o.timeout); err != nil {
   154  		return err
   155  	}
   156  	var res []error
   157  	if o.Silence != nil {
   158  		if err := r.SetBodyParam(o.Silence); err != nil {
   159  			return err
   160  		}
   161  	}
   162  
   163  	if len(res) > 0 {
   164  		return errors.CompositeValidationError(res...)
   165  	}
   166  	return nil
   167  }
   168  

View as plain text