terraform-provider-cloudflare icon indicating copy to clipboard operation
terraform-provider-cloudflare copied to clipboard

Adds recently supported per_page/pagination teams_list

Open AkemiDavisson opened this issue 2 years ago • 10 comments

Relates to: https://github.com/cloudflare/terraform-provider-cloudflare/issues/1422 cf-go PR: https://github.com/cloudflare/cloudflare-go/pull/897

AkemiDavisson avatar Jun 16 '22 14:06 AkemiDavisson

@tjstansell you've mentioned in a couple of issues you've got near 5k team list items. are you able to take this PR for a spin and confirm you get them all back and managed correctly?

jacobbednarz avatar Jun 20 '22 05:06 jacobbednarz

changelog detected :white_check_mark:

github-actions[bot] avatar Jun 20 '22 05:06 github-actions[bot]

@tjstansell you've mentioned in a couple of issues you've got near 5k team list items. are you able to take this PR for a spin and confirm you get them all back and managed correctly?

Seems like there should be a unit test for this.

tjstansell avatar Jun 20 '22 16:06 tjstansell

pending TotalPages to land in the API response.

jacobbednarz avatar Jun 22 '22 08:06 jacobbednarz

Marking this pull request as stale due to 14 days of inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the lifecycle/stale label. If this pull request was automatically closed and you feel this pull request should be reopened, we encourage creating a new pull request linking back to this one for added context. Thank you!

github-actions[bot] avatar Jul 07 '22 00:07 github-actions[bot]

@jacobbednarz is this PR still waiting on anything?

fwwieffering avatar Jul 13 '22 12:07 fwwieffering

acceptance tests are green

TF_ACC=1 go test $(go list ./...) -v -run "^TestAccCloudflareTeamsList" -count 1 -parallel 1 -timeout 120m -parallel 1
?       github.com/cloudflare/terraform-provider-cloudflare     [no test files]
=== RUN   TestAccCloudflareTeamsListBasic
--- PASS: TestAccCloudflareTeamsListBasic (9.49s)
=== RUN   TestAccCloudflareTeamsListReordered
--- PASS: TestAccCloudflareTeamsListReordered (22.99s)
PASS
ok      github.com/cloudflare/terraform-provider-cloudflare/internal/provider   32.775s
?       github.com/cloudflare/terraform-provider-cloudflare/tools/cmd/changelog-check   [no test files]
?       github.com/cloudflare/terraform-provider-cloudflare/tools/cmd/maintainer-only-file-check        [no test files]
?       github.com/cloudflare/terraform-provider-cloudflare/tools/cmd/tf-log-check      [no test files]
?       github.com/cloudflare/terraform-provider-cloudflare/version     [no test files]

jacobbednarz avatar Jul 21 '22 02:07 jacobbednarz

@fwwieffering see two comments up from yours 😄

jacobbednarz avatar Jul 21 '22 02:07 jacobbednarz

Marking this pull request as stale due to 14 days of inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the lifecycle/stale label. If this pull request was automatically closed and you feel this pull request should be reopened, we encourage creating a new pull request linking back to this one for added context. Thank you!

github-actions[bot] avatar Aug 05 '22 00:08 github-actions[bot]

Marking this pull request as stale due to 14 days of inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the lifecycle/stale label. If this pull request was automatically closed and you feel this pull request should be reopened, we encourage creating a new pull request linking back to this one for added context. Thank you!

github-actions[bot] avatar Aug 23 '22 00:08 github-actions[bot]

@jacobbednarz API now returnst his: https://api.cloudflare.com/#zero-trust-lists-zero-trust-list-items

  "result_info": {
    "page": 1,
    "per_page": 20,
    "count": 1,
    "total_count": 2000
  }

Can you confirm this is not sufficient and you need total_pages as well? E.g. total_count / per_page? That seems redundant, but we can add it.

geota avatar Oct 04 '22 19:10 geota

there is a little bit of nuance in the v4 envelope that can be confusing.

  • page is the current page of results
  • per_page is the number of results expected in the current response
  • count is the number of filtered results found (say if you provide param1=blah to the request)
  • total_count is the number of all results without filters
  • total_pages is to return the number of all results without filters

i don't agree with this pattern (including filtered + unfiltered options in the response, as really, we don't actually care) however, that is the intended use of those fields which we're lacking some of here. some teams internally don't follow this and that's fine but we're trying to make sure all the fields at least exist for a consistent payload.

we are also in the process of standardising pagination in cloudflare-go so in the near future, consumers can do something like paginateResults(...) and this is will fetch all the results - see https://github.com/cloudflare/cloudflare-go/blob/dc6c002de52f15566cbcedb5be9a5e758858dabb/pagination.go. this relies on the TotalPages field being present.

jacobbednarz avatar Oct 04 '22 22:10 jacobbednarz

i've updated the internals of cloudflare-go to handle the pagination automatically via cloudflare/cloudflare-go#1114 so we no longer need it here. once that is released, this PR will be good to merge.

acceptance tests are all green

TF_ACC=1 go test $(go list ./...) -v -run "^TestAccCloudflareTeamsList_" -count 1 -parallel 1 -timeout 120m -parallel 1
?       github.com/cloudflare/terraform-provider-cloudflare     [no test files]
=== RUN   TestAccCloudflareTeamsList_Basic
--- PASS: TestAccCloudflareTeamsList_Basic (10.73s)
=== RUN   TestAccCloudflareTeamsList_LottaListItems
--- PASS: TestAccCloudflareTeamsList_LottaListItems (31.84s)
=== RUN   TestAccCloudflareTeamsList_Reordered
--- PASS: TestAccCloudflareTeamsList_Reordered (21.29s)
PASS
ok      github.com/cloudflare/terraform-provider-cloudflare/internal/provider   64.198s

jacobbednarz avatar Oct 20 '22 01:10 jacobbednarz

This functionality has been released in v3.27.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] avatar Nov 02 '22 00:11 github-actions[bot]