github.com/cilium/cilium@v1.16.2/api/v1/server/restapi/policy/get_identity_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 policy
     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"
    16  	"github.com/go-openapi/runtime/middleware"
    17  	"github.com/go-openapi/validate"
    18  
    19  	"github.com/cilium/cilium/api/v1/models"
    20  )
    21  
    22  // NewGetIdentityParams creates a new GetIdentityParams object
    23  //
    24  // There are no default values defined in the spec.
    25  func NewGetIdentityParams() GetIdentityParams {
    26  
    27  	return GetIdentityParams{}
    28  }
    29  
    30  // GetIdentityParams contains all the bound params for the get identity operation
    31  // typically these are obtained from a http.Request
    32  //
    33  // swagger:parameters GetIdentity
    34  type GetIdentityParams struct {
    35  
    36  	// HTTP Request Object
    37  	HTTPRequest *http.Request `json:"-"`
    38  
    39  	/*List of labels
    40  
    41  	  In: body
    42  	*/
    43  	Labels models.Labels
    44  }
    45  
    46  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    47  // for simple values it will use straight method calls.
    48  //
    49  // To ensure default values, the struct must have been initialized with NewGetIdentityParams() beforehand.
    50  func (o *GetIdentityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    51  	var res []error
    52  
    53  	o.HTTPRequest = r
    54  
    55  	if runtime.HasBody(r) {
    56  		defer r.Body.Close()
    57  		var body models.Labels
    58  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    59  			res = append(res, errors.NewParseError("labels", "body", "", err))
    60  		} else {
    61  			// validate body object
    62  			if err := body.Validate(route.Formats); err != nil {
    63  				res = append(res, err)
    64  			}
    65  
    66  			ctx := validate.WithOperationRequest(r.Context())
    67  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
    68  				res = append(res, err)
    69  			}
    70  
    71  			if len(res) == 0 {
    72  				o.Labels = body
    73  			}
    74  		}
    75  	}
    76  	if len(res) > 0 {
    77  		return errors.CompositeValidationError(res...)
    78  	}
    79  	return nil
    80  }