Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] workspaceClient.Users.ListAll is doing an additional API call even if TotalResults is specified and the number of returned users matches it #734

Open
alexott opened this issue Dec 9, 2023 · 2 comments

Comments

@alexott
Copy link
Contributor

alexott commented Dec 9, 2023

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: "user@domain.com",
				},
			},
			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: databricks/terraform-provider-databricks#2980

@alexott alexott changed the title [ISSUE] [ISSUE] workspaceClient.Users.ListAll is doing an additional API call even if TotalResults is specified and the number of returned users matches it Dec 9, 2023
@mgyucht
Copy link
Contributor

mgyucht commented Jan 3, 2024

Yup, this is a good point. We can add an extra check to skip the last request in this case.

@alexott
Copy link
Contributor Author

alexott commented Jan 3, 2024

I think that it's applicable to most of the list APIs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants