api_op_ListHealthChecks.go (9961B)
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 // 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. 41 // 42 // If the value of IsTruncated in the previous response was false , there are no 43 // more health checks to get. 44 Marker *string 45 46 // The maximum number of health checks that you want ListHealthChecks to return in 47 // response to the current request. Amazon Route 53 returns a maximum of 1000 48 // items. If you set MaxItems to a value greater than 1000, Route 53 returns only 49 // the first 1000 health checks. 50 MaxItems *int32 51 52 noSmithyDocumentSerde 53 } 54 55 // A complex type that contains the response to a ListHealthChecks request. 56 type ListHealthChecksOutput struct { 57 58 // A complex type that contains one HealthCheck element for each health check that 59 // is associated with the current Amazon Web Services account. 60 // 61 // This member is required. 62 HealthChecks []types.HealthCheck 63 64 // A flag that indicates whether there are more health checks to be listed. If the 65 // response was truncated, you can get the next group of health checks by 66 // submitting another ListHealthChecks request and specifying the value of 67 // NextMarker in the marker parameter. 68 // 69 // This member is required. 70 IsTruncated bool 71 72 // For the second and subsequent calls to ListHealthChecks , Marker is the value 73 // that you specified for the marker parameter in the previous request. 74 // 75 // This member is required. 76 Marker *string 77 78 // The value that you specified for the maxitems parameter in the call to 79 // ListHealthChecks that produced the current response. 80 // 81 // This member is required. 82 MaxItems *int32 83 84 // If IsTruncated is true , the value of NextMarker identifies the first health 85 // check that Amazon Route 53 returns if you submit another ListHealthChecks 86 // request and specify the value of NextMarker in the marker parameter. 87 NextMarker *string 88 89 // Metadata pertaining to the operation's result. 90 ResultMetadata middleware.Metadata 91 92 noSmithyDocumentSerde 93 } 94 95 func (c *Client) addOperationListHealthChecksMiddlewares(stack *middleware.Stack, options Options) (err error) { 96 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil { 97 return err 98 } 99 err = stack.Serialize.Add(&awsRestxml_serializeOpListHealthChecks{}, middleware.After) 100 if err != nil { 101 return err 102 } 103 err = stack.Deserialize.Add(&awsRestxml_deserializeOpListHealthChecks{}, middleware.After) 104 if err != nil { 105 return err 106 } 107 if err := addProtocolFinalizerMiddlewares(stack, options, "ListHealthChecks"); err != nil { 108 return fmt.Errorf("add protocol finalizers: %v", err) 109 } 110 111 if err = addlegacyEndpointContextSetter(stack, options); err != nil { 112 return err 113 } 114 if err = addSetLoggerMiddleware(stack, options); err != nil { 115 return err 116 } 117 if err = addClientRequestID(stack); err != nil { 118 return err 119 } 120 if err = addComputeContentLength(stack); err != nil { 121 return err 122 } 123 if err = addResolveEndpointMiddleware(stack, options); err != nil { 124 return err 125 } 126 if err = addComputePayloadSHA256(stack); err != nil { 127 return err 128 } 129 if err = addRetry(stack, options); err != nil { 130 return err 131 } 132 if err = addRawResponseToMetadata(stack); err != nil { 133 return err 134 } 135 if err = addRecordResponseTiming(stack); err != nil { 136 return err 137 } 138 if err = addSpanRetryLoop(stack, options); err != nil { 139 return err 140 } 141 if err = addClientUserAgent(stack, options); err != nil { 142 return err 143 } 144 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 145 return err 146 } 147 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 148 return err 149 } 150 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil { 151 return err 152 } 153 if err = addTimeOffsetBuild(stack, c); err != nil { 154 return err 155 } 156 if err = addUserAgentRetryMode(stack, options); err != nil { 157 return err 158 } 159 if err = addCredentialSource(stack, options); err != nil { 160 return err 161 } 162 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListHealthChecks(options.Region), middleware.Before); err != nil { 163 return err 164 } 165 if err = addRecursionDetection(stack); err != nil { 166 return err 167 } 168 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 169 return err 170 } 171 if err = addResponseErrorMiddleware(stack); err != nil { 172 return err 173 } 174 if err = addRequestResponseLogging(stack, options); err != nil { 175 return err 176 } 177 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 178 return err 179 } 180 if err = addInterceptBeforeRetryLoop(stack, options); err != nil { 181 return err 182 } 183 if err = addInterceptAttempt(stack, options); err != nil { 184 return err 185 } 186 if err = addInterceptExecution(stack, options); err != nil { 187 return err 188 } 189 if err = addInterceptBeforeSerialization(stack, options); err != nil { 190 return err 191 } 192 if err = addInterceptAfterSerialization(stack, options); err != nil { 193 return err 194 } 195 if err = addInterceptBeforeSigning(stack, options); err != nil { 196 return err 197 } 198 if err = addInterceptAfterSigning(stack, options); err != nil { 199 return err 200 } 201 if err = addInterceptTransmit(stack, options); err != nil { 202 return err 203 } 204 if err = addInterceptBeforeDeserialization(stack, options); err != nil { 205 return err 206 } 207 if err = addInterceptAfterDeserialization(stack, options); err != nil { 208 return err 209 } 210 if err = addSpanInitializeStart(stack); err != nil { 211 return err 212 } 213 if err = addSpanInitializeEnd(stack); err != nil { 214 return err 215 } 216 if err = addSpanBuildRequestStart(stack); err != nil { 217 return err 218 } 219 if err = addSpanBuildRequestEnd(stack); err != nil { 220 return err 221 } 222 return nil 223 } 224 225 // ListHealthChecksPaginatorOptions is the paginator options for ListHealthChecks 226 type ListHealthChecksPaginatorOptions struct { 227 // The maximum number of health checks that you want ListHealthChecks to return in 228 // response to the current request. Amazon Route 53 returns a maximum of 1000 229 // items. If you set MaxItems to a value greater than 1000, Route 53 returns only 230 // the first 1000 health checks. 231 Limit int32 232 233 // Set to true if pagination should stop if the service returns a pagination token 234 // that matches the most recent token provided to the service. 235 StopOnDuplicateToken bool 236 } 237 238 // ListHealthChecksPaginator is a paginator for ListHealthChecks 239 type ListHealthChecksPaginator struct { 240 options ListHealthChecksPaginatorOptions 241 client ListHealthChecksAPIClient 242 params *ListHealthChecksInput 243 nextToken *string 244 firstPage bool 245 } 246 247 // NewListHealthChecksPaginator returns a new ListHealthChecksPaginator 248 func NewListHealthChecksPaginator(client ListHealthChecksAPIClient, params *ListHealthChecksInput, optFns ...func(*ListHealthChecksPaginatorOptions)) *ListHealthChecksPaginator { 249 if params == nil { 250 params = &ListHealthChecksInput{} 251 } 252 253 options := ListHealthChecksPaginatorOptions{} 254 if params.MaxItems != nil { 255 options.Limit = *params.MaxItems 256 } 257 258 for _, fn := range optFns { 259 fn(&options) 260 } 261 262 return &ListHealthChecksPaginator{ 263 options: options, 264 client: client, 265 params: params, 266 firstPage: true, 267 nextToken: params.Marker, 268 } 269 } 270 271 // HasMorePages returns a boolean indicating whether more pages are available 272 func (p *ListHealthChecksPaginator) HasMorePages() bool { 273 return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0) 274 } 275 276 // NextPage retrieves the next ListHealthChecks page. 277 func (p *ListHealthChecksPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListHealthChecksOutput, error) { 278 if !p.HasMorePages() { 279 return nil, fmt.Errorf("no more pages available") 280 } 281 282 params := *p.params 283 params.Marker = p.nextToken 284 285 var limit *int32 286 if p.options.Limit > 0 { 287 limit = &p.options.Limit 288 } 289 params.MaxItems = limit 290 291 optFns = append([]func(*Options){ 292 addIsPaginatorUserAgent, 293 }, optFns...) 294 result, err := p.client.ListHealthChecks(ctx, ¶ms, optFns...) 295 if err != nil { 296 return nil, err 297 } 298 p.firstPage = false 299 300 prevToken := p.nextToken 301 p.nextToken = result.NextMarker 302 303 if p.options.StopOnDuplicateToken && 304 prevToken != nil && 305 p.nextToken != nil && 306 *prevToken == *p.nextToken { 307 p.nextToken = nil 308 } 309 310 return result, nil 311 } 312 313 // ListHealthChecksAPIClient is a client that implements the ListHealthChecks 314 // operation. 315 type ListHealthChecksAPIClient interface { 316 ListHealthChecks(context.Context, *ListHealthChecksInput, ...func(*Options)) (*ListHealthChecksOutput, error) 317 } 318 319 var _ ListHealthChecksAPIClient = (*Client)(nil) 320 321 func newServiceMetadataMiddleware_opListHealthChecks(region string) *awsmiddleware.RegisterServiceMetadata { 322 return &awsmiddleware.RegisterServiceMetadata{ 323 Region: region, 324 ServiceID: ServiceID, 325 OperationName: "ListHealthChecks", 326 } 327 }