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

package admin

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

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

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

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

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

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

	for the domain block create operation.

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

	/* Domain.

	   Single domain to block. Used only if `import` is not `true`.
	*/
	Domain *string

	/* Domains.

	   JSON-formatted list of domain blocks to import. This is only used if `import` is set to `true`.
	*/
	Domains runtime.NamedReadCloser

	/* Import.

	   Signal that a list of domain blocks is being imported as a file. If set to `true`, then 'domains' must be present as a JSON-formatted file. If set to `false`, then `domains` will be ignored, and `domain` must be present.
	*/
	Import *bool

	/* Obfuscate.

	   Obfuscate the name of the domain when serving it publicly. Eg., `example.org` becomes something like `ex***e.org`. Used only if `import` is not `true`.
	*/
	Obfuscate *bool

	/* PrivateComment.

	   Private comment about this domain block. Will only be shown to other admins, so this is a useful way of internally keeping track of why a certain domain ended up blocked. Used only if `import` is not `true`.
	*/
	PrivateComment *string

	/* PublicComment.

	   Public comment about this domain block. This will be displayed alongside the domain block if you choose to share blocks. Used only if `import` is not `true`.
	*/
	PublicComment *string

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

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

// SetDefaults hydrates default values in the domain block create params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *DomainBlockCreateParams) SetDefaults() {
	var (
		importVarDefault = bool(false)
	)

	val := DomainBlockCreateParams{
		Import: &importVarDefault,
	}

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

// WithTimeout adds the timeout to the domain block create params
func (o *DomainBlockCreateParams) WithTimeout(timeout time.Duration) *DomainBlockCreateParams {
	o.SetTimeout(timeout)
	return o
}

// SetTimeout adds the timeout to the domain block create params
func (o *DomainBlockCreateParams) SetTimeout(timeout time.Duration) {
	o.timeout = timeout
}

// WithContext adds the context to the domain block create params
func (o *DomainBlockCreateParams) WithContext(ctx context.Context) *DomainBlockCreateParams {
	o.SetContext(ctx)
	return o
}

// SetContext adds the context to the domain block create params
func (o *DomainBlockCreateParams) SetContext(ctx context.Context) {
	o.Context = ctx
}

// WithHTTPClient adds the HTTPClient to the domain block create params
func (o *DomainBlockCreateParams) WithHTTPClient(client *http.Client) *DomainBlockCreateParams {
	o.SetHTTPClient(client)
	return o
}

// SetHTTPClient adds the HTTPClient to the domain block create params
func (o *DomainBlockCreateParams) SetHTTPClient(client *http.Client) {
	o.HTTPClient = client
}

// WithDomain adds the domain to the domain block create params
func (o *DomainBlockCreateParams) WithDomain(domain *string) *DomainBlockCreateParams {
	o.SetDomain(domain)
	return o
}

// SetDomain adds the domain to the domain block create params
func (o *DomainBlockCreateParams) SetDomain(domain *string) {
	o.Domain = domain
}

// WithDomains adds the domains to the domain block create params
func (o *DomainBlockCreateParams) WithDomains(domains runtime.NamedReadCloser) *DomainBlockCreateParams {
	o.SetDomains(domains)
	return o
}

// SetDomains adds the domains to the domain block create params
func (o *DomainBlockCreateParams) SetDomains(domains runtime.NamedReadCloser) {
	o.Domains = domains
}

// WithImport adds the importVar to the domain block create params
func (o *DomainBlockCreateParams) WithImport(importVar *bool) *DomainBlockCreateParams {
	o.SetImport(importVar)
	return o
}

// SetImport adds the import to the domain block create params
func (o *DomainBlockCreateParams) SetImport(importVar *bool) {
	o.Import = importVar
}

// WithObfuscate adds the obfuscate to the domain block create params
func (o *DomainBlockCreateParams) WithObfuscate(obfuscate *bool) *DomainBlockCreateParams {
	o.SetObfuscate(obfuscate)
	return o
}

// SetObfuscate adds the obfuscate to the domain block create params
func (o *DomainBlockCreateParams) SetObfuscate(obfuscate *bool) {
	o.Obfuscate = obfuscate
}

// WithPrivateComment adds the privateComment to the domain block create params
func (o *DomainBlockCreateParams) WithPrivateComment(privateComment *string) *DomainBlockCreateParams {
	o.SetPrivateComment(privateComment)
	return o
}

// SetPrivateComment adds the privateComment to the domain block create params
func (o *DomainBlockCreateParams) SetPrivateComment(privateComment *string) {
	o.PrivateComment = privateComment
}

// WithPublicComment adds the publicComment to the domain block create params
func (o *DomainBlockCreateParams) WithPublicComment(publicComment *string) *DomainBlockCreateParams {
	o.SetPublicComment(publicComment)
	return o
}

// SetPublicComment adds the publicComment to the domain block create params
func (o *DomainBlockCreateParams) SetPublicComment(publicComment *string) {
	o.PublicComment = publicComment
}

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

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

	if o.Domain != nil {

		// form param domain
		var frDomain string
		if o.Domain != nil {
			frDomain = *o.Domain
		}
		fDomain := frDomain
		if fDomain != "" {
			if err := r.SetFormParam("domain", fDomain); err != nil {
				return err
			}
		}
	}

	if o.Domains != nil {

		if o.Domains != nil {
			// form file param domains
			if err := r.SetFileParam("domains", o.Domains); err != nil {
				return err
			}
		}
	}

	if o.Import != nil {

		// query param import
		var qrImport bool

		if o.Import != nil {
			qrImport = *o.Import
		}
		qImport := swag.FormatBool(qrImport)
		if qImport != "" {

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

	if o.Obfuscate != nil {

		// form param obfuscate
		var frObfuscate bool
		if o.Obfuscate != nil {
			frObfuscate = *o.Obfuscate
		}
		fObfuscate := swag.FormatBool(frObfuscate)
		if fObfuscate != "" {
			if err := r.SetFormParam("obfuscate", fObfuscate); err != nil {
				return err
			}
		}
	}

	if o.PrivateComment != nil {

		// form param private_comment
		var frPrivateComment string
		if o.PrivateComment != nil {
			frPrivateComment = *o.PrivateComment
		}
		fPrivateComment := frPrivateComment
		if fPrivateComment != "" {
			if err := r.SetFormParam("private_comment", fPrivateComment); err != nil {
				return err
			}
		}
	}

	if o.PublicComment != nil {

		// form param public_comment
		var frPublicComment string
		if o.PublicComment != nil {
			frPublicComment = *o.PublicComment
		}
		fPublicComment := frPublicComment
		if fPublicComment != "" {
			if err := r.SetFormParam("public_comment", fPublicComment); err != nil {
				return err
			}
		}
	}

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