From 9ffe1fa89f69a64c8aff5e5cbb002b1106aaa630 Mon Sep 17 00:00:00 2001 From: Chris Marchetti Date: Thu, 2 Nov 2023 14:01:26 -0600 Subject: [PATCH] feat: added asset type stream --- config.json | 4 ---- tap_freshservice/streams/asset_types.py | 27 +++++++++++++++++++++++++ tap_freshservice/tap.py | 3 ++- 3 files changed, 29 insertions(+), 5 deletions(-) delete mode 100644 config.json create mode 100644 tap_freshservice/streams/asset_types.py diff --git a/config.json b/config.json deleted file mode 100644 index aab3c4a..0000000 --- a/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "api_key": "", - "url_base": "https://.freshservice.com/api/v2" -} \ No newline at end of file diff --git a/tap_freshservice/streams/asset_types.py b/tap_freshservice/streams/asset_types.py new file mode 100644 index 0000000..ff0ef02 --- /dev/null +++ b/tap_freshservice/streams/asset_types.py @@ -0,0 +1,27 @@ +"""Stream type classes for tap-freshservice.""" +from singer_sdk import typing as th # JSON Schema typing helpers + +from tap_freshservice.client import FreshserviceStream + +class AssetTypesStream(FreshserviceStream): + name = "asset_types" + path = "/asset_types" + records_jsonpath="$.asset_types[*]" + + def get_url(self, context: dict): + url = super().get_url(context) + return url + + def build_prepared_request(self, *args, **kwargs): + req = super().build_prepared_request(*args, **kwargs) + return req + + schema = th.PropertiesList( + th.Property("id", th.IntegerType), + th.Property("name", th.StringType), + th.Property("parent_asset_type_id", th.IntegerType), + th.Property("visible", th.BooleanType), + th.Property("description", th.StringType), + th.Property("created_at", th.DateTimeType), + th.Property("updated_at", th.DateTimeType), + ).to_dict() \ No newline at end of file diff --git a/tap_freshservice/tap.py b/tap_freshservice/tap.py index 4f3fb17..8bf07b2 100644 --- a/tap_freshservice/tap.py +++ b/tap_freshservice/tap.py @@ -5,7 +5,7 @@ from singer_sdk import Tap from singer_sdk import typing as th # JSON schema typing helpers -from tap_freshservice.streams import (assets, groups, tickets) +from tap_freshservice.streams import (assets, asset_types, groups, tickets) class TapFreshservice(Tap): @@ -46,6 +46,7 @@ def discover_streams(self) -> list[tickets.FreshserviceStream]: tickets.TicketsStream(self), groups.GroupsStream(self), assets.AssetsStream(self), + asset_types.AssetTypesStream(self), ]