Skip to content

Refactor(policy-set): convert list to Iterator pattern#95

Merged
isivaselvan merged 3 commits into
hashicorp:next-0.1.3from
TanyaSingh369-svg:refactor/iterator-pattern/policy-set
Mar 5, 2026
Merged

Refactor(policy-set): convert list to Iterator pattern#95
isivaselvan merged 3 commits into
hashicorp:next-0.1.3from
TanyaSingh369-svg:refactor/iterator-pattern/policy-set

Conversation

@TanyaSingh369-svg

@TanyaSingh369-svg TanyaSingh369-svg commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Description

Refactored Policy Set resource listing from the previous ModelList-style return to an iterator pattern.

This aligns PolicySets.list() with other iterator-based resources and enables lazy pagination via the shared _Service._list helper.

Changes include:

  • Converted PolicySets.list() to return Iterator[PolicySet] (generator-based) instead of a list wrapper
  • Removed unused PolicySetList import from policy_set.py
  • Verified that the required PolicySet models are already correctly exported in models/__init__.py (no update needed)

Testing

-- 396 unit tests passing

-- Policy set related tests verified:
PYTHONPATH=. pytest -v tests/units -k policy_set
→ 14 passed

-- Example updated and verified:
examples/policy_set.py runs successfully with iterator output

-- Models unchanged for backward compatibility

Output from tests

Screenshot 2026-03-05 at 3 30 43 PM

Output from Unit Test

Screenshot 2026-03-05 at 3 31 34 PM Unit test

Output from Examples

Screenshot 2026-03-05 at 3 32 39 PM

@TanyaSingh369-svg TanyaSingh369-svg requested a review from a team as a code owner February 25, 2026 16:44
@isivaselvan

Copy link
Copy Markdown
Collaborator

Update the examples, models for policy_set and add the output of examples/policy_set.py in the conversation.

@isivaselvan isivaselvan merged commit a088311 into hashicorp:next-0.1.3 Mar 5, 2026
11 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.

2 participants