...

Source file src/github.com/sigstore/rekor/pkg/generated/restapi/operations/index/search_index_parameters.go

Documentation: github.com/sigstore/rekor/pkg/generated/restapi/operations/index

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  //
     4  // Copyright 2021 The Sigstore Authors.
     5  //
     6  // Licensed under the Apache License, Version 2.0 (the "License");
     7  // you may not use this file except in compliance with the License.
     8  // You may obtain a copy of the License at
     9  //
    10  //     http://www.apache.org/licenses/LICENSE-2.0
    11  //
    12  // Unless required by applicable law or agreed to in writing, software
    13  // distributed under the License is distributed on an "AS IS" BASIS,
    14  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  // See the License for the specific language governing permissions and
    16  // limitations under the License.
    17  //
    18  
    19  package index
    20  
    21  // This file was generated by the swagger tool.
    22  // Editing this file might prove futile when you re-run the swagger generate command
    23  
    24  import (
    25  	"io"
    26  	"net/http"
    27  
    28  	"github.com/go-openapi/errors"
    29  	"github.com/go-openapi/runtime"
    30  	"github.com/go-openapi/runtime/middleware"
    31  	"github.com/go-openapi/validate"
    32  
    33  	"github.com/sigstore/rekor/pkg/generated/models"
    34  )
    35  
    36  // NewSearchIndexParams creates a new SearchIndexParams object
    37  //
    38  // There are no default values defined in the spec.
    39  func NewSearchIndexParams() SearchIndexParams {
    40  
    41  	return SearchIndexParams{}
    42  }
    43  
    44  // SearchIndexParams contains all the bound params for the search index operation
    45  // typically these are obtained from a http.Request
    46  //
    47  // swagger:parameters searchIndex
    48  type SearchIndexParams struct {
    49  
    50  	// HTTP Request Object
    51  	HTTPRequest *http.Request `json:"-"`
    52  
    53  	/*
    54  	  Required: true
    55  	  In: body
    56  	*/
    57  	Query *models.SearchIndex
    58  }
    59  
    60  // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
    61  // for simple values it will use straight method calls.
    62  //
    63  // To ensure default values, the struct must have been initialized with NewSearchIndexParams() beforehand.
    64  func (o *SearchIndexParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
    65  	var res []error
    66  
    67  	o.HTTPRequest = r
    68  
    69  	if runtime.HasBody(r) {
    70  		defer r.Body.Close()
    71  		var body models.SearchIndex
    72  		if err := route.Consumer.Consume(r.Body, &body); err != nil {
    73  			if err == io.EOF {
    74  				res = append(res, errors.Required("query", "body", ""))
    75  			} else {
    76  				res = append(res, errors.NewParseError("query", "body", "", err))
    77  			}
    78  		} else {
    79  			// validate body object
    80  			if err := body.Validate(route.Formats); err != nil {
    81  				res = append(res, err)
    82  			}
    83  
    84  			ctx := validate.WithOperationRequest(r.Context())
    85  			if err := body.ContextValidate(ctx, route.Formats); err != nil {
    86  				res = append(res, err)
    87  			}
    88  
    89  			if len(res) == 0 {
    90  				o.Query = &body
    91  			}
    92  		}
    93  	} else {
    94  		res = append(res, errors.Required("query", "body", ""))
    95  	}
    96  	if len(res) > 0 {
    97  		return errors.CompositeValidationError(res...)
    98  	}
    99  	return nil
   100  }
   101  

View as plain text