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, c.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 noSmithyDocumentSerde 63} 64 65type PutDashboardOutput struct { 66 67 // If the input for PutDashboard was correct and the dashboard was successfully 68 // created or modified, this result is empty. If this result includes only warning 69 // messages, then the input was valid enough for the dashboard to be created or 70 // modified, but some elements of the dashboard might not render. If this result 71 // includes error messages, the input was not valid and the operation failed. 72 DashboardValidationMessages []types.DashboardValidationMessage 73 74 // Metadata pertaining to the operation's result. 75 ResultMetadata middleware.Metadata 76 77 noSmithyDocumentSerde 78} 79 80func (c *Client) addOperationPutDashboardMiddlewares(stack *middleware.Stack, options Options) (err error) { 81 err = stack.Serialize.Add(&awsAwsquery_serializeOpPutDashboard{}, middleware.After) 82 if err != nil { 83 return err 84 } 85 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpPutDashboard{}, middleware.After) 86 if err != nil { 87 return err 88 } 89 if err = addSetLoggerMiddleware(stack, options); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 93 return err 94 } 95 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 96 return err 97 } 98 if err = addResolveEndpointMiddleware(stack, options); err != nil { 99 return err 100 } 101 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 102 return err 103 } 104 if err = addRetryMiddlewares(stack, options); err != nil { 105 return err 106 } 107 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 108 return err 109 } 110 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 111 return err 112 } 113 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 114 return err 115 } 116 if err = addClientUserAgent(stack); err != nil { 117 return err 118 } 119 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 120 return err 121 } 122 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addOpPutDashboardValidationMiddleware(stack); err != nil { 126 return err 127 } 128 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutDashboard(options.Region), middleware.Before); err != nil { 129 return err 130 } 131 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 132 return err 133 } 134 if err = addResponseErrorMiddleware(stack); err != nil { 135 return err 136 } 137 if err = addRequestResponseLogging(stack, options); err != nil { 138 return err 139 } 140 return nil 141} 142 143func newServiceMetadataMiddleware_opPutDashboard(region string) *awsmiddleware.RegisterServiceMetadata { 144 return &awsmiddleware.RegisterServiceMetadata{ 145 Region: region, 146 ServiceID: ServiceID, 147 SigningName: "monitoring", 148 OperationName: "PutDashboard", 149 } 150} 151