Skip to content

Commit 938aca7

Browse files
committed
Tiny one to add specific incident_types stream
We already have this resource and this endpoint exists so why not.
1 parent a39fc89 commit 938aca7

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tap/stream_incident_types.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(&StreamIncidentTypes{})
14+
}
15+
16+
type StreamIncidentTypes struct {
17+
}
18+
19+
func (s *StreamIncidentTypes) Output() *Output {
20+
return &Output{
21+
Type: OutputTypeSchema,
22+
Stream: "incident_types",
23+
Schema: &model.Schema{
24+
HasAdditionalProperties: false,
25+
Type: []string{"object"},
26+
Properties: model.IncidentTypeV1.Schema().Properties,
27+
},
28+
KeyProperties: []string{"id"},
29+
BookmarkProperties: []string{},
30+
}
31+
}
32+
33+
func (s *StreamIncidentTypes) 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.IncidentTypesV1ListWithResponse(ctx)
39+
if err != nil {
40+
return nil, errors.Wrap(err, "listing incidents for actions stream")
41+
}
42+
43+
for _, element := range response.JSON200.IncidentTypes {
44+
results = append(results, model.IncidentTypeV1.Serialize(&element))
45+
}
46+
47+
return results, nil
48+
}

0 commit comments

Comments
 (0)