// Add custom screenboard dashboard to an existing dashboard list returns "OK" response package main import ( "context" "encoding/json" "fmt" "os" "strconv" "github.com/DataDog/datadog-api-client-go/v2/api/datadog" "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" ) func main() { // there is a valid "dashboard_list" in the system DashboardListID, _ := strconv.ParseInt(os.Getenv("DASHBOARD_LIST_ID"), 10, 64) // there is a valid "screenboard_dashboard" in the system ScreenboardDashboardID := os.Getenv("SCREENBOARD_DASHBOARD_ID") body := datadogV2.DashboardListAddItemsRequest{ Dashboards: []datadogV2.DashboardListItemRequest{ { Id: ScreenboardDashboardID, Type: datadogV2.DASHBOARDTYPE_CUSTOM_SCREENBOARD, }, }, } ctx := datadog.NewDefaultContext(context.Background()) configuration := datadog.NewConfiguration() apiClient := datadog.NewAPIClient(configuration) api := datadogV2.NewDashboardListsApi(apiClient) resp, r, err := api.CreateDashboardListItems(ctx, DashboardListID, body) if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `DashboardListsApi.CreateDashboardListItems`: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } responseContent, _ := json.MarshalIndent(resp, "", " ") fmt.Fprintf(os.Stdout, "Response from `DashboardListsApi.CreateDashboardListItems`:\n%s\n", responseContent) }