Skip to content

Commit 1cc0686

Browse files
committed
update readme file and add options
1 parent 34a563e commit 1cc0686

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+148
-53
lines changed

README.md

+56

gen_models.py

+48-9
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@
77
from pathlib import Path
88
import subprocess
99
import sys
10+
import argparse # Added import
1011
from requests.adapters import HTTPAdapter
1112
from requests.packages.urllib3.util.retry import Retry
1213

1314
logging.basicConfig(level=logging.INFO)
1415
logger = logging.getLogger(__name__)
1516

1617
class OpenAPIDiscovery:
17-
def __init__(self):
18+
def __init__(self, input_dir, output_dir, verbose, use_cache):
1819
self.base_url = "https://api.github.com/repos/eda-labs/openapi"
1920
self.raw_base = "https://raw.githubusercontent.com/eda-labs/openapi/main"
2021
self.headers = {"Accept": "application/vnd.github.v3+json"}
2122
self.cache_file = Path("cached_specs.json")
22-
23+
self.input_dir = Path(input_dir) # Added
24+
self.output_dir = Path(output_dir) # Added
25+
self.verbose = verbose # Added
26+
self.use_cache = use_cache # Added
27+
28+
if self.verbose:
29+
logger.setLevel(logging.DEBUG)
30+
2331
# Configure retry strategy
2432
retry_strategy = Retry(
2533
total=3,
@@ -107,10 +115,10 @@ def discover_specs(self, use_cache=True):
107115

108116
return specs
109117

110-
def generate_models(self, use_cache=True):
111-
output_dir = Path("models")
118+
def generate_models(self):
119+
output_dir = self.output_dir # Modified to use argument
112120
output_dir.mkdir(exist_ok=True)
113-
specs = self.discover_specs(use_cache=use_cache)
121+
specs = self.discover_specs(use_cache=self.use_cache)
114122

115123
if not specs:
116124
logger.warning("No specs found!")
@@ -136,7 +144,38 @@ def generate_models(self, use_cache=True):
136144
logger.error(f"Error generating models for {module_name}: {e}")
137145

138146
if __name__ == "__main__":
139-
discovery = OpenAPIDiscovery()
140-
# Use --no-cache flag to force fresh discovery
141-
use_cache = "--no-cache" not in sys.argv
142-
discovery.generate_models(use_cache=use_cache)
147+
parser = argparse.ArgumentParser(
148+
description="Discover OpenAPI specifications and generate Pydantic models."
149+
)
150+
parser.add_argument(
151+
"--input",
152+
type=str,
153+
default="./openapi_specs",
154+
help="Path to the OpenAPI specifications directory. Default: ./openapi_specs",
155+
)
156+
parser.add_argument(
157+
"--output",
158+
type=str,
159+
default="./models",
160+
help="Path to the output models directory. Default: ./models",
161+
)
162+
parser.add_argument(
163+
"--verbose",
164+
action="store_true",
165+
help="Enable verbose logging. Default: False",
166+
)
167+
parser.add_argument(
168+
"--no-cache",
169+
action="store_true",
170+
help="Force fresh discovery by ignoring the cache. Default: False",
171+
)
172+
173+
args = parser.parse_args()
174+
175+
discovery = OpenAPIDiscovery(
176+
input_dir=args.input,
177+
output_dir=args.output,
178+
verbose=args.verbose,
179+
use_cache=not args.no_cache
180+
)
181+
discovery.generate_models()

models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/topologies.eda.nokia.com/v1alpha1/topologies.json
3-
# timestamp: 2025-01-22T14:01:37+00:00
3+
# timestamp: 2025-01-22T14:26:22+00:00
44

55
from __future__ import annotations
66

models/com/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/topologies.eda.nokia.com/v1alpha1/topologies.json
3-
# timestamp: 2025-01-22T14:01:37+00:00
3+
# timestamp: 2025-01-22T14:26:22+00:00

models/com/nokia/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/topologies.eda.nokia.com/v1alpha1/topologies.json
3-
# timestamp: 2025-01-22T14:01:37+00:00
3+
# timestamp: 2025-01-22T14:26:22+00:00

models/com/nokia/eda/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/topologies.eda.nokia.com/v1alpha1/topologies.json
3-
# timestamp: 2025-01-22T14:01:37+00:00
3+
# timestamp: 2025-01-22T14:26:22+00:00

models/com/nokia/eda/aaa/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/aaa.eda.nokia.com/v1alpha1/aaa.json
3-
# timestamp: 2025-01-22T14:01:02+00:00
3+
# timestamp: 2025-01-22T14:25:42+00:00

models/com/nokia/eda/aaa/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/aaa.eda.nokia.com/v1alpha1/aaa.json
3-
# timestamp: 2025-01-22T14:01:02+00:00
3+
# timestamp: 2025-01-22T14:25:42+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/appstore.eda.nokia.com/v1/appstore.json
3-
# timestamp: 2025-01-22T14:01:04+00:00
3+
# timestamp: 2025-01-22T14:25:44+00:00

models/com/nokia/eda/appstore/v1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/appstore.eda.nokia.com/v1/appstore.json
3-
# timestamp: 2025-01-22T14:01:04+00:00
3+
# timestamp: 2025-01-22T14:25:44+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/bootstrap.eda.nokia.com/v1alpha1/bootstrap.json
3-
# timestamp: 2025-01-22T14:01:05+00:00
3+
# timestamp: 2025-01-22T14:25:46+00:00

models/com/nokia/eda/bootstrap/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/bootstrap.eda.nokia.com/v1alpha1/bootstrap.json
3-
# timestamp: 2025-01-22T14:01:05+00:00
3+
# timestamp: 2025-01-22T14:25:46+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/components.eda.nokia.com/v1alpha1/components.json
3-
# timestamp: 2025-01-22T14:01:07+00:00
3+
# timestamp: 2025-01-22T14:25:48+00:00

models/com/nokia/eda/components/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/components.eda.nokia.com/v1alpha1/components.json
3-
# timestamp: 2025-01-22T14:01:07+00:00
3+
# timestamp: 2025-01-22T14:25:48+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/config.eda.nokia.com/v1alpha1/config.json
3-
# timestamp: 2025-01-22T14:01:08+00:00
3+
# timestamp: 2025-01-22T14:25:50+00:00

models/com/nokia/eda/config/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/config.eda.nokia.com/v1alpha1/config.json
3-
# timestamp: 2025-01-22T14:01:08+00:00
3+
# timestamp: 2025-01-22T14:25:50+00:00
44

55
from __future__ import annotations
66

models/com/nokia/eda/core/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/core.eda.nokia.com/v1/core.json
3-
# timestamp: 2025-01-22T14:01:11+00:00
3+
# timestamp: 2025-01-22T14:25:53+00:00

models/com/nokia/eda/core/v1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/core.eda.nokia.com/v1/core.json
3-
# timestamp: 2025-01-22T14:01:11+00:00
3+
# timestamp: 2025-01-22T14:25:53+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/fabrics.eda.nokia.com/v1alpha1/fabrics.json
3-
# timestamp: 2025-01-22T14:01:13+00:00
3+
# timestamp: 2025-01-22T14:25:55+00:00

models/com/nokia/eda/fabrics/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/fabrics.eda.nokia.com/v1alpha1/fabrics.json
3-
# timestamp: 2025-01-22T14:01:13+00:00
3+
# timestamp: 2025-01-22T14:25:55+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/filters.eda.nokia.com/v1alpha1/filters.json
3-
# timestamp: 2025-01-22T14:01:14+00:00
3+
# timestamp: 2025-01-22T14:25:57+00:00

models/com/nokia/eda/filters/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/filters.eda.nokia.com/v1alpha1/filters.json
3-
# timestamp: 2025-01-22T14:01:14+00:00
3+
# timestamp: 2025-01-22T14:25:57+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/interfaces.eda.nokia.com/v1alpha1/interfaces.json
3-
# timestamp: 2025-01-22T14:01:16+00:00
3+
# timestamp: 2025-01-22T14:26:00+00:00

models/com/nokia/eda/interfaces/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/interfaces.eda.nokia.com/v1alpha1/interfaces.json
3-
# timestamp: 2025-01-22T14:01:16+00:00
3+
# timestamp: 2025-01-22T14:26:00+00:00
44

55
from __future__ import annotations
66

models/com/nokia/eda/oam/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/oam.eda.nokia.com/v1alpha1/oam.json
3-
# timestamp: 2025-01-22T14:01:18+00:00
3+
# timestamp: 2025-01-22T14:26:02+00:00

models/com/nokia/eda/oam/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/oam.eda.nokia.com/v1alpha1/oam.json
3-
# timestamp: 2025-01-22T14:01:18+00:00
3+
# timestamp: 2025-01-22T14:26:02+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/protocols.eda.nokia.com/v1alpha1/protocols.json
3-
# timestamp: 2025-01-22T14:01:21+00:00
3+
# timestamp: 2025-01-22T14:26:06+00:00

models/com/nokia/eda/protocols/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/protocols.eda.nokia.com/v1alpha1/protocols.json
3-
# timestamp: 2025-01-22T14:01:21+00:00
3+
# timestamp: 2025-01-22T14:26:06+00:00
44

55
from __future__ import annotations
66

models/com/nokia/eda/qos/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/qos.eda.nokia.com/v1alpha1/qos.json
3-
# timestamp: 2025-01-22T14:01:23+00:00
3+
# timestamp: 2025-01-22T14:26:08+00:00

models/com/nokia/eda/qos/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/qos.eda.nokia.com/v1alpha1/qos.json
3-
# timestamp: 2025-01-22T14:01:23+00:00
3+
# timestamp: 2025-01-22T14:26:08+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/routing.eda.nokia.com/v1alpha1/routing.json
3-
# timestamp: 2025-01-22T14:01:24+00:00
3+
# timestamp: 2025-01-22T14:26:10+00:00

models/com/nokia/eda/routing/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/routing.eda.nokia.com/v1alpha1/routing.json
3-
# timestamp: 2025-01-22T14:01:24+00:00
3+
# timestamp: 2025-01-22T14:26:10+00:00
44

55
from __future__ import annotations
66

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/routingpolicies.eda.nokia.com/v1alpha1/routingpolicies.json
3-
# timestamp: 2025-01-22T14:01:26+00:00
3+
# timestamp: 2025-01-22T14:26:11+00:00

models/com/nokia/eda/routingpolicies/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/routingpolicies.eda.nokia.com/v1alpha1/routingpolicies.json
3-
# timestamp: 2025-01-22T14:01:26+00:00
3+
# timestamp: 2025-01-22T14:26:11+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/security.eda.nokia.com/v1alpha1/security.json
3-
# timestamp: 2025-01-22T14:01:27+00:00
3+
# timestamp: 2025-01-22T14:26:12+00:00

models/com/nokia/eda/security/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/security.eda.nokia.com/v1alpha1/security.json
3-
# timestamp: 2025-01-22T14:01:27+00:00
3+
# timestamp: 2025-01-22T14:26:12+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/services.eda.nokia.com/v1alpha1/services.json
3-
# timestamp: 2025-01-22T14:01:31+00:00
3+
# timestamp: 2025-01-22T14:26:16+00:00

models/com/nokia/eda/services/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/services.eda.nokia.com/v1alpha1/services.json
3-
# timestamp: 2025-01-22T14:01:31+00:00
3+
# timestamp: 2025-01-22T14:26:16+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/siteinfo.eda.nokia.com/v1alpha1/siteinfo.json
3-
# timestamp: 2025-01-22T14:01:33+00:00
3+
# timestamp: 2025-01-22T14:26:17+00:00

models/com/nokia/eda/siteinfo/v1alpha1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/siteinfo.eda.nokia.com/v1alpha1/siteinfo.json
3-
# timestamp: 2025-01-22T14:01:33+00:00
3+
# timestamp: 2025-01-22T14:26:17+00:00
44

55
from __future__ import annotations
66

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# generated by datamodel-codegen:
22
# filename: https://raw.githubusercontent.com/eda-labs/openapi/main/apps/system.eda.nokia.com/v1alpha1/system.json
3-
# timestamp: 2025-01-22T14:01:34+00:00
3+
# timestamp: 2025-01-22T14:26:19+00:00

0 commit comments

Comments
 (0)