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// Creates a dashboard if it does not already exist, or updates an existing 15// dashboard. If you update a dashboard, the entire contents are replaced with what 16// you specify here. All dashboards in your account are global, not 17// region-specific. A simple way to create a dashboard using PutDashboard is to 18// copy an existing dashboard. To copy an existing dashboard using the console, you 19// can load the dashboard and then use the View/edit source command in the Actions 20// menu to display the JSON block for that dashboard. Another way to copy a 21// dashboard is to use GetDashboard, and then use the data returned within 22// DashboardBody as the template for the new dashboard when you call PutDashboard. 23// When you create a dashboard with PutDashboard, a good practice is to add a text 24// widget at the top of the dashboard with a message that the dashboard was created 25// by script and should not be changed in the console. This message could also 26// point console users to the location of the DashboardBody script or the 27// CloudFormation template used to create the dashboard. 28func (c *Client) PutDashboard(ctx context.Context, params *PutDashboardInput, optFns ...func(*Options)) (*PutDashboardOutput, error) { 29 if params == nil { 30 params = &PutDashboardInput{} 31 } 32 33 result, metadata, err := c.invokeOperation(ctx, "PutDashboard", params, optFns, addOperationPutDashboardMiddlewares) 34 if err != nil { 35 return nil, err 36 } 37 38 out := result.(*PutDashboardOutput) 39 out.ResultMetadata = metadata 40 return out, nil 41} 42 43type PutDashboardInput struct { 44 45 // The detailed information about the dashboard in JSON format, including the 46 // widgets to include and their location on the dashboard. This parameter is 47 // required. For more information about the syntax, see Dashboard Body Structure 48 // and Syntax 49 // (https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html). 50 // 51 // This member is required. 52 DashboardBody *string 53 54 // The name of the dashboard. If a dashboard with this name already exists, this 55 // call modifies that dashboard, replacing its current contents. Otherwise, a new 56 // dashboard is created. The maximum length is 255, and valid characters are A-Z, 57 // a-z, 0-9, "-", and "_". This parameter is required. 58 // 59 // This member is required. 60 DashboardName *string 61} 62 63type PutDashboardOutput struct { 64 65 // If the input for PutDashboard was correct and the dashboard was successfully 66 // created or modified, this result is empty. If this result includes only warning 67 // messages, then the input was valid enough for the dashboard to be created or 68 // modified, but some elements of the dashboard might not render. If this result 69 // includes error messages, the input was not valid and the operation failed. 70 DashboardValidationMessages []types.DashboardValidationMessage 71 72 // Metadata pertaining to the operation's result. 73 ResultMetadata middleware.Metadata 74} 75 76func addOperationPutDashboardMiddlewares(stack *middleware.Stack, options Options) (err error) { 77 err = stack.Serialize.Add(&awsAwsquery_serializeOpPutDashboard{}, middleware.After) 78 if err != nil { 79 return err 80 } 81 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpPutDashboard{}, middleware.After) 82 if err != nil { 83 return err 84 } 85 if err = addSetLoggerMiddleware(stack, options); err != nil { 86 return err 87 } 88 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 89 return err 90 } 91 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 92 return err 93 } 94 if err = addResolveEndpointMiddleware(stack, options); err != nil { 95 return err 96 } 97 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 98 return err 99 } 100 if err = addRetryMiddlewares(stack, options); err != nil { 101 return err 102 } 103 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 104 return err 105 } 106 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 107 return err 108 } 109 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 110 return err 111 } 112 if err = addClientUserAgent(stack); err != nil { 113 return err 114 } 115 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 116 return err 117 } 118 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 119 return err 120 } 121 if err = addOpPutDashboardValidationMiddleware(stack); err != nil { 122 return err 123 } 124 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutDashboard(options.Region), middleware.Before); err != nil { 125 return err 126 } 127 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 128 return err 129 } 130 if err = addResponseErrorMiddleware(stack); err != nil { 131 return err 132 } 133 if err = addRequestResponseLogging(stack, options); err != nil { 134 return err 135 } 136 return nil 137} 138 139func newServiceMetadataMiddleware_opPutDashboard(region string) *awsmiddleware.RegisterServiceMetadata { 140 return &awsmiddleware.RegisterServiceMetadata{ 141 Region: region, 142 ServiceID: ServiceID, 143 SigningName: "monitoring", 144 OperationName: "PutDashboard", 145 } 146} 147