api_op_GetAlarms.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  // Returns information about the configured alarms. Specify an alarm name in your
  15  // request to return information about a specific alarm, or specify a monitored
  16  // resource name to return information about all alarms for a specific resource.
  17  //
  18  // An alarm is used to monitor a single metric for one of your resources. When a
  19  // metric condition is met, the alarm can notify you by email, SMS text message,
  20  // and a banner displayed on the Amazon Lightsail console. For more information,
  21  // see [Alarms in Amazon Lightsail].
  22  //
  23  // [Alarms in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-alarms
  24  func (c *Client) GetAlarms(ctx context.Context, params *GetAlarmsInput, optFns ...func(*Options)) (*GetAlarmsOutput, error) {
  25  	if params == nil {
  26  		params = &GetAlarmsInput{}
  27  	}
  28  
  29  	result, metadata, err := c.invokeOperation(ctx, "GetAlarms", params, optFns, c.addOperationGetAlarmsMiddlewares)
  30  	if err != nil {
  31  		return nil, err
  32  	}
  33  
  34  	out := result.(*GetAlarmsOutput)
  35  	out.ResultMetadata = metadata
  36  	return out, nil
  37  }
  38  
  39  type GetAlarmsInput struct {
  40  
  41  	// The name of the alarm.
  42  	//
  43  	// Specify an alarm name to return information about a specific alarm.
  44  	AlarmName *string
  45  
  46  	// The name of the Lightsail resource being monitored by the alarm.
  47  	//
  48  	// Specify a monitored resource name to return information about all alarms for a
  49  	// specific resource.
  50  	MonitoredResourceName *string
  51  
  52  	// The token to advance to the next page of results from your request.
  53  	//
  54  	// To get a page token, perform an initial GetAlarms request. If your results are
  55  	// paginated, the response will return a next page token that you can specify as
  56  	// the page token in a subsequent request.
  57  	PageToken *string
  58  
  59  	noSmithyDocumentSerde
  60  }
  61  
  62  type GetAlarmsOutput struct {
  63  
  64  	// An array of objects that describe the alarms.
  65  	Alarms []types.Alarm
  66  
  67  	// The token to advance to the next page of results from your request.
  68  	//
  69  	// A next page token is not returned if there are no more results to display.
  70  	//
  71  	// To get the next page of results, perform another GetAlarms request and specify
  72  	// the next page token using the pageToken parameter.
  73  	NextPageToken *string
  74  
  75  	// Metadata pertaining to the operation's result.
  76  	ResultMetadata middleware.Metadata
  77  
  78  	noSmithyDocumentSerde
  79  }
  80  
  81  func (c *Client) addOperationGetAlarmsMiddlewares(stack *middleware.Stack, options Options) (err error) {
  82  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  83  		return err
  84  	}
  85  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetAlarms{}, middleware.After)
  86  	if err != nil {
  87  		return err
  88  	}
  89  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetAlarms{}, middleware.After)
  90  	if err != nil {
  91  		return err
  92  	}
  93  	if err := addProtocolFinalizerMiddlewares(stack, options, "GetAlarms"); err != nil {
  94  		return fmt.Errorf("add protocol finalizers: %v", err)
  95  	}
  96  
  97  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  98  		return err
  99  	}
 100  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 101  		return err
 102  	}
 103  	if err = addClientRequestID(stack); err != nil {
 104  		return err
 105  	}
 106  	if err = addComputeContentLength(stack); err != nil {
 107  		return err
 108  	}
 109  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 110  		return err
 111  	}
 112  	if err = addComputePayloadSHA256(stack); err != nil {
 113  		return err
 114  	}
 115  	if err = addRetry(stack, options); err != nil {
 116  		return err
 117  	}
 118  	if err = addRawResponseToMetadata(stack); err != nil {
 119  		return err
 120  	}
 121  	if err = addRecordResponseTiming(stack); err != nil {
 122  		return err
 123  	}
 124  	if err = addSpanRetryLoop(stack, options); err != nil {
 125  		return err
 126  	}
 127  	if err = addClientUserAgent(stack, options); err != nil {
 128  		return err
 129  	}
 130  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 131  		return err
 132  	}
 133  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 134  		return err
 135  	}
 136  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 137  		return err
 138  	}
 139  	if err = addTimeOffsetBuild(stack, c); err != nil {
 140  		return err
 141  	}
 142  	if err = addUserAgentRetryMode(stack, options); err != nil {
 143  		return err
 144  	}
 145  	if err = addCredentialSource(stack, options); err != nil {
 146  		return err
 147  	}
 148  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetAlarms(options.Region), middleware.Before); err != nil {
 149  		return err
 150  	}
 151  	if err = addRecursionDetection(stack); err != nil {
 152  		return err
 153  	}
 154  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 155  		return err
 156  	}
 157  	if err = addResponseErrorMiddleware(stack); err != nil {
 158  		return err
 159  	}
 160  	if err = addRequestResponseLogging(stack, options); err != nil {
 161  		return err
 162  	}
 163  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 164  		return err
 165  	}
 166  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 167  		return err
 168  	}
 169  	if err = addInterceptAttempt(stack, options); err != nil {
 170  		return err
 171  	}
 172  	if err = addInterceptors(stack, options); err != nil {
 173  		return err
 174  	}
 175  	return nil
 176  }
 177  
 178  func newServiceMetadataMiddleware_opGetAlarms(region string) *awsmiddleware.RegisterServiceMetadata {
 179  	return &awsmiddleware.RegisterServiceMetadata{
 180  		Region:        region,
 181  		ServiceID:     ServiceID,
 182  		OperationName: "GetAlarms",
 183  	}
 184  }
 185