src

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

api_op_ListHealthChecks.go (7148B)


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