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 // Returns the data points of a specific metric for an Amazon Lightsail bucket.
16 //
17 // Metrics report the utilization of a bucket. View and collect metric data
18 // regularly to monitor the number of objects stored in a bucket (including object
19 // versions) and the storage space used by those objects.
20 func (c *Client) GetBucketMetricData(ctx context.Context, params *GetBucketMetricDataInput, optFns ...func(*Options)) (*GetBucketMetricDataOutput, error) {
21 if params == nil {
22 params = &GetBucketMetricDataInput{}
23 }
24 25 result, metadata, err := c.invokeOperation(ctx, "GetBucketMetricData", params, optFns, c.addOperationGetBucketMetricDataMiddlewares)
26 if err != nil {
27 return nil, err
28 }
29 30 out := result.(*GetBucketMetricDataOutput)
31 out.ResultMetadata = metadata
32 return out, nil
33 }
34 35 type GetBucketMetricDataInput struct {
36 37 // The name of the bucket for which to get metric data.
38 //
39 // This member is required.
40 BucketName *string
41 42 // The timestamp indicating the latest data to be returned.
43 //
44 // This member is required.
45 EndTime *time.Time
46 47 // The metric for which you want to return information.
48 //
49 // Valid bucket metric names are listed below, along with the most useful
50 // statistics to include in your request, and the published unit value.
51 //
52 // These bucket metrics are reported once per day.
53 //
54 // - BucketSizeBytes - The amount of data in bytes stored in a bucket. This value
55 // is calculated by summing the size of all objects in the bucket (including object
56 // versions), including the size of all parts for all incomplete multipart uploads
57 // to the bucket.
58 //
59 // Statistics: The most useful statistic is Maximum .
60 //
61 // Unit: The published unit is Bytes .
62 //
63 // - NumberOfObjects - The total number of objects stored in a bucket. This value
64 // is calculated by counting all objects in the bucket (including object versions)
65 // and the total number of parts for all incomplete multipart uploads to the
66 // bucket.
67 //
68 // Statistics: The most useful statistic is Average .
69 //
70 // Unit: The published unit is Count .
71 //
72 // This member is required.
73 MetricName types.BucketMetricName
74 75 // The granularity, in seconds, of the returned data points.
76 //
77 // Bucket storage metrics are reported once per day. Therefore, you should specify
78 // a period of 86400 seconds, which is the number of seconds in a day.
79 //
80 // This member is required.
81 Period *int32
82 83 // The timestamp indicating the earliest data to be returned.
84 //
85 // This member is required.
86 StartTime *time.Time
87 88 // The statistic for the metric.
89 //
90 // The following statistics are available:
91 //
92 // - Minimum - The lowest value observed during the specified period. Use this
93 // value to determine low volumes of activity for your application.
94 //
95 // - Maximum - The highest value observed during the specified period. Use this
96 // value to determine high volumes of activity for your application.
97 //
98 // - Sum - The sum of all values submitted for the matching metric. You can use
99 // this statistic to determine the total volume of a metric.
100 //
101 // - Average - The value of Sum / SampleCount during the specified period. By
102 // comparing this statistic with the Minimum and Maximum values, you can
103 // determine the full scope of a metric and how close the average use is to the
104 // Minimum and Maximum values. This comparison helps you to know when to increase
105 // or decrease your resources.
106 //
107 // - SampleCount - The count, or number, of data points used for the statistical
108 // calculation.
109 //
110 // This member is required.
111 Statistics []types.MetricStatistic
112 113 // The unit for the metric data request.
114 //
115 // Valid units depend on the metric data being requested. For the valid units with
116 // each available metric, see the metricName parameter.
117 //
118 // This member is required.
119 Unit types.MetricUnit
120 121 noSmithyDocumentSerde
122 }
123 124 type GetBucketMetricDataOutput struct {
125 126 // An array of objects that describe the metric data returned.
127 MetricData []types.MetricDatapoint
128 129 // The name of the metric returned.
130 MetricName types.BucketMetricName
131 132 // Metadata pertaining to the operation's result.
133 ResultMetadata middleware.Metadata
134 135 noSmithyDocumentSerde
136 }
137 138 func (c *Client) addOperationGetBucketMetricDataMiddlewares(stack *middleware.Stack, options Options) (err error) {
139 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
140 return err
141 }
142 err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetBucketMetricData{}, middleware.After)
143 if err != nil {
144 return err
145 }
146 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetBucketMetricData{}, middleware.After)
147 if err != nil {
148 return err
149 }
150 if err := addProtocolFinalizerMiddlewares(stack, options, "GetBucketMetricData"); err != nil {
151 return fmt.Errorf("add protocol finalizers: %v", err)
152 }
153 154 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
155 return err
156 }
157 if err = addSetLoggerMiddleware(stack, options); err != nil {
158 return err
159 }
160 if err = addClientRequestID(stack); err != nil {
161 return err
162 }
163 if err = addComputeContentLength(stack); err != nil {
164 return err
165 }
166 if err = addResolveEndpointMiddleware(stack, options); err != nil {
167 return err
168 }
169 if err = addComputePayloadSHA256(stack); err != nil {
170 return err
171 }
172 if err = addRetry(stack, options); err != nil {
173 return err
174 }
175 if err = addRawResponseToMetadata(stack); err != nil {
176 return err
177 }
178 if err = addRecordResponseTiming(stack); err != nil {
179 return err
180 }
181 if err = addSpanRetryLoop(stack, options); err != nil {
182 return err
183 }
184 if err = addClientUserAgent(stack, options); err != nil {
185 return err
186 }
187 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
188 return err
189 }
190 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
191 return err
192 }
193 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
194 return err
195 }
196 if err = addTimeOffsetBuild(stack, c); err != nil {
197 return err
198 }
199 if err = addUserAgentRetryMode(stack, options); err != nil {
200 return err
201 }
202 if err = addCredentialSource(stack, options); err != nil {
203 return err
204 }
205 if err = addOpGetBucketMetricDataValidationMiddleware(stack); err != nil {
206 return err
207 }
208 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetBucketMetricData(options.Region), middleware.Before); err != nil {
209 return err
210 }
211 if err = addRecursionDetection(stack); err != nil {
212 return err
213 }
214 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
215 return err
216 }
217 if err = addResponseErrorMiddleware(stack); err != nil {
218 return err
219 }
220 if err = addRequestResponseLogging(stack, options); err != nil {
221 return err
222 }
223 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
224 return err
225 }
226 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
227 return err
228 }
229 if err = addInterceptAttempt(stack, options); err != nil {
230 return err
231 }
232 if err = addInterceptors(stack, options); err != nil {
233 return err
234 }
235 return nil
236 }
237 238 func newServiceMetadataMiddleware_opGetBucketMetricData(region string) *awsmiddleware.RegisterServiceMetadata {
239 return &awsmiddleware.RegisterServiceMetadata{
240 Region: region,
241 ServiceID: ServiceID,
242 OperationName: "GetBucketMetricData",
243 }
244 }
245