github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/service/get_service_id_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package service
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the swagger generate command
    10  
    11  import (
    12  	"net/http"
    13  
    14  	"github.com/go-openapi/errors"
    15  	"github.com/go-openapi/runtime/middleware"
    16  	"github.com/go-openapi/strfmt"
    17  	"github.com/go-openapi/swag"
    18  )
    19  
    20  // NewGetServiceIDParams creates a new GetServiceIDParams object
    21  //
    22  // There are no default values defined in the spec.
    23  func NewGetServiceIDParams() GetServiceIDParams {
    24  
    25  	return GetServiceIDParams{}
    26  }
    27  
    28  // GetServiceIDParams contains all the bound params for the get service ID operation
    29  // typically these are obtained from a http.Request
    30  //
    31  // swagger:parameters GetServiceID
    32  type GetServiceIDParams struct {
    33  
    34  	// HTTP Request Object
    35  	HTTPRequest *http.Request `json:"-"`
    36  
    37  	/*ID of service
    38  	  Required: true
    39  	  In: path
    40  	*/
    41  	ID int64
    42  }
    43  
    44  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    45  // for simple values it will use straight method calls.
    46  //
    47  // To ensure default values, the struct must have been initialized with NewGetServiceIDParams() beforehand.
    48  func (o *GetServiceIDParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    49  	var res []error
    50  
    51  	o.HTTPRequest = r
    52  
    53  	rID, rhkID, _ := route.Params.GetOK("id")
    54  	if err := o.bindID(rID, rhkID, route.Formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  	if len(res) > 0 {
    58  		return errors.CompositeValidationError(res...)
    59  	}
    60  	return nil
    61  }
    62  
    63  // bindID binds and validates parameter ID from path.
    64  func (o *GetServiceIDParams) bindID(rawData []string, hasKey bool, formats strfmt.Registry) error {
    65  	var raw string
    66  	if len(rawData) > 0 {
    67  		raw = rawData[len(rawData)-1]
    68  	}
    69  
    70  	// Required: true
    71  	// Parameter is provided by construction from the route
    72  
    73  	value, err := swag.ConvertInt64(raw)
    74  	if err != nil {
    75  		return errors.InvalidType("id", "path", "int64", raw)
    76  	}
    77  	o.ID = value
    78  
    79  	return nil
    80  }