File: api_op_GetUserData.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.17.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 384,244 kB
  • sloc: java: 13,538; makefile: 400; sh: 137
file content (60 lines) | stat: -rw-r--r-- 1,518 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package imds

import (
	"context"
	"io"

	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

const getUserDataPath = "/latest/user-data"

// GetUserData uses the path provided to request information from the EC2
// instance metadata service for dynamic data. The content will be returned
// as a string, or error if the request failed.
func (c *Client) GetUserData(ctx context.Context, params *GetUserDataInput, optFns ...func(*Options)) (*GetUserDataOutput, error) {
	if params == nil {
		params = &GetUserDataInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "GetUserData", params, optFns,
		addGetUserDataMiddleware,
	)
	if err != nil {
		return nil, err
	}

	out := result.(*GetUserDataOutput)
	out.ResultMetadata = metadata
	return out, nil
}

// GetUserDataInput provides the input parameters for the GetUserData
// operation.
type GetUserDataInput struct{}

// GetUserDataOutput provides the output parameters for the GetUserData
// operation.
type GetUserDataOutput struct {
	Content io.ReadCloser

	ResultMetadata middleware.Metadata
}

func addGetUserDataMiddleware(stack *middleware.Stack, options Options) error {
	return addAPIRequestMiddleware(stack,
		options,
		buildGetUserDataPath,
		buildGetUserDataOutput)
}

func buildGetUserDataPath(params interface{}) (string, error) {
	return getUserDataPath, nil
}

func buildGetUserDataOutput(resp *smithyhttp.Response) (interface{}, error) {
	return &GetUserDataOutput{
		Content: resp.Body,
	}, nil
}