Skip to content

Commit

Permalink
Move shared modules outside of versions (#870)
Browse files Browse the repository at this point in the history
* Move shared modules outside of versions

This moves the top level modules outside of v1 and v2 to remove
duplication.

* Rebase

* Move auth

* Rebase
  • Loading branch information
therve authored Mar 9, 2022
1 parent d689662 commit 93243d9
Show file tree
Hide file tree
Showing 1,177 changed files with 2,072 additions and 5,734 deletions.
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

0 comments on commit 93243d9

Please sign in to comment.