Add missing trial label link to API
@@ -40,6 +40,7 @@ const (
relationPrevious = "previous"
relationTrials = "https://carbonrelay.com/rel/trials"
relationNextTrial = "https://carbonrelay.com/rel/nextTrial"
+ relationTrialLabels = "https://carbonrelay.com/rel/trialLabels"
)
// Meta is used to collect resource metadata from the response
@@ -319,11 +320,17 @@ type ExperimentList struct {
type TrialMeta struct {
ReportTrial string `json:"-"`
+ TrialLabels string `json:"-"`
}
func (m *TrialMeta) SetLocation(location string) { m.ReportTrial = location }
func (m *TrialMeta) SetLastModified(time.Time) {}
-func (m *TrialMeta) SetLink(string, string) {}
+func (m *TrialMeta) SetLink(rel, link string) {
+ switch rel {
+ case relationTrialLabels:
+ m.TrialLabels = link
+ }
+}
type Assignment struct {
// The name of the parameter in the experiment the assignment corresponds to.
@@ -375,6 +382,9 @@ type TrialItem struct {
Number int64 `json:"number"`
// Labels for this trial.
Labels map[string]string `json:"labels,omitempty"`
+
+ // The metadata for an individual trial.
+ Metadata Metadata `json:"_metadata,omitempty"`
}
type TrialListQuery struct {
@@ -614,6 +624,9 @@ func (h *httpAPI) GetAllTrials(ctx context.Context, u string, q *TrialListQuery)
switch resp.StatusCode {
case http.StatusOK:
err = json.Unmarshal(body, &lst)
+ for i := range lst.Trials {
+ metaUnmarshal(http.Header(lst.Trials[i].Metadata), &lst.Trials[i].TrialAssignments.TrialMeta)
+ }
return lst, err
default:
return lst, unexpected(resp, body)
