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