Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move shared modules outside of versions #870

Merged
merged 5 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .generator/src/generator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def cli(input, output):
"exceptions.py": env.get_template("exceptions.j2"),
"model_utils.py": env.get_template("model_utils.j2"),
"rest.py": env.get_template("rest.j2"),
"configuration.py": env.get_template("base_configuration.j2"),
}

apis = openapi.apis(spec)
Expand All @@ -79,10 +80,11 @@ def cli(input, output):
package = output / config["packageName"].replace(".", "/")
package.mkdir(parents=True, exist_ok=True)

top_package = package.parent
for name, template in extra_files.items():
filename = package / name
filename = top_package / name
with filename.open("w") as fp:
fp.write(template.render(apis=apis, models=models))
fp.write(template.render())

for name, model in models.items():
filename = formatter.snake_case(name) + ".py"
Expand Down
4 changes: 2 additions & 2 deletions .generator/src/generator/templates/api.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% include "api_info.j2" %}


from {{ config["packageName"] }}.api_client import ApiClient, Endpoint as _Endpoint
from {{ config["packageName"] }}.model_utils import (
from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
from datadog_api_client.model_utils import (
date,
datetime,
file_type,
Expand Down
11 changes: 4 additions & 7 deletions .generator/src/generator/templates/api_client.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ from urllib.parse import quote
from urllib3.fields import RequestField


from {{ config["packageName"] }} import rest
from {{ config["packageName"] }}.configuration import Configuration
from {{ config["packageName"] }}.exceptions import ApiTypeError, ApiValueError
from {{ config["packageName"] }}.model_utils import (
from datadog_api_client import rest
from datadog_api_client.exceptions import ApiTypeError, ApiValueError
from datadog_api_client.model_utils import (
ModelNormal,
ModelSimple,
ModelComposed,
Expand Down Expand Up @@ -52,9 +51,7 @@ class ApiClient(object):

_pool = None

def __init__(self, configuration=None, cookie=None, pool_threads=1):
if configuration is None:
configuration = Configuration.get_default_copy()
def __init__(self, configuration, cookie=None, pool_threads=1):
self.configuration = configuration
self.pool_threads = pool_threads

Expand Down
Loading