// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.

package globalaccelerator

import (
	"context"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/internal/awsutil"
)

// Please also see https://docs.aws.amazon.com/goto/WebAPI/globalaccelerator-2018-08-08/CreateAcceleratorRequest
type CreateAcceleratorInput struct {
	_ struct{} `type:"structure"`

	// Indicates whether an accelerator is enabled. The value is true or false.
	// The default value is true.
	//
	// If the value is set to true, an accelerator cannot be deleted. If set to
	// false, the accelerator can be deleted.
	Enabled *bool `type:"boolean"`

	// A unique, case-sensitive identifier that you provide to ensure the idempotency—that
	// is, the uniqueness—of an accelerator.
	//
	// IdempotencyToken is a required field
	IdempotencyToken *string `type:"string" required:"true"`

	// The value for the address type must be IPv4.
	IpAddressType IpAddressType `type:"string" enum:"true"`

	// The name of an accelerator. The name can have a maximum of 32 characters,
	// must contain only alphanumeric characters or hyphens (-), and must not begin
	// or end with a hyphen.
	//
	// Name is a required field
	Name *string `type:"string" required:"true"`
}

// String returns the string representation
func (s CreateAcceleratorInput) String() string {
	return awsutil.Prettify(s)
}

// Validate inspects the fields of the type to determine if they are valid.
func (s *CreateAcceleratorInput) Validate() error {
	invalidParams := aws.ErrInvalidParams{Context: "CreateAcceleratorInput"}

	if s.IdempotencyToken == nil {
		invalidParams.Add(aws.NewErrParamRequired("IdempotencyToken"))
	}

	if s.Name == nil {
		invalidParams.Add(aws.NewErrParamRequired("Name"))
	}

	if invalidParams.Len() > 0 {
		return invalidParams
	}
	return nil
}

// Please also see https://docs.aws.amazon.com/goto/WebAPI/globalaccelerator-2018-08-08/CreateAcceleratorResponse
type CreateAcceleratorOutput struct {
	_ struct{} `type:"structure"`

	// The accelerator that is created by specifying a listener and the supported
	// IP address types.
	Accelerator *Accelerator `type:"structure"`
}

// String returns the string representation
func (s CreateAcceleratorOutput) String() string {
	return awsutil.Prettify(s)
}

const opCreateAccelerator = "CreateAccelerator"

// CreateAcceleratorRequest returns a request value for making API operation for
// AWS Global Accelerator.
//
// Create an accelerator. An accelerator includes one or more listeners that
// process inbound connections and direct traffic to one or more endpoint groups,
// each of which includes endpoints, such as Network Load Balancers. To see
// an AWS CLI example of creating an accelerator, scroll down to Example.
//
//    // Example sending a request using CreateAcceleratorRequest.
//    req := client.CreateAcceleratorRequest(params)
//    resp, err := req.Send(context.TODO())
//    if err == nil {
//        fmt.Println(resp)
//    }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/globalaccelerator-2018-08-08/CreateAccelerator
func (c *Client) CreateAcceleratorRequest(input *CreateAcceleratorInput) CreateAcceleratorRequest {
	op := &aws.Operation{
		Name:       opCreateAccelerator,
		HTTPMethod: "POST",
		HTTPPath:   "/",
	}

	if input == nil {
		input = &CreateAcceleratorInput{}
	}

	req := c.newRequest(op, input, &CreateAcceleratorOutput{})
	return CreateAcceleratorRequest{Request: req, Input: input, Copy: c.CreateAcceleratorRequest}
}

// CreateAcceleratorRequest is the request type for the
// CreateAccelerator API operation.
type CreateAcceleratorRequest struct {
	*aws.Request
	Input *CreateAcceleratorInput
	Copy  func(*CreateAcceleratorInput) CreateAcceleratorRequest
}

// Send marshals and sends the CreateAccelerator API request.
func (r CreateAcceleratorRequest) Send(ctx context.Context) (*CreateAcceleratorResponse, error) {
	r.Request.SetContext(ctx)
	err := r.Request.Send()
	if err != nil {
		return nil, err
	}

	resp := &CreateAcceleratorResponse{
		CreateAcceleratorOutput: r.Request.Data.(*CreateAcceleratorOutput),
		response:                &aws.Response{Request: r.Request},
	}

	return resp, nil
}

// CreateAcceleratorResponse is the response type for the
// CreateAccelerator API operation.
type CreateAcceleratorResponse struct {
	*CreateAcceleratorOutput

	response *aws.Response
}

// SDKResponseMetdata returns the response metadata for the
// CreateAccelerator request.
func (r *CreateAcceleratorResponse) SDKResponseMetdata() *aws.Response {
	return r.response
}
