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

package components

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

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

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

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

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

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

	for the get components operation.

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

	/* ContinuationToken.

	   A token returned by a prior request. If present, the next page of results are returned
	*/
	ContinuationToken *string

	/* Repository.

	   Repository from which you would like to retrieve components
	*/
	Repository string

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

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

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

// WithTimeout adds the timeout to the get components params
func (o *GetComponentsParams) WithTimeout(timeout time.Duration) *GetComponentsParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the get components params
func (o *GetComponentsParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the get components params
func (o *GetComponentsParams) WithContext(ctx context.Context) *GetComponentsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the get components params
func (o *GetComponentsParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the get components params
func (o *GetComponentsParams) WithHTTPClient(client *http.Client) *GetComponentsParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the get components params
func (o *GetComponentsParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithContinuationToken adds the continuationToken to the get components params
func (o *GetComponentsParams) WithContinuationToken(continuationToken *string) *GetComponentsParams {
	o.SetContinuationToken(continuationToken)
	return o
}

// SetContinuationToken adds the continuationToken to the get components params
func (o *GetComponentsParams) SetContinuationToken(continuationToken *string) {
	o.ContinuationToken = continuationToken
}

// WithRepository adds the repository to the get components params
func (o *GetComponentsParams) WithRepository(repository string) *GetComponentsParams {
	o.SetRepository(repository)
	return o
}

// SetRepository adds the repository to the get components params
func (o *GetComponentsParams) SetRepository(repository string) {
	o.Repository = repository
}

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

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

	if o.ContinuationToken != nil {

		// query param continuationToken
		var qrContinuationToken string

		if o.ContinuationToken != nil {
			qrContinuationToken = *o.ContinuationToken
		}
		qContinuationToken := qrContinuationToken
		if qContinuationToken != "" {

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

	// query param repository
	qrRepository := o.Repository
	qRepository := qrRepository
	if qRepository != "" {

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

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