Skip to content

Refactor/iterator pattern conversion#113

Merged
isivaselvan merged 4 commits intonext-0.1.3from
refactor/Iterator-pattern-conversion
Mar 13, 2026
Merged

Refactor/iterator pattern conversion#113
isivaselvan merged 4 commits intonext-0.1.3from
refactor/Iterator-pattern-conversion

Conversation

@isivaselvan
Copy link
Copy Markdown
Collaborator

@isivaselvan isivaselvan commented Mar 12, 2026

Description

This PR converts list operations in selected resources to iterator-based behavior, aligns examples and unit tests.

Changes

  • Converted list methods to return iterators for:
    • Policy checks
    • State versions
    • State Version Outputs
    • Variable sets
    • Variable set variables
  • Updated related list options models to match iterator-style usage.
  • Removed page_number usage where it was no longer applicable for iterator-based list options.
  • Updated example scripts to consume iterators correctly using list materialization or direct iteration.
  • Updated and added unit tests for iterator behaviour.

Testing plan

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

image

VariableSet and VariableSetVariable

TFE Python SDK - Variable Set Examples
==================================================
=== Variable Set Operations Example ===

1. Listing existing variable sets...
Found 0 existing variable sets

2. Creating a new variable set...
Created variable set: python-sdk-example-varset (ID: varset-gzGhAo2Tf)
Description: Example variable set created with Python SDK
Global: False
Priority: True

Listing existing variable sets...
Found 1 existing variable sets
- python-sdk-example-varset (ID: varset-gzo2Tf, Global: False)

3. Creating variables in the variable set...
Created Terraform variable: environment = production
Created environment variable: DATABASE_URL (sensitive)
Created HCL variable: instance_config (HCL format)

4. Listing variables in the variable set...
Found 3 variables in the set:
- environment: terraform
Description: Environment name
- DATABASE_URL: env (sensitive)
Description: Production database connection string
- instance_config: terraform (HCL)
Description: Instance configuration

7. Workspace operations example...
Applying variable set to workspace: test-duplicate-20251125-185311
Successfully applied to workspace
Listing variable sets for workspace: test-duplicate-20251125-185311
- python-sdk-updated-varset (ID: varset-gzGo2Tf)
Workspace now has 1 variable sets
Successfully removed from workspace

8. Project operations example...
Applying variable set to project: Default Project
Successfully applied to project
Listing variable sets for project: Default Project
- python-sdk-updated-varset (ID: varset-gzGMo2Tf)
Project now has 1 variable sets
Successfully removed from project

StateVersion and StateVersionOutputs

python examples/state_versions.py --org=siva --workspace-id=ws-hwGNpHx4u --workspace=output-test-workspace
Total state versions: 1

- sv-FBGYjv | status=StateVersionStatus.FINALIZED | created_at=2026-03-06 09:03:51.617000+00:00

================================================================================
Org-scoped listing via /api/v2/state-versions (first page)
================================================================================
- sv-FGYjv | status=StateVersionStatus.FINALIZED | created_at=2026-03-06 09:03:51.617000+00:00

================================================================================
Listing outputs (current state version)
================================================================================
- environment: sensitive=False type=string value=test
- vpc1_id: sensitive=False type=string value=AY-gA
- vpc2_id: sensitive=False type=string value=kOSlI
- vpc_config: sensitive=False type=object value={'region': 'us-east-1', 'vpc1_cidr': '10.0.0.0/16', 'vpc1_id': 'AY-gA', 'vpc2_cidr': '10.1.0.0/16', 'vpc2_id': 'kOSlI'}
- vpc_ids: sensitive=False type=array value=['AY-gp7bDcmA', 'kOSlI']

================================================================================
Listing outputs via workspace endpoint
================================================================================
- environment: sensitive=False type=string value=test
- vpc1_id: sensitive=False type=string value=AY-gA
- vpc2_id: sensitive=False type=string value=kOSlI
- vpc_config: sensitive=False type=object value={'region': 'us-east-1', 'vpc1_cidr': '10.0.0.0/16', 'vpc1_id': 'AY-gA', 'vpc2_cidr': '10.1.0.0/16', 'vpc2_id': 'kOSlI'}
- vpc_ids: sensitive=False type=array value=['AY-gp7bDcmA', 'kOSlI']

Rollback Plan

Changes to Security Controls

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

If you have any questions, please contact your direct supervisor, GRC (#team-grc), or the PCI working group (#proj-pci-reboot). You can also find more information at PCI Compliance.

@isivaselvan isivaselvan requested a review from a team as a code owner March 12, 2026 08:08
@isivaselvan isivaselvan merged commit 316b52a into next-0.1.3 Mar 13, 2026
11 checks passed
KshitijaChoudhari pushed a commit that referenced this pull request Mar 30, 2026
…ersion

Refactor/iterator pattern conversion
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.

1 participant