1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/ec2/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Allocates a Dedicated Host to your account. At a minimum, specify the supported 15// instance type or instance family, the Availability Zone in which to allocate the 16// host, and the number of hosts to allocate. 17func (c *Client) AllocateHosts(ctx context.Context, params *AllocateHostsInput, optFns ...func(*Options)) (*AllocateHostsOutput, error) { 18 if params == nil { 19 params = &AllocateHostsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "AllocateHosts", params, optFns, addOperationAllocateHostsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*AllocateHostsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type AllocateHostsInput struct { 33 34 // The Availability Zone in which to allocate the Dedicated Host. 35 // 36 // This member is required. 37 AvailabilityZone *string 38 39 // The number of Dedicated Hosts to allocate to your account with these parameters. 40 // 41 // This member is required. 42 Quantity int32 43 44 // Indicates whether the host accepts any untargeted instance launches that match 45 // its instance type configuration, or if it only accepts Host tenancy instance 46 // launches that specify its unique host ID. For more information, see 47 // Understanding auto-placement and affinity 48 // (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/how-dedicated-hosts-work.html#dedicated-hosts-understanding) 49 // in the Amazon EC2 User Guide. Default: on 50 AutoPlacement types.AutoPlacement 51 52 // Unique, case-sensitive identifier that you provide to ensure the idempotency of 53 // the request. For more information, see Ensuring Idempotency 54 // (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html). 55 ClientToken *string 56 57 // Indicates whether to enable or disable host recovery for the Dedicated Host. 58 // Host recovery is disabled by default. For more information, see Host recovery 59 // (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-hosts-recovery.html) 60 // in the Amazon EC2 User Guide. Default: off 61 HostRecovery types.HostRecovery 62 63 // Specifies the instance family to be supported by the Dedicated Hosts. If you 64 // specify an instance family, the Dedicated Hosts support multiple instance types 65 // within that instance family. If you want the Dedicated Hosts to support a 66 // specific instance type only, omit this parameter and specify InstanceType 67 // instead. You cannot specify InstanceFamily and InstanceType in the same request. 68 InstanceFamily *string 69 70 // Specifies the instance type to be supported by the Dedicated Hosts. If you 71 // specify an instance type, the Dedicated Hosts support instances of the specified 72 // instance type only. If you want the Dedicated Hosts to support multiple instance 73 // types in a specific instance family, omit this parameter and specify 74 // InstanceFamily instead. You cannot specify InstanceType and InstanceFamily in 75 // the same request. 76 InstanceType *string 77 78 // The tags to apply to the Dedicated Host during creation. 79 TagSpecifications []types.TagSpecification 80} 81 82// Contains the output of AllocateHosts. 83type AllocateHostsOutput struct { 84 85 // The ID of the allocated Dedicated Host. This is used to launch an instance onto 86 // a specific host. 87 HostIds []string 88 89 // Metadata pertaining to the operation's result. 90 ResultMetadata middleware.Metadata 91} 92 93func addOperationAllocateHostsMiddlewares(stack *middleware.Stack, options Options) (err error) { 94 err = stack.Serialize.Add(&awsEc2query_serializeOpAllocateHosts{}, middleware.After) 95 if err != nil { 96 return err 97 } 98 err = stack.Deserialize.Add(&awsEc2query_deserializeOpAllocateHosts{}, 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 = addOpAllocateHostsValidationMiddleware(stack); err != nil { 139 return err 140 } 141 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAllocateHosts(options.Region), middleware.Before); err != nil { 142 return err 143 } 144 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 145 return err 146 } 147 if err = addResponseErrorMiddleware(stack); err != nil { 148 return err 149 } 150 if err = addRequestResponseLogging(stack, options); err != nil { 151 return err 152 } 153 return nil 154} 155 156func newServiceMetadataMiddleware_opAllocateHosts(region string) *awsmiddleware.RegisterServiceMetadata { 157 return &awsmiddleware.RegisterServiceMetadata{ 158 Region: region, 159 ServiceID: ServiceID, 160 SigningName: "ec2", 161 OperationName: "AllocateHosts", 162 } 163} 164