// Code generated by go-swagger; DO NOT EDIT.

package operations

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"net/http"
	"time"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime"
	cr "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// NewPostManifestfileParams creates a new PostManifestfileParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewPostManifestfileParams() *PostManifestfileParams {
	return &PostManifestfileParams{
		timeout: cr.DefaultTimeout,
	}
}

// NewPostManifestfileParamsWithTimeout creates a new PostManifestfileParams object
// with the ability to set a timeout on a request.
func NewPostManifestfileParamsWithTimeout(timeout time.Duration) *PostManifestfileParams {
	return &PostManifestfileParams{
		timeout: timeout,
	}
}

// NewPostManifestfileParamsWithContext creates a new PostManifestfileParams object
// with the ability to set a context for a request.
func NewPostManifestfileParamsWithContext(ctx context.Context) *PostManifestfileParams {
	return &PostManifestfileParams{
		Context: ctx,
	}
}

// NewPostManifestfileParamsWithHTTPClient creates a new PostManifestfileParams object
// with the ability to set a custom HTTPClient for a request.
func NewPostManifestfileParamsWithHTTPClient(client *http.Client) *PostManifestfileParams {
	return &PostManifestfileParams{
		HTTPClient: client,
	}
}

/*
PostManifestfileParams contains all the parameters to send to the API endpoint

	for the post manifestfile operation.

	Typically these are written to a http.Request.
*/
type PostManifestfileParams struct {

	/* Checksum.

	   ECU file checksum
	*/
	Checksum string

	/* File.

	   Update file
	*/
	File runtime.NamedReadCloser

	/* ManifestEcuID.

	   Manifest ECU id
	*/
	ManifestEcuID int64

	/* Offset.

	   ECU file offset
	*/
	Offset string

	/* Order.

	   ECU file order
	*/
	Order *string

	/* Type.

	   ECU file type
	*/
	Type *string

	/* Version.

	   ECU file version
	*/
	Version string

	timeout    time.Duration
	Context    context.Context
	HTTPClient *http.Client
}

// WithDefaults hydrates default values in the post manifestfile params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *PostManifestfileParams) WithDefaults() *PostManifestfileParams {
	o.SetDefaults()
	return o
}

// SetDefaults hydrates default values in the post manifestfile params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *PostManifestfileParams) SetDefaults() {
	// no default values defined for this parameter
}

// WithTimeout adds the timeout to the post manifestfile params
func (o *PostManifestfileParams) WithTimeout(timeout time.Duration) *PostManifestfileParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the post manifestfile params
func (o *PostManifestfileParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the post manifestfile params
func (o *PostManifestfileParams) WithContext(ctx context.Context) *PostManifestfileParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the post manifestfile params
func (o *PostManifestfileParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the post manifestfile params
func (o *PostManifestfileParams) WithHTTPClient(client *http.Client) *PostManifestfileParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the post manifestfile params
func (o *PostManifestfileParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithChecksum adds the checksum to the post manifestfile params
func (o *PostManifestfileParams) WithChecksum(checksum string) *PostManifestfileParams {
	o.SetChecksum(checksum)
	return o
}

// SetChecksum adds the checksum to the post manifestfile params
func (o *PostManifestfileParams) SetChecksum(checksum string) {
	o.Checksum = checksum
}

// WithFile adds the file to the post manifestfile params
func (o *PostManifestfileParams) WithFile(file runtime.NamedReadCloser) *PostManifestfileParams {
	o.SetFile(file)
	return o
}

// SetFile adds the file to the post manifestfile params
func (o *PostManifestfileParams) SetFile(file runtime.NamedReadCloser) {
	o.File = file
}

// WithManifestEcuID adds the manifestEcuID to the post manifestfile params
func (o *PostManifestfileParams) WithManifestEcuID(manifestEcuID int64) *PostManifestfileParams {
	o.SetManifestEcuID(manifestEcuID)
	return o
}

// SetManifestEcuID adds the manifestEcuId to the post manifestfile params
func (o *PostManifestfileParams) SetManifestEcuID(manifestEcuID int64) {
	o.ManifestEcuID = manifestEcuID
}

// WithOffset adds the offset to the post manifestfile params
func (o *PostManifestfileParams) WithOffset(offset string) *PostManifestfileParams {
	o.SetOffset(offset)
	return o
}

// SetOffset adds the offset to the post manifestfile params
func (o *PostManifestfileParams) SetOffset(offset string) {
	o.Offset = offset
}

// WithOrder adds the order to the post manifestfile params
func (o *PostManifestfileParams) WithOrder(order *string) *PostManifestfileParams {
	o.SetOrder(order)
	return o
}

// SetOrder adds the order to the post manifestfile params
func (o *PostManifestfileParams) SetOrder(order *string) {
	o.Order = order
}

// WithType adds the typeVar to the post manifestfile params
func (o *PostManifestfileParams) WithType(typeVar *string) *PostManifestfileParams {
	o.SetType(typeVar)
	return o
}

// SetType adds the type to the post manifestfile params
func (o *PostManifestfileParams) SetType(typeVar *string) {
	o.Type = typeVar
}

// WithVersion adds the version to the post manifestfile params
func (o *PostManifestfileParams) WithVersion(version string) *PostManifestfileParams {
	o.SetVersion(version)
	return o
}

// SetVersion adds the version to the post manifestfile params
func (o *PostManifestfileParams) SetVersion(version string) {
	o.Version = version
}

// WriteToRequest writes these params to a swagger request
func (o *PostManifestfileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {

	if err := r.SetTimeout(o.timeout); err != nil {
		return err
	}
	var res []error

	// form param checksum
	frChecksum := o.Checksum
	fChecksum := frChecksum
	if fChecksum != "" {
		if err := r.SetFormParam("checksum", fChecksum); err != nil {
			return err
		}
	}
	// form file param file
	if err := r.SetFileParam("file", o.File); err != nil {
		return err
	}

	// form param manifest_ecu_id
	frManifestEcuID := o.ManifestEcuID
	fManifestEcuID := swag.FormatInt64(frManifestEcuID)
	if fManifestEcuID != "" {
		if err := r.SetFormParam("manifest_ecu_id", fManifestEcuID); err != nil {
			return err
		}
	}

	// form param offset
	frOffset := o.Offset
	fOffset := frOffset
	if fOffset != "" {
		if err := r.SetFormParam("offset", fOffset); err != nil {
			return err
		}
	}

	if o.Order != nil {

		// form param order
		var frOrder string
		if o.Order != nil {
			frOrder = *o.Order
		}
		fOrder := frOrder
		if fOrder != "" {
			if err := r.SetFormParam("order", fOrder); err != nil {
				return err
			}
		}
	}

	if o.Type != nil {

		// form param type
		var frType string
		if o.Type != nil {
			frType = *o.Type
		}
		fType := frType
		if fType != "" {
			if err := r.SetFormParam("type", fType); err != nil {
				return err
			}
		}
	}

	// form param version
	frVersion := o.Version
	fVersion := frVersion
	if fVersion != "" {
		if err := r.SetFormParam("version", fVersion); err != nil {
			return err
		}
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
