api_op_GetDistributionMetricData.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  // Returns the data points of a specific metric for an Amazon Lightsail content
  16  // delivery network (CDN) distribution.
  17  //
  18  // Metrics report the utilization of your resources, and the error counts
  19  // generated by them. Monitor and collect metric data regularly to maintain the
  20  // reliability, availability, and performance of your resources.
  21  func (c *Client) GetDistributionMetricData(ctx context.Context, params *GetDistributionMetricDataInput, optFns ...func(*Options)) (*GetDistributionMetricDataOutput, error) {
  22  	if params == nil {
  23  		params = &GetDistributionMetricDataInput{}
  24  	}
  25  
  26  	result, metadata, err := c.invokeOperation(ctx, "GetDistributionMetricData", params, optFns, c.addOperationGetDistributionMetricDataMiddlewares)
  27  	if err != nil {
  28  		return nil, err
  29  	}
  30  
  31  	out := result.(*GetDistributionMetricDataOutput)
  32  	out.ResultMetadata = metadata
  33  	return out, nil
  34  }
  35  
  36  type GetDistributionMetricDataInput struct {
  37  
  38  	// The name of the distribution for which to get metric data.
  39  	//
  40  	// Use the GetDistributions action to get a list of distribution names that you
  41  	// can specify.
  42  	//
  43  	// This member is required.
  44  	DistributionName *string
  45  
  46  	// The end of the time interval for which to get metric data.
  47  	//
  48  	// Constraints:
  49  	//
  50  	//   - Specified in Coordinated Universal Time (UTC).
  51  	//
  52  	//   - Specified in the Unix time format.
  53  	//
  54  	// For example, if you wish to use an end time of October 1, 2018, at 9 PM UTC,
  55  	//   specify 1538427600 as the end time.
  56  	//
  57  	// You can convert a human-friendly time to Unix time format using a converter
  58  	// like [Epoch converter].
  59  	//
  60  	// [Epoch converter]: https://www.epochconverter.com/
  61  	//
  62  	// This member is required.
  63  	EndTime *time.Time
  64  
  65  	// The metric for which you want to return information.
  66  	//
  67  	// Valid distribution metric names are listed below, along with the most useful
  68  	// statistics to include in your request, and the published unit value.
  69  	//
  70  	//   - Requests - The total number of viewer requests received by your Lightsail
  71  	//   distribution, for all HTTP methods, and for both HTTP and HTTPS requests.
  72  	//
  73  	// Statistics : The most useful statistic is Sum .
  74  	//
  75  	// Unit : The published unit is None .
  76  	//
  77  	//   - BytesDownloaded - The number of bytes downloaded by viewers for GET, HEAD,
  78  	//   and OPTIONS requests.
  79  	//
  80  	// Statistics : The most useful statistic is Sum .
  81  	//
  82  	// Unit : The published unit is None .
  83  	//
  84  	//   - BytesUploaded - The number of bytes uploaded to your origin by your
  85  	//   Lightsail distribution, using POST and PUT requests.
  86  	//
  87  	// Statistics : The most useful statistic is Sum .
  88  	//
  89  	// Unit : The published unit is None .
  90  	//
  91  	//   - TotalErrorRate - The percentage of all viewer requests for which the
  92  	//   response's HTTP status code was 4xx or 5xx.
  93  	//
  94  	// Statistics : The most useful statistic is Average .
  95  	//
  96  	// Unit : The published unit is Percent .
  97  	//
  98  	//   - 4xxErrorRate - The percentage of all viewer requests for which the
  99  	//   response's HTTP status cod was 4xx. In these cases, the client or client viewer
 100  	//   may have made an error. For example, a status code of 404 (Not Found) means that
 101  	//   the client requested an object that could not be found.
 102  	//
 103  	// Statistics : The most useful statistic is Average .
 104  	//
 105  	// Unit : The published unit is Percent .
 106  	//
 107  	//   - 5xxErrorRate - The percentage of all viewer requests for which the
 108  	//   response's HTTP status code was 5xx. In these cases, the origin server did not
 109  	//   satisfy the requests. For example, a status code of 503 (Service Unavailable)
 110  	//   means that the origin server is currently unavailable.
 111  	//
 112  	// Statistics : The most useful statistic is Average .
 113  	//
 114  	// Unit : The published unit is Percent .
 115  	//
 116  	// This member is required.
 117  	MetricName types.DistributionMetricName
 118  
 119  	// The granularity, in seconds, for the metric data points that will be returned.
 120  	//
 121  	// This member is required.
 122  	Period *int32
 123  
 124  	// The start of the time interval for which to get metric data.
 125  	//
 126  	// Constraints:
 127  	//
 128  	//   - Specified in Coordinated Universal Time (UTC).
 129  	//
 130  	//   - Specified in the Unix time format.
 131  	//
 132  	// For example, if you wish to use a start time of October 1, 2018, at 8 PM UTC,
 133  	//   specify 1538424000 as the start time.
 134  	//
 135  	// You can convert a human-friendly time to Unix time format using a converter
 136  	// like [Epoch converter].
 137  	//
 138  	// [Epoch converter]: https://www.epochconverter.com/
 139  	//
 140  	// This member is required.
 141  	StartTime *time.Time
 142  
 143  	// The statistic for the metric.
 144  	//
 145  	// The following statistics are available:
 146  	//
 147  	//   - Minimum - The lowest value observed during the specified period. Use this
 148  	//   value to determine low volumes of activity for your application.
 149  	//
 150  	//   - Maximum - The highest value observed during the specified period. Use this
 151  	//   value to determine high volumes of activity for your application.
 152  	//
 153  	//   - Sum - All values submitted for the matching metric added together. You can
 154  	//   use this statistic to determine the total volume of a metric.
 155  	//
 156  	//   - Average - The value of Sum / SampleCount during the specified period. By
 157  	//   comparing this statistic with the Minimum and Maximum values, you can determine
 158  	//   the full scope of a metric and how close the average use is to the Minimum and
 159  	//   Maximum values. This comparison helps you to know when to increase or decrease
 160  	//   your resources.
 161  	//
 162  	//   - SampleCount - The count, or number, of data points used for the statistical
 163  	//   calculation.
 164  	//
 165  	// This member is required.
 166  	Statistics []types.MetricStatistic
 167  
 168  	// The unit for the metric data request.
 169  	//
 170  	// Valid units depend on the metric data being requested. For the valid units with
 171  	// each available metric, see the metricName parameter.
 172  	//
 173  	// This member is required.
 174  	Unit types.MetricUnit
 175  
 176  	noSmithyDocumentSerde
 177  }
 178  
 179  type GetDistributionMetricDataOutput struct {
 180  
 181  	// An array of objects that describe the metric data returned.
 182  	MetricData []types.MetricDatapoint
 183  
 184  	// The name of the metric returned.
 185  	MetricName types.DistributionMetricName
 186  
 187  	// Metadata pertaining to the operation's result.
 188  	ResultMetadata middleware.Metadata
 189  
 190  	noSmithyDocumentSerde
 191  }
 192  
 193  func (c *Client) addOperationGetDistributionMetricDataMiddlewares(stack *middleware.Stack, options Options) (err error) {
 194  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 195  		return err
 196  	}
 197  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetDistributionMetricData{}, middleware.After)
 198  	if err != nil {
 199  		return err
 200  	}
 201  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetDistributionMetricData{}, middleware.After)
 202  	if err != nil {
 203  		return err
 204  	}
 205  	if err := addProtocolFinalizerMiddlewares(stack, options, "GetDistributionMetricData"); err != nil {
 206  		return fmt.Errorf("add protocol finalizers: %v", err)
 207  	}
 208  
 209  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 210  		return err
 211  	}
 212  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 213  		return err
 214  	}
 215  	if err = addClientRequestID(stack); err != nil {
 216  		return err
 217  	}
 218  	if err = addComputeContentLength(stack); err != nil {
 219  		return err
 220  	}
 221  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 222  		return err
 223  	}
 224  	if err = addComputePayloadSHA256(stack); err != nil {
 225  		return err
 226  	}
 227  	if err = addRetry(stack, options); err != nil {
 228  		return err
 229  	}
 230  	if err = addRawResponseToMetadata(stack); err != nil {
 231  		return err
 232  	}
 233  	if err = addRecordResponseTiming(stack); err != nil {
 234  		return err
 235  	}
 236  	if err = addSpanRetryLoop(stack, options); err != nil {
 237  		return err
 238  	}
 239  	if err = addClientUserAgent(stack, options); err != nil {
 240  		return err
 241  	}
 242  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 243  		return err
 244  	}
 245  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 246  		return err
 247  	}
 248  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 249  		return err
 250  	}
 251  	if err = addTimeOffsetBuild(stack, c); err != nil {
 252  		return err
 253  	}
 254  	if err = addUserAgentRetryMode(stack, options); err != nil {
 255  		return err
 256  	}
 257  	if err = addCredentialSource(stack, options); err != nil {
 258  		return err
 259  	}
 260  	if err = addOpGetDistributionMetricDataValidationMiddleware(stack); err != nil {
 261  		return err
 262  	}
 263  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetDistributionMetricData(options.Region), middleware.Before); err != nil {
 264  		return err
 265  	}
 266  	if err = addRecursionDetection(stack); err != nil {
 267  		return err
 268  	}
 269  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 270  		return err
 271  	}
 272  	if err = addResponseErrorMiddleware(stack); err != nil {
 273  		return err
 274  	}
 275  	if err = addRequestResponseLogging(stack, options); err != nil {
 276  		return err
 277  	}
 278  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 279  		return err
 280  	}
 281  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 282  		return err
 283  	}
 284  	if err = addInterceptAttempt(stack, options); err != nil {
 285  		return err
 286  	}
 287  	if err = addInterceptors(stack, options); err != nil {
 288  		return err
 289  	}
 290  	return nil
 291  }
 292  
 293  func newServiceMetadataMiddleware_opGetDistributionMetricData(region string) *awsmiddleware.RegisterServiceMetadata {
 294  	return &awsmiddleware.RegisterServiceMetadata{
 295  		Region:        region,
 296  		ServiceID:     ServiceID,
 297  		OperationName: "GetDistributionMetricData",
 298  	}
 299  }
 300