Skip to content

Commit

Permalink
last files
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanford8 committed Dec 12, 2023
1 parent a57d2f7 commit 8a217fd
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
13 changes: 13 additions & 0 deletions model_broadcast_status.go.patch
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"
)
59 changes: 59 additions & 0 deletions model_get_metric_timeseries_data_response.go.patch
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
+}
13 changes: 13 additions & 0 deletions model_space_status.go.patch
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"
)

0 comments on commit 8a217fd

Please sign in to comment.