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

package events

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

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

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

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

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

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

	for the v2 list events operation.

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

	/* Categories.

	   A comma-separated list of event categories.
	*/
	Categories []string

	/* ClusterID.

	   The cluster to return events for.

	   Format: uuid
	*/
	ClusterID *strfmt.UUID

	/* ClusterLevel.

	   Cluster level events flag.
	*/
	ClusterLevel *bool

	/* DeletedHosts.

	   Deleted hosts flag.
	*/
	DeletedHosts *bool

	/* HostID.

	   A host in the specified cluster to return events for (DEPRECATED. Use `host_ids` instead).

	   Format: uuid
	*/
	HostID *strfmt.UUID

	/* HostIds.

	   Hosts in the specified cluster to return events for.
	*/
	HostIds []strfmt.UUID

	/* InfraEnvID.

	   The infra-env to return events for.

	   Format: uuid
	*/
	InfraEnvID *strfmt.UUID

	/* Limit.

	   The maximum number of records to retrieve.
	*/
	Limit *int64

	/* Message.

	   Retrieved events message pattern.
	*/
	Message *string

	/* Offset.

	   Number of records to skip before starting to return the records.
	*/
	Offset *int64

	/* Order.

	   Order by event_time of events retrieved.

	   Default: "ascending"
	*/
	Order *string

	/* Severities.

	   Retrieved events severities.
	*/
	Severities []string

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

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

// SetDefaults hydrates default values in the v2 list events params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *V2ListEventsParams) SetDefaults() {
	var (
		orderDefault = string("ascending")
	)

	val := V2ListEventsParams{
		Order: &orderDefault,
	}

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

