Skip to content

Fixed a bug to continue visting NextPageLink when listing key vaults from ARM API #17618

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

Merged
merged 3 commits into from
Mar 29, 2022

Conversation

BethanyZhou
Copy link
Contributor

@BethanyZhou BethanyZhou commented Mar 25, 2022

  • Fixed a bug to continue visting NextPageLink when listing key vaults from ARM API
  • Avoid listing key vaults twice

Description

Checklist

  • I have read the Submitting Changes section of CONTRIBUTING.md
  • The title of the PR is clear and informative
  • The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • The PR does not introduce breaking changes
  • If applicable, the changes made in the PR have proper test coverage
  • For public API changes to cmdlets:
    • a cmdlet design review was approved for the changes in this repository (Microsoft internal only)
      • {Please put the link here}
    • the markdown help files have been regenerated using the commands listed here

@BethanyZhou
Copy link
Contributor Author

/azp run azure-powershell - powershell-core

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@BethanyZhou
Copy link
Contributor Author

/azp run azure-powershell - windows-powershell

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@@ -18,7 +18,8 @@
- Additional information about change #1
-->
## Upcoming Release

* Fixed a bug to continue visting `NextPageLink` when listing key vaults from ARM API
Copy link
Member

Choose a reason for hiding this comment

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

bug id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No bug id, this issue is reported by email

{
IResourceManagementClient armClient = ResourceClient;

return new GenericPageEnumerable<GenericResource>(() => armClient.Resources.List(filter), armClient.Resources.ListNext, first, skip).Select(r => new PSKeyVaultIdentityItem(r));
var response = armClient.Resources.List(filter);
Copy link
Member

Choose a reason for hiding this comment

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

Refactor to avoid duplicated code

Copy link
Member

Choose a reason for hiding this comment

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

Introduce a new method
ListPagable(Func<type of response> getFirstPage, Func<string, type of response> getNextPage)
Then you can simplify these two methods to call ListPagable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored without delegate function as the signature of Resources.List(filter) and ResourceGroup.ListResources(resourcegroupName, filter) is different.

@BethanyZhou BethanyZhou requested a review from isra-fel March 28, 2022 11:11
@BethanyZhou BethanyZhou merged commit 3e2d09f into main Mar 29, 2022
@BethanyZhou BethanyZhou deleted the bez/keyvault branch March 29, 2022 05:13
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.

2 participants