Skip to content

Commit

Permalink
add sample data for api service
Browse files Browse the repository at this point in the history
  • Loading branch information
harshsoni2024 committed Jul 9, 2024
1 parent 3b2aeff commit 2d17366
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "sample collection",
"service": "MOCK_API_SERVICE"
}
6 changes: 6 additions & 0 deletions ingestion/examples/sample_data/api_service/api_endpoint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "sample endpoint",
"apiCollection": "MOCK_API_SERVICE.MOCK_API_COLLECTION",
"endpointURL": "localhost:1234/api/v2"
}

14 changes: 14 additions & 0 deletions ingestion/examples/sample_data/api_service/service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "API",
"serviceName": "sample_api",
"serviceConnection": {
"config": {
"type": "REST",
"openAPISchemaURL": "http://localhost:2000",
"token":"mock_token"
}
},
"sourceConfig": {
"config": {}
}
}
49 changes: 48 additions & 1 deletion ingestion/src/metadata/ingestion/source/database/sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
from pydantic import ValidationError

from metadata.generated.schema.analytics.reportData import ReportData, ReportDataType
from metadata.generated.schema.api.data.createAPICollection import (
CreateAPICollectionRequest,
)
from metadata.generated.schema.api.data.createAPIEndpoint import (
CreateAPIEndpointRequest,
)
from metadata.generated.schema.api.data.createChart import CreateChartRequest
from metadata.generated.schema.api.data.createContainer import CreateContainerRequest
from metadata.generated.schema.api.data.createDashboard import CreateDashboardRequest
Expand Down Expand Up @@ -536,6 +542,31 @@ def __init__(self, config: WorkflowSource, metadata: OpenMetadata):
encoding=UTF_8,
)
)
# self.api_service_json = json.load(
# open( # pylint: disable=consider-using-with
# sample_data_folder + "/api_service/service.json",
# "r",
# encoding=UTF_8,
# )
# )
# self.api_service = self.metadata.get_service_or_create(
# entity=ApiService,
# config=WorkflowSource(**self.api_service_json),
# )
self.api_collection = json.load(
open(
sample_data_folder + "/api_service/api_collection.json",
"r",
encoding=UTF_8,
)
)
self.api_endpoint = json.load(
open(
sample_data_folder + "/api_service/api_endpoint.json",
"r",
encoding=UTF_8,
)
)

@classmethod
def create(
Expand Down Expand Up @@ -577,7 +608,8 @@ def _iter(self, *_, **__) -> Iterable[Entity]:
yield from self.ingest_incidents()
yield from self.ingest_logical_test_suite()
yield from self.ingest_data_insights()
yield from self.ingest_life_cycle()
# yield from self.ingest_life_cycle()
yield from self.ingest_api_service()

def ingest_teams(self) -> Iterable[Either[CreateTeamRequest]]:
"""
Expand Down Expand Up @@ -1655,3 +1687,18 @@ def close(self):

def test_connection(self) -> None:
"""Custom sources don't support testing connections"""

def ingest_api_service(self) -> Iterable[Either[Entity]]:
"""Ingest API services"""

collection_request = CreateAPICollectionRequest(
name=self.api_collection["name"], service=self.api_collection["service"]
)
yield Either(right=collection_request)

endpoint_request = CreateAPIEndpointRequest(
name=self.api_endpoint["name"],
apiCollection=self.api_endpoint["apiCollection"],
endpointURL=self.api_endpoint["endpointURL"],
)
yield Either(right=endpoint_request)

0 comments on commit 2d17366

Please sign in to comment.