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

package cloudwatchlogs

import (
	"context"

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

// Please also see https://docs.aws.amazon.com/goto/WebAPI/logs-2014-03-28/CancelExportTaskRequest
type CancelExportTaskInput struct {
	_ struct{} `type:"structure"`

	// The ID of the export task.
	//
	// TaskId is a required field
	TaskId *string `locationName:"taskId" min:"1" type:"string" required:"true"`
}

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

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

	if s.TaskId == nil {
		invalidParams.Add(aws.NewErrParamRequired("TaskId"))
	}
	if s.TaskId != nil && len(*s.TaskId) < 1 {
		invalidParams.Add(aws.NewErrParamMinLen("TaskId", 1))
	}

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

// Please also see https://docs.aws.amazon.com/goto/WebAPI/logs-2014-03-28/CancelExportTaskOutput
type CancelExportTaskOutput struct {
	_ struct{} `type:"structure"`
}

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

const opCancelExportTask = "CancelExportTask"

// CancelExportTaskRequest returns a request value for making API operation for
// Amazon CloudWatch Logs.
//
// Cancels the specified export task.
//
// The task must be in the PENDING or RUNNING state.
//
//    // Example sending a request using CancelExportTaskRequest.
//    req := client.CancelExportTaskRequest(params)
//    resp, err := req.Send(context.TODO())
//    if err == nil {
//        fmt.Println(resp)
//    }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/logs-2014-03-28/CancelExportTask
func (c *Client) CancelExportTaskRequest(input *CancelExportTaskInput) CancelExportTaskRequest {
	op := &aws.Operation{
		Name:       opCancelExportTask,
		HTTPMethod: "POST",
		HTTPPath:   "/",
	}

	if input == nil {
		input = &CancelExportTaskInput{}
	}

	req := c.newRequest(op, input, &CancelExportTaskOutput{})
	req.Handlers.Unmarshal.Remove(jsonrpc.UnmarshalHandler)
	req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler)
	return CancelExportTaskRequest{Request: req, Input: input, Copy: c.CancelExportTaskRequest}
}

// CancelExportTaskRequest is the request type for the
// CancelExportTask API operation.
type CancelExportTaskRequest struct {
	*aws.Request
	Input *CancelExportTaskInput
	Copy  func(*CancelExportTaskInput) CancelExportTaskRequest
}

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

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

	return resp, nil
}

// CancelExportTaskResponse is the response type for the
// CancelExportTask API operation.
type CancelExportTaskResponse struct {
	*CancelExportTaskOutput

	response *aws.Response
}

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