Skip to content

Commit 54933d4

Browse files
authored
Merge pull request #10 from incident-io/rob/add-incident-statuses-stream
Add the statuses stream
2 parents 48eaa2f + 5f1e164 commit 54933d4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tap/stream_incident_statuses.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package tap
2+
3+
import (
4+
"context"
5+
6+
kitlog "github.com/go-kit/log"
7+
"github.com/incident-io/singer-tap/client"
8+
"github.com/incident-io/singer-tap/model"
9+
"github.com/pkg/errors"
10+
)
11+
12+
func init() {
13+
register(&StreamIncidentStatuses{})
14+
}
15+
16+
type StreamIncidentStatuses struct {
17+
}
18+
19+
func (s *StreamIncidentStatuses) Output() *Output {
20+
return &Output{
21+
Type: OutputTypeSchema,
22+
Stream: "incident_statuses",
23+
Schema: &model.Schema{
24+
HasAdditionalProperties: false,
25+
Type: []string{"object"},
26+
Properties: model.IncidentStatusV1.Schema().Properties,
27+
},
28+
KeyProperties: []string{"id"},
29+
BookmarkProperties: []string{},
30+
}
31+
}
32+
33+
func (s *StreamIncidentStatuses) GetRecords(ctx context.Context, logger kitlog.Logger, cl *client.ClientWithResponses) ([]map[string]any, error) {
34+
var (
35+
results = []map[string]any{}
36+
)
37+
38+
response, err := cl.IncidentStatusesV1ListWithResponse(ctx)
39+
if err != nil {
40+
return nil, errors.Wrap(err, "listing incident statuses")
41+
}
42+
43+
for _, element := range response.JSON200.IncidentStatuses {
44+
results = append(results, model.IncidentStatusV1.Serialize(element))
45+
}
46+
47+
return results, nil
48+
}

0 commit comments

Comments
 (0)