1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package cloudwatch 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Retrieves the alarms for the specified metric. To filter the results, specify a 15// statistic, period, or unit. This operation retrieves only standard alarms that 16// are based on the specified metric. It does not return alarms based on math 17// expressions that use the specified metric, or composite alarms that use the 18// specified metric. 19func (c *Client) DescribeAlarmsForMetric(ctx context.Context, params *DescribeAlarmsForMetricInput, optFns ...func(*Options)) (*DescribeAlarmsForMetricOutput, error) { 20 if params == nil { 21 params = &DescribeAlarmsForMetricInput{} 22 } 23 24 result, metadata, err := c.invokeOperation(ctx, "DescribeAlarmsForMetric", params, optFns, addOperationDescribeAlarmsForMetricMiddlewares) 25 if err != nil { 26 return nil, err 27 } 28 29 out := result.(*DescribeAlarmsForMetricOutput) 30 out.ResultMetadata = metadata 31 return out, nil 32} 33 34type DescribeAlarmsForMetricInput struct { 35 36 // The name of the metric. 37 // 38 // This member is required. 39 MetricName *string 40 41 // The namespace of the metric. 42 // 43 // This member is required. 44 Namespace *string 45 46 // The dimensions associated with the metric. If the metric has any associated 47 // dimensions, you must specify them in order for the call to succeed. 48 Dimensions []types.Dimension 49 50 // The percentile statistic for the metric. Specify a value between p0.0 and p100. 51 ExtendedStatistic *string 52 53 // The period, in seconds, over which the statistic is applied. 54 Period *int32 55 56 // The statistic for the metric, other than percentiles. For percentile statistics, 57 // use ExtendedStatistics. 58 Statistic types.Statistic 59 60 // The unit for the metric. 61 Unit types.StandardUnit 62} 63 64type DescribeAlarmsForMetricOutput struct { 65 66 // The information for each alarm with the specified metric. 67 MetricAlarms []types.MetricAlarm 68 69 // Metadata pertaining to the operation's result. 70 ResultMetadata middleware.Metadata 71} 72 73func addOperationDescribeAlarmsForMetricMiddlewares(stack *middleware.Stack, options Options) (err error) { 74 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeAlarmsForMetric{}, middleware.After) 75 if err != nil { 76 return err 77 } 78 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeAlarmsForMetric{}, middleware.After) 79 if err != nil { 80 return err 81 } 82 if err = addSetLoggerMiddleware(stack, options); err != nil { 83 return err 84 } 85 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 86 return err 87 } 88 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 89 return err 90 } 91 if err = addResolveEndpointMiddleware(stack, options); err != nil { 92 return err 93 } 94 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 95 return err 96 } 97 if err = addRetryMiddlewares(stack, options); err != nil { 98 return err 99 } 100 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 104 return err 105 } 106 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 107 return err 108 } 109 if err = addClientUserAgent(stack); err != nil { 110 return err 111 } 112 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 113 return err 114 } 115 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 116 return err 117 } 118 if err = addOpDescribeAlarmsForMetricValidationMiddleware(stack); err != nil { 119 return err 120 } 121 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeAlarmsForMetric(options.Region), middleware.Before); err != nil { 122 return err 123 } 124 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 125 return err 126 } 127 if err = addResponseErrorMiddleware(stack); err != nil { 128 return err 129 } 130 if err = addRequestResponseLogging(stack, options); err != nil { 131 return err 132 } 133 return nil 134} 135 136func newServiceMetadataMiddleware_opDescribeAlarmsForMetric(region string) *awsmiddleware.RegisterServiceMetadata { 137 return &awsmiddleware.RegisterServiceMetadata{ 138 Region: region, 139 ServiceID: ServiceID, 140 SigningName: "monitoring", 141 OperationName: "DescribeAlarmsForMetric", 142 } 143} 144