github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/contributed-templates/stratoscale/client/pet/pet_list_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package pet
     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  	"github.com/go-openapi/swag"
    18  )
    19  
    20  // NewPetListParams creates a new PetListParams object,
    21  // with the default timeout for this client.
    22  //
    23  // Default values are not hydrated, since defaults are normally applied by the API server side.
    24  //
    25  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    26  func NewPetListParams() *PetListParams {
    27  	return &PetListParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewPetListParamsWithTimeout creates a new PetListParams object
    33  // with the ability to set a timeout on a request.
    34  func NewPetListParamsWithTimeout(timeout time.Duration) *PetListParams {
    35  	return &PetListParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewPetListParamsWithContext creates a new PetListParams object
    41  // with the ability to set a context for a request.
    42  func NewPetListParamsWithContext(ctx context.Context) *PetListParams {
    43  	return &PetListParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewPetListParamsWithHTTPClient creates a new PetListParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewPetListParamsWithHTTPClient(client *http.Client) *PetListParams {
    51  	return &PetListParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /*
    57  PetListParams contains all the parameters to send to the API endpoint
    58  
    59  	for the pet list operation.
    60  
    61  	Typically these are written to a http.Request.
    62  */
    63  type PetListParams struct {
    64  
    65  	/* Status.
    66  
    67  	   Status values that need to be considered for filter
    68  	*/
    69  	Status []string
    70  
    71  	timeout    time.Duration
    72  	Context    context.Context
    73  	HTTPClient *http.Client
    74  }
    75  
    76  // WithDefaults hydrates default values in the pet list params (not the query body).
    77  //
    78  // All values with no default are reset to their zero value.
    79  func (o *PetListParams) WithDefaults() *PetListParams {
    80  	o.SetDefaults()
    81  	return o
    82  }
    83  
    84  // SetDefaults hydrates default values in the pet list params (not the query body).
    85  //
    86  // All values with no default are reset to their zero value.
    87  func (o *PetListParams) SetDefaults() {
    88  	// no default values defined for this parameter
    89  }
    90  
    91  // WithTimeout adds the timeout to the pet list params
    92  func (o *PetListParams) WithTimeout(timeout time.Duration) *PetListParams {
    93  	o.SetTimeout(timeout)
    94  	return o
    95  }
    96  
    97  // SetTimeout adds the timeout to the pet list params
    98  func (o *PetListParams) SetTimeout(timeout time.Duration) {
    99  	o.timeout = timeout
   100  }
   101  
   102  // WithContext adds the context to the pet list params
   103  func (o *PetListParams) WithContext(ctx context.Context) *PetListParams {
   104  	o.SetContext(ctx)
   105  	return o
   106  }
   107  
   108  // SetContext adds the context to the pet list params
   109  func (o *PetListParams) SetContext(ctx context.Context) {
   110  	o.Context = ctx
   111  }
   112  
   113  // WithHTTPClient adds the HTTPClient to the pet list params
   114  func (o *PetListParams) WithHTTPClient(client *http.Client) *PetListParams {
   115  	o.SetHTTPClient(client)
   116  	return o
   117  }
   118  
   119  // SetHTTPClient adds the HTTPClient to the pet list params
   120  func (o *PetListParams) SetHTTPClient(client *http.Client) {
   121  	o.HTTPClient = client
   122  }
   123  
   124  // WithStatus adds the status to the pet list params
   125  func (o *PetListParams) WithStatus(status []string) *PetListParams {
   126  	o.SetStatus(status)
   127  	return o
   128  }
   129  
   130  // SetStatus adds the status to the pet list params
   131  func (o *PetListParams) SetStatus(status []string) {
   132  	o.Status = status
   133  }
   134  
   135  // WriteToRequest writes these params to a swagger request
   136  func (o *PetListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   137  
   138  	if err := r.SetTimeout(o.timeout); err != nil {
   139  		return err
   140  	}
   141  	var res []error
   142  
   143  	if o.Status != nil {
   144  
   145  		// binding items for status
   146  		joinedStatus := o.bindParamStatus(reg)
   147  
   148  		// query array param status
   149  		if err := r.SetQueryParam("status", joinedStatus...); err != nil {
   150  			return err
   151  		}
   152  	}
   153  
   154  	if len(res) > 0 {
   155  		return errors.CompositeValidationError(res...)
   156  	}
   157  	return nil
   158  }
   159  
   160  // bindParamPetList binds the parameter status
   161  func (o *PetListParams) bindParamStatus(formats strfmt.Registry) []string {
   162  	statusIR := o.Status
   163  
   164  	var statusIC []string
   165  	for _, statusIIR := range statusIR { // explode []string
   166  
   167  		statusIIV := statusIIR // string as string
   168  		statusIC = append(statusIC, statusIIV)
   169  	}
   170  
   171  	// items.CollectionFormat: "multi"
   172  	statusIS := swag.JoinByFormat(statusIC, "multi")
   173  
   174  	return statusIS
   175  }