.generator/src/generator/templates/api.j2 in datadog_api_client-2.14.0 vs .generator/src/generator/templates/api.j2 in datadog_api_client-2.15.0
- old
+ new
@@ -226,20 +226,26 @@
# @yield [{{ get_type_at_path(operation, pagination.resultsPath) }}] Paginated items
def {{ operation.operationId|snake_case }}_with_pagination({% for name, parameter in operation|parameters if parameter.required %}{{ name|attribute_name }}, {% endfor %}opts = {})
api_version = "{{ version|upper }}"
page_size = @api_client.get_attribute_from_path({{ get_container(operation, pagination.limitParam) }}, {{ get_default(operation, pagination.limitParam) }})
@api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.limitParam, True) }}, page_size)
+ {%- if pagination.pageParam %}
+ @api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.pageParam, True) }}, 0)
+ {%- endif %}
while true do
response = {{ operation.operationId|snake_case }}({% for name, parameter in operation|parameters if parameter.required %}{{ name|attribute_name }}, {% endfor %}opts)
- @api_client.get_attribute_from_path(response, "{{ pagination.resultsPath|attribute_path }}").each { |item| yield(item) }
- if @api_client.get_attribute_from_path(response, "{{ pagination.resultsPath|attribute_path }}").length < page_size
+ @api_client.get_attribute_from_path(response, "{{ pagination.resultsPath|default('')|attribute_path }}").each { |item| yield(item) }
+ if @api_client.get_attribute_from_path(response, "{{ pagination.resultsPath|default('')|attribute_path }}").length < page_size
break
end
{%- if pagination.pageOffsetParam %}
@api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.pageOffsetParam, True) }}, @api_client.get_attribute_from_path({{ get_container(operation, pagination.pageOffsetParam) }}, 0) + page_size)
{%- endif %}
{%- if pagination.cursorParam %}
@api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.cursorParam, True) }}, @api_client.get_attribute_from_path(response, "{{ pagination.cursorPath }}"))
+ {%- endif %}
+ {%- if pagination.pageParam %}
+ @api_client.set_attribute_from_path(api_version, {{ get_container(operation, pagination.pageParam, True) }}, @api_client.get_attribute_from_path({{ get_container(operation, pagination.pageParam) }}, 0) + 1)
{%- endif %}
end
end
{%- endif %}
{%- if not loop.last %}