github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/stream-client/client/operations/chunked_parameters.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package operations
     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  // NewChunkedParams creates a new ChunkedParams 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 NewChunkedParams() *ChunkedParams {
    26  	return &ChunkedParams{
    27  		timeout: cr.DefaultTimeout,
    28  	}
    29  }
    30  
    31  // NewChunkedParamsWithTimeout creates a new ChunkedParams object
    32  // with the ability to set a timeout on a request.
    33  func NewChunkedParamsWithTimeout(timeout time.Duration) *ChunkedParams {
    34  	return &ChunkedParams{
    35  		timeout: timeout,
    36  	}
    37  }
    38  
    39  // NewChunkedParamsWithContext creates a new ChunkedParams object
    40  // with the ability to set a context for a request.
    41  func NewChunkedParamsWithContext(ctx context.Context) *ChunkedParams {
    42  	return &ChunkedParams{
    43  		Context: ctx,
    44  	}
    45  }
    46  
    47  // NewChunkedParamsWithHTTPClient creates a new ChunkedParams object
    48  // with the ability to set a custom HTTPClient for a request.
    49  func NewChunkedParamsWithHTTPClient(client *http.Client) *ChunkedParams {
    50  	return &ChunkedParams{
    51  		HTTPClient: client,
    52  	}
    53  }
    54  
    55  /*
    56  ChunkedParams contains all the parameters to send to the API endpoint
    57  
    58  	for the chunked operation.
    59  
    60  	Typically these are written to a http.Request.
    61  */
    62  type ChunkedParams struct {
    63  	timeout    time.Duration
    64  	Context    context.Context
    65  	HTTPClient *http.Client
    66  }
    67  
    68  // WithDefaults hydrates default values in the chunked params (not the query body).
    69  //
    70  // All values with no default are reset to their zero value.
    71  func (o *ChunkedParams) WithDefaults() *ChunkedParams {
    72  	o.SetDefaults()
    73  	return o
    74  }
    75  
    76  // SetDefaults hydrates default values in the chunked params (not the query body).
    77  //
    78  // All values with no default are reset to their zero value.
    79  func (o *ChunkedParams) SetDefaults() {
    80  	// no default values defined for this parameter
    81  }
    82  
    83  // WithTimeout adds the timeout to the chunked params
    84  func (o *ChunkedParams) WithTimeout(timeout time.Duration) *ChunkedParams {
    85  	o.SetTimeout(timeout)
    86  	return o
    87  }
    88  
    89  // SetTimeout adds the timeout to the chunked params
    90  func (o *ChunkedParams) SetTimeout(timeout time.Duration) {
    91  	o.timeout = timeout
    92  }
    93  
    94  // WithContext adds the context to the chunked params
    95  func (o *ChunkedParams) WithContext(ctx context.Context) *ChunkedParams {
    96  	o.SetContext(ctx)
    97  	return o
    98  }
    99  
   100  // SetContext adds the context to the chunked params
   101  func (o *ChunkedParams) SetContext(ctx context.Context) {
   102  	o.Context = ctx
   103  }
   104  
   105  // WithHTTPClient adds the HTTPClient to the chunked params
   106  func (o *ChunkedParams) WithHTTPClient(client *http.Client) *ChunkedParams {
   107  	o.SetHTTPClient(client)
   108  	return o
   109  }
   110  
   111  // SetHTTPClient adds the HTTPClient to the chunked params
   112  func (o *ChunkedParams) SetHTTPClient(client *http.Client) {
   113  	o.HTTPClient = client
   114  }
   115  
   116  // WriteToRequest writes these params to a swagger request
   117  func (o *ChunkedParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   118  
   119  	if err := r.SetTimeout(o.timeout); err != nil {
   120  		return err
   121  	}
   122  	var res []error
   123  
   124  	if len(res) > 0 {
   125  		return errors.CompositeValidationError(res...)
   126  	}
   127  	return nil
   128  }