go-datadog-api icon indicating copy to clipboard operation
go-datadog-api copied to clipboard

Use json.Number for Screenboard.Width and ConditionalFormat.Value

Open knqyf263 opened this issue 5 years ago • 0 comments

I got the following error.

FATA[0001] json: cannot unmarshal string into Go struct field Screenboard.width of type int

I investigated this error and found that width is occasionally returned as string.

$ curl -G "https://app.datadoghq.com/api/v1/screen/XXXXXX" -d "api_key=$DATADOG_API_KEY" -d "application_key=$DATADOG_APP_KEY" | jq . | grep width
 "width": "100%",

Another dashboard:

$ curl -G "https://app.datadoghq.com/api/v1/screen/XXXXXX" -d "api_key=$DATADOG_API_KEY" -d "application_key=$DATADOG_APP_KEY" | jq . | grep width
  "width": 424,

ConditionalFormat.Value is also the same.

            "conditional_formats": [
              {
                "palette": "white_on_red",
                "comparator": ">",
                "invert": false,
                "value": 10,
                "custom_bg_color": null,
                "custom_fg_color": null
              },
...
            "conditional_formats": [
              {
                "palette": "white_on_red",
                "comparator": "<",
                "value": "3"
              },

This PR includes breaking changes because it was written in the same way as the codes in other places. But please tell me if there is a better way.

knqyf263 avatar Feb 25 '19 10:02 knqyf263