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// Modify the auto-placement setting of a Dedicated Host. When auto-placement is
15// enabled, any instances that you launch with a tenancy of host but without a
16// specific host ID are placed onto any available Dedicated Host in your account
17// that has auto-placement enabled. When auto-placement is disabled, you need to
18// provide a host ID to have the instance launch onto a specific host. If no host
19// ID is provided, the instance is launched onto a suitable host with
20// auto-placement enabled. You can also use this API action to modify a Dedicated
21// Host to support either multiple instance types in an instance family, or to
22// support a specific instance type only.
23func (c *Client) ModifyHosts(ctx context.Context, params *ModifyHostsInput, optFns ...func(*Options)) (*ModifyHostsOutput, error) {
24	if params == nil {
25		params = &ModifyHostsInput{}
26	}
27
28	result, metadata, err := c.invokeOperation(ctx, "ModifyHosts", params, optFns, addOperationModifyHostsMiddlewares)
29	if err != nil {
30		return nil, err
31	}
32
33	out := result.(*ModifyHostsOutput)
34	out.ResultMetadata = metadata
35	return out, nil
36}
37
38type ModifyHostsInput struct {
39
40	// The IDs of the Dedicated Hosts to modify.
41	//
42	// This member is required.
43	HostIds []string
44
45	// Specify whether to enable or disable auto-placement.
46	AutoPlacement types.AutoPlacement
47
48	// Indicates whether to enable or disable host recovery for the Dedicated Host. For
49	// more information, see  Host recovery
50	// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-hosts-recovery.html)
51	// in the Amazon EC2 User Guide.
52	HostRecovery types.HostRecovery
53
54	// Specifies the instance family to be supported by the Dedicated Host. Specify
55	// this parameter to modify a Dedicated Host to support multiple instance types
56	// within its current instance family. If you want to modify a Dedicated Host to
57	// support a specific instance type only, omit this parameter and specify
58	// InstanceType instead. You cannot specify InstanceFamily and InstanceType in the
59	// same request.
60	InstanceFamily *string
61
62	// Specifies the instance type to be supported by the Dedicated Host. Specify this
63	// parameter to modify a Dedicated Host to support only a specific instance type.
64	// If you want to modify a Dedicated Host to support multiple instance types in its
65	// current instance family, omit this parameter and specify InstanceFamily instead.
66	// You cannot specify InstanceType and InstanceFamily in the same request.
67	InstanceType *string
68}
69
70type ModifyHostsOutput struct {
71
72	// The IDs of the Dedicated Hosts that were successfully modified.
73	Successful []string
74
75	// The IDs of the Dedicated Hosts that could not be modified. Check whether the
76	// setting you requested can be used.
77	Unsuccessful []types.UnsuccessfulItem
78
79	// Metadata pertaining to the operation's result.
80	ResultMetadata middleware.Metadata
81}
82
83func addOperationModifyHostsMiddlewares(stack *middleware.Stack, options Options) (err error) {
84	err = stack.Serialize.Add(&awsEc2query_serializeOpModifyHosts{}, middleware.After)
85	if err != nil {
86		return err
87	}
88	err = stack.Deserialize.Add(&awsEc2query_deserializeOpModifyHosts{}, middleware.After)
89	if err != nil {
90		return err
91	}
92	if err = addSetLoggerMiddleware(stack, options); err != nil {
93		return err
94	}
95	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
96		return err
97	}
98	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
99		return err
100	}
101	if err = addResolveEndpointMiddleware(stack, options); err != nil {
102		return err
103	}
104	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
105		return err
106	}
107	if err = addRetryMiddlewares(stack, options); err != nil {
108		return err
109	}
110	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
111		return err
112	}
113	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
117		return err
118	}
119	if err = addClientUserAgent(stack); err != nil {
120		return err
121	}
122	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
126		return err
127	}
128	if err = addOpModifyHostsValidationMiddleware(stack); err != nil {
129		return err
130	}
131	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opModifyHosts(options.Region), middleware.Before); err != nil {
132		return err
133	}
134	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
135		return err
136	}
137	if err = addResponseErrorMiddleware(stack); err != nil {
138		return err
139	}
140	if err = addRequestResponseLogging(stack, options); err != nil {
141		return err
142	}
143	return nil
144}
145
146func newServiceMetadataMiddleware_opModifyHosts(region string) *awsmiddleware.RegisterServiceMetadata {
147	return &awsmiddleware.RegisterServiceMetadata{
148		Region:        region,
149		ServiceID:     ServiceID,
150		SigningName:   "ec2",
151		OperationName: "ModifyHosts",
152	}
153}
154