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

package device_service

// 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"
)

// NewDeviceServiceGetMetricsParams creates a new DeviceServiceGetMetricsParams 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 NewDeviceServiceGetMetricsParams() *DeviceServiceGetMetricsParams {
	return &DeviceServiceGetMetricsParams{
		timeout: cr.DefaultTimeout,
	}
}

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

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

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

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

	for the device service get metrics operation.

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

	/* Aggregation.

	    Aggregation.

	- HOUR: Hour.
	- DAY: Day.
	- MONTH: Month.
	- MINUTE: Minute.

	    Default: "HOUR"
	*/
	Aggregation *string

	/* DevEui.

	   DevEUI (EUI64).
	*/
	DevEui string

	/* End.

	   Interval end timestamp.

	   Format: date-time
	*/
	End *strfmt.DateTime

	/* Start.

	   Interval start timestamp.

	   Format: date-time
	*/
	Start *strfmt.DateTime

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

// WithDefaults hydrates default values in the device service get metrics params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeviceServiceGetMetricsParams) WithDefaults() *DeviceServiceGetMetricsParams {
	o.SetDefaults()
	return o
}

// SetDefaults hydrates default values in the device service get metrics params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DeviceServiceGetMetricsParams) SetDefaults() {
	var (
		aggregationDefault = string("HOUR")
	)

	val := DeviceServiceGetMetricsParams{
		Aggregation: &aggregationDefault,
	}

	val.timeout = o.timeout
	val.Context = o.Context
	val.HTTPClient = o.HTTPClient
	*o = val
}

// WithTimeout adds the timeout to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) WithTimeout(timeout time.Duration) *DeviceServiceGetMetricsParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) WithContext(ctx context.Context) *DeviceServiceGetMetricsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) WithHTTPClient(client *http.Client) *DeviceServiceGetMetricsParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithAggregation adds the aggregation to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) WithAggregation(aggregation *string) *DeviceServiceGetMetricsParams {
	o.SetAggregation(aggregation)
	return o
}

// SetAggregation adds the aggregation to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) SetAggregation(aggregation *string) {
	o.Aggregation = aggregation
}

// WithDevEui adds the devEui to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) WithDevEui(devEui string) *DeviceServiceGetMetricsParams {
	o.SetDevEui(devEui)
	return o
}

// SetDevEui adds the devEui to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) SetDevEui(devEui string) {
	o.DevEui = devEui
}

// WithEnd adds the end to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) WithEnd(end *strfmt.DateTime) *DeviceServiceGetMetricsParams {
	o.SetEnd(end)
	return o
}

// SetEnd adds the end to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) SetEnd(end *strfmt.DateTime) {
	o.End = end
}

// WithStart adds the start to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) WithStart(start *strfmt.DateTime) *DeviceServiceGetMetricsParams {
	o.SetStart(start)
	return o
}

// SetStart adds the start to the device service get metrics params
func (o *DeviceServiceGetMetricsParams) SetStart(start *strfmt.DateTime) {
	o.Start = start
}

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

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

	if o.Aggregation != nil {

		// query param aggregation
		var qrAggregation string

		if o.Aggregation != nil {
			qrAggregation = *o.Aggregation
		}
		qAggregation := qrAggregation
		if qAggregation != "" {

			if err := r.SetQueryParam("aggregation", qAggregation); err != nil {
				return err
			}
		}
	}

	// path param devEui
	if err := r.SetPathParam("devEui", o.DevEui); err != nil {
		return err
	}

	if o.End != nil {

		// query param end
		var qrEnd strfmt.DateTime

		if o.End != nil {
			qrEnd = *o.End
		}
		qEnd := qrEnd.String()
		if qEnd != "" {

			if err := r.SetQueryParam("end", qEnd); err != nil {
				return err
			}
		}
	}

	if o.Start != nil {

		// query param start
		var qrStart strfmt.DateTime

		if o.Start != nil {
			qrStart = *o.Start
		}
		qStart := qrStart.String()
		if qStart != "" {

			if err := r.SetQueryParam("start", qStart); err != nil {
				return err
			}
		}
	}

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