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

package iam_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"
	"github.com/go-openapi/swag"
)

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

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

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

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

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

	for the iam service batch get principals operation.

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

	/* OrganizationID.

	   organization_id is the organization to query principals in.
	*/
	OrganizationID string

	/* PrincipalIds.

	     principal_ids is the list of principals to retrieve.
	A maximum of 1000 princiapls are allowed in a single request.
	*/
	PrincipalIds []string

	/* View.

	     view allows the caller to choose the set of principal data that is returned.
	If unset, the request defaults to PRINCIPAL_VIEW_BASIC.

	 - PRINCIPAL_VIEW_UNSPECIFIED: The default / unset value.
	 - PRINCIPAL_VIEW_BASIC: Include basic metadata about the principal, but not the principal details.
	This will return the Id and Type only.
	 - PRINCIPAL_VIEW_FULL: Include everything.

	     Default: "PRINCIPAL_VIEW_UNSPECIFIED"
	*/
	View *string

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

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

// SetDefaults hydrates default values in the iam service batch get principals params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *IamServiceBatchGetPrincipalsParams) SetDefaults() {
	var (
		viewDefault = string("PRINCIPAL_VIEW_UNSPECIFIED")
	)

	val := IamServiceBatchGetPrincipalsParams{
		View: &viewDefault,
	}

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

// WithTimeout adds the timeout to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) WithTimeout(timeout time.Duration) *IamServiceBatchGetPrincipalsParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) WithContext(ctx context.Context) *IamServiceBatchGetPrincipalsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) WithHTTPClient(client *http.Client) *IamServiceBatchGetPrincipalsParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithOrganizationID adds the organizationID to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) WithOrganizationID(organizationID string) *IamServiceBatchGetPrincipalsParams {
	o.SetOrganizationID(organizationID)
	return o
}

// SetOrganizationID adds the organizationId to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) SetOrganizationID(organizationID string) {
	o.OrganizationID = organizationID
}

// WithPrincipalIds adds the principalIds to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) WithPrincipalIds(principalIds []string) *IamServiceBatchGetPrincipalsParams {
	o.SetPrincipalIds(principalIds)
	return o
}

// SetPrincipalIds adds the principalIds to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) SetPrincipalIds(principalIds []string) {
	o.PrincipalIds = principalIds
}

// WithView adds the view to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) WithView(view *string) *IamServiceBatchGetPrincipalsParams {
	o.SetView(view)
	return o
}

// SetView adds the view to the iam service batch get principals params
func (o *IamServiceBatchGetPrincipalsParams) SetView(view *string) {
	o.View = view
}

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

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

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

	if o.PrincipalIds != nil {

		// binding items for principal_ids
		joinedPrincipalIds := o.bindParamPrincipalIds(reg)

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

	if o.View != nil {

		// query param view
		var qrView string

		if o.View != nil {
			qrView = *o.View
		}
		qView := qrView
		if qView != "" {

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

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

// bindParamIamServiceBatchGetPrincipals binds the parameter principal_ids
func (o *IamServiceBatchGetPrincipalsParams) bindParamPrincipalIds(formats strfmt.Registry) []string {
	principalIdsIR := o.PrincipalIds

	var principalIdsIC []string
	for _, principalIdsIIR := range principalIdsIR { // explode []string

		principalIdsIIV := principalIdsIIR // string as string
		principalIdsIC = append(principalIdsIC, principalIdsIIV)
	}

	// items.CollectionFormat: "multi"
	principalIdsIS := swag.JoinByFormat(principalIdsIC, "multi")

	return principalIdsIS
}
