File tree Expand file tree Collapse file tree 4 files changed +108
-0
lines changed
examples/signals_annotate Expand file tree Collapse file tree 4 files changed +108
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "context"
5+ "encoding/json"
6+ "os"
7+
8+ clarify "github.com/clarify/clarify-go"
9+ "github.com/clarify/clarify-go/views"
10+ clarifyx "github.com/clarify/clarify-go/x"
11+ )
12+
13+ func main () {
14+ // To select or publish signals, you must grant the integration access to
15+ // the "admin" namespace in the Clarify admin panel.
16+ creds , err := clarify .CredentialsFromFile ("clarify-credentials.json" )
17+ if err != nil {
18+ panic (err )
19+ }
20+
21+ ctx := context .Background ()
22+ client := creds .Client (ctx )
23+ xclient := clarifyx .Upgrade (client )
24+
25+ // For this example, the signals we want to select are created by the same
26+ // integration that we are using to select them. Note that this isn't a
27+ // requirement; for production cases, you may want this integration ID to be
28+ // configured to be something else.
29+ integrationID := creds .Integration
30+ signalID := "cl1d4kobi2aq0ttkc4b0"
31+
32+ data := []views.SignalAnnotate {{
33+ ID : signalID ,
34+ Annotations : map [string ]string {
35+ "my-new-annotation" : "with-new-value" ,
36+ "annotations-to-delete-has-empty-values" : "" ,
37+ },
38+ }}
39+
40+ result , err := xclient .Admin ().Signals ().Annotate (integrationID , data ).Do (ctx )
41+ if err != nil {
42+ panic (err )
43+ }
44+ enc := json .NewEncoder (os .Stdout )
45+ enc .SetIndent ("" , " " )
46+ enc .Encode (result )
47+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2022-2025 Searis AS
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ package views
16+
17+ type SignalAnnotate struct {
18+ ID string `json:"id"`
19+ Annotations map [string ]string `json:"annotations"`
20+ }
Original file line number Diff line number Diff line change 1+ package clarifyx
2+
3+ import (
4+ "github.com/clarify/clarify-go/internal/request"
5+ "github.com/clarify/clarify-go/views"
6+ )
7+
8+ type SignalAdminGroup struct {
9+ AdminNamespace
10+ }
11+
12+ func (ns AdminNamespace ) Signals () SignalAdminGroup {
13+ return SignalAdminGroup {AdminNamespace : ns }
14+ }
15+
16+ // Annotate returns a new request for publishing signals as items.
17+ func (s SignalAdminGroup ) Annotate (integration string , data []views.SignalAnnotate ) SignalsAnnotateRequest {
18+ return methodSignalsAnnotate .NewRequest (s .Handler (),
19+ paramIntegration .Value (integration ),
20+ paramData .Value (data ),
21+ paramFormat .Value (views.SelectionFormat {
22+ DataAsArray : true ,
23+ GroupIncludedByType : true ,
24+ }),
25+ )
26+ }
27+
28+ type (
29+ // SignalsAnnotateRequest describe an initialized admin.signals.annotate RPC
30+ // request with access to a request handler.
31+ SignalsAnnotateRequest = request.Request [SignalsAnnotateResult ]
32+
33+ // SignalsAnnotateResult describe the result format for a SignalsAnnotateRequest.
34+ SignalsAnnotateResult = views.Selection [[]views.Signal , views.SignalInclude ]
35+ )
36+
37+ var methodSignalsAnnotate = request.Method [SignalsAnnotateResult ]{
38+ APIVersion : apiVersionExperimental ,
39+ Method : "admin.signals.annotate" ,
40+ }
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const (
2828
2929 paramFormat jsonrpc.ParamName = "format"
3030 paramIntegration jsonrpc.ParamName = "integration"
31+ paramData jsonrpc.ParamName = "data"
3132 paramItem jsonrpc.ParamName = "item"
3233 paramQuery jsonrpc.ParamName = "query"
3334)
You can’t perform that action at this time.
0 commit comments