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

package groups_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"
)

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

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

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

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

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

	for the groups service count groups operation.

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

	/* FilterGroupResourceIds.

	     group_resource_ids is a way to filter groups by a list of group
	ids when we need to resolve group attributes (e.g. name) from a
	list of ids we get from a project policy.
	*/
	FilterGroupResourceIds []string

	/* FilterMemberPrincipalID.

	   member_principal_id is an optional query param to filter groups that a principal belongs to.
	*/
	FilterMemberPrincipalID *string

	/* ParentResourceName.

	     parent_resource is the parent resource of the group.
	organization/<org_id>
	*/
	ParentResourceName string

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

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

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

// WithTimeout adds the timeout to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) WithTimeout(timeout time.Duration) *GroupsServiceCountGroupsParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) WithContext(ctx context.Context) *GroupsServiceCountGroupsParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) WithHTTPClient(client *http.Client) *GroupsServiceCountGroupsParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithFilterGroupResourceIds adds the filterGroupResourceIds to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) WithFilterGroupResourceIds(filterGroupResourceIds []string) *GroupsServiceCountGroupsParams {
	o.SetFilterGroupResourceIds(filterGroupResourceIds)
	return o
}

// SetFilterGroupResourceIds adds the filterGroupResourceIds to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) SetFilterGroupResourceIds(filterGroupResourceIds []string) {
	o.FilterGroupResourceIds = filterGroupResourceIds
}

// WithFilterMemberPrincipalID adds the filterMemberPrincipalID to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) WithFilterMemberPrincipalID(filterMemberPrincipalID *string) *GroupsServiceCountGroupsParams {
	o.SetFilterMemberPrincipalID(filterMemberPrincipalID)
	return o
}

// SetFilterMemberPrincipalID adds the filterMemberPrincipalId to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) SetFilterMemberPrincipalID(filterMemberPrincipalID *string) {
	o.FilterMemberPrincipalID = filterMemberPrincipalID
}

// WithParentResourceName adds the parentResourceName to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) WithParentResourceName(parentResourceName string) *GroupsServiceCountGroupsParams {
	o.SetParentResourceName(parentResourceName)
	return o
}

// SetParentResourceName adds the parentResourceName to the groups service count groups params
func (o *GroupsServiceCountGroupsParams) SetParentResourceName(parentResourceName string) {
	o.ParentResourceName = parentResourceName
}

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

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

	if o.FilterGroupResourceIds != nil {

		// binding items for filter.group_resource_ids
		joinedFilterGroupResourceIds := o.bindParamFilterGroupResourceIds(reg)

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

	if o.FilterMemberPrincipalID != nil {

		// query param filter.member_principal_id
		var qrFilterMemberPrincipalID string

		if o.FilterMemberPrincipalID != nil {
			qrFilterMemberPrincipalID = *o.FilterMemberPrincipalID
		}
		qFilterMemberPrincipalID := qrFilterMemberPrincipalID
		if qFilterMemberPrincipalID != "" {

			if err := r.SetQueryParam("filter.member_principal_id", qFilterMemberPrincipalID); err != nil {
				return err
			}
		}
	}

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

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

// bindParamGroupsServiceCountGroups binds the parameter filter.group_resource_ids
func (o *GroupsServiceCountGroupsParams) bindParamFilterGroupResourceIds(formats strfmt.Registry) []string {
	filterGroupResourceIdsIR := o.FilterGroupResourceIds

	var filterGroupResourceIdsIC []string
	for _, filterGroupResourceIdsIIR := range filterGroupResourceIdsIR { // explode []string

		filterGroupResourceIdsIIV := filterGroupResourceIdsIIR // string as string
		filterGroupResourceIdsIC = append(filterGroupResourceIdsIC, filterGroupResourceIdsIIV)
	}

	// items.CollectionFormat: "multi"
	filterGroupResourceIdsIS := swag.JoinByFormat(filterGroupResourceIdsIC, "multi")

	return filterGroupResourceIdsIS
}
