...

Source file src/github.com/prometheus/alertmanager/api/v2/restapi/operations/silence/post_silences.go

Documentation: github.com/prometheus/alertmanager/api/v2/restapi/operations/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 generate command
    21  
    22  import (
    23  	"context"
    24  	"net/http"
    25  
    26  	"github.com/go-openapi/runtime/middleware"
    27  	"github.com/go-openapi/strfmt"
    28  	"github.com/go-openapi/swag"
    29  )
    30  
    31  // PostSilencesHandlerFunc turns a function with the right signature into a post silences handler
    32  type PostSilencesHandlerFunc func(PostSilencesParams) middleware.Responder
    33  
    34  // Handle executing the request and returning a response
    35  func (fn PostSilencesHandlerFunc) Handle(params PostSilencesParams) middleware.Responder {
    36  	return fn(params)
    37  }
    38  
    39  // PostSilencesHandler interface for that can handle valid post silences params
    40  type PostSilencesHandler interface {
    41  	Handle(PostSilencesParams) middleware.Responder
    42  }
    43  
    44  // NewPostSilences creates a new http.Handler for the post silences operation
    45  func NewPostSilences(ctx *middleware.Context, handler PostSilencesHandler) *PostSilences {
    46  	return &PostSilences{Context: ctx, Handler: handler}
    47  }
    48  
    49  /*
    50  	PostSilences swagger:route POST /silences silence postSilences
    51  
    52  Post a new silence or update an existing one
    53  */
    54  type PostSilences struct {
    55  	Context *middleware.Context
    56  	Handler PostSilencesHandler
    57  }
    58  
    59  func (o *PostSilences) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
    60  	route, rCtx, _ := o.Context.RouteInfo(r)
    61  	if rCtx != nil {
    62  		*r = *rCtx
    63  	}
    64  	var Params = NewPostSilencesParams()
    65  	if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
    66  		o.Context.Respond(rw, r, route.Produces, route, err)
    67  		return
    68  	}
    69  
    70  	res := o.Handler.Handle(Params) // actually handle the request
    71  	o.Context.Respond(rw, r, route.Produces, route, res)
    72  
    73  }
    74  
    75  // PostSilencesOKBody post silences o k body
    76  //
    77  // swagger:model PostSilencesOKBody
    78  type PostSilencesOKBody struct {
    79  
    80  	// silence ID
    81  	SilenceID string `json:"silenceID,omitempty"`
    82  }
    83  
    84  // Validate validates this post silences o k body
    85  func (o *PostSilencesOKBody) Validate(formats strfmt.Registry) error {
    86  	return nil
    87  }
    88  
    89  // ContextValidate validates this post silences o k body based on context it is used
    90  func (o *PostSilencesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    91  	return nil
    92  }
    93  
    94  // MarshalBinary interface implementation
    95  func (o *PostSilencesOKBody) MarshalBinary() ([]byte, error) {
    96  	if o == nil {
    97  		return nil, nil
    98  	}
    99  	return swag.WriteJSON(o)
   100  }
   101  
   102  // UnmarshalBinary interface implementation
   103  func (o *PostSilencesOKBody) UnmarshalBinary(b []byte) error {
   104  	var res PostSilencesOKBody
   105  	if err := swag.ReadJSON(b, &res); err != nil {
   106  		return err
   107  	}
   108  	*o = res
   109  	return nil
   110  }
   111  

View as plain text