api_op_TestAlarm.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  )
  13  
  14  // Tests an alarm by displaying a banner on the Amazon Lightsail console. If a
  15  // notification trigger is configured for the specified alarm, the test also sends
  16  // a notification to the notification protocol ( Email and/or SMS ) configured for
  17  // the alarm.
  18  //
  19  // An alarm is used to monitor a single metric for one of your resources. When a
  20  // metric condition is met, the alarm can notify you by email, SMS text message,
  21  // and a banner displayed on the Amazon Lightsail console. For more information,
  22  // see [Alarms in Amazon Lightsail].
  23  //
  24  // [Alarms in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-alarms
  25  func (c *Client) TestAlarm(ctx context.Context, params *TestAlarmInput, optFns ...func(*Options)) (*TestAlarmOutput, error) {
  26  	if params == nil {
  27  		params = &TestAlarmInput{}
  28  	}
  29  
  30  	result, metadata, err := c.invokeOperation(ctx, "TestAlarm", params, optFns, c.addOperationTestAlarmMiddlewares)
  31  	if err != nil {
  32  		return nil, err
  33  	}
  34  
  35  	out := result.(*TestAlarmOutput)
  36  	out.ResultMetadata = metadata
  37  	return out, nil
  38  }
  39  
  40  type TestAlarmInput struct {
  41  
  42  	// The name of the alarm to test.
  43  	//
  44  	// This member is required.
  45  	AlarmName *string
  46  
  47  	// The alarm state to test.
  48  	//
  49  	// An alarm has the following possible states that can be tested:
  50  	//
  51  	//   - ALARM - The metric is outside of the defined threshold.
  52  	//
  53  	//   - INSUFFICIENT_DATA - The alarm has just started, the metric is not available,
  54  	//   or not enough data is available for the metric to determine the alarm state.
  55  	//
  56  	//   - OK - The metric is within the defined threshold.
  57  	//
  58  	// This member is required.
  59  	State types.AlarmState
  60  
  61  	noSmithyDocumentSerde
  62  }
  63  
  64  type TestAlarmOutput struct {
  65  
  66  	// An array of objects that describe the result of the action, such as the status
  67  	// of the request, the timestamp of the request, and the resources affected by the
  68  	// request.
  69  	Operations []types.Operation
  70  
  71  	// Metadata pertaining to the operation's result.
  72  	ResultMetadata middleware.Metadata
  73  
  74  	noSmithyDocumentSerde
  75  }
  76  
  77  func (c *Client) addOperationTestAlarmMiddlewares(stack *middleware.Stack, options Options) (err error) {
  78  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  79  		return err
  80  	}
  81  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpTestAlarm{}, middleware.After)
  82  	if err != nil {
  83  		return err
  84  	}
  85  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpTestAlarm{}, middleware.After)
  86  	if err != nil {
  87  		return err
  88  	}
  89  	if err := addProtocolFinalizerMiddlewares(stack, options, "TestAlarm"); err != nil {
  90  		return fmt.Errorf("add protocol finalizers: %v", err)
  91  	}
  92  
  93  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  94  		return err
  95  	}
  96  	if err = addSetLoggerMiddleware(stack, options); err != nil {
  97  		return err
  98  	}
  99  	if err = addClientRequestID(stack); err != nil {
 100  		return err
 101  	}
 102  	if err = addComputeContentLength(stack); err != nil {
 103  		return err
 104  	}
 105  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 106  		return err
 107  	}
 108  	if err = addComputePayloadSHA256(stack); err != nil {
 109  		return err
 110  	}
 111  	if err = addRetry(stack, options); err != nil {
 112  		return err
 113  	}
 114  	if err = addRawResponseToMetadata(stack); err != nil {
 115  		return err
 116  	}
 117  	if err = addRecordResponseTiming(stack); err != nil {
 118  		return err
 119  	}
 120  	if err = addSpanRetryLoop(stack, options); err != nil {
 121  		return err
 122  	}
 123  	if err = addClientUserAgent(stack, options); err != nil {
 124  		return err
 125  	}
 126  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 127  		return err
 128  	}
 129  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 130  		return err
 131  	}
 132  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 133  		return err
 134  	}
 135  	if err = addTimeOffsetBuild(stack, c); err != nil {
 136  		return err
 137  	}
 138  	if err = addUserAgentRetryMode(stack, options); err != nil {
 139  		return err
 140  	}
 141  	if err = addCredentialSource(stack, options); err != nil {
 142  		return err
 143  	}
 144  	if err = addOpTestAlarmValidationMiddleware(stack); err != nil {
 145  		return err
 146  	}
 147  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opTestAlarm(options.Region), middleware.Before); err != nil {
 148  		return err
 149  	}
 150  	if err = addRecursionDetection(stack); err != nil {
 151  		return err
 152  	}
 153  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 154  		return err
 155  	}
 156  	if err = addResponseErrorMiddleware(stack); err != nil {
 157  		return err
 158  	}
 159  	if err = addRequestResponseLogging(stack, options); err != nil {
 160  		return err
 161  	}
 162  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 163  		return err
 164  	}
 165  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 166  		return err
 167  	}
 168  	if err = addInterceptAttempt(stack, options); err != nil {
 169  		return err
 170  	}
 171  	if err = addInterceptors(stack, options); err != nil {
 172  		return err
 173  	}
 174  	return nil
 175  }
 176  
 177  func newServiceMetadataMiddleware_opTestAlarm(region string) *awsmiddleware.RegisterServiceMetadata {
 178  	return &awsmiddleware.RegisterServiceMetadata{
 179  		Region:        region,
 180  		ServiceID:     ServiceID,
 181  		OperationName: "TestAlarm",
 182  	}
 183  }
 184