-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/model_broadcast_status.go b/model_broadcast_status.go | ||
index 2411549..f8db8a4 100644 | ||
--- a/model_broadcast_status.go | ||
+++ b/model_broadcast_status.go | ||
@@ -8,6 +8,6 @@ type BroadcastStatus string | ||
|
||
// List of BroadcastStatus | ||
const ( | ||
- IDLE BroadcastStatus = "idle" | ||
- ACTIVE BroadcastStatus = "active" | ||
+ BROADCAST_IDLE BroadcastStatus = "idle" | ||
+ BROADCAST_ACTIVE BroadcastStatus = "active" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
diff --git a/model_get_metric_timeseries_data_response.go b/model_get_metric_timeseries_data_response.go | ||
index 288dfe6..f174a6c 100644 | ||
--- a/model_get_metric_timeseries_data_response.go | ||
+++ b/model_get_metric_timeseries_data_response.go | ||
@@ -3,9 +3,54 @@ | ||
|
||
package muxgo | ||
|
||
+import ( | ||
+ "encoding/json" | ||
+ "fmt" | ||
+) | ||
+ | ||
type GetMetricTimeseriesDataResponse struct { | ||
Data [][]string `json:"data,omitempty"` | ||
TotalRowCount int64 `json:"total_row_count,omitempty"` | ||
Timeframe []int64 `json:"timeframe,omitempty"` | ||
Meta ListBreakdownValuesResponseMeta `json:"meta,omitempty"` | ||
} | ||
+ | ||
+// !!! 🐉 Here be dragons 🐉 !!! | ||
+// We use a custom Unmarshal to work around one awkward API call where we can't model the response | ||
+// from the API elegantly since go doesn't have heterogeneous arrays. This isn't perfect, or memory | ||
+// friendly, but it works. | ||
+func (this *GetMetricTimeseriesDataResponse) UnmarshalJSON(data []byte) error { | ||
+ | ||
+ // Unmarshal JSON into a string => interface{} map | ||
+ var result map[string]interface{} | ||
+ json.Unmarshal(data, &result) | ||
+ | ||
+ // Build up a new list of each of the datapoints from data as [][]string, nil checking as we go | ||
+ datapoints := [][]string{} | ||
+ for _, node := range result["data"].([]interface{}) { | ||
+ nodeAsArray := node.([]interface{}) | ||
+ d := make([]string, 3) | ||
+ d[0] = nodeAsArray[0].(string) | ||
+ if nodeAsArray[1] != nil { | ||
+ d[1] = fmt.Sprintf("%f", nodeAsArray[1].(float64)) | ||
+ } | ||
+ if nodeAsArray[2] != nil { | ||
+ d[2] = fmt.Sprintf("%f", nodeAsArray[2].(float64)) | ||
+ } | ||
+ datapoints = append(datapoints, d) | ||
+ } | ||
+ | ||
+ // Build the array of timeframe | ||
+ timeframes := []int64{} | ||
+ for _, time := range result["timeframe"].([]interface{}) { | ||
+ timefloat := time.(float64) | ||
+ timeframes = append(timeframes, int64(timefloat)) | ||
+ } | ||
+ | ||
+ // Set the fields on the response object to what we've pieced together | ||
+ this.Data = datapoints | ||
+ this.Timeframe = timeframes | ||
+ this.TotalRowCount = int64(result["total_row_count"].(float64)) | ||
+ | ||
+ return nil | ||
+} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/model_space_status.go b/model_space_status.go | ||
index 31572b7..9adb99c 100644 | ||
--- a/model_space_status.go | ||
+++ b/model_space_status.go | ||
@@ -8,6 +8,6 @@ type SpaceStatus string | ||
|
||
// List of SpaceStatus | ||
const ( | ||
- IDLE SpaceStatus = "idle" | ||
- ACTIVE SpaceStatus = "active" | ||
+ SPACE_IDLE SpaceStatus = "idle" | ||
+ SPACE_ACTIVE SpaceStatus = "active" | ||
) |