...

Source file src/github.com/prometheus/alertmanager/api/v2/restapi/operations/silence/delete_silence_parameters.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 swagger generate command
    21  
    22  import (
    23  	"net/http"
    24  
    25  	"github.com/go-openapi/errors"
    26  	"github.com/go-openapi/runtime/middleware"
    27  	"github.com/go-openapi/strfmt"
    28  	"github.com/go-openapi/validate"
    29  )
    30  
    31  // NewDeleteSilenceParams creates a new DeleteSilenceParams object
    32  //
    33  // There are no default values defined in the spec.
    34  func NewDeleteSilenceParams() DeleteSilenceParams {
    35  
    36  	return DeleteSilenceParams{}
    37  }
    38  
    39  // DeleteSilenceParams contains all the bound params for the delete silence operation
    40  // typically these are obtained from a http.Request
    41  //
    42  // swagger:parameters deleteSilence
    43  type DeleteSilenceParams struct {
    44  
    45  	// HTTP Request Object
    46  	HTTPRequest *http.Request `json:"-"`
    47  
    48  	/*ID of the silence to get
    49  	  Required: true
    50  	  In: path
    51  	*/
    52  	SilenceID strfmt.UUID
    53  }
    54  
    55  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    56  // for simple values it will use straight method calls.
    57  //
    58  // To ensure default values, the struct must have been initialized with NewDeleteSilenceParams() beforehand.
    59  func (o *DeleteSilenceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    60  	var res []error
    61  
    62  	o.HTTPRequest = r
    63  
    64  	rSilenceID, rhkSilenceID, _ := route.Params.GetOK("silenceID")
    65  	if err := o.bindSilenceID(rSilenceID, rhkSilenceID, route.Formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  	if len(res) > 0 {
    69  		return errors.CompositeValidationError(res...)
    70  	}
    71  	return nil
    72  }
    73  
    74  // bindSilenceID binds and validates parameter SilenceID from path.
    75  func (o *DeleteSilenceParams) bindSilenceID(rawData []string, hasKey bool, formats strfmt.Registry) error {
    76  	var raw string
    77  	if len(rawData) > 0 {
    78  		raw = rawData[len(rawData)-1]
    79  	}
    80  
    81  	// Required: true
    82  	// Parameter is provided by construction from the route
    83  
    84  	// Format: uuid
    85  	value, err := formats.Parse("uuid", raw)
    86  	if err != nil {
    87  		return errors.InvalidType("silenceID", "path", "strfmt.UUID", raw)
    88  	}
    89  	o.SilenceID = *(value.(*strfmt.UUID))
    90  
    91  	if err := o.validateSilenceID(formats); err != nil {
    92  		return err
    93  	}
    94  
    95  	return nil
    96  }
    97  
    98  // validateSilenceID carries on validations for parameter SilenceID
    99  func (o *DeleteSilenceParams) validateSilenceID(formats strfmt.Registry) error {
   100  
   101  	if err := validate.FormatOf("silenceID", "path", "uuid", o.SilenceID.String(), formats); err != nil {
   102  		return err
   103  	}
   104  	return nil
   105  }
   106  

View as plain text