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

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package store
     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  	"github.com/thetreep/go-swagger/examples/contributed-templates/stratoscale/models"
    19  )
    20  
    21  // NewOrderCreateParams creates a new OrderCreateParams object,
    22  // with the default timeout for this client.
    23  //
    24  // Default values are not hydrated, since defaults are normally applied by the API server side.
    25  //
    26  // To enforce default values in parameter, use SetDefaults or WithDefaults.
    27  func NewOrderCreateParams() *OrderCreateParams {
    28  	return &OrderCreateParams{
    29  		timeout: cr.DefaultTimeout,
    30  	}
    31  }
    32  
    33  // NewOrderCreateParamsWithTimeout creates a new OrderCreateParams object
    34  // with the ability to set a timeout on a request.
    35  func NewOrderCreateParamsWithTimeout(timeout time.Duration) *OrderCreateParams {
    36  	return &OrderCreateParams{
    37  		timeout: timeout,
    38  	}
    39  }
    40  
    41  // NewOrderCreateParamsWithContext creates a new OrderCreateParams object
    42  // with the ability to set a context for a request.
    43  func NewOrderCreateParamsWithContext(ctx context.Context) *OrderCreateParams {
    44  	return &OrderCreateParams{
    45  		Context: ctx,
    46  	}
    47  }
    48  
    49  // NewOrderCreateParamsWithHTTPClient creates a new OrderCreateParams object
    50  // with the ability to set a custom HTTPClient for a request.
    51  func NewOrderCreateParamsWithHTTPClient(client *http.Client) *OrderCreateParams {
    52  	return &OrderCreateParams{
    53  		HTTPClient: client,
    54  	}
    55  }
    56  
    57  /*
    58  OrderCreateParams contains all the parameters to send to the API endpoint
    59  
    60  	for the order create operation.
    61  
    62  	Typically these are written to a http.Request.
    63  */
    64  type OrderCreateParams struct {
    65  
    66  	/* Body.
    67  
    68  	   order placed for purchasing the pet
    69  	*/
    70  	Body *models.Order
    71  
    72  	timeout    time.Duration
    73  	Context    context.Context
    74  	HTTPClient *http.Client
    75  }
    76  
    77  // WithDefaults hydrates default values in the order create params (not the query body).
    78  //
    79  // All values with no default are reset to their zero value.
    80  func (o *OrderCreateParams) WithDefaults() *OrderCreateParams {
    81  	o.SetDefaults()
    82  	return o
    83  }
    84  
    85  // SetDefaults hydrates default values in the order create params (not the query body).
    86  //
    87  // All values with no default are reset to their zero value.
    88  func (o *OrderCreateParams) SetDefaults() {
    89  	// no default values defined for this parameter
    90  }
    91  
    92  // WithTimeout adds the timeout to the order create params
    93  func (o *OrderCreateParams) WithTimeout(timeout time.Duration) *OrderCreateParams {
    94  	o.SetTimeout(timeout)
    95  	return o
    96  }
    97  
    98  // SetTimeout adds the timeout to the order create params
    99  func (o *OrderCreateParams) SetTimeout(timeout time.Duration) {
   100  	o.timeout = timeout
   101  }
   102  
   103  // WithContext adds the context to the order create params
   104  func (o *OrderCreateParams) WithContext(ctx context.Context) *OrderCreateParams {
   105  	o.SetContext(ctx)
   106  	return o
   107  }
   108  
   109  // SetContext adds the context to the order create params
   110  func (o *OrderCreateParams) SetContext(ctx context.Context) {
   111  	o.Context = ctx
   112  }
   113  
   114  // WithHTTPClient adds the HTTPClient to the order create params
   115  func (o *OrderCreateParams) WithHTTPClient(client *http.Client) *OrderCreateParams {
   116  	o.SetHTTPClient(client)
   117  	return o
   118  }
   119  
   120  // SetHTTPClient adds the HTTPClient to the order create params
   121  func (o *OrderCreateParams) SetHTTPClient(client *http.Client) {
   122  	o.HTTPClient = client
   123  }
   124  
   125  // WithBody adds the body to the order create params
   126  func (o *OrderCreateParams) WithBody(body *models.Order) *OrderCreateParams {
   127  	o.SetBody(body)
   128  	return o
   129  }
   130  
   131  // SetBody adds the body to the order create params
   132  func (o *OrderCreateParams) SetBody(body *models.Order) {
   133  	o.Body = body
   134  }
   135  
   136  // WriteToRequest writes these params to a swagger request
   137  func (o *OrderCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   138  
   139  	if err := r.SetTimeout(o.timeout); err != nil {
   140  		return err
   141  	}
   142  	var res []error
   143  	if o.Body != nil {
   144  		if err := r.SetBodyParam(o.Body); err != nil {
   145  			return err
   146  		}
   147  	}
   148  
   149  	if len(res) > 0 {
   150  		return errors.CompositeValidationError(res...)
   151  	}
   152  	return nil
   153  }