api_op_UpdateInstanceMetadataOptions.go raw

   1  // Code generated by smithy-go-codegen DO NOT EDIT.
   2  
   3  package lightsail
   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/lightsail/types"
  10  	"github.com/aws/smithy-go/middleware"
  11  	smithyhttp "github.com/aws/smithy-go/transport/http"
  12  )
  13  
  14  // Modifies the Amazon Lightsail instance metadata parameters on a running or
  15  // stopped instance. When you modify the parameters on a running instance, the
  16  // GetInstance or GetInstances API operation initially responds with a state of
  17  // pending . After the parameter modifications are successfully applied, the state
  18  // changes to applied in subsequent GetInstance or GetInstances API calls. For
  19  // more information, see [Use IMDSv2 with an Amazon Lightsail instance]in the Amazon Lightsail Developer Guide.
  20  //
  21  // [Use IMDSv2 with an Amazon Lightsail instance]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-configuring-instance-metadata-service
  22  func (c *Client) UpdateInstanceMetadataOptions(ctx context.Context, params *UpdateInstanceMetadataOptionsInput, optFns ...func(*Options)) (*UpdateInstanceMetadataOptionsOutput, error) {
  23  	if params == nil {
  24  		params = &UpdateInstanceMetadataOptionsInput{}
  25  	}
  26  
  27  	result, metadata, err := c.invokeOperation(ctx, "UpdateInstanceMetadataOptions", params, optFns, c.addOperationUpdateInstanceMetadataOptionsMiddlewares)
  28  	if err != nil {
  29  		return nil, err
  30  	}
  31  
  32  	out := result.(*UpdateInstanceMetadataOptionsOutput)
  33  	out.ResultMetadata = metadata
  34  	return out, nil
  35  }
  36  
  37  type UpdateInstanceMetadataOptionsInput struct {
  38  
  39  	// The name of the instance for which to update metadata parameters.
  40  	//
  41  	// This member is required.
  42  	InstanceName *string
  43  
  44  	// Enables or disables the HTTP metadata endpoint on your instances. If this
  45  	// parameter is not specified, the existing state is maintained.
  46  	//
  47  	// If you specify a value of disabled , you cannot access your instance metadata.
  48  	HttpEndpoint types.HttpEndpoint
  49  
  50  	// Enables or disables the IPv6 endpoint for the instance metadata service. This
  51  	// setting applies only when the HTTP metadata endpoint is enabled.
  52  	//
  53  	// This parameter is available only for instances in the Europe (Stockholm) Amazon
  54  	// Web Services Region ( eu-north-1 ).
  55  	HttpProtocolIpv6 types.HttpProtocolIpv6
  56  
  57  	// The desired HTTP PUT response hop limit for instance metadata requests. A
  58  	// larger number means that the instance metadata requests can travel farther. If
  59  	// no parameter is specified, the existing state is maintained.
  60  	HttpPutResponseHopLimit *int32
  61  
  62  	// The state of token usage for your instance metadata requests. If the parameter
  63  	// is not specified in the request, the default state is optional .
  64  	//
  65  	// If the state is optional , you can choose whether to retrieve instance metadata
  66  	// with a signed token header on your request. If you retrieve the IAM role
  67  	// credentials without a token, the version 1.0 role credentials are returned. If
  68  	// you retrieve the IAM role credentials by using a valid signed token, the version
  69  	// 2.0 role credentials are returned.
  70  	//
  71  	// If the state is required , you must send a signed token header with all instance
  72  	// metadata retrieval requests. In this state, retrieving the IAM role credential
  73  	// always returns the version 2.0 credentials. The version 1.0 credentials are not
  74  	// available.
  75  	HttpTokens types.HttpTokens
  76  
  77  	noSmithyDocumentSerde
  78  }
  79  
  80  type UpdateInstanceMetadataOptionsOutput struct {
  81  
  82  	// An array of objects that describe the result of the action, such as the status
  83  	// of the request, the timestamp of the request, and the resources affected by the
  84  	// request.
  85  	Operation *types.Operation
  86  
  87  	// Metadata pertaining to the operation's result.
  88  	ResultMetadata middleware.Metadata
  89  
  90  	noSmithyDocumentSerde
  91  }
  92  
  93  func (c *Client) addOperationUpdateInstanceMetadataOptionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
  94  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  95  		return err
  96  	}
  97  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateInstanceMetadataOptions{}, middleware.After)
  98  	if err != nil {
  99  		return err
 100  	}
 101  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateInstanceMetadataOptions{}, middleware.After)
 102  	if err != nil {
 103  		return err
 104  	}
 105  	if err := addProtocolFinalizerMiddlewares(stack, options, "UpdateInstanceMetadataOptions"); err != nil {
 106  		return fmt.Errorf("add protocol finalizers: %v", err)
 107  	}
 108  
 109  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 110  		return err
 111  	}
 112  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 113  		return err
 114  	}
 115  	if err = addClientRequestID(stack); err != nil {
 116  		return err
 117  	}
 118  	if err = addComputeContentLength(stack); err != nil {
 119  		return err
 120  	}
 121  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 122  		return err
 123  	}
 124  	if err = addComputePayloadSHA256(stack); err != nil {
 125  		return err
 126  	}
 127  	if err = addRetry(stack, options); err != nil {
 128  		return err
 129  	}
 130  	if err = addRawResponseToMetadata(stack); err != nil {
 131  		return err
 132  	}
 133  	if err = addRecordResponseTiming(stack); err != nil {
 134  		return err
 135  	}
 136  	if err = addSpanRetryLoop(stack, options); err != nil {
 137  		return err
 138  	}
 139  	if err = addClientUserAgent(stack, options); err != nil {
 140  		return err
 141  	}
 142  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 143  		return err
 144  	}
 145  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 146  		return err
 147  	}
 148  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 149  		return err
 150  	}
 151  	if err = addTimeOffsetBuild(stack, c); err != nil {
 152  		return err
 153  	}
 154  	if err = addUserAgentRetryMode(stack, options); err != nil {
 155  		return err
 156  	}
 157  	if err = addCredentialSource(stack, options); err != nil {
 158  		return err
 159  	}
 160  	if err = addOpUpdateInstanceMetadataOptionsValidationMiddleware(stack); err != nil {
 161  		return err
 162  	}
 163  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateInstanceMetadataOptions(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  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 182  		return err
 183  	}
 184  	if err = addInterceptAttempt(stack, options); err != nil {
 185  		return err
 186  	}
 187  	if err = addInterceptors(stack, options); err != nil {
 188  		return err
 189  	}
 190  	return nil
 191  }
 192  
 193  func newServiceMetadataMiddleware_opUpdateInstanceMetadataOptions(region string) *awsmiddleware.RegisterServiceMetadata {
 194  	return &awsmiddleware.RegisterServiceMetadata{
 195  		Region:        region,
 196  		ServiceID:     ServiceID,
 197  		OperationName: "UpdateInstanceMetadataOptions",
 198  	}
 199  }
 200