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

Document unique pagination method used in Org Runs Index endpoint #770

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions website/docs/cloud-docs/api-docs/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: >-

Keep track of changes to the API for HCP Terraform and Terraform Enterprise.

## 2024-10-15
* Document unique pagination metadata given in the response of [Organization Runs Index API](/terraform/cloud-docs/api-docs/run##list-runs-in-an-organization).

## 2024-10-15
* Add new documentation for the ability to deprecate, and revert the deprecation of, module versions. Learn more about [Managing module versions](/terraform/cloud-docs/api-docs/private-registry/manage-module-versions).
Expand Down
37 changes: 35 additions & 2 deletions website/docs/cloud-docs/api-docs/run.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,24 @@ curl \
}
},
{...}
]
],
"links": {
"first": "https://app.terraform.io/api/v2/workspaces/ws-yF7z4gyEQRhaCNG9/runs?page[number]=1&page[size]=20",
"last": "https://app.terraform.io/api/v2/workspaces/ws-yF7z4gyEQRhaCNG9/runs?page[number]=19206&page[size]=20",
"self": "https://app.terraform.io/api/v2/workspaces/ws-yF7z4gyEQRhaCNG9/runs?page[number]=2&page[size]=20",
"prev": "https://app.terraform.io/api/v2/workspaces/ws-yF7z4gyEQRhaCNG9/runs?page[number]=1&page[size]=20",
"next": "https://app.terraform.io/api/v2/workspaces/ws-yF7z4gyEQRhaCNG9/runs?page[number]=3&page[size]=20"
},
"meta": {
"pagination": {
"current-page": 2,
"next-page": 3,
"prev-page": 1,
"page-size": 20,
"total-count": 384105,
"total-pages": 19206
}
}
}
```

Expand All @@ -456,6 +473,8 @@ curl \

This endpoint has an adjusted rate limit of 30 requests per minute. Note that most endpoints are limited to 30 requests per second.

Note that this endpoint differs from others in the pagination metadata included in the response, such as the exclusion of the typical `total-count` and `total-pages`. See the Sample Response below for more details.

| Status | Response | Reason |
|---------|--------------------------------------------------|--------------------------|
| [200][] | Array of [JSON API document][]s (`type: "runs"`) | Successfully listed runs |
Expand Down Expand Up @@ -553,7 +572,21 @@ curl \
}
},
{...}
]
],
"links": {
"self": "https://app.terraform.io/api/v2/organizations/hashicorp/runs?page[number]=2&page[size]=20",
"prev": "https://app.terraform.io/api/v2/organizations/hashicorp/runs?page[number]=1&page[size]=20",
"next": "https://app.terraform.io/api/v2/organizations/hashicorp/runs?page[number]=3&page[size]=20"
},
"meta": {
"pagination": {
"current-page": 1,
"next-page": 2,
"prev-page": null,
Comment on lines +584 to +585
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 554, there there is a "links" section. We could also reinforce the flexibility of the existing data by including the pagination links (not this example in particular but something similar)

This exists on workspace runs.. does it also exist on org runs?

For example:

"links": {
    "self": "https://app.terraform.io/api/v2/workspaces/ws-SqohByt1nDRfQhzT/runs?filter%5Boperation%5D=plan_only&page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "first": "https://app.terraform.io/api/v2/workspaces/ws-SqohByt1nDRfQhzT/runs?filter%5Boperation%5D=plan_only&page%5Bnumber%5D=1&page%5Bsize%5D=20",
    "prev": null,
    "next": null,
    "last": "https://app.terraform.io/api/v2/workspaces/ws-SqohByt1nDRfQhzT/runs?filter%5Boperation%5D=plan_only&page%5Bnumber%5D=1&page%5Bsize%5D=20"
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hadn't considered including this metadata portion from the original pagination method. Currently the related PR for the org runs endpoint pagination update doesn't have these links. I'm wondering if it's worth adding them now, though I suppose it wouldn't be a breaking change if the new pagination method was later updated if there was a found need for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the associated altas PR to include pagination links, as well as documented them here: c8aefb1

Additionally added pagination documentation for the workspace run list endpoint to better highlight the differences.

"page-size": 20,
"page-count": 20
}
}
}
```

Expand Down