github.com/kubearmor/cilium@v1.6.12/api/v1/server/restapi/policy/get_identity_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package policy
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"net/http"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/runtime"
    13  	"github.com/go-openapi/runtime/middleware"
    14  
    15  	models "github.com/cilium/cilium/api/v1/models"
    16  )
    17  
    18  // NewGetIdentityParams creates a new GetIdentityParams object
    19  // no default values defined in spec.
    20  func NewGetIdentityParams() GetIdentityParams {
    21  
    22  	return GetIdentityParams{}
    23  }
    24  
    25  // GetIdentityParams contains all the bound params for the get identity operation
    26  // typically these are obtained from a http.Request
    27  //
    28  // swagger:parameters GetIdentity
    29  type GetIdentityParams struct {
    30  
    31  	// HTTP Request Object
    32  	HTTPRequest *http.Request `json:"-"`
    33  
    34  	/*List of labels
    35  
    36  	  In: body
    37  	*/
    38  	Labels models.Labels
    39  }
    40  
    41  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    42  // for simple values it will use straight method calls.
    43  //
    44  // To ensure default values, the struct must have been initialized with NewGetIdentityParams() beforehand.
    45  func (o *GetIdentityParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    46  	var res []error
    47  
    48  	o.HTTPRequest = r
    49  
    50  	if runtime.HasBody(r) {
    51  		defer r.Body.Close()
    52  		var body models.Labels
    53  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    54  			res = append(res, errors.NewParseError("labels", "body", "", err))
    55  		} else {
    56  			// validate body object
    57  			if err := body.Validate(route.Formats); err != nil {
    58  				res = append(res, err)
    59  			}
    60  
    61  			if len(res) == 0 {
    62  				o.Labels = body
    63  			}
    64  		}
    65  	}
    66  	if len(res) > 0 {
    67  		return errors.CompositeValidationError(res...)
    68  	}
    69  	return nil
    70  }