databricks-sdk-go
databricks-sdk-go copied to clipboard
[ISSUE] `workspaceClient.Users.ListAll` is doing an additional API call even if `TotalResults` is specified and the number of returned users matches it
Description
workspaceClient.Users.ListAll is doing an additional API call even if TotalResults is specified and the number of returned users matches it.
Reproduction
In Terraform exporter I'm returning following answer to the ListAll API call:
userListIdUsernameFixture = qa.HTTPFixture{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/Users?attributes=id%2CuserName&count=100&startIndex=1",
Response: iam.ListUsersResponse{
Resources: []iam.User{
{
Id: "id",
UserName: "[email protected]",
},
},
TotalResults: 1,
StartIndex: 1,
},
ReuseRequest: true,
}
But even if the number of resources matches to TotalResults, I'm still need to add a fixture with empty results:
userListIdUsernameFixture2 = qa.HTTPFixture{
Method: "GET",
Resource: "/api/2.0/preview/scim/v2/Users?attributes=id%2CuserName&count=100&startIndex=2",
Response: iam.ListUsersResponse{
Resources: []iam.User{},
TotalResults: 1,
StartIndex: 2,
},
ReuseRequest: true,
}
Expected behavior
An additional API call isn't required
Is it a regression?
No
Other Information
- OS: [e.g. macOS]
- Version: 0.26.1
Additional context
Was need to modify PR after upgrade of SDK: https://github.com/databricks/terraform-provider-databricks/pull/2980
Yup, this is a good point. We can add an extra check to skip the last request in this case.
I think that it's applicable to most of the list APIs