src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

api_op_ListHealthChecks.go (8464B)


      1 // Code generated by smithy-go-codegen DO NOT EDIT.
      2 
      3 package route53
      4 
      5 import (
      6 	"context"
      7 	"fmt"
      8 	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
      9 	"github.com/aws/aws-sdk-go-v2/service/route53/types"
     10 	"github.com/aws/smithy-go/middleware"
     11 	smithyhttp "github.com/aws/smithy-go/transport/http"
     12 )
     13 
     14 // Retrieve a list of the health checks that are associated with the current
     15 // Amazon Web Services account.
     16 func (c *Client) ListHealthChecks(ctx context.Context, params *ListHealthChecksInput, optFns ...func(*Options)) (*ListHealthChecksOutput, error) {
     17 	if params == nil {
     18 		params = &ListHealthChecksInput{}
     19 	}
     20 
     21 	result, metadata, err := c.invokeOperation(ctx, "ListHealthChecks", params, optFns, c.addOperationListHealthChecksMiddlewares)
     22 	if err != nil {
     23 		return nil, err
     24 	}
     25 
     26 	out := result.(*ListHealthChecksOutput)
     27 	out.ResultMetadata = metadata
     28 	return out, nil
     29 }
     30 
     31 // A request to retrieve a list of the health checks that are associated with the
     32 // current Amazon Web Services account.
     33 type ListHealthChecksInput struct {
     34 
     35 	// If the value of IsTruncated in the previous response was true , you have more
     36 	// health checks. To get another group, submit another ListHealthChecks request.
     37 	// For the value of marker , specify the value of NextMarker from the previous
     38 	// response, which is the ID of the first health check that Amazon Route 53 will
     39 	// return if you submit another request. If the value of IsTruncated in the
     40 	// previous response was false , there are no more health checks to get.
     41 	Marker *string
     42 
     43 	// The maximum number of health checks that you want ListHealthChecks to return in
     44 	// response to the current request. Amazon Route 53 returns a maximum of 1000
     45 	// items. If you set MaxItems to a value greater than 1000, Route 53 returns only
     46 	// the first 1000 health checks.
     47 	MaxItems *int32
     48 
     49 	noSmithyDocumentSerde
     50 }
     51 
     52 // A complex type that contains the response to a ListHealthChecks request.
     53 type ListHealthChecksOutput struct {
     54 
     55 	// A complex type that contains one HealthCheck element for each health check that
     56 	// is associated with the current Amazon Web Services account.
     57 	//
     58 	// This member is required.
     59 	HealthChecks []types.HealthCheck
     60 
     61 	// A flag that indicates whether there are more health checks to be listed. If the
     62 	// response was truncated, you can get the next group of health checks by
     63 	// submitting another ListHealthChecks request and specifying the value of
     64 	// NextMarker in the marker parameter.
     65 	//
     66 	// This member is required.
     67 	IsTruncated bool
     68 
     69 	// For the second and subsequent calls to ListHealthChecks , Marker is the value
     70 	// that you specified for the marker parameter in the previous request.
     71 	//
     72 	// This member is required.
     73 	Marker *string
     74 
     75 	// The value that you specified for the maxitems parameter in the call to
     76 	// ListHealthChecks that produced the current response.
     77 	//
     78 	// This member is required.
     79 	MaxItems *int32
     80 
     81 	// If IsTruncated is true , the value of NextMarker identifies the first health
     82 	// check that Amazon Route 53 returns if you submit another ListHealthChecks
     83 	// request and specify the value of NextMarker in the marker parameter.
     84 	NextMarker *string
     85 
     86 	// Metadata pertaining to the operation's result.
     87 	ResultMetadata middleware.Metadata
     88 
     89 	noSmithyDocumentSerde
     90 }
     91 
     92 func (c *Client) addOperationListHealthChecksMiddlewares(stack *middleware.Stack, options Options) (err error) {
     93 	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
     94 		return err
     95 	}
     96 	err = stack.Serialize.Add(&awsRestxml_serializeOpListHealthChecks{}, middleware.After)
     97 	if err != nil {
     98 		return err
     99 	}
    100 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListHealthChecks{}, middleware.After)
    101 	if err != nil {
    102 		return err
    103 	}
    104 	if err := addProtocolFinalizerMiddlewares(stack, options, "ListHealthChecks"); err != nil {
    105 		return fmt.Errorf("add protocol finalizers: %v", err)
    106 	}
    107 
    108 	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
    109 		return err
    110 	}
    111 	if err = addSetLoggerMiddleware(stack, options); err != nil {
    112 		return err
    113 	}
    114 	if err = addClientRequestID(stack); err != nil {
    115 		return err
    116 	}
    117 	if err = addComputeContentLength(stack); err != nil {
    118 		return err
    119 	}
    120 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
    121 		return err
    122 	}
    123 	if err = addComputePayloadSHA256(stack); err != nil {
    124 		return err
    125 	}
    126 	if err = addRetry(stack, options); err != nil {
    127 		return err
    128 	}
    129 	if err = addRawResponseToMetadata(stack); err != nil {
    130 		return err
    131 	}
    132 	if err = addRecordResponseTiming(stack); err != nil {
    133 		return err
    134 	}
    135 	if err = addClientUserAgent(stack, options); err != nil {
    136 		return err
    137 	}
    138 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    139 		return err
    140 	}
    141 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    142 		return err
    143 	}
    144 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    145 		return err
    146 	}
    147 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListHealthChecks(options.Region), middleware.Before); err != nil {
    148 		return err
    149 	}
    150 	if err = addRecursionDetection(stack); err != nil {
    151 		return err
    152 	}
    153 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    154 		return err
    155 	}
    156 	if err = addResponseErrorMiddleware(stack); err != nil {
    157 		return err
    158 	}
    159 	if err = addRequestResponseLogging(stack, options); err != nil {
    160 		return err
    161 	}
    162 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    163 		return err
    164 	}
    165 	return nil
    166 }
    167 
    168 // ListHealthChecksAPIClient is a client that implements the ListHealthChecks
    169 // operation.
    170 type ListHealthChecksAPIClient interface {
    171 	ListHealthChecks(context.Context, *ListHealthChecksInput, ...func(*Options)) (*ListHealthChecksOutput, error)
    172 }
    173 
    174 var _ ListHealthChecksAPIClient = (*Client)(nil)
    175 
    176 // ListHealthChecksPaginatorOptions is the paginator options for ListHealthChecks
    177 type ListHealthChecksPaginatorOptions struct {
    178 	// The maximum number of health checks that you want ListHealthChecks to return in
    179 	// response to the current request. Amazon Route 53 returns a maximum of 1000
    180 	// items. If you set MaxItems to a value greater than 1000, Route 53 returns only
    181 	// the first 1000 health checks.
    182 	Limit int32
    183 
    184 	// Set to true if pagination should stop if the service returns a pagination token
    185 	// that matches the most recent token provided to the service.
    186 	StopOnDuplicateToken bool
    187 }
    188 
    189 // ListHealthChecksPaginator is a paginator for ListHealthChecks
    190 type ListHealthChecksPaginator struct {
    191 	options   ListHealthChecksPaginatorOptions
    192 	client    ListHealthChecksAPIClient
    193 	params    *ListHealthChecksInput
    194 	nextToken *string
    195 	firstPage bool
    196 }
    197 
    198 // NewListHealthChecksPaginator returns a new ListHealthChecksPaginator
    199 func NewListHealthChecksPaginator(client ListHealthChecksAPIClient, params *ListHealthChecksInput, optFns ...func(*ListHealthChecksPaginatorOptions)) *ListHealthChecksPaginator {
    200 	if params == nil {
    201 		params = &ListHealthChecksInput{}
    202 	}
    203 
    204 	options := ListHealthChecksPaginatorOptions{}
    205 	if params.MaxItems != nil {
    206 		options.Limit = *params.MaxItems
    207 	}
    208 
    209 	for _, fn := range optFns {
    210 		fn(&options)
    211 	}
    212 
    213 	return &ListHealthChecksPaginator{
    214 		options:   options,
    215 		client:    client,
    216 		params:    params,
    217 		firstPage: true,
    218 		nextToken: params.Marker,
    219 	}
    220 }
    221 
    222 // HasMorePages returns a boolean indicating whether more pages are available
    223 func (p *ListHealthChecksPaginator) HasMorePages() bool {
    224 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    225 }
    226 
    227 // NextPage retrieves the next ListHealthChecks page.
    228 func (p *ListHealthChecksPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListHealthChecksOutput, error) {
    229 	if !p.HasMorePages() {
    230 		return nil, fmt.Errorf("no more pages available")
    231 	}
    232 
    233 	params := *p.params
    234 	params.Marker = p.nextToken
    235 
    236 	var limit *int32
    237 	if p.options.Limit > 0 {
    238 		limit = &p.options.Limit
    239 	}
    240 	params.MaxItems = limit
    241 
    242 	result, err := p.client.ListHealthChecks(ctx, &params, optFns...)
    243 	if err != nil {
    244 		return nil, err
    245 	}
    246 	p.firstPage = false
    247 
    248 	prevToken := p.nextToken
    249 	p.nextToken = result.NextMarker
    250 
    251 	if p.options.StopOnDuplicateToken &&
    252 		prevToken != nil &&
    253 		p.nextToken != nil &&
    254 		*prevToken == *p.nextToken {
    255 		p.nextToken = nil
    256 	}
    257 
    258 	return result, nil
    259 }
    260 
    261 func newServiceMetadataMiddleware_opListHealthChecks(region string) *awsmiddleware.RegisterServiceMetadata {
    262 	return &awsmiddleware.RegisterServiceMetadata{
    263 		Region:        region,
    264 		ServiceID:     ServiceID,
    265 		OperationName: "ListHealthChecks",
    266 	}
    267 }