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

tools/generator-go-sdk: generate custom pager for list method #3958

Merged

Conversation

teowa
Copy link
Contributor

@teowa teowa commented Mar 14, 2024

resolves hashicorp/terraform-provider-azurerm#24948

handle x-ms-pageable.nextLinkName, so the custom nextlink can be processed.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @teowa

Thanks for this PR - I've taken a look through and left some comments inline, but if we can fix those up then this should otherwise be good to go. Out of interest have you run the unit tests on the generated SDK to validate the output too?

Thanks!

@teowa teowa marked this pull request as ready for review March 15, 2024 08:00
NextLink *odata.Link %[2]s
}

func (p *ListCustomPager) NextPageLink() *odata.Link {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

No that's mostly for testing purposes, so this is fine. If NextPageLink returns nil then we assume we're at the end of the dataset, so that's fine/should be logged elsewhere

@tombuildsstuff
Copy link
Contributor

@teowa to pull the comment out from the last PR review - out of interest have you run the unit tests on the generated SDK to validate the output too?

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Thanks @teowa, this LGTM pending test results 👍

@teowa
Copy link
Contributor Author

teowa commented Mar 18, 2024

Hi, I just find some test failures, because customPager struct for long-running operation was not generated but pager option in request was generated, which causes go build failure. Some POST APIs are long-running opertion with pageable response, e.g., AppServiceEnvironments_ChangeVnet.

I have added these struct to pass the unit test but it won't take effect since long-running operation does not use ExecutePaged method like in normal list operation. And we may need to change the poll logic.

Or I should not generate customPager and pager option for long-running operation?

The list of 59 POST operations with `x-ms-pageable` and `x-ms-long-running-operation`:
containerapps/2023-05-01/jobs/method_stopmultipleexecutions.go
mysql/2021-05-01/configurations/method_batchupdate.go
mysql/2021-12-01-preview/configurations/method_batchupdate.go
mysql/2022-01-01/configurations/method_batchupdate.go
network/2023-04-01/bastionhosts/method_getactivesessions.go
network/2023-04-01/bastionhosts/method_putbastionshareablelink.go
network/2023-04-01/bastionshareablelink/method_putbastionshareablelink.go
network/2023-04-01/expressroutecircuitarptable/method_expressroutecircuitslistarptable.go
network/2023-04-01/expressroutecircuitroutestable/method_expressroutecircuitslistroutestable.go
network/2023-04-01/expressroutecircuitroutestablesummary/method_expressroutecircuitslistroutestablesummary.go
network/2023-04-01/expressroutecrossconnectionarptable/method_expressroutecrossconnectionslistarptable.go
network/2023-04-01/expressroutecrossconnectionroutetable/method_expressroutecrossconnectionslistroutestable.go
network/2023-04-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go
network/2023-04-01/networkinterfaces/method_geteffectiveroutetable.go
network/2023-04-01/networkinterfaces/method_listeffectivenetworksecuritygroups.go
network/2023-04-01/virtualnetworks/method_virtualnetworkslistddosprotectionstatus.go
network/2023-05-01/bastionshareablelink/method_putbastionshareablelink.go
network/2023-05-01/bastionhosts/method_getactivesessions.go
network/2023-05-01/bastionhosts/method_putbastionshareablelink.go
network/2023-05-01/expressroutecircuitarptable/method_expressroutecircuitslistarptable.go
network/2023-05-01/expressroutecircuitroutestable/method_expressroutecircuitslistroutestable.go
network/2023-05-01/expressroutecircuitroutestablesummary/method_expressroutecircuitslistroutestablesummary.go
network/2023-05-01/expressroutecrossconnectionarptable/method_expressroutecrossconnectionslistarptable.go
network/2023-05-01/expressroutecrossconnectionroutetable/method_expressroutecrossconnectionslistroutestable.go
network/2023-05-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go
network/2023-05-01/networkinterfaces/method_geteffectiveroutetable.go
network/2023-05-01/networkinterfaces/method_listeffectivenetworksecuritygroups.go
network/2023-05-01/virtualnetworks/method_virtualnetworkslistddosprotectionstatus.go
network/2023-06-01/bastionshareablelink/method_putbastionshareablelink.go
network/2023-06-01/bastionhosts/method_getactivesessions.go
network/2023-06-01/bastionhosts/method_putbastionshareablelink.go
network/2023-06-01/expressroutecircuitarptable/method_expressroutecircuitslistarptable.go
network/2023-06-01/expressroutecircuitroutestable/method_expressroutecircuitslistroutestable.go
network/2023-06-01/expressroutecircuitroutestablesummary/method_expressroutecircuitslistroutestablesummary.go
network/2023-06-01/expressroutecrossconnectionarptable/method_expressroutecrossconnectionslistarptable.go
network/2023-06-01/expressroutecrossconnectionroutetable/method_expressroutecrossconnectionslistroutestable.go
network/2023-06-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go
network/2023-06-01/networkinterfaces/method_geteffectiveroutetable.go
network/2023-06-01/networkinterfaces/method_listeffectivenetworksecuritygroups.go
network/2023-06-01/virtualnetworks/method_virtualnetworkslistddosprotectionstatus.go
network/2023-09-01/bastionshareablelink/method_putbastionshareablelink.go
network/2023-09-01/bastionhosts/method_getactivesessions.go
network/2023-09-01/bastionhosts/method_putbastionshareablelink.go
network/2023-09-01/expressroutecircuitarptable/method_expressroutecircuitslistarptable.go
network/2023-09-01/expressroutecircuitroutestable/method_expressroutecircuitslistroutestable.go
network/2023-09-01/expressroutecircuitroutestablesummary/method_expressroutecircuitslistroutestablesummary.go
network/2023-09-01/expressroutecrossconnectionarptable/method_expressroutecrossconnectionslistarptable.go
network/2023-09-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go
network/2023-09-01/expressroutecrossconnectionroutetable/method_expressroutecrossconnectionslistroutestable.go
network/2023-09-01/networkinterfaces/method_geteffectiveroutetable.go
network/2023-09-01/networkinterfaces/method_listeffectivenetworksecuritygroups.go
network/2023-09-01/virtualnetworks/method_virtualnetworkslistddosprotectionstatus.go
orbital/2022-11-01/contact/method_spacecraftslistavailablecontacts.go
web/2022-09-01/appserviceenvironments/method_changevnet.go
web/2022-09-01/appserviceenvironments/method_resume.go
web/2022-09-01/appserviceenvironments/method_suspend.go
web/2023-01-01/appserviceenvironments/method_changevnet.go
web/2023-01-01/appserviceenvironments/method_resume.go
web/2023-01-01/appserviceenvironments/method_suspend.go

@jschoombee
Copy link

any update?

@teowa
Copy link
Contributor Author

teowa commented May 30, 2024

I have added logic to generate customPager for immediateOperationTemplate and longRunningOperationTemplate additional to listOperationTemplate, the test can pass now. But as mentioned above, custom pager does not work in long-running operation since it does not use ExecutePaged method like in normal list operation.

@tombuildsstuff tombuildsstuff merged commit cea4f04 into hashicorp:main Jun 28, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

hashicorp/go-azure-sdk refactoring for azurerm_subscriptions - pagination and modelling issue
4 participants