Repository: grafana/grafana-plugin-sdk-go (go)

Issue:
Add field to data queries to ease "routing"/looking up query type
Core data datasources in Grafana are supporting/handling multiple query types and/or data source types.
Azure monitor example:
https://github.com/grafana/grafana/blob/c6cc840ceb6ff64dc45200888477b14c89bc0785/pkg/tsdb/azuremonitor/azuremonitor.go#L49-L65
CloudWatch example:
https://github.com/grafana/grafana/blob/c6cc840ceb6ff64dc45200888477b14c89bc0785/pkg/tsdb/cloudwatch/cloudwatch.go#L47-L63

We would like to enhance the data query request to include a new field that can be used to identify "query type". SDK can then provide some basic routing/map of "query type" to query handler and by that supporting several query handlers without having to parse the model json first to understand the query type.

With that plugin developer should be able to register a handler for a "query type" and marschal model json to struct for type safe handling.

Pull request:
Query type mux
Remembered we haven't done anything in the SDK regarding to [queryType](https://github.com/grafana/grafana/blob/21cbcde15fcb6ed7182e3398063ced4f8a379d71/packages/grafana-data/src/types/datasource.ts#L397).

Closes #75

Patch:
diff --git a/backend/convert_from_protobuf.go b/backend/convert_from_protobuf.go
index 4b46365..368c962 100644
--- a/backend/convert_from_protobuf.go
+++ b/backend/convert_from_protobuf.go
@@ -91,6 +91,7 @@ func (f ConvertFromProtobuf) TimeRange(proto *pluginv2.TimeRange) TimeRange {
 func (f ConvertFromProtobuf) DataQuery(proto *pluginv2.DataQuery) *DataQuery {
 	return &DataQuery{
 		RefID:         proto.RefId,
+		QueryType:     proto.QueryType,
 		MaxDataPoints: proto.MaxDataPoints,
 		TimeRange:     f.TimeRange(proto.TimeRange),
 		Interval:      time.Duration(proto.IntervalMS) * time.Millisecond,
diff --git a/backend/convert_to_protobuf.go b/backend/convert_to_protobuf.go
index 86b1093..a4eed38 100644
--- a/backend/convert_to_protobuf.go
+++ b/backend/convert_to_protobuf.go
@@ -111,6 +111,7 @@ func (t ConvertToProtobuf) CheckHealthResponse(res *CheckHealthResult) *pluginv2
 func (t ConvertToProtobuf) DataQuery(q DataQuery) *pluginv2.DataQuery {
 	return &pluginv2.DataQuery{
 		RefId:         q.RefID,
+		QueryType:     q.QueryType,
 		MaxDataPoints: q.MaxDataPoints,
 		IntervalMS:    q.Interval.Milliseconds(),
 		TimeRange:     t.TimeRange(q.TimeRange),
@@ -132,11 +133,18 @@ func (t ConvertToProtobuf) QueryDataRequest(req *QueryDataRequest) *pluginv2.Que
 }
 
 // QueryDataResponse converts the SDK version of a QueryDataResponse to the protobuf version.
+// It will set the RefID on the frames to the RefID key in Responses if a Frame's
+// RefId property is an empty string.
 func (t ConvertToProtobuf) QueryDataResponse(res *QueryDataResponse) (*pluginv2.QueryDataResponse, error) {
 	pQDR := &pluginv2.QueryDataResponse{
 		Responses: make(map[string]*pluginv2.DataResponse, len(res.Responses)),
 	}
 	for refID, dr := range res.Responses {
+		for _, f := range dr.Frames {
+			if f.RefID == "" {
+				f.RefID = refID
+			}
+		}
 		encodedFrames, err := dr.Frames.MarshalArrow()
 		if err != nil {
 			return nil, err
diff --git a/backend/data.go b/backend/data.go
index b4ab6f1..6fa6293 100644
--- a/backend/data.go
+++ b/backend/data.go
@@ -14,6 +14,10 @@ type QueryDataHandler interface {
 	// req contains the queries []DataQuery (where each query contains RefID as a unique identifer).
 	// The QueryDataResponse contains a map of RefID to the response for each query, and each response
 	// contains Frames ([]*Frame).
+	//
+	// The Frames' RefID property, when it is an empty string, will be automatically set to
+	// the RefID in QueryDataResponse.Responses map. This is done before the QueryDataResponse is
+	// sent to Grafana. Therefore one does not need to be set that property on frames when using this method.
 	QueryData(ctx context.Context, req *QueryDataRequest) (*QueryDataResponse, error)
 }
 
@@ -31,6 +35,10 @@ type DataQuery struct {
 	// RefID is the unique identifer of the query, set by the frontend call.
 	RefID string
 
+	// QueryType is an optional identifier for the type of query.
+	// It can be used to distinguish different types of queries.
+	QueryType string
+
 	// MaxDataPoints is the maximum number of datapoints that should be returned from a time series query.
 	MaxDataPoints int64
 
@@ -59,6 +67,8 @@ func NewQueryDataResponse() *QueryDataResponse {
 }
 
 // Responses is a map of RefIDs (Unique Query ID) to DataResponses.
+// The QueryData method the QueryDataHandler method will set the RefId
+// property on the DataRespones' frames based on these RefIDs.
 type Responses map[string]DataResponse
 
 // DataResponse contains the results from a DataQuery.
diff --git a/backend/datasource/doc.go b/backend/datasource/doc.go
new file mode 100644
index 0000000..8a61b05
--- /dev/null
+++ b/backend/datasource/doc.go
@@ -0,0 +1,2 @@
+// Package datasource provides utilities for data source plugins.
+package datasource
diff --git a/backend/datasource/query_type_mux.go b/backend/datasource/query_type_mux.go
new file mode 100644
index 0000000..107e624
--- /dev/null
+++ b/backend/datasource/query_type_mux.go
@@ -0,0 +1,135 @@
+package datasource
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/grafana/grafana-plugin-sdk-go/backend/log"
+
+	"github.com/grafana/grafana-plugin-sdk-go/backend"
+)
+
+// QueryTypeHandlerFunc is an adapter to allow the use of
+// ordinary functions as backend.QueryDataHandler. If f is a function
+// with the appropriate signature, QueryTypeHandlerFunc(f) is a
+// Handler that calls f.
+type QueryTypeHandlerFunc func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
+
+// QueryData calls f(ctx, req).
+func (fn QueryTypeHandlerFunc) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
+	return fn(ctx, req)
+}
+
+// QueryTypeMux is a query type multiplexer.
+type QueryTypeMux struct {
+	m               map[string]backend.QueryDataHandler
+	fallbackHandler backend.QueryDataHandler
+}
+
+// NewQueryTypeMux allocates and returns a new QueryTypeMux.
+func NewQueryTypeMux() *QueryTypeMux {
+	return new(QueryTypeMux)
+}
+
+// Handle registers the handler for the given query type.
+//
+// Providing an empty queryType registers the handler as a fallback handler
+// that will be called when query type doesn't match any registered handlers.
+// If handler is nil, Handle panics.
+// If a handler already exists for queryType, Handle panics.
+func (mux *QueryTypeMux) Handle(queryType string, handler backend.QueryDataHandler) {
+	if handler == nil {
+		panic("datasource: nil handler")
+	}
+
+	if mux.m == nil {
+		mux.m = map[string]backend.QueryDataHandler{}
+		mux.fallbackHandler = QueryTypeHandlerFunc(fallbackHandler)
+	}
+
+	if _, exist := mux.m[queryType]; exist {
+		panic("datasource: multiple registrations for " + queryType)
+	}
+
+	if queryType == "" {
+		log.DefaultLogger.Debug("datasource: registering query type fallback handler")
+		mux.fallbackHandler = handler
+		return
+	}
+
+	log.DefaultLogger.Debug("datasource: registering query type handler", "queryType", queryType)
+	mux.m[queryType] = handler
+}
+
+// HandleFunc registers the handler function for the given query type.
+//
+// Providing an empty queryType registers the handler as a fallback handler
+// that will be called when query type doesn't match any registered handlers.
+// If handler is nil, Handle panics.
+// If a handler already exists for queryType, Handle panics.
+func (mux *QueryTypeMux) HandleFunc(queryType string, handler func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)) {
+	mux.Handle(queryType, QueryTypeHandlerFunc(handler))
+}
+
+// QueryData dispatches the request to the handler(s) whose
+// query type matches the request queries query type.
+func (mux *QueryTypeMux) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
+	type requestHandler struct {
+		handler backend.QueryDataHandler
+		request *backend.QueryDataRequest
+	}
+
+	requests := map[string]requestHandler{}
+	for _, q := range req.Queries {
+		qt, handler := mux.getHandler(q.QueryType)
+		if _, exists := requests[qt]; !exists {
+			requests[qt] = requestHandler{
+				handler: handler,
+				request: &backend.QueryDataRequest{
+					PluginContext: req.PluginContext,
+					Headers:       req.Headers,
+					Queries:       []backend.DataQuery{},
+				},
+			}
+		}
+		requests[qt].request.Queries = append(requests[qt].request.Queries, q)
+	}
+
+	responses := backend.Responses{}
+	for _, rh := range requests {
+		qtResponse, err := rh.handler.QueryData(ctx, rh.request)
+		if err != nil {
+			return nil, err
+		}
+
+		for k, v := range qtResponse.Responses {
+			responses[k] = v
+		}
+	}
+
+	return &backend.QueryDataResponse{
+		Responses: responses,
+	}, nil
+}
+
+func (mux *QueryTypeMux) getHandler(queryType string) (string, backend.QueryDataHandler) {
+	handler, exists := mux.m[queryType]
+	if !exists {
+		return "", mux.fallbackHandler
+	}
+
+	return queryType, handler
+}
+
+func fallbackHandler(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
+	responses := backend.Responses{}
+	for _, q := range req.Queries {
+		responses[q.RefID] = backend.DataResponse{
+			Error: fmt.Errorf("no handler found for query type '%s'", q.QueryType),
+		}
+	}
+
+	return &backend.QueryDataResponse{
+		Responses: responses,
+	}, nil
+}
diff --git a/backend/doc.go b/backend/doc.go
new file mode 100644
index 0000000..6d44b45
--- /dev/null
+++ b/backend/doc.go
@@ -0,0 +1,2 @@
+// Package backend provides SDK handler interfaces and contracts for implementing and serving backend plugins.
+package backend
diff --git a/data/frame.go b/data/frame.go
index ca1431e..bc308ae 100644
--- a/data/frame.go
+++ b/data/frame.go
@@ -34,7 +34,7 @@ type Frame struct {
 	// All Fields must be of the same the length when marshalling the Frame for transmission.
 	Fields []*Field
 
-	// RefID is a property that can be set to match a Frame to its orginating query
+	// RefID is a property that can be set to match a Frame to its orginating query.
 	RefID string
 
 	// Meta is metadata about the Frame, and includes space for custom metadata.
diff --git a/data/frame_meta.go b/data/frame_meta.go
index 98f5134..83f7aaf 100644
--- a/data/frame_meta.go
+++ b/data/frame_meta.go
@@ -1,6 +1,9 @@
 package data
 
-import "encoding/json"
+import (
+	"encoding/json"
+	"fmt"
+)
 
 // FrameMeta matches:
 // https://github.com/grafana/grafana/blob/master/packages/grafana-data/src/types/data.ts#L11
@@ -80,6 +83,31 @@ func (n NoticeSeverity) String() string {
 	return ""
 }
 
+// MarshalJSON implements the json.Marshaler interface.
+func (n NoticeSeverity) MarshalJSON() ([]byte, error) {
+	return json.Marshal(n.String())
+}
+
+// UnmarshalJSON implements the json.Unmarshaler interface.
+func (n *NoticeSeverity) UnmarshalJSON(b []byte) error {
+	var s string
+	err := json.Unmarshal(b, &s)
+	if err != nil {
+		return err
+	}
+	switch s {
+	case "info":
+		*n = NoticeSeverityInfo
+	case "warning":
+		*n = NoticeSeverityWarning
+	case "error":
+		*n = NoticeSeverityError
+	default:
+		return fmt.Errorf("unrecognized notice severity %v", s)
+	}
+	return nil
+}
+
 // InspectType is a type for the Inspect property of a Notice.
 type InspectType int
 
diff --git a/doc.go b/doc.go
new file mode 100644
index 0000000..a45672d
--- /dev/null
+++ b/doc.go
@@ -0,0 +1,5 @@
+/*
+Package sdk is the root of the packages used to access Grafana Plugin SDK for Go.
+See https://pkg.go.dev/github.com/grafana/grafana-plugin-sdk-go for a full list of sub-packages.
+*/
+package sdk // import "github.com/grafana/grafana-plugin-sdk-go"
diff --git a/genproto/pluginv2/backend.pb.go b/genproto/pluginv2/backend.pb.go
index 06122ba..b11e40a 100644
--- a/genproto/pluginv2/backend.pb.go
+++ b/genproto/pluginv2/backend.pb.go
@@ -593,6 +593,7 @@ type DataQuery struct {
 	IntervalMS           int64      `protobuf:"varint,3,opt,name=intervalMS,proto3" json:"intervalMS,omitempty"`
 	TimeRange            *TimeRange `protobuf:"bytes,4,opt,name=timeRange,proto3" json:"timeRange,omitempty"`
 	Json                 []byte     `protobuf:"bytes,5,opt,name=json,proto3" json:"json,omitempty"`
+	QueryType            string     `protobuf:"bytes,6,opt,name=queryType,proto3" json:"queryType,omitempty"`
 	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
 	XXX_unrecognized     []byte     `json:"-"`
 	XXX_sizecache        int32      `json:"-"`
@@ -658,6 +659,13 @@ func (m *DataQuery) GetJson() []byte {
 	return nil
 }
 
+func (m *DataQuery) GetQueryType() string {
+	if m != nil {
+		return m.QueryType
+	}
+	return ""
+}
+
 // QueryDataRequest
 type QueryDataRequest struct {
 	PluginContext *PluginContext `protobuf:"bytes,1,opt,name=pluginContext,proto3" json:"pluginContext,omitempty"`
@@ -1056,81 +1064,82 @@ func init() {
 }
 
 var fileDescriptor_5ab9ba5b8d8b2ba5 = []byte{
-	// 1176 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xdb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d, 0x2f, 0xfc, 0xf4, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2f, 0x3a,
+	0xd4, 0x1a, 0x28, 0x0e, 0x00, 0x00,
 }
 
 // Reference imports to suppress errors if they are not otherwise used.
diff --git a/go.mod b/go.mod
index 10ea5f3..5ebeaf3 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,6 @@ go 1.14
 require (
 	github.com/apache/arrow/go/arrow v0.0.0-20200403134915-89ce1cadb678
 	github.com/cheekybits/genny v1.0.0
-	github.com/davecgh/go-spew v1.1.1
 	github.com/golang/protobuf v1.3.4
 	github.com/google/go-cmp v0.3.1
 	github.com/grpc-ecosystem/go-grpc-middleware v1.2.0
diff --git a/go.sum b/go.sum
index 7af82cd..225dd37 100644
--- a/go.sum
+++ b/go.sum
@@ -113,6 +113,7 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
diff --git a/proto/backend.proto b/proto/backend.proto
index 18655f9..d5bb555 100644
--- a/proto/backend.proto
+++ b/proto/backend.proto
@@ -106,6 +106,7 @@ message DataQuery {
   int64 intervalMS = 3;
   TimeRange timeRange = 4;
   bytes json = 5;
+  string queryType = 6;
 }
 
 // QueryDataRequest


Test patch:
diff --git a/backend/convert_from_protobuf_test.go b/backend/convert_from_protobuf_test.go
index 893cf7d..1486387 100644
--- a/backend/convert_from_protobuf_test.go
+++ b/backend/convert_from_protobuf_test.go
@@ -7,7 +7,6 @@ import (
 	"testing"
 	"time"
 
-	"github.com/davecgh/go-spew/spew"
 	"github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2"
 	"github.com/mitchellh/reflectwalk"
 	"github.com/stretchr/testify/require"
@@ -30,7 +29,6 @@ func (w *walker) StructField(f reflect.StructField, v reflect.Value) error {
 	if f.PkgPath != "" {
 		return nil
 	}
-	spew.Dump(f)
 	w.FieldCount++
 	if v.IsZero() {
 		w.ZeroValueFieldCount++
@@ -304,6 +302,7 @@ var protoDataQuery = &pluginv2.DataQuery{
 	TimeRange:     protoTimeRange,
 	IntervalMS:    60 * 1000,
 	Json:          []byte(`{ "query": "SELECT * from FUN"`),
+	QueryType:     "qt",
 }
 
 func TestConvertFromProtobufDataQuery(t *testing.T) {
@@ -334,6 +333,8 @@ func TestConvertFromProtobufDataQuery(t *testing.T) {
 
 	requireCounter.Equal(t, protoDQ.RefId, sdkDQ.RefID)
 	requireCounter.Equal(t, protoDQ.MaxDataPoints, sdkDQ.MaxDataPoints)
+	requireCounter.Equal(t, protoDQ.QueryType, sdkDQ.QueryType)
+
 	requireCounter.Equal(t, time.Duration(time.Minute), sdkDQ.Interval)
 	requireCounter.Equal(t, sdkTimeRange.From, sdkDQ.TimeRange.From)
 	requireCounter.Equal(t, sdkTimeRange.To, sdkDQ.TimeRange.To)
@@ -406,6 +407,7 @@ func TestConvertFromProtobufQueryDataRequest(t *testing.T) {
 	// Queries
 	requireCounter.Equal(t, protoQDR.Queries[0].RefId, sdkQDR.Queries[0].RefID)
 	requireCounter.Equal(t, protoQDR.Queries[0].MaxDataPoints, sdkQDR.Queries[0].MaxDataPoints)
+	requireCounter.Equal(t, protoQDR.Queries[0].QueryType, sdkQDR.Queries[0].QueryType)
 	requireCounter.Equal(t, time.Duration(time.Minute), sdkQDR.Queries[0].Interval)
 	requireCounter.Equal(t, sdkTimeRange.From, sdkQDR.Queries[0].TimeRange.From)
 	requireCounter.Equal(t, sdkTimeRange.To, sdkQDR.Queries[0].TimeRange.To)
diff --git a/backend/datasource/query_type_mux_test.go b/backend/datasource/query_type_mux_test.go
new file mode 100644
index 0000000..ccf797e
--- /dev/null
+++ b/backend/datasource/query_type_mux_test.go
@@ -0,0 +1,104 @@
+package datasource
+
+import (
+	"context"
+	"errors"
+	"testing"
+
+	"github.com/grafana/grafana-plugin-sdk-go/backend"
+	"github.com/stretchr/testify/require"
+)
+
+func ExampleQueryTypeMux() {
+	mux := NewQueryTypeMux()
+	mux.HandleFunc("queryTypeA", func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
+		// handle queryTypeA
+		return nil, nil
+	})
+	mux.HandleFunc("queryTypeB", func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
+		// handle queryTypeB
+		return nil, nil
+	})
+
+	_ = backend.ServeOpts{
+		QueryDataHandler: mux,
+	}
+}
+
+func TestQueryTypeMux(t *testing.T) {
+	mux := NewQueryTypeMux()
+	aHandler := &testHandler{}
+	mux.Handle("a", aHandler)
+	bHandler := &testHandler{}
+	mux.Handle("b", bHandler)
+
+	res, err := mux.QueryData(context.Background(), &backend.QueryDataRequest{
+		Queries: []backend.DataQuery{
+			backend.DataQuery{
+				RefID:     "A",
+				QueryType: "a",
+			},
+			backend.DataQuery{
+				RefID:     "B",
+				QueryType: "b",
+			},
+			backend.DataQuery{
+				RefID:     "C",
+				QueryType: "a",
+			},
+			backend.DataQuery{
+				RefID:     "D",
+				QueryType: "d",
+			},
+		},
+	})
+
+	require.NoError(t, err)
+	require.Equal(t, 1, aHandler.callCount)
+	require.Len(t, aHandler.request.Queries, 2)
+	require.Equal(t, "A", aHandler.request.Queries[0].RefID)
+	require.Equal(t, "C", aHandler.request.Queries[1].RefID)
+
+	require.Equal(t, 1, bHandler.callCount)
+	require.Len(t, bHandler.request.Queries, 1)
+	require.Equal(t, "B", bHandler.request.Queries[0].RefID)
+	require.Len(t, res.Responses, 4)
+	require.Equal(t, "no handler found for query type 'd'", res.Responses["D"].Error.Error())
+
+	t.Run("When overriding fallback handler should call fallback handler", func(t *testing.T) {
+		errBoom := errors.New("BOOM")
+		mux.HandleFunc("", func(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
+			return nil, errBoom
+		})
+		res, err = mux.QueryData(context.Background(), &backend.QueryDataRequest{
+			Queries: []backend.DataQuery{
+				backend.DataQuery{
+					RefID:     "A",
+					QueryType: "unhandled",
+				},
+			},
+		})
+
+		require.Nil(t, res)
+		require.Error(t, err)
+		require.Equal(t, errBoom, err)
+	})
+}
+
+type testHandler struct {
+	callCount int
+	request   *backend.QueryDataRequest
+}
+
+func (th *testHandler) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
+	th.callCount++
+	th.request = req
+	responses := backend.Responses{}
+	for _, q := range req.Queries {
+		responses[q.RefID] = backend.DataResponse{}
+	}
+
+	return &backend.QueryDataResponse{
+		Responses: responses,
+	}, nil
+}
diff --git a/data/frame_meta_test.go b/data/frame_meta_test.go
new file mode 100644
index 0000000..64f6f5a
--- /dev/null
+++ b/data/frame_meta_test.go
@@ -0,0 +1,37 @@
+package data
+
+import (
+	"encoding/json"
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestJSONNotice(t *testing.T) {
+	tests := []struct {
+		name   string
+		notice Notice
+		json   string
+	}{
+		{
+			name: "notice with severity and text",
+			notice: Notice{
+				Severity: NoticeSeverityError,
+				Text:     "Some text",
+			},
+			json: `{"severity":"error","text":"Some text"}`,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b, err := json.Marshal(tt.notice)
+			require.NoError(t, err)
+			require.Equal(t, tt.json, string(b))
+
+			n := Notice{}
+			err = json.Unmarshal([]byte(tt.json), &n)
+			require.NoError(t, err)
+			require.Equal(t, tt.notice, n)
+		})
+	}
+}