// WithTimeout adds the timeout to the v2 list events params
func (o *V2ListEventsParams) WithTimeout(timeout time.Duration) *V2ListEventsParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the v2 list events params
func (o *V2ListEventsParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the v2 list events params
func (o *V2ListEventsParams) WithContext(ctx context.Context) *V2ListEventsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the v2 list events params
func (o *V2ListEventsParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the v2 list events params
func (o *V2ListEventsParams) WithHTTPClient(client *http.Client) *V2ListEventsParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the v2 list events params
func (o *V2ListEventsParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithCategories adds the categories to the v2 list events params
func (o *V2ListEventsParams) WithCategories(categories []string) *V2ListEventsParams {
	o.SetCategories(categories)
	return o
}

// SetCategories adds the categories to the v2 list events params
func (o *V2ListEventsParams) SetCategories(categories []string) {
	o.Categories = categories
}

// WithClusterID adds the clusterID to the v2 list events params
func (o *V2ListEventsParams) WithClusterID(clusterID *strfmt.UUID) *V2ListEventsParams {
	o.SetClusterID(clusterID)
	return o
}

// SetClusterID adds the clusterId to the v2 list events params
func (o *V2ListEventsParams) SetClusterID(clusterID *strfmt.UUID) {
	o.ClusterID = clusterID
}

// WithClusterLevel adds the clusterLevel to the v2 list events params
func (o *V2ListEventsParams) WithClusterLevel(clusterLevel *bool) *V2ListEventsParams {
	o.SetClusterLevel(clusterLevel)
	return o
}

// SetClusterLevel adds the clusterLevel to the v2 list events params
func (o *V2ListEventsParams) SetClusterLevel(clusterLevel *bool) {
	o.ClusterLevel = clusterLevel
}

// WithDeletedHosts adds the deletedHosts to the v2 list events params
func (o *V2ListEventsParams) WithDeletedHosts(deletedHosts *bool) *V2ListEventsParams {
	o.SetDeletedHosts(deletedHosts)
	return o
}

// SetDeletedHosts adds the deletedHosts to the v2 list events params
func (o *V2ListEventsParams) SetDeletedHosts(deletedHosts *bool) {
	o.DeletedHosts = deletedHosts
}

// WithHostID adds the hostID to the v2 list events params
func (o *V2ListEventsParams) WithHostID(hostID *strfmt.UUID) *V2ListEventsParams {
	o.SetHostID(hostID)
	return o
}

// SetHostID adds the hostId to the v2 list events params
func (o *V2ListEventsParams) SetHostID(hostID *strfmt.UUID) {
	o.HostID = hostID
}

// WithHostIds adds the hostIds to the v2 list events params
func (o *V2ListEventsParams) WithHostIds(hostIds []strfmt.UUID) *V2ListEventsParams {
	o.SetHostIds(hostIds)
	return o
}

// SetHostIds adds the hostIds to the v2 list events params
func (o *V2ListEventsParams) SetHostIds(hostIds []strfmt.UUID) {
	o.HostIds = hostIds
}

// WithInfraEnvID adds the infraEnvID to the v2 list events params
func (o *V2ListEventsParams) WithInfraEnvID(infraEnvID *strfmt.UUID) *V2ListEventsParams {
	o.SetInfraEnvID(infraEnvID)
	return o
}

// SetInfraEnvID adds the infraEnvId to the v2 list events params
func (o *V2ListEventsParams) SetInfraEnvID(infraEnvID *strfmt.UUID) {
	o.InfraEnvID = infraEnvID
}

// WithLimit adds the limit to the v2 list events params
func (o *V2ListEventsParams) WithLimit(limit *int64) *V2ListEventsParams {
	o.SetLimit(limit)
	return o
}

// SetLimit adds the limit to the v2 list events params
func (o *V2ListEventsParams) SetLimit(limit *int64) {
	o.Limit = limit
}

// WithMessage adds the message to the v2 list events params
func (o *V2ListEventsParams) WithMessage(message *string) *V2ListEventsParams {
	o.SetMessage(message)
	return o
}

// SetMessage adds the message to the v2 list events params
func (o *V2ListEventsParams) SetMessage(message *string) {
	o.Message = message
}

// WithOffset adds the offset to the v2 list events params
func (o *V2ListEventsParams) WithOffset(offset *int64) *V2ListEventsParams {
	o.SetOffset(offset)
	return o
}

// SetOffset adds the offset to the v2 list events params
func (o *V2ListEventsParams) SetOffset(offset *int64) {
	o.Offset = offset
}

// WithOrder adds the order to the v2 list events params
func (o *V2ListEventsParams) WithOrder(order *string) *V2ListEventsParams {
	o.SetOrder(order)
	return o
}

// SetOrder adds the order to the v2 list events params
func (o *V2ListEventsParams) SetOrder(order *string) {
	o.Order = order
}

// WithSeverities adds the severities to the v2 list events params
func (o *V2ListEventsParams) WithSeverities(severities []string) *V2ListEventsParams {
	o.SetSeverities(severities)
	return o
}

// SetSeverities adds the severities to the v2 list events params
func (o *V2ListEventsParams) SetSeverities(severities []string) {
	o.Severities = severities
}

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

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

	if o.Categories != nil {

		// binding items for categories
		joinedCategories := o.bindParamCategories(reg)

		// query array param categories
		if err := r.SetQueryParam("categories", joinedCategories...); err != nil {
			return err
		}
	}

	if o.ClusterID != nil {

		// query param cluster_id
		var qrClusterID strfmt.UUID

		if o.ClusterID != nil {
			qrClusterID = *o.ClusterID
		}
		qClusterID := qrClusterID.String()
		if qClusterID != "" {

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

	if o.ClusterLevel != nil {

		// query param cluster_level
		var qrClusterLevel bool

		if o.ClusterLevel != nil {
			qrClusterLevel = *o.ClusterLevel
		}
		qClusterLevel := swag.FormatBool(qrClusterLevel)
		if qClusterLevel != "" {

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

	if o.DeletedHosts != nil {

		// query param deleted_hosts
		var qrDeletedHosts bool

		if o.DeletedHosts != nil {
			qrDeletedHosts = *o.DeletedHosts
		}
		qDeletedHosts := swag.FormatBool(qrDeletedHosts)
		if qDeletedHosts != "" {

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

	if o.HostID != nil {

		// query param host_id
		var qrHostID strfmt.UUID

		if o.HostID != nil {
			qrHostID = *o.HostID
		}
		qHostID := qrHostID.String()
		if qHostID != "" {

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

	if o.HostIds != nil {

		// binding items for host_ids
		joinedHostIds := o.bindParamHostIds(reg)

		// query array param host_ids
		if err := r.SetQueryParam("host_ids", joinedHostIds...); err != nil {
			return err
		}
	}

	if o.InfraEnvID != nil {

		// query param infra_env_id
		var qrInfraEnvID strfmt.UUID

		if o.InfraEnvID != nil {
			qrInfraEnvID = *o.InfraEnvID
		}
		qInfraEnvID := qrInfraEnvID.String()
		if qInfraEnvID != "" {

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

	if o.Limit != nil {

		// query param limit
		var qrLimit int64

		if o.Limit != nil {
			qrLimit = *o.Limit
		}
		qLimit := swag.FormatInt64(qrLimit)
		if qLimit != "" {

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

	if o.Message != nil {

		// query param message
		var qrMessage string

		if o.Message != nil {
			qrMessage = *o.Message
		}
		qMessage := qrMessage
		if qMessage != "" {

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

	if o.Offset != nil {

		// query param offset
		var qrOffset int64

		if o.Offset != nil {
			qrOffset = *o.Offset
		}
		qOffset := swag.FormatInt64(qrOffset)
		if qOffset != "" {

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

	if o.Order != nil {

		// query param order
		var qrOrder string

		if o.Order != nil {
			qrOrder = *o.Order
		}
		qOrder := qrOrder
		if qOrder != "" {

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

	if o.Severities != nil {

		// binding items for severities
		joinedSeverities := o.bindParamSeverities(reg)

		// query array param severities
		if err := r.SetQueryParam("severities", joinedSeverities...); err != nil {
			return err
		}
	}

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

// bindParamV2ListEvents binds the parameter categories
func (o *V2ListEventsParams) bindParamCategories(formats strfmt.Registry) []string {
	categoriesIR := o.Categories

	var categoriesIC []string
	for _, categoriesIIR := range categoriesIR { // explode []string

		categoriesIIV := categoriesIIR // string as string
		categoriesIC = append(categoriesIC, categoriesIIV)
	}

	// items.CollectionFormat: ""
	categoriesIS := swag.JoinByFormat(categoriesIC, "")

	return categoriesIS
}

// bindParamV2ListEvents binds the parameter host_ids
func (o *V2ListEventsParams) bindParamHostIds(formats strfmt.Registry) []string {
	hostIdsIR := o.HostIds

	var hostIdsIC []string
	for _, hostIdsIIR := range hostIdsIR { // explode []strfmt.UUID

		hostIdsIIV := hostIdsIIR.String() // strfmt.UUID as string
		hostIdsIC = append(hostIdsIC, hostIdsIIV)
	}

	// items.CollectionFormat: ""
	hostIdsIS := swag.JoinByFormat(hostIdsIC, "")

	return hostIdsIS
}

// bindParamV2ListEvents binds the parameter severities
func (o *V2ListEventsParams) bindParamSeverities(formats strfmt.Registry) []string {
	severitiesIR := o.Severities

	var severitiesIC []string
	for _, severitiesIIR := range severitiesIR { // explode []string

		severitiesIIV := severitiesIIR // string as string
		severitiesIC = append(severitiesIC, severitiesIIV)
	}

	// items.CollectionFormat: ""
	severitiesIS := swag.JoinByFormat(severitiesIC, "")

	return severitiesIS
}
