terraform-provider-cloudflare
terraform-provider-cloudflare copied to clipboard
Adds recently supported per_page/pagination teams_list
Relates to: https://github.com/cloudflare/terraform-provider-cloudflare/issues/1422 cf-go PR: https://github.com/cloudflare/cloudflare-go/pull/897
@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?
changelog detected :white_check_mark:
@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.
pending TotalPages
to land in the API response.
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!
@jacobbednarz is this PR still waiting on anything?
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]
@fwwieffering see two comments up from yours 😄
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!
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!
@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.
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 provideparam1=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.
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
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!