...
1 package imds
2
3 import (
4 "context"
5 "fmt"
6 "io"
7
8 "github.com/aws/smithy-go/middleware"
9 smithyhttp "github.com/aws/smithy-go/transport/http"
10 )
11
12 const getMetadataPath = "/latest/meta-data"
13
14
15
16
17 func (c *Client) GetMetadata(ctx context.Context, params *GetMetadataInput, optFns ...func(*Options)) (*GetMetadataOutput, error) {
18 if params == nil {
19 params = &GetMetadataInput{}
20 }
21
22 result, metadata, err := c.invokeOperation(ctx, "GetMetadata", params, optFns,
23 addGetMetadataMiddleware,
24 )
25 if err != nil {
26 return nil, err
27 }
28
29 out := result.(*GetMetadataOutput)
30 out.ResultMetadata = metadata
31 return out, nil
32 }
33
34
35
36 type GetMetadataInput struct {
37
38
39
40
41
42
43
44
45 Path string
46 }
47
48
49
50 type GetMetadataOutput struct {
51 Content io.ReadCloser
52
53 ResultMetadata middleware.Metadata
54 }
55
56 func addGetMetadataMiddleware(stack *middleware.Stack, options Options) error {
57 return addAPIRequestMiddleware(stack,
58 options,
59 "GetMetadata",
60 buildGetMetadataPath,
61 buildGetMetadataOutput)
62 }
63
64 func buildGetMetadataPath(params interface{}) (string, error) {
65 p, ok := params.(*GetMetadataInput)
66 if !ok {
67 return "", fmt.Errorf("unknown parameter type %T", params)
68 }
69
70 return appendURIPath(getMetadataPath, p.Path), nil
71 }
72
73 func buildGetMetadataOutput(resp *smithyhttp.Response) (interface{}, error) {
74 return &GetMetadataOutput{
75 Content: resp.Body,
76 }, nil
77 }
78
View as plain text