src

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

api_op_CreateHealthCheck.go (8767B)


      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 // Creates a new health check.
     15 //
     16 // For information about adding health checks to resource record sets, see [HealthCheckId] in [ChangeResourceRecordSets].
     17 //
     18 // # ELB Load Balancers
     19 //
     20 // If you're registering EC2 instances with an Elastic Load Balancing (ELB) load
     21 // balancer, do not create Amazon Route 53 health checks for the EC2 instances.
     22 // When you register an EC2 instance with a load balancer, you configure settings
     23 // for an ELB health check, which performs a similar function to a Route 53 health
     24 // check.
     25 //
     26 // # Private Hosted Zones
     27 //
     28 // You can associate health checks with failover resource record sets in a private
     29 // hosted zone. Note the following:
     30 //
     31 //   - Route 53 health checkers are outside the VPC. To check the health of an
     32 //     endpoint within a VPC by IP address, you must assign a public IP address to the
     33 //     instance in the VPC.
     34 //
     35 //   - You can configure a health checker to check the health of an external
     36 //     resource that the instance relies on, such as a database server.
     37 //
     38 //   - You can create a CloudWatch metric, associate an alarm with the metric, and
     39 //     then create a health check that is based on the state of the alarm. For example,
     40 //     you might create a CloudWatch metric that checks the status of the Amazon EC2
     41 //     StatusCheckFailed metric, add an alarm to the metric, and then create a health
     42 //     check that is based on the state of the alarm. For information about creating
     43 //     CloudWatch metrics and alarms by using the CloudWatch console, see the [Amazon CloudWatch User Guide].
     44 //
     45 // [HealthCheckId]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ResourceRecordSet.html#Route53-Type-ResourceRecordSet-HealthCheckId
     46 // [ChangeResourceRecordSets]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html
     47 // [Amazon CloudWatch User Guide]: https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/WhatIsCloudWatch.html
     48 func (c *Client) CreateHealthCheck(ctx context.Context, params *CreateHealthCheckInput, optFns ...func(*Options)) (*CreateHealthCheckOutput, error) {
     49 	if params == nil {
     50 		params = &CreateHealthCheckInput{}
     51 	}
     52 
     53 	result, metadata, err := c.invokeOperation(ctx, "CreateHealthCheck", params, optFns, c.addOperationCreateHealthCheckMiddlewares)
     54 	if err != nil {
     55 		return nil, err
     56 	}
     57 
     58 	out := result.(*CreateHealthCheckOutput)
     59 	out.ResultMetadata = metadata
     60 	return out, nil
     61 }
     62 
     63 // A complex type that contains the health check request information.
     64 type CreateHealthCheckInput struct {
     65 
     66 	// A unique string that identifies the request and that allows you to retry a
     67 	// failed CreateHealthCheck request without the risk of creating two identical
     68 	// health checks:
     69 	//
     70 	//   - If you send a CreateHealthCheck request with the same CallerReference and
     71 	//   settings as a previous request, and if the health check doesn't exist, Amazon
     72 	//   Route 53 creates the health check. If the health check does exist, Route 53
     73 	//   returns the health check configuration in the response.
     74 	//
     75 	//   - If you send a CreateHealthCheck request with the same CallerReference as a
     76 	//   deleted health check, regardless of the settings, Route 53 returns a
     77 	//   HealthCheckAlreadyExists error.
     78 	//
     79 	//   - If you send a CreateHealthCheck request with the same CallerReference as an
     80 	//   existing health check but with different settings, Route 53 returns a
     81 	//   HealthCheckAlreadyExists error.
     82 	//
     83 	//   - If you send a CreateHealthCheck request with a unique CallerReference but
     84 	//   settings identical to an existing health check, Route 53 creates the health
     85 	//   check.
     86 	//
     87 	// Route 53 does not store the CallerReference for a deleted health check
     88 	// indefinitely. The CallerReference for a deleted health check will be deleted
     89 	// after a number of days.
     90 	//
     91 	// This member is required.
     92 	CallerReference *string
     93 
     94 	// A complex type that contains settings for a new health check.
     95 	//
     96 	// This member is required.
     97 	HealthCheckConfig *types.HealthCheckConfig
     98 
     99 	noSmithyDocumentSerde
    100 }
    101 
    102 // A complex type containing the response information for the new health check.
    103 type CreateHealthCheckOutput struct {
    104 
    105 	// A complex type that contains identifying information about the health check.
    106 	//
    107 	// This member is required.
    108 	HealthCheck *types.HealthCheck
    109 
    110 	// The unique URL representing the new health check.
    111 	//
    112 	// This member is required.
    113 	Location *string
    114 
    115 	// Metadata pertaining to the operation's result.
    116 	ResultMetadata middleware.Metadata
    117 
    118 	noSmithyDocumentSerde
    119 }
    120 
    121 func (c *Client) addOperationCreateHealthCheckMiddlewares(stack *middleware.Stack, options Options) (err error) {
    122 	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
    123 		return err
    124 	}
    125 	err = stack.Serialize.Add(&awsRestxml_serializeOpCreateHealthCheck{}, middleware.After)
    126 	if err != nil {
    127 		return err
    128 	}
    129 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpCreateHealthCheck{}, middleware.After)
    130 	if err != nil {
    131 		return err
    132 	}
    133 	if err := addProtocolFinalizerMiddlewares(stack, options, "CreateHealthCheck"); err != nil {
    134 		return fmt.Errorf("add protocol finalizers: %v", err)
    135 	}
    136 
    137 	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
    138 		return err
    139 	}
    140 	if err = addSetLoggerMiddleware(stack, options); err != nil {
    141 		return err
    142 	}
    143 	if err = addClientRequestID(stack); err != nil {
    144 		return err
    145 	}
    146 	if err = addComputeContentLength(stack); err != nil {
    147 		return err
    148 	}
    149 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
    150 		return err
    151 	}
    152 	if err = addComputePayloadSHA256(stack); err != nil {
    153 		return err
    154 	}
    155 	if err = addRetry(stack, options); err != nil {
    156 		return err
    157 	}
    158 	if err = addRawResponseToMetadata(stack); err != nil {
    159 		return err
    160 	}
    161 	if err = addRecordResponseTiming(stack); err != nil {
    162 		return err
    163 	}
    164 	if err = addSpanRetryLoop(stack, options); err != nil {
    165 		return err
    166 	}
    167 	if err = addClientUserAgent(stack, options); err != nil {
    168 		return err
    169 	}
    170 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    171 		return err
    172 	}
    173 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    174 		return err
    175 	}
    176 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    177 		return err
    178 	}
    179 	if err = addTimeOffsetBuild(stack, c); err != nil {
    180 		return err
    181 	}
    182 	if err = addUserAgentRetryMode(stack, options); err != nil {
    183 		return err
    184 	}
    185 	if err = addCredentialSource(stack, options); err != nil {
    186 		return err
    187 	}
    188 	if err = addOpCreateHealthCheckValidationMiddleware(stack); err != nil {
    189 		return err
    190 	}
    191 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateHealthCheck(options.Region), middleware.Before); err != nil {
    192 		return err
    193 	}
    194 	if err = addRecursionDetection(stack); err != nil {
    195 		return err
    196 	}
    197 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    198 		return err
    199 	}
    200 	if err = addResponseErrorMiddleware(stack); err != nil {
    201 		return err
    202 	}
    203 	if err = addRequestResponseLogging(stack, options); err != nil {
    204 		return err
    205 	}
    206 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    207 		return err
    208 	}
    209 	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
    210 		return err
    211 	}
    212 	if err = addInterceptAttempt(stack, options); err != nil {
    213 		return err
    214 	}
    215 	if err = addInterceptExecution(stack, options); err != nil {
    216 		return err
    217 	}
    218 	if err = addInterceptBeforeSerialization(stack, options); err != nil {
    219 		return err
    220 	}
    221 	if err = addInterceptAfterSerialization(stack, options); err != nil {
    222 		return err
    223 	}
    224 	if err = addInterceptBeforeSigning(stack, options); err != nil {
    225 		return err
    226 	}
    227 	if err = addInterceptAfterSigning(stack, options); err != nil {
    228 		return err
    229 	}
    230 	if err = addInterceptTransmit(stack, options); err != nil {
    231 		return err
    232 	}
    233 	if err = addInterceptBeforeDeserialization(stack, options); err != nil {
    234 		return err
    235 	}
    236 	if err = addInterceptAfterDeserialization(stack, options); err != nil {
    237 		return err
    238 	}
    239 	if err = addSpanInitializeStart(stack); err != nil {
    240 		return err
    241 	}
    242 	if err = addSpanInitializeEnd(stack); err != nil {
    243 		return err
    244 	}
    245 	if err = addSpanBuildRequestStart(stack); err != nil {
    246 		return err
    247 	}
    248 	if err = addSpanBuildRequestEnd(stack); err != nil {
    249 		return err
    250 	}
    251 	return nil
    252 }
    253 
    254 func newServiceMetadataMiddleware_opCreateHealthCheck(region string) *awsmiddleware.RegisterServiceMetadata {
    255 	return &awsmiddleware.RegisterServiceMetadata{
    256 		Region:        region,
    257 		ServiceID:     ServiceID,
    258 		OperationName: "CreateHealthCheck",
    259 	}
    260 }