Skip to content

Refactor Run resource to use Iterator pattern#86

Closed
NimishaShrivastava-dev wants to merge 3 commits into
hashicorp:mainfrom
NimishaShrivastava-dev:Refactoring/iterator-pattern/run
Closed

Refactor Run resource to use Iterator pattern#86
NimishaShrivastava-dev wants to merge 3 commits into
hashicorp:mainfrom
NimishaShrivastava-dev:Refactoring/iterator-pattern/run

Conversation

@NimishaShrivastava-dev

Copy link
Copy Markdown
Contributor

Summary

Converted the run resource listing methods to use the Iterator pattern instead of returning ModelList objects.

Changes

  • Updated Runs.list() to return Iterator[Run]
  • Updated Runs.list_for_organization() to return Iterator[Run]
  • Both methods now use the internal _list() helper for pagination
  • Updated examples/run.py to convert iterators to lists where needed
  • Updated unit tests to mock _list() and verify data transformation

Testing

  • All 396 tests pass
  • No breaking changes to public API
  • Models remain unchanged for backward compatibility

Related

Aligns with iterator pattern used in policy_evaluation and oauth_token resources

@NimishaShrivastava-dev NimishaShrivastava-dev requested a review from a team as a code owner February 19, 2026 08:44
@hashicorp-cla-app

hashicorp-cla-app Bot commented Feb 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread examples/run.py
print(f"Total runs fetched: {len(run_list)}")
print()

for run in run_list.items:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Share the output results of examples/run.py file in the conversation.

Comment thread src/pytfe/models/run.py
value: str = Field(..., alias="value")


class RunList(BaseModel):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add back the RunList and OrganizationRunList models.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

restored these models

Comment thread tests/units/test_run.py
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