diff --git a/README.md b/README.md index cf88c02..e530a02 100644 --- a/README.md +++ b/README.md @@ -132,10 +132,20 @@ settings_value = { settings_object = SettingsObjectCreate(schema_id="builtin:anomaly-detection.metric-events", value=settings_value, scope="environment") dt.settings.create_object(validate_only=False, body=settings_object) + +events = [ + { + "id": "HOST-82F576674F19AC16", + "tags:custom.test": {"test": "test"}, + } +] +response = dt.openpipeline.smartscape_eventv1_ingest(events) +print(response.status_code) ``` ## Implementation Progress + ### Environment API V2 API | Level | Access | @@ -250,3 +260,12 @@ dt.settings.create_object(validate_only=False, body=settings_object) Service - IBM MQ tracing | :x: | | Service - Request attributes | :x: | | Service - Request naming | :x: | | + +### OpenPipeline + + API | Level | Access | +:----------------------------------------|:------------------:|:------------------------------------------| + ingest Built-in Smartscape v1 events | :heavy_check_mark: | `dt.openpipeline.smartscape_eventv1_ingest` | + ingest Generic Events | :x: | | + ingest SDLC Events | :x: | | + ingest Security Events | :x: | | diff --git a/dynatrace/main.py b/dynatrace/main.py index 144b892..417213a 100644 --- a/dynatrace/main.py +++ b/dynatrace/main.py @@ -58,6 +58,7 @@ from dynatrace.environment_v2.service_level_objectives import SloService from dynatrace.environment_v2.logs import LogService from dynatrace.environment_v2.settings import SettingService +from dynatrace.openpipeline.ingest import OpenPipelineService from dynatrace.http_client import HttpClient @@ -144,3 +145,4 @@ def __init__( # New implementations should be done here, above is deprecated self.config_v1: ConfigurationV1 = ConfigurationV1(self.__http_client) + self.openpipeline: OpenPipelineService = OpenPipelineService(self.__http_client) diff --git a/dynatrace/openpipeline/__init__.py b/dynatrace/openpipeline/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dynatrace/openpipeline/ingest.py b/dynatrace/openpipeline/ingest.py new file mode 100644 index 0000000..1eb6395 --- /dev/null +++ b/dynatrace/openpipeline/ingest.py @@ -0,0 +1,31 @@ +""" +Copyright 2026 Dynatrace LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +from typing import Any, Dict, List + +from requests import Response + +from dynatrace.http_client import HttpClient + + +class OpenPipelineService: + SMARTSCAPE_ENDPOINT = "/platform/ingest/v1/smartscape.events" + + def __init__(self, http_client: HttpClient): + self.__http_client = http_client + + def smartscape_eventv1_ingest(self, events: List[Dict[str, Any]]): + return self.__http_client.make_request(self.SMARTSCAPE_ENDPOINT, params=events, method="POST") diff --git a/test/mock_data/POST_platform_ingest_v1_smartscape_events_d81457a1c73ef2d.json b/test/mock_data/POST_platform_ingest_v1_smartscape_events_d81457a1c73ef2d.json new file mode 100644 index 0000000..e69de29 diff --git a/test/openpipeline/__init__.py b/test/openpipeline/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/openpipeline/test_smartscape_events.py b/test/openpipeline/test_smartscape_events.py new file mode 100644 index 0000000..92ab844 --- /dev/null +++ b/test/openpipeline/test_smartscape_events.py @@ -0,0 +1,11 @@ +from dynatrace import Dynatrace + + +def test_ingest(dt: Dynatrace): + events = [ + { + "id": "HOST-82F576674F19AC16", + "tags:custom.test": {"test": "test"}, + } + ] + response = dt.openpipeline.smartscape_eventv1_ingest(events) \ No newline at end of file