// Code generated by smithy-go-codegen DO NOT EDIT.

package lightsail

import (
	"context"
	"github.com/aws/smithy-go/middleware"
	"time"
)

// Returns the timestamp and status of the last cache reset of a specific Amazon
// Lightsail content delivery network (CDN) distribution.
func (c *Client) GetDistributionLatestCacheReset(ctx context.Context, params *GetDistributionLatestCacheResetInput, optFns ...func(*Options)) (*GetDistributionLatestCacheResetOutput, error) {
	if params == nil {
		params = &GetDistributionLatestCacheResetInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "GetDistributionLatestCacheReset", params, optFns, c.addOperationGetDistributionLatestCacheResetMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*GetDistributionLatestCacheResetOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type GetDistributionLatestCacheResetInput struct {

	// The name of the distribution for which to return the timestamp of the last
	// cache reset.
	//
	// Use the GetDistributions action to get a list of distribution names that you
	// can specify.
	//
	// When omitted, the response includes the latest cache reset timestamp of all
	// your distributions.
	DistributionName *string

	noSmithyDocumentSerde
}

type GetDistributionLatestCacheResetOutput struct {

	// The timestamp of the last cache reset ( 1479734909.17 ) in Unix time format.
	CreateTime *time.Time

	// The status of the last cache reset.
	Status *string

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationGetDistributionLatestCacheResetMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetDistributionLatestCacheReset{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetDistributionLatestCacheReset{}, middleware.After)
	if err != nil {
		return err
	}

	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack, options); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
