api_op_GetCostEstimate.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 "time"
13 )
14
15 // Retrieves information about the cost estimate for a specified resource. A cost
16 // estimate will not generate for a resource that has been deleted.
17 func (c *Client) GetCostEstimate(ctx context.Context, params *GetCostEstimateInput, optFns ...func(*Options)) (*GetCostEstimateOutput, error) {
18 if params == nil {
19 params = &GetCostEstimateInput{}
20 }
21
22 result, metadata, err := c.invokeOperation(ctx, "GetCostEstimate", params, optFns, c.addOperationGetCostEstimateMiddlewares)
23 if err != nil {
24 return nil, err
25 }
26
27 out := result.(*GetCostEstimateOutput)
28 out.ResultMetadata = metadata
29 return out, nil
30 }
31
32 type GetCostEstimateInput struct {
33
34 // The cost estimate end time.
35 //
36 // Constraints:
37 //
38 // - Specified in Coordinated Universal Time (UTC).
39 //
40 // - Specified in the Unix time format.
41 //
42 // For example, if you want to use an end time of October 1, 2018, at 9 PM UTC,
43 // specify 1538427600 as the end time.
44 //
45 // You can convert a human-friendly time to Unix time format using a converter
46 // like [Epoch converter].
47 //
48 // [Epoch converter]: https://www.epochconverter.com/
49 //
50 // This member is required.
51 EndTime *time.Time
52
53 // The resource name.
54 //
55 // This member is required.
56 ResourceName *string
57
58 // The cost estimate start time.
59 //
60 // Constraints:
61 //
62 // - Specified in Coordinated Universal Time (UTC).
63 //
64 // - Specified in the Unix time format.
65 //
66 // For example, if you want to use a start time of October 1, 2018, at 8 PM UTC,
67 // specify 1538424000 as the start time.
68 //
69 // You can convert a human-friendly time to Unix time format using a converter
70 // like [Epoch converter].
71 //
72 // [Epoch converter]: https://www.epochconverter.com/
73 //
74 // This member is required.
75 StartTime *time.Time
76
77 noSmithyDocumentSerde
78 }
79
80 type GetCostEstimateOutput struct {
81
82 // Returns the estimate's forecasted cost or usage.
83 ResourcesBudgetEstimate []types.ResourceBudgetEstimate
84
85 // Metadata pertaining to the operation's result.
86 ResultMetadata middleware.Metadata
87
88 noSmithyDocumentSerde
89 }
90
91 func (c *Client) addOperationGetCostEstimateMiddlewares(stack *middleware.Stack, options Options) (err error) {
92 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
93 return err
94 }
95 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetCostEstimate{}, middleware.After)
96 if err != nil {
97 return err
98 }
99 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetCostEstimate{}, middleware.After)
100 if err != nil {
101 return err
102 }
103 if err := addProtocolFinalizerMiddlewares(stack, options, "GetCostEstimate"); err != nil {
104 return fmt.Errorf("add protocol finalizers: %v", err)
105 }
106
107 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
108 return err
109 }
110 if err = addSetLoggerMiddleware(stack, options); err != nil {
111 return err
112 }
113 if err = addClientRequestID(stack); err != nil {
114 return err
115 }
116 if err = addComputeContentLength(stack); err != nil {
117 return err
118 }
119 if err = addResolveEndpointMiddleware(stack, options); err != nil {
120 return err
121 }
122 if err = addComputePayloadSHA256(stack); err != nil {
123 return err
124 }
125 if err = addRetry(stack, options); err != nil {
126 return err
127 }
128 if err = addRawResponseToMetadata(stack); err != nil {
129 return err
130 }
131 if err = addRecordResponseTiming(stack); err != nil {
132 return err
133 }
134 if err = addSpanRetryLoop(stack, options); err != nil {
135 return err
136 }
137 if err = addClientUserAgent(stack, options); err != nil {
138 return err
139 }
140 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
141 return err
142 }
143 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
144 return err
145 }
146 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
147 return err
148 }
149 if err = addTimeOffsetBuild(stack, c); err != nil {
150 return err
151 }
152 if err = addUserAgentRetryMode(stack, options); err != nil {
153 return err
154 }
155 if err = addCredentialSource(stack, options); err != nil {
156 return err
157 }
158 if err = addOpGetCostEstimateValidationMiddleware(stack); err != nil {
159 return err
160 }
161 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetCostEstimate(options.Region), middleware.Before); err != nil {
162 return err
163 }
164 if err = addRecursionDetection(stack); err != nil {
165 return err
166 }
167 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
168 return err
169 }
170 if err = addResponseErrorMiddleware(stack); err != nil {
171 return err
172 }
173 if err = addRequestResponseLogging(stack, options); err != nil {
174 return err
175 }
176 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
177 return err
178 }
179 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
180 return err
181 }
182 if err = addInterceptAttempt(stack, options); err != nil {
183 return err
184 }
185 if err = addInterceptors(stack, options); err != nil {
186 return err
187 }
188 return nil
189 }
190
191 func newServiceMetadataMiddleware_opGetCostEstimate(region string) *awsmiddleware.RegisterServiceMetadata {
192 return &awsmiddleware.RegisterServiceMetadata{
193 Region: region,
194 ServiceID: ServiceID,
195 OperationName: "GetCostEstimate",
196 }
197 }
198