Skip to content

Commit

Permalink
Cleanup endpoints creation (#1526)
Browse files Browse the repository at this point in the history
Remove some small default arguments.
  • Loading branch information
therve authored Jun 14, 2023
1 parent 6a068f6 commit b84918a
Show file tree
Hide file tree
Showing 70 changed files with 10 additions and 753 deletions.
4 changes: 0 additions & 4 deletions .generator/src/generator/templates/api.j2
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class {{ classname }}:
},
{%- endfor %}
],
{%- else %}
"servers": None,
{%- endif %}
},
params_map={
Expand Down Expand Up @@ -132,8 +130,6 @@ class {{ classname }}:
{%- if operation.requestBody %}
"content_type": [
{%- for mediaType in operation.requestBody.content.keys() %}"{{ mediaType }}"{%- if not loop.last %}, {% endif %}{%- endfor %}]
{% else %}
"content_type": [],
{%- endif %}
},
api_client=api_client,
Expand Down
9 changes: 5 additions & 4 deletions .generator/src/generator/templates/api_client.j2
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ class Endpoint:
elif is_unstable is False:
raise ApiValueError("Unstable operation '{0}' is disabled".format(self.settings["operation_id"]))

servers = self.settings.get("servers")
try:
index = self.api_client.configuration.server_operation_index.get(
self.settings["operation_id"], self.api_client.configuration.server_index
Expand All @@ -665,11 +666,11 @@ class Endpoint:
self.settings["operation_id"], self.api_client.configuration.server_variables
)
host = self.api_client.configuration.get_host_from_settings(
index, variables=server_variables, servers=self.settings["servers"]
index, variables=server_variables, servers=servers
)
except IndexError:
if self.settings["servers"]:
raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(self.settings["servers"]))
if servers:
raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(servers))
host = None

for key, value in kwargs.items():
Expand Down Expand Up @@ -704,7 +705,7 @@ class Endpoint:
if accept_headers_list:
params["header"]["Accept"] = self.api_client.select_header_accept(accept_headers_list)

content_type_headers_list = self.headers_map["content_type"]
content_type_headers_list = self.headers_map.get("content_type")
if content_type_headers_list:
header_list = self.api_client.select_header_content_type(content_type_headers_list)
params["header"]["Content-Type"] = header_list
Expand Down
9 changes: 5 additions & 4 deletions src/datadog_api_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ def call_with_http_info(self, **kwargs):
elif is_unstable is False:
raise ApiValueError("Unstable operation '{0}' is disabled".format(self.settings["operation_id"]))

servers = self.settings.get("servers")
try:
index = self.api_client.configuration.server_operation_index.get(
self.settings["operation_id"], self.api_client.configuration.server_index
Expand All @@ -664,11 +665,11 @@ def call_with_http_info(self, **kwargs):
self.settings["operation_id"], self.api_client.configuration.server_variables
)
host = self.api_client.configuration.get_host_from_settings(
index, variables=server_variables, servers=self.settings["servers"]
index, variables=server_variables, servers=servers
)
except IndexError:
if self.settings["servers"]:
raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(self.settings["servers"]))
if servers:
raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(servers))
host = None

for key, value in kwargs.items():
Expand Down Expand Up @@ -703,7 +704,7 @@ def call_with_http_info(self, **kwargs):
if accept_headers_list:
params["header"]["Accept"] = self.api_client.select_header_accept(accept_headers_list)

content_type_headers_list = self.headers_map["content_type"]
content_type_headers_list = self.headers_map.get("content_type")
if content_type_headers_list:
header_list = self.api_client.select_header_content_type(content_type_headers_list)
params["header"]["Content-Type"] = header_list
Expand Down
2 changes: 0 additions & 2 deletions src/datadog_api_client/v1/api/authentication_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ def __init__(self, api_client=None):
"operation_id": "validate",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand Down
12 changes: 0 additions & 12 deletions src/datadog_api_client/v1/api/aws_integration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def __init__(self, api_client=None):
"operation_id": "create_aws_account",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -60,7 +59,6 @@ def __init__(self, api_client=None):
"operation_id": "create_aws_tag_filter",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -81,7 +79,6 @@ def __init__(self, api_client=None):
"operation_id": "create_new_aws_external_id",
"http_method": "PUT",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -102,7 +99,6 @@ def __init__(self, api_client=None):
"operation_id": "delete_aws_account",
"http_method": "DELETE",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -123,7 +119,6 @@ def __init__(self, api_client=None):
"operation_id": "delete_aws_tag_filter",
"http_method": "DELETE",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -144,12 +139,10 @@ def __init__(self, api_client=None):
"operation_id": "list_available_aws_namespaces",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -162,7 +155,6 @@ def __init__(self, api_client=None):
"operation_id": "list_aws_accounts",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={
"account_id": {
Expand All @@ -183,7 +175,6 @@ def __init__(self, api_client=None):
},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -196,7 +187,6 @@ def __init__(self, api_client=None):
"operation_id": "list_aws_tag_filters",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={
"account_id": {
Expand All @@ -208,7 +198,6 @@ def __init__(self, api_client=None):
},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -221,7 +210,6 @@ def __init__(self, api_client=None):
"operation_id": "update_aws_account",
"http_method": "PUT",
"version": "v1",
"servers": None,
},
params_map={
"account_id": {
Expand Down
9 changes: 0 additions & 9 deletions src/datadog_api_client/v1/api/aws_logs_integration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(self, api_client=None):
"operation_id": "check_aws_logs_lambda_async",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -54,7 +53,6 @@ def __init__(self, api_client=None):
"operation_id": "check_aws_logs_services_async",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -75,7 +73,6 @@ def __init__(self, api_client=None):
"operation_id": "create_aws_lambda_arn",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -96,7 +93,6 @@ def __init__(self, api_client=None):
"operation_id": "delete_aws_lambda_arn",
"http_method": "DELETE",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -117,7 +113,6 @@ def __init__(self, api_client=None):
"operation_id": "enable_aws_log_services",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -138,12 +133,10 @@ def __init__(self, api_client=None):
"operation_id": "list_aws_logs_integrations",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -156,12 +149,10 @@ def __init__(self, api_client=None):
"operation_id": "list_aws_logs_services",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand Down
6 changes: 0 additions & 6 deletions src/datadog_api_client/v1/api/azure_integration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def __init__(self, api_client=None):
"operation_id": "create_azure_integration",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -51,7 +50,6 @@ def __init__(self, api_client=None):
"operation_id": "delete_azure_integration",
"http_method": "DELETE",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -72,12 +70,10 @@ def __init__(self, api_client=None):
"operation_id": "list_azure_integration",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -90,7 +86,6 @@ def __init__(self, api_client=None):
"operation_id": "update_azure_host_filters",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -111,7 +106,6 @@ def __init__(self, api_client=None):
"operation_id": "update_azure_integration",
"http_method": "PUT",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand Down
8 changes: 0 additions & 8 deletions src/datadog_api_client/v1/api/dashboard_lists_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def __init__(self, api_client=None):
"operation_id": "create_dashboard_list",
"http_method": "POST",
"version": "v1",
"servers": None,
},
params_map={
"body": {
Expand All @@ -53,7 +52,6 @@ def __init__(self, api_client=None):
"operation_id": "delete_dashboard_list",
"http_method": "DELETE",
"version": "v1",
"servers": None,
},
params_map={
"list_id": {
Expand All @@ -65,7 +63,6 @@ def __init__(self, api_client=None):
},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -78,7 +75,6 @@ def __init__(self, api_client=None):
"operation_id": "get_dashboard_list",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={
"list_id": {
Expand All @@ -90,7 +86,6 @@ def __init__(self, api_client=None):
},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -103,12 +98,10 @@ def __init__(self, api_client=None):
"operation_id": "list_dashboard_lists",
"http_method": "GET",
"version": "v1",
"servers": None,
},
params_map={},
headers_map={
"accept": ["application/json"],
"content_type": [],
},
api_client=api_client,
)
Expand All @@ -121,7 +114,6 @@ def __init__(self, api_client=None):
"operation_id": "update_dashboard_list",
"http_method": "PUT",
"version": "v1",
"servers": None,
},
params_map={
"list_id": {
Expand Down
Loading

0 comments on commit b84918a

Please sign in to comment.