src

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

api_op_CreateHealthCheck.go (7231B)


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