Skip to content

Commit 4bb8371

Browse files
Fix SCIM pagination (#193)
## Changes Supersedes #188. This PR incorporates two hard-coded changes for the SCIM API in the Python SDK: startIndex starts at 1 for SCIM APIs, not 0. However, the existing .Pagination.Increment controls both the start index as well as whether the pagination is per-page or per-resource. Later, we should replace this extension with two independent OpenAPI options: one_indexed (defaulting to false) and pagination_basis (defaulting to resource but can be overridden to page). If users don't specify a limit, the SDK will include a hard-coded limit of 100 resources per request. We could add this to the OpenAPI spec as an option default_limit, which is useful for any non-paginated APIs that later expose pagination options and allow the SDK to gracefully support those. However, we don't want to encourage folks to use this pattern: all new list APIs are required to be paginated from the start. ## Tests <!-- How is this tested? --> --------- Co-authored-by: Xinjie Zheng <[email protected]>
1 parent f814e5b commit 4bb8371

File tree

8 files changed

+37
-7
lines changed

8 files changed

+37
-7
lines changed

.codegen/api.java.tmpl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,18 @@ public class {{.PascalName}}API {
131131
{{define "method-call-paginated" -}}
132132
{{- if .Pagination.MultiRequest -}}
133133
{{- if and .Pagination.Offset (not (eq .Path "/api/2.0/clusters/events")) -}}
134-
request.set{{.Pagination.Offset.PascalName}}({{if eq .Pagination.Increment 1}}1{{else}}0{{end}}L);{{end -}}
134+
request.set{{.Pagination.Offset.PascalName}}(
135+
{{- if eq .Pagination.Increment 1 -}}
136+
1
137+
{{- else if contains .Path "/scim/v2/" -}}
138+
1
139+
{{- else -}}
140+
0
141+
{{- end}}L);{{end -}}
142+
{{if and .Pagination.Limit (contains .Path "/scim/v2/")}}
143+
if (request.get{{.Pagination.Limit.PascalName}}() == 0L) {
144+
request.set{{.Pagination.Limit.PascalName}}(100L);
145+
}{{end -}}
135146
return new Paginator<>(request, impl::{{template "java-name" .}}, {{template "type" .Response}}::get{{.Pagination.Results.PascalName}}, response -> {
136147
{{if eq .Path "/api/2.0/clusters/events" -}}
137148
return response.getNextPage();

databricks-sdk-java/src/main/java/com/databricks/sdk/service/iam/AccountGroupsAPI.java

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks-sdk-java/src/main/java/com/databricks/sdk/service/iam/AccountServicePrincipalsAPI.java

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks-sdk-java/src/main/java/com/databricks/sdk/service/iam/AccountUsersAPI.java

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks-sdk-java/src/main/java/com/databricks/sdk/service/iam/GroupsAPI.java

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks-sdk-java/src/main/java/com/databricks/sdk/service/iam/ServicePrincipalsAPI.java

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks-sdk-java/src/main/java/com/databricks/sdk/service/iam/UsersAPI.java

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks-sdk-java/src/main/java/com/databricks/sdk/service/sql/ChannelName.java

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)