github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/contributed-templates/stratoscale/client/pet/pet_upload_image_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  // NewPetUploadImageParams creates a new PetUploadImageParams 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 NewPetUploadImageParams() *PetUploadImageParams {
    27  	return &PetUploadImageParams{
    28  		timeout: cr.DefaultTimeout,
    29  	}
    30  }
    31  
    32  // NewPetUploadImageParamsWithTimeout creates a new PetUploadImageParams object
    33  // with the ability to set a timeout on a request.
    34  func NewPetUploadImageParamsWithTimeout(timeout time.Duration) *PetUploadImageParams {
    35  	return &PetUploadImageParams{
    36  		timeout: timeout,
    37  	}
    38  }
    39  
    40  // NewPetUploadImageParamsWithContext creates a new PetUploadImageParams object
    41  // with the ability to set a context for a request.
    42  func NewPetUploadImageParamsWithContext(ctx context.Context) *PetUploadImageParams {
    43  	return &PetUploadImageParams{
    44  		Context: ctx,
    45  	}
    46  }
    47  
    48  // NewPetUploadImageParamsWithHTTPClient creates a new PetUploadImageParams object
    49  // with the ability to set a custom HTTPClient for a request.
    50  func NewPetUploadImageParamsWithHTTPClient(client *http.Client) *PetUploadImageParams {
    51  	return &PetUploadImageParams{
    52  		HTTPClient: client,
    53  	}
    54  }
    55  
    56  /*
    57  PetUploadImageParams contains all the parameters to send to the API endpoint
    58  
    59  	for the pet upload image operation.
    60  
    61  	Typically these are written to a http.Request.
    62  */
    63  type PetUploadImageParams struct {
    64  
    65  	/* AdditionalMetadata.
    66  
    67  	   Additional data to pass to server
    68  	*/
    69  	AdditionalMetadata *string
    70  
    71  	/* File.
    72  
    73  	   file to upload
    74  	*/
    75  	File runtime.NamedReadCloser
    76  
    77  	/* PetID.
    78  
    79  	   ID of pet to update
    80  
    81  	   Format: int64
    82  	*/
    83  	PetID int64
    84  
    85  	timeout    time.Duration
    86  	Context    context.Context
    87  	HTTPClient *http.Client
    88  }
    89  
    90  // WithDefaults hydrates default values in the pet upload image params (not the query body).
    91  //
    92  // All values with no default are reset to their zero value.
    93  func (o *PetUploadImageParams) WithDefaults() *PetUploadImageParams {
    94  	o.SetDefaults()
    95  	return o
    96  }
    97  
    98  // SetDefaults hydrates default values in the pet upload image params (not the query body).
    99  //
   100  // All values with no default are reset to their zero value.
   101  func (o *PetUploadImageParams) SetDefaults() {
   102  	// no default values defined for this parameter
   103  }
   104  
   105  // WithTimeout adds the timeout to the pet upload image params
   106  func (o *PetUploadImageParams) WithTimeout(timeout time.Duration) *PetUploadImageParams {
   107  	o.SetTimeout(timeout)
   108  	return o
   109  }
   110  
   111  // SetTimeout adds the timeout to the pet upload image params
   112  func (o *PetUploadImageParams) SetTimeout(timeout time.Duration) {
   113  	o.timeout = timeout
   114  }
   115  
   116  // WithContext adds the context to the pet upload image params
   117  func (o *PetUploadImageParams) WithContext(ctx context.Context) *PetUploadImageParams {
   118  	o.SetContext(ctx)
   119  	return o
   120  }
   121  
   122  // SetContext adds the context to the pet upload image params
   123  func (o *PetUploadImageParams) SetContext(ctx context.Context) {
   124  	o.Context = ctx
   125  }
   126  
   127  // WithHTTPClient adds the HTTPClient to the pet upload image params
   128  func (o *PetUploadImageParams) WithHTTPClient(client *http.Client) *PetUploadImageParams {
   129  	o.SetHTTPClient(client)
   130  	return o
   131  }
   132  
   133  // SetHTTPClient adds the HTTPClient to the pet upload image params
   134  func (o *PetUploadImageParams) SetHTTPClient(client *http.Client) {
   135  	o.HTTPClient = client
   136  }
   137  
   138  // WithAdditionalMetadata adds the additionalMetadata to the pet upload image params
   139  func (o *PetUploadImageParams) WithAdditionalMetadata(additionalMetadata *string) *PetUploadImageParams {
   140  	o.SetAdditionalMetadata(additionalMetadata)
   141  	return o
   142  }
   143  
   144  // SetAdditionalMetadata adds the additionalMetadata to the pet upload image params
   145  func (o *PetUploadImageParams) SetAdditionalMetadata(additionalMetadata *string) {
   146  	o.AdditionalMetadata = additionalMetadata
   147  }
   148  
   149  // WithFile adds the file to the pet upload image params
   150  func (o *PetUploadImageParams) WithFile(file runtime.NamedReadCloser) *PetUploadImageParams {
   151  	o.SetFile(file)
   152  	return o
   153  }
   154  
   155  // SetFile adds the file to the pet upload image params
   156  func (o *PetUploadImageParams) SetFile(file runtime.NamedReadCloser) {
   157  	o.File = file
   158  }
   159  
   160  // WithPetID adds the petID to the pet upload image params
   161  func (o *PetUploadImageParams) WithPetID(petID int64) *PetUploadImageParams {
   162  	o.SetPetID(petID)
   163  	return o
   164  }
   165  
   166  // SetPetID adds the petId to the pet upload image params
   167  func (o *PetUploadImageParams) SetPetID(petID int64) {
   168  	o.PetID = petID
   169  }
   170  
   171  // WriteToRequest writes these params to a swagger request
   172  func (o *PetUploadImageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
   173  
   174  	if err := r.SetTimeout(o.timeout); err != nil {
   175  		return err
   176  	}
   177  	var res []error
   178  
   179  	if o.AdditionalMetadata != nil {
   180  
   181  		// form param additionalMetadata
   182  		var frAdditionalMetadata string
   183  		if o.AdditionalMetadata != nil {
   184  			frAdditionalMetadata = *o.AdditionalMetadata
   185  		}
   186  		fAdditionalMetadata := frAdditionalMetadata
   187  		if fAdditionalMetadata != "" {
   188  			if err := r.SetFormParam("additionalMetadata", fAdditionalMetadata); err != nil {
   189  				return err
   190  			}
   191  		}
   192  	}
   193  
   194  	if o.File != nil {
   195  
   196  		if o.File != nil {
   197  			// form file param file
   198  			if err := r.SetFileParam("file", o.File); err != nil {
   199  				return err
   200  			}
   201  		}
   202  	}
   203  
   204  	// path param petId
   205  	if err := r.SetPathParam("petId", swag.FormatInt64(o.PetID)); err != nil {
   206  		return err
   207  	}
   208  
   209  	if len(res) > 0 {
   210  		return errors.CompositeValidationError(res...)
   211  	}
   212  	return nil
   213  }