updateDashboard method

Future<UpdateDashboardResponse> updateDashboard({
  1. required String dashboardId,
  2. RefreshSchedule? refreshSchedule,
  3. bool? terminationProtectionEnabled,
  4. List<RequestWidget>? widgets,
})

Updates the specified dashboard.

To set a refresh schedule, CloudTrail must be granted permissions to run the StartDashboardRefresh operation to refresh the dashboard on your behalf. To provide permissions, run the PutResourcePolicy operation to attach a resource-based policy to the dashboard. For more information, see Resource-based policy example for a dashboard in the CloudTrail User Guide.

CloudTrail runs queries to populate the dashboard's widgets during a manual or scheduled refresh. CloudTrail must be granted permissions to run the StartQuery operation on your behalf. To provide permissions, run the PutResourcePolicy operation to attach a resource-based policy to each event data store. For more information, see Example: Allow CloudTrail to run queries to populate a dashboard in the CloudTrail User Guide.

May throw ConflictException. May throw EventDataStoreNotFoundException. May throw InactiveEventDataStoreException. May throw InsufficientEncryptionPolicyException. May throw InvalidQueryStatementException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw UnsupportedOperationException.

Parameter dashboardId : The name or ARN of the dashboard.

Parameter refreshSchedule : The refresh schedule configuration for the dashboard.

Parameter terminationProtectionEnabled : Specifies whether termination protection is enabled for the dashboard. If termination protection is enabled, you cannot delete the dashboard until termination protection is disabled.

Parameter widgets : An array of widgets for the dashboard. A custom dashboard can have a maximum of 10 widgets.

To add new widgets, pass in an array that includes the existing widgets along with any new widgets. Run the GetDashboard operation to get the list of widgets for the dashboard.

To remove widgets, pass in an array that includes the existing widgets minus the widgets you want removed.

Implementation

Future<UpdateDashboardResponse> updateDashboard({
  required String dashboardId,
  RefreshSchedule? refreshSchedule,
  bool? terminationProtectionEnabled,
  List<RequestWidget>? widgets,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CloudTrail_20131101.UpdateDashboard'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DashboardId': dashboardId,
      if (refreshSchedule != null) 'RefreshSchedule': refreshSchedule,
      if (terminationProtectionEnabled != null)
        'TerminationProtectionEnabled': terminationProtectionEnabled,
      if (widgets != null) 'Widgets': widgets,
    },
  );

  return UpdateDashboardResponse.fromJson(jsonResponse.body);
}