github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/search/search_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package search
     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  	"context"
    10  	"net/http"
    11  	"time"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/runtime"
    15  	cr "github.com/go-openapi/runtime/client"
    16  	"github.com/go-openapi/strfmt"
    17  )
    18  
    19  // NewSearchParams creates a new SearchParams object,
    20  // with the default timeout for this client.
    21  //
    22  // Default values are not hydrated, since defaults are normally applied by the API server side.
    23  //
    24  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    25  func NewSearchParams() *SearchParams {
    26  	return &SearchParams{
    27  		timeout: cr.DefaultTimeout,
    28  	}
    29  }
    30  
    31  // NewSearchParamsWithTimeout creates a new SearchParams object
    32  // with the ability to set a timeout on a request.
    33  func NewSearchParamsWithTimeout(timeout time.Duration) *SearchParams {
    34  	return &SearchParams{
    35  		timeout: timeout,
    36  	}
    37  }
    38  
    39  // NewSearchParamsWithContext creates a new SearchParams object
    40  // with the ability to set a context for a request.
    41  func NewSearchParamsWithContext(ctx context.Context) *SearchParams {
    42  	return &SearchParams{
    43  		Context: ctx,
    44  	}
    45  }
    46  
    47  // NewSearchParamsWithHTTPClient creates a new SearchParams object
    48  // with the ability to set a custom HTTPClient for a request.
    49  func NewSearchParamsWithHTTPClient(client *http.Client) *SearchParams {
    50  	return &SearchParams{
    51  		HTTPClient: client,
    52  	}
    53  }
    54  
    55  /*
    56  SearchParams contains all the parameters to send to the API endpoint
    57  
    58  	for the search operation.
    59  
    60  	Typically these are written to a http.Request.
    61  */
    62  type SearchParams struct {
    63  
    64  	/* XRequestID.
    65  
    66  	   An unique ID for the request
    67  	*/
    68  	XRequestID *string
    69  
    70  	/* Q.
    71  
    72  	   Search parameter for project and repository name.
    73  	*/
    74  	Q string
    75  
    76  	timeout    time.Duration
    77  	Context    context.Context
    78  	HTTPClient *http.Client
    79  }
    80  
    81  // WithDefaults hydrates default values in the search params (not the query body).
    82  //
    83  // All values with no default are reset to their zero value.
    84  func (o *SearchParams) WithDefaults() *SearchParams {
    85  	o.SetDefaults()
    86  	return o
    87  }
    88  
    89  // SetDefaults hydrates default values in the search params (not the query body).
    90  //
    91  // All values with no default are reset to their zero value.
    92  func (o *SearchParams) SetDefaults() {
    93  	// no default values defined for this parameter
    94  }
    95  
    96  // WithTimeout adds the timeout to the search params
    97  func (o *SearchParams) WithTimeout(timeout time.Duration) *SearchParams {
    98  	o.SetTimeout(timeout)
    99  	return o
   100  }
   101  
   102  // SetTimeout adds the timeout to the search params
   103  func (o *SearchParams) SetTimeout(timeout time.Duration) {
   104  	o.timeout = timeout
   105  }
   106  
   107  // WithContext adds the context to the search params
   108  func (o *SearchParams) WithContext(ctx context.Context) *SearchParams {
   109  	o.SetContext(ctx)
   110  	return o
   111  }
   112  
   113  // SetContext adds the context to the search params
   114  func (o *SearchParams) SetContext(ctx context.Context) {
   115  	o.Context = ctx
   116  }
   117  
   118  // WithHTTPClient adds the HTTPClient to the search params
   119  func (o *SearchParams) WithHTTPClient(client *http.Client) *SearchParams {
   120  	o.SetHTTPClient(client)
   121  	return o
   122  }
   123  
   124  // SetHTTPClient adds the HTTPClient to the search params
   125  func (o *SearchParams) SetHTTPClient(client *http.Client) {
   126  	o.HTTPClient = client
   127  }
   128  
   129  // WithXRequestID adds the xRequestID to the search params
   130  func (o *SearchParams) WithXRequestID(xRequestID *string) *SearchParams {
   131  	o.SetXRequestID(xRequestID)
   132  	return o
   133  }
   134  
   135  // SetXRequestID adds the xRequestId to the search params
   136  func (o *SearchParams) SetXRequestID(xRequestID *string) {
   137  	o.XRequestID = xRequestID
   138  }
   139  
   140  // WithQ adds the q to the search params
   141  func (o *SearchParams) WithQ(q string) *SearchParams {
   142  	o.SetQ(q)
   143  	return o
   144  }
   145  
   146  // SetQ adds the q to the search params
   147  func (o *SearchParams) SetQ(q string) {
   148  	o.Q = q
   149  }
   150  
   151  // WriteToRequest writes these params to a swagger request
   152  func (o *SearchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   153  
   154  	if err := r.SetTimeout(o.timeout); err != nil {
   155  		return err
   156  	}
   157  	var res []error
   158  
   159  	if o.XRequestID != nil {
   160  
   161  		// header param X-Request-Id
   162  		if err := r.SetHeaderParam("X-Request-Id", *o.XRequestID); err != nil {
   163  			return err
   164  		}
   165  	}
   166  
   167  	// query param q
   168  	qrQ := o.Q
   169  	qQ := qrQ
   170  	if qQ != "" {
   171  
   172  		if err := r.SetQueryParam("q", qQ); err != nil {
   173  			return err
   174  		}
   175  	}
   176  
   177  	if len(res) > 0 {
   178  		return errors.CompositeValidationError(res...)
   179  	}
   180  	return nil
   181  }