Skip to content

Ssh-iterator pattern added#101

Merged
isivaselvan merged 7 commits into
hashicorp:next-0.1.3from
NimishaShrivastava-dev:refactor-sshkey-list-iterator
Mar 13, 2026
Merged

Ssh-iterator pattern added#101
isivaselvan merged 7 commits into
hashicorp:next-0.1.3from
NimishaShrivastava-dev:refactor-sshkey-list-iterator

Conversation

@NimishaShrivastava-dev

@NimishaShrivastava-dev NimishaShrivastava-dev commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Refactored SSH Keys resource to implement iterator pattern for listing operations, providing better memory efficiency and consistent API behavior across the SDK.

Changed list() method to return iterator[SSHkey] instead of SSHKeyList
Implemented lazy evaluation using list() helper method for automatic pagination.

In Examples
Updated listing to use iterator pattern with for-loop
Replaced pagination object return with generator-style iteration
Demonstrated practical usage of iterator with pagination options
Simplified code by removing manual list length tracking

and updated Test Files
All 8 tests passing
!ssh
achments/assets/fdb07a89-a857-43bb-a6cc-90837abb5207)
ssh2

SSH Keys API Example for organization: prab-sandbox01

  1. Listing SSH keys...
  • ID: sshkey-QjhSWDSssCWKnksi, Name: test-key-20251217-192455
    Found 1 SSH keys
  1. Creating a new SSH key...
    Created SSH key: sshkey-Y6fCsxdmSv94VqYZ - Python TFE Example SSH Key

  2. Reading the SSH key...
    Read SSH key: sshkey-Y6fCsxdmSv94VqYZ - Python TFE Example SSH Key

  3. Updating the SSH key...
    Updated SSH key: sshkey-Y6fCsxdmSv94VqYZ - Updated Python TFE Example SSH Key

  4. Deleting the SSH key...
    Deleted SSH key: sshkey-Y6fCsxdmSv94VqYZ

  5. Verifying deletion...
    SSH keys after deletion: 1

  6. Demonstrating iterator with pagination options...
      - test-key-20251217-192455
    Listed 1 keys with pagination options

 SSH Keys API example completed successfully!
(.venv) nimishashrivastava@dhcp-9-124-203-8 python-tfe %

 SSH Keys API Example for organization: prab-sandbox01

  1. Listing SSH keys...
  • ID: sshkey-QjhSWDSssCWKnksi, Name: test-key-20251217-192455
  • ID: sshkey-fKiMM2S3bmzqagYq, Name: terraform-ssh-key
  • ID: sshkey-hki4xje1kz1uTZfc, Name: terraform_key_2
    Found 3 SSH keys
  1. Creating a new SSH key...
    Created SSH key: sshkey-GYqnR1bSBvr25Bfp - Python TFE Example SSH Key

  2. Reading the SSH key...
    Read SSH key: sshkey-GYqnR1bSBvr25Bfp - Python TFE Example SSH Key

  3. Updating the SSH key...
    Updated SSH key: sshkey-GYqnR1bSBvr25Bfp - Updated Python TFE Example SSH Key

  4. Deleting the SSH key...
    Deleted SSH key: sshkey-GYqnR1bSBvr25Bfp

  5. Verifying deletion...
    SSH keys after deletion: 3

  6. Demonstrating iterator with pagination options...
      - test-key-20251217-192455
      - terraform-ssh-key
      - terraform_key_2
    Listed 3 keys with pagination options

 SSH Keys API example completed successfully!
(.venv) nimishashrivastava@dhcp-9-124-203-8 python-tfe %

@NimishaShrivastava-dev NimishaShrivastava-dev requested a review from a team as a code owner March 2, 2026 07:28
Comment thread .gitignore Outdated
# Local RSA keys
.local/*

terraform_key*

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.

why these were added to the .gitignore?

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.

updated gitignore

@isivaselvan isivaselvan merged commit 3ff9aff into hashicorp:next-0.1.3 Mar 13, 2026
11 checks passed
@NimishaShrivastava-dev NimishaShrivastava-dev deleted the refactor-sshkey-list-iterator branch June 4, 2026 13:52
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