From 36827955294af4a68874111ca33365ff9dfa638b Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Tue, 7 Apr 2026 11:02:58 +0530 Subject: [PATCH 01/19] makefile updated to run example files --- Makefile | 264 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 251 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 8eb5654..22ccc83 100644 --- a/Makefile +++ b/Makefile @@ -9,18 +9,42 @@ VENV_PIP := $(VENV)/bin/pip help: @echo "Available targets:" - @echo " venv Create virtual environment" - @echo " activate Show command to activate virtual environment" - @echo " install Install package dependencies" - @echo " dev-install Install package and development dependencies" - @echo " fmt Format code" - @echo " fmt-check Check code formatting" - @echo " lint Run linting" - @echo " check Run format check + lint + type check" - @echo " type-check Run type checking" - @echo " test Run unit tests" - @echo " clean Clean build artifacts and cache" - @echo " all Run clean + dev-install + fmt + lint + test" + @echo " venv Create virtual environment" + @echo " activate Show command to activate virtual environment" + @echo " install Install package dependencies" + @echo " dev-install Install package and development dependencies" + @echo " fmt Format code" + @echo " fmt-check Check code formatting" + @echo " lint Run linting" + @echo " check Run format check + lint + type check" + @echo " type-check Run type checking" + @echo " test Run unit tests + all example files" + @echo " clean Clean build artifacts and cache" + @echo " all Run clean + dev-install + fmt + lint + test" + @echo "" + @echo "Required env vars:" + @echo " TFE_TOKEN API token" + @echo " TFE_ORG Organization name" + @echo "" + @echo "Optional env vars (examples skip cleanly if not set):" + @echo " TFE_ADDRESS TFE address (default: https://app.terraform.io)" + @echo " TFE_WORKSPACE_ID Workspace ID" + @echo " -- needed by: configuration_version, notification_configuration," + @echo " variables, workspace_resources, state_versions" + @echo " TFE_WORKSPACE_NAME Workspace name" + @echo " -- needed by: notification_configuration, state_versions" + @echo " TFE_APPLY_ID Apply ID -- needed by: apply" + @echo " TFE_PLAN_ID Plan ID -- needed by: plan" + @echo " TFE_RUN_ID Run ID -- needed by: policy_check, run_events" + @echo " TFE_TASK_STAGE_ID Task stage ID -- needed by: policy_evaluation" + @echo " TFE_POLICY_SET_ID Policy set ID -- needed by: policy_set_parameter" + @echo " TFE_POLICY_NAME Policy name -- needed by: policy" + @echo " TFE_REG_PROV_NS Registry provider namespace -- needed by: registry_provider_version" + @echo " TFE_REG_PROV_NAME Registry provider name -- needed by: registry_provider_version" + @echo " SSH_PRIVATE_KEY SSH private key -- needed by: ssh_keys" + @echo " OAUTH_CLIENT_GITHUB_TOKEN GitHub token (optional, enables GitHub tests in oauth_client)" + @echo " WEBHOOK_URL Webhook URL -- used by: notification_configuration" + @echo " TEAMS_WEBHOOK_URL Teams URL -- used by: notification_configuration" $(VENV)/bin/activate: pyproject.toml $(PYTHON) -m venv $(VENV) @@ -59,7 +83,220 @@ type-check: $(VENV_PYTHON) -m mypy $(SRC_DIR) test: - $(VENV_PYTHON) -m pytest -v + @echo "Checking required environment variables..." + @if [ -z "$${TFE_TOKEN}" ] || [ -z "$${TFE_ORG}" ]; then \ + echo "ERROR: TFE_TOKEN and TFE_ORG must be set"; \ + exit 1; \ + fi + + @echo "" + @echo "========================================" + @echo "Running unit tests..." + @echo "========================================" + $(VENV_PYTHON) -m pytest -v tests/ + + @echo "" + @echo "========================================" + @echo "Running example files..." + @echo "========================================" + + @echo "" + @echo "--- agent.py ---" + -$(VENV_PYTHON) examples/agent.py + + @echo "" + @echo "--- agent_pool.py ---" + -$(VENV_PYTHON) examples/agent_pool.py + + @echo "" + @echo "--- apply.py ---" + @if [ -z "$${TFE_APPLY_ID}" ]; then \ + echo "SKIPPED: set TFE_APPLY_ID to run apply.py"; \ + else \ + $(VENV_PYTHON) examples/apply.py --apply-id "$${TFE_APPLY_ID}" || true; \ + fi + + @echo "" + @echo "--- configuration_version.py ---" + @if [ -z "$${TFE_WORKSPACE_ID}" ]; then \ + echo "SKIPPED: set TFE_WORKSPACE_ID to run configuration_version.py"; \ + else \ + $(VENV_PYTHON) examples/configuration_version.py || true; \ + fi + + @echo "" + @echo "--- notification_configuration.py ---" + @if [ -z "$${TFE_WORKSPACE_ID}" ] && [ -z "$${TFE_WORKSPACE_NAME}" ]; then \ + echo "SKIPPED: set TFE_WORKSPACE_ID or TFE_WORKSPACE_NAME to run notification_configuration.py"; \ + else \ + $(VENV_PYTHON) examples/notification_configuration.py || true; \ + fi + + @echo "" + @echo "--- oauth_client.py ---" + -$(VENV_PYTHON) examples/oauth_client.py + + @echo "" + @echo "--- oauth_token.py ---" + -$(VENV_PYTHON) examples/oauth_token.py + + @echo "" + @echo "--- org.py ---" + -$(VENV_PYTHON) examples/org.py + + @echo "" + @echo "--- organization_membership.py ---" + -$(VENV_PYTHON) examples/organization_membership.py + + @echo "" + @echo "--- plan.py ---" + @if [ -z "$${TFE_PLAN_ID}" ]; then \ + echo "SKIPPED: set TFE_PLAN_ID to run plan.py"; \ + else \ + $(VENV_PYTHON) examples/plan.py --plan-id "$${TFE_PLAN_ID}" || true; \ + fi + + @echo "" + @echo "--- policy_check.py ---" + @if [ -z "$${TFE_RUN_ID}" ]; then \ + echo "SKIPPED: set TFE_RUN_ID to run policy_check.py"; \ + else \ + $(VENV_PYTHON) examples/policy_check.py --run-id "$${TFE_RUN_ID}" || true; \ + fi + + @echo "" + @echo "--- policy_evaluation.py ---" + @if [ -z "$${TFE_TASK_STAGE_ID}" ]; then \ + echo "SKIPPED: set TFE_TASK_STAGE_ID to run policy_evaluation.py"; \ + else \ + $(VENV_PYTHON) examples/policy_evaluation.py \ + --task-stage-id "$${TFE_TASK_STAGE_ID}" || true; \ + fi + + @echo "" + @echo "--- policy_set_parameter.py ---" + @if [ -z "$${TFE_POLICY_SET_ID}" ]; then \ + echo "SKIPPED: set TFE_POLICY_SET_ID to run policy_set_parameter.py"; \ + else \ + $(VENV_PYTHON) examples/policy_set_parameter.py \ + --policy-set-id "$${TFE_POLICY_SET_ID}" || true; \ + fi + + @echo "" + @echo "--- policy_set.py ---" + -$(VENV_PYTHON) examples/policy_set.py --org "$${TFE_ORG}" + + @echo "" + @echo "--- policy.py ---" + @if [ -z "$${TFE_POLICY_NAME}" ]; then \ + echo "SKIPPED: set TFE_POLICY_NAME to run policy.py"; \ + else \ + $(VENV_PYTHON) examples/policy.py \ + --org "$${TFE_ORG}" \ + --policy-name "$${TFE_POLICY_NAME}" || true; \ + fi + + @echo "" + @echo "--- project.py ---" + -$(VENV_PYTHON) examples/project.py --list --organization "$${TFE_ORG}" + + @echo "" + @echo "--- query_run.py ---" + -$(VENV_PYTHON) examples/query_run.py + + @echo "" + @echo "--- registry_module.py ---" + -$(VENV_PYTHON) examples/registry_module.py + + @echo "" + @echo "--- registry_provider_version.py ---" + @if [ -z "$${TFE_REG_PROV_NS}" ] || [ -z "$${TFE_REG_PROV_NAME}" ]; then \ + echo "SKIPPED: set TFE_REG_PROV_NS and TFE_REG_PROV_NAME to run registry_provider_version.py"; \ + else \ + $(VENV_PYTHON) examples/registry_provider_version.py \ + --organization "$${TFE_ORG}" \ + --namespace "$${TFE_REG_PROV_NS}" \ + --name "$${TFE_REG_PROV_NAME}" || true; \ + fi + + @echo "" + @echo "--- registry_provider.py ---" + -$(VENV_PYTHON) examples/registry_provider.py + + @echo "" + @echo "--- reserved_tag_key.py ---" + -$(VENV_PYTHON) examples/reserved_tag_key.py + + @echo "" + @echo "--- run_events.py ---" + @if [ -z "$${TFE_RUN_ID}" ]; then \ + echo "SKIPPED: set TFE_RUN_ID to run run_events.py"; \ + else \ + $(VENV_PYTHON) examples/run_events.py --run-id "$${TFE_RUN_ID}" || true; \ + fi + + @echo "" + @echo "--- run_task.py ---" + -$(VENV_PYTHON) examples/run_task.py --org "$${TFE_ORG}" + + @echo "" + @echo "--- run_trigger.py ---" + -$(VENV_PYTHON) examples/run_trigger.py --org "$${TFE_ORG}" + + @echo "" + @echo "--- run.py ---" + -$(VENV_PYTHON) examples/run.py --organization "$${TFE_ORG}" + + @echo "" + @echo "--- ssh_keys.py ---" + @if [ -z "$${SSH_PRIVATE_KEY}" ]; then \ + echo "SKIPPED: set SSH_PRIVATE_KEY to run ssh_keys.py"; \ + else \ + $(VENV_PYTHON) examples/ssh_keys.py || true; \ + fi + + @echo "" + @echo "--- state_versions.py ---" + @if [ -z "$${TFE_WORKSPACE_ID}" ] || [ -z "$${TFE_WORKSPACE_NAME}" ]; then \ + echo "SKIPPED: set TFE_WORKSPACE_ID and TFE_WORKSPACE_NAME to run state_versions.py"; \ + else \ + $(VENV_PYTHON) examples/state_versions.py \ + --org "$${TFE_ORG}" \ + --workspace "$${TFE_WORKSPACE_NAME}" \ + --workspace-id "$${TFE_WORKSPACE_ID}" || true; \ + fi + + @echo "" + @echo "--- variable_sets.py ---" + -$(VENV_PYTHON) examples/variable_sets.py + + @echo "" + @echo "--- variables.py ---" + @if [ -z "$${TFE_WORKSPACE_ID}" ]; then \ + echo "SKIPPED: set TFE_WORKSPACE_ID to run variables.py"; \ + else \ + $(VENV_PYTHON) examples/variables.py || true; \ + fi + + @echo "" + @echo "--- workspace_resources.py ---" + @if [ -z "$${TFE_WORKSPACE_ID}" ]; then \ + echo "SKIPPED: set TFE_WORKSPACE_ID to run workspace_resources.py"; \ + else \ + $(VENV_PYTHON) examples/workspace_resources.py \ + --list \ + --workspace-id "$${TFE_WORKSPACE_ID}" \ + --page-size 10 || true; \ + fi + + @echo "" + @echo "--- workspace.py ---" + -$(VENV_PYTHON) examples/workspace.py --org "$${TFE_ORG}" --list + + @echo "" + @echo "========================================" + @echo "All examples completed." + @echo "========================================" clean: find . -type f -name "*.pyc" -delete @@ -71,3 +308,4 @@ clean: rm -rf build/ dist/ $(VENV) all: clean dev-install fmt lint test + From d46ea8edd85d616a9b03e3e708a0736d2eede92e Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Tue, 7 Apr 2026 11:24:24 +0530 Subject: [PATCH 02/19] makefile updated tun run example file - so ci/cd can run --- .github/workflows/integration-test.yml | 192 +++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 .github/workflows/integration-test.yml diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000..1060b58 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,192 @@ +name: SDK Integration Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: make dev-install + + - name: Run format check + run: make fmt-check + + - name: Run lint + run: make lint + + - name: Run unit tests + run: make type-check && .venv/bin/python -m pytest -v tests/ + + integration-tests: + name: Integration Tests (Example Files) + runs-on: ubuntu-latest + needs: unit-tests # only runs if unit tests pass + + env: + TFE_TOKEN: ${{ secrets.TFE_TOKEN }} + TFE_ORG: ${{ secrets.TFE_ORG }} + TFE_ADDRESS: ${{ secrets.TFE_ADDRESS }} + TFE_WORKSPACE_ID: ${{ secrets.TFE_WORKSPACE_ID }} + TFE_WORKSPACE_NAME: ${{ secrets.TFE_WORKSPACE_NAME }} + TFE_RUN_ID: ${{ secrets.TFE_RUN_ID }} + TFE_APPLY_ID: ${{ secrets.TFE_APPLY_ID }} + TFE_PLAN_ID: ${{ secrets.TFE_PLAN_ID }} + TFE_TASK_STAGE_ID: ${{ secrets.TFE_TASK_STAGE_ID }} + TFE_POLICY_SET_ID: ${{ secrets.TFE_POLICY_SET_ID }} + TFE_POLICY_NAME: ${{ secrets.TFE_POLICY_NAME }} + TFE_REG_PROV_NS: ${{ secrets.TFE_REG_PROV_NS }} + TFE_REG_PROV_NAME: ${{ secrets.TFE_REG_PROV_NAME }} + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + OAUTH_CLIENT_GITHUB_TOKEN: ${{ secrets.OAUTH_CLIENT_GITHUB_TOKEN }} + WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} + TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: make dev-install + + - name: agent.py + run: .venv/bin/python examples/agent.py || true + + - name: agent_pool.py + run: .venv/bin/python examples/agent_pool.py || true + + - name: apply.py + if: ${{ env.TFE_APPLY_ID != '' }} + run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID" || true + + - name: configuration_version.py + if: ${{ env.TFE_WORKSPACE_ID != '' }} + run: .venv/bin/python examples/configuration_version.py || true + + - name: notification_configuration.py + if: ${{ env.TFE_WORKSPACE_ID != '' || env.TFE_WORKSPACE_NAME != '' }} + run: .venv/bin/python examples/notification_configuration.py || true + + - name: oauth_client.py + run: .venv/bin/python examples/oauth_client.py || true + + - name: oauth_token.py + run: .venv/bin/python examples/oauth_token.py || true + + - name: org.py + run: .venv/bin/python examples/org.py || true + + - name: organization_membership.py + run: .venv/bin/python examples/organization_membership.py || true + + - name: plan.py + if: ${{ env.TFE_PLAN_ID != '' }} + run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID" || true + + - name: policy_check.py + if: ${{ env.TFE_RUN_ID != '' }} + run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID" || true + + - name: policy_evaluation.py + if: ${{ env.TFE_TASK_STAGE_ID != '' }} + run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID" || true + + - name: policy_set_parameter.py + if: ${{ env.TFE_POLICY_SET_ID != '' }} + run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID" || true + + - name: policy_set.py + run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG" || true + + - name: policy.py + if: ${{ env.TFE_POLICY_NAME != '' }} + run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME" || true + + - name: project.py + run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG" || true + + - name: query_run.py + if: ${{ env.TFE_WORKSPACE_NAME != '' }} + run: .venv/bin/python examples/query_run.py || true + + - name: registry_module.py + run: .venv/bin/python examples/registry_module.py || true + + - name: registry_provider_version.py + if: ${{ env.TFE_REG_PROV_NS != '' && env.TFE_REG_PROV_NAME != '' }} + run: | + .venv/bin/python examples/registry_provider_version.py \ + --organization "$TFE_ORG" \ + --namespace "$TFE_REG_PROV_NS" \ + --name "$TFE_REG_PROV_NAME" || true + + - name: registry_provider.py + run: .venv/bin/python examples/registry_provider.py || true + + - name: reserved_tag_key.py + run: .venv/bin/python examples/reserved_tag_key.py || true + + - name: run_events.py + if: ${{ env.TFE_RUN_ID != '' }} + run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID" || true + + - name: run_task.py + run: .venv/bin/python examples/run_task.py --org "$TFE_ORG" || true + + - name: run_trigger.py + run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG" || true + + - name: run.py + run: .venv/bin/python examples/run.py --organization "$TFE_ORG" || true + + - name: ssh_keys.py + if: ${{ env.SSH_PRIVATE_KEY != '' }} + run: .venv/bin/python examples/ssh_keys.py || true + + - name: state_versions.py + if: ${{ env.TFE_WORKSPACE_ID != '' && env.TFE_WORKSPACE_NAME != '' }} + run: | + .venv/bin/python examples/state_versions.py \ + --org "$TFE_ORG" \ + --workspace "$TFE_WORKSPACE_NAME" \ + --workspace-id "$TFE_WORKSPACE_ID" || true + + - name: variable_sets.py + run: .venv/bin/python examples/variable_sets.py || true + + - name: variables.py + if: ${{ env.TFE_WORKSPACE_ID != '' }} + run: .venv/bin/python examples/variables.py || true + + - name: workspace_resources.py + if: ${{ env.TFE_WORKSPACE_ID != '' }} + run: | + .venv/bin/python examples/workspace_resources.py \ + --list \ + --workspace-id "$TFE_WORKSPACE_ID" \ + --page-size 10 || true + + - name: workspace.py + run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list || true From 0cc4acfb05eb1b1fe140da776a1f9c5f02be552a Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Tue, 7 Apr 2026 11:38:54 +0530 Subject: [PATCH 03/19] updated make file to run alll integration tests and have ddedd integration-tet.yml file for same --- .github/workflows/integration-test.yml | 163 ++----------------------- 1 file changed, 11 insertions(+), 152 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 1060b58..c1985d5 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -2,43 +2,26 @@ name: SDK Integration Tests on: push: - branches: - - main - pull_request: - branches: - - main workflow_dispatch: jobs: unit-tests: name: Unit Tests runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - - - name: Install dependencies - run: make dev-install - - - name: Run format check - run: make fmt-check - - - name: Run lint - run: make lint - - - name: Run unit tests - run: make type-check && .venv/bin/python -m pytest -v tests/ + - run: make dev-install + - run: make fmt-check + - run: make lint + - run: make type-check && .venv/bin/python -m pytest -v tests/ integration-tests: name: Integration Tests (Example Files) runs-on: ubuntu-latest - needs: unit-tests # only runs if unit tests pass + needs: unit-tests env: TFE_TOKEN: ${{ secrets.TFE_TOKEN }} @@ -60,133 +43,9 @@ jobs: TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" - - - name: Install dependencies - run: make dev-install - - - name: agent.py - run: .venv/bin/python examples/agent.py || true - - - name: agent_pool.py - run: .venv/bin/python examples/agent_pool.py || true - - - name: apply.py - if: ${{ env.TFE_APPLY_ID != '' }} - run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID" || true - - - name: configuration_version.py - if: ${{ env.TFE_WORKSPACE_ID != '' }} - run: .venv/bin/python examples/configuration_version.py || true - - - name: notification_configuration.py - if: ${{ env.TFE_WORKSPACE_ID != '' || env.TFE_WORKSPACE_NAME != '' }} - run: .venv/bin/python examples/notification_configuration.py || true - - - name: oauth_client.py - run: .venv/bin/python examples/oauth_client.py || true - - - name: oauth_token.py - run: .venv/bin/python examples/oauth_token.py || true - - - name: org.py - run: .venv/bin/python examples/org.py || true - - - name: organization_membership.py - run: .venv/bin/python examples/organization_membership.py || true - - - name: plan.py - if: ${{ env.TFE_PLAN_ID != '' }} - run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID" || true - - - name: policy_check.py - if: ${{ env.TFE_RUN_ID != '' }} - run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID" || true - - - name: policy_evaluation.py - if: ${{ env.TFE_TASK_STAGE_ID != '' }} - run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID" || true - - - name: policy_set_parameter.py - if: ${{ env.TFE_POLICY_SET_ID != '' }} - run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID" || true - - - name: policy_set.py - run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG" || true - - - name: policy.py - if: ${{ env.TFE_POLICY_NAME != '' }} - run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME" || true - - - name: project.py - run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG" || true - - - name: query_run.py - if: ${{ env.TFE_WORKSPACE_NAME != '' }} - run: .venv/bin/python examples/query_run.py || true - - - name: registry_module.py - run: .venv/bin/python examples/registry_module.py || true - - - name: registry_provider_version.py - if: ${{ env.TFE_REG_PROV_NS != '' && env.TFE_REG_PROV_NAME != '' }} - run: | - .venv/bin/python examples/registry_provider_version.py \ - --organization "$TFE_ORG" \ - --namespace "$TFE_REG_PROV_NS" \ - --name "$TFE_REG_PROV_NAME" || true - - - name: registry_provider.py - run: .venv/bin/python examples/registry_provider.py || true - - - name: reserved_tag_key.py - run: .venv/bin/python examples/reserved_tag_key.py || true - - - name: run_events.py - if: ${{ env.TFE_RUN_ID != '' }} - run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID" || true - - - name: run_task.py - run: .venv/bin/python examples/run_task.py --org "$TFE_ORG" || true - - - name: run_trigger.py - run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG" || true - - - name: run.py - run: .venv/bin/python examples/run.py --organization "$TFE_ORG" || true - - - name: ssh_keys.py - if: ${{ env.SSH_PRIVATE_KEY != '' }} - run: .venv/bin/python examples/ssh_keys.py || true - - - name: state_versions.py - if: ${{ env.TFE_WORKSPACE_ID != '' && env.TFE_WORKSPACE_NAME != '' }} - run: | - .venv/bin/python examples/state_versions.py \ - --org "$TFE_ORG" \ - --workspace "$TFE_WORKSPACE_NAME" \ - --workspace-id "$TFE_WORKSPACE_ID" || true - - - name: variable_sets.py - run: .venv/bin/python examples/variable_sets.py || true - - - name: variables.py - if: ${{ env.TFE_WORKSPACE_ID != '' }} - run: .venv/bin/python examples/variables.py || true - - - name: workspace_resources.py - if: ${{ env.TFE_WORKSPACE_ID != '' }} - run: | - .venv/bin/python examples/workspace_resources.py \ - --list \ - --workspace-id "$TFE_WORKSPACE_ID" \ - --page-size 10 || true - - - name: workspace.py - run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list || true + - run: make dev-install + - run: make test # ← single step, Makefile handles everything \ No newline at end of file From f4a33d9740da141aee8922c662f93b2c1b4dcfec Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Tue, 7 Apr 2026 15:00:37 +0530 Subject: [PATCH 04/19] updates varibles and oauth client example file sto pickup runtime environmnet variables as workspace ids --- examples/oauth_client.py | 2 +- examples/variables.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/oauth_client.py b/examples/oauth_client.py index 5e2ba07..1e39a1c 100644 --- a/examples/oauth_client.py +++ b/examples/oauth_client.py @@ -64,7 +64,7 @@ def main(): # Initialize the TFE client client = TFEClient(TFEConfig.from_env()) - organization_name = "aayush-test" # Replace with your organization + organization_name = os.getenv("TFE_ORG") # Variables to store created resources for dependent tests created_oauth_client = None diff --git a/examples/variables.py b/examples/variables.py index bc723b9..1ecde98 100644 --- a/examples/variables.py +++ b/examples/variables.py @@ -25,7 +25,7 @@ def main(): client = TFEClient(TFEConfig.from_env()) # Replace this with your actual workspace ID - workspace_id = "ws-example123456789" # Get this from your TFE workspace + workspace_id = # Get this from your TFE workspace print(f"Testing all variable operations in workspace: {workspace_id}") print("=" * 60) From 6248b9e9d42bb669f7c3e13036c22e6c2621cdd7 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Tue, 7 Apr 2026 15:05:15 +0530 Subject: [PATCH 05/19] updates variables and ouath client exampel files to use run time workspace ids for ci/cd testing instead of hardcoded once --- examples/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/variables.py b/examples/variables.py index 1ecde98..f1eab61 100644 --- a/examples/variables.py +++ b/examples/variables.py @@ -25,7 +25,7 @@ def main(): client = TFEClient(TFEConfig.from_env()) # Replace this with your actual workspace ID - workspace_id = # Get this from your TFE workspace + workspace_id = os.environ.get("TFE_WORKSPACE_ID") # Get this from your TFE workspace print(f"Testing all variable operations in workspace: {workspace_id}") print("=" * 60) From 40975a8e11af68bbf538109ce0c9ed4375c44866 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Tue, 7 Apr 2026 15:08:08 +0530 Subject: [PATCH 06/19] updates variables and uath client exampel files to use run time workspace ids for ci/cd testing instead of hardcoded once --- examples/variables.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/variables.py b/examples/variables.py index f1eab61..f5d5ca6 100644 --- a/examples/variables.py +++ b/examples/variables.py @@ -25,7 +25,9 @@ def main(): client = TFEClient(TFEConfig.from_env()) # Replace this with your actual workspace ID - workspace_id = os.environ.get("TFE_WORKSPACE_ID") # Get this from your TFE workspace + workspace_id = os.environ.get( + "TFE_WORKSPACE_ID" + ) # Get this from your TFE workspace print(f"Testing all variable operations in workspace: {workspace_id}") print("=" * 60) From 74739bfecfbd66338fcf2aecd393fd54f7790376 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Tue, 7 Apr 2026 15:27:53 +0530 Subject: [PATCH 07/19] makecheck file restored to orginial one and updated integration file to test the example files instead - so that all checks in ci should paas --- .github/workflows/integration-test.yml | 163 ++++++++++++++- Makefile | 266 ++----------------------- 2 files changed, 166 insertions(+), 263 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index c1985d5..1060b58 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -2,26 +2,43 @@ name: SDK Integration Tests on: push: + branches: + - main + pull_request: + branches: + - main workflow_dispatch: jobs: unit-tests: name: Unit Tests runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 with: python-version: "3.11" - - run: make dev-install - - run: make fmt-check - - run: make lint - - run: make type-check && .venv/bin/python -m pytest -v tests/ + + - name: Install dependencies + run: make dev-install + + - name: Run format check + run: make fmt-check + + - name: Run lint + run: make lint + + - name: Run unit tests + run: make type-check && .venv/bin/python -m pytest -v tests/ integration-tests: name: Integration Tests (Example Files) runs-on: ubuntu-latest - needs: unit-tests + needs: unit-tests # only runs if unit tests pass env: TFE_TOKEN: ${{ secrets.TFE_TOKEN }} @@ -43,9 +60,133 @@ jobs: TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 with: python-version: "3.11" - - run: make dev-install - - run: make test # ← single step, Makefile handles everything \ No newline at end of file + + - name: Install dependencies + run: make dev-install + + - name: agent.py + run: .venv/bin/python examples/agent.py || true + + - name: agent_pool.py + run: .venv/bin/python examples/agent_pool.py || true + + - name: apply.py + if: ${{ env.TFE_APPLY_ID != '' }} + run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID" || true + + - name: configuration_version.py + if: ${{ env.TFE_WORKSPACE_ID != '' }} + run: .venv/bin/python examples/configuration_version.py || true + + - name: notification_configuration.py + if: ${{ env.TFE_WORKSPACE_ID != '' || env.TFE_WORKSPACE_NAME != '' }} + run: .venv/bin/python examples/notification_configuration.py || true + + - name: oauth_client.py + run: .venv/bin/python examples/oauth_client.py || true + + - name: oauth_token.py + run: .venv/bin/python examples/oauth_token.py || true + + - name: org.py + run: .venv/bin/python examples/org.py || true + + - name: organization_membership.py + run: .venv/bin/python examples/organization_membership.py || true + + - name: plan.py + if: ${{ env.TFE_PLAN_ID != '' }} + run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID" || true + + - name: policy_check.py + if: ${{ env.TFE_RUN_ID != '' }} + run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID" || true + + - name: policy_evaluation.py + if: ${{ env.TFE_TASK_STAGE_ID != '' }} + run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID" || true + + - name: policy_set_parameter.py + if: ${{ env.TFE_POLICY_SET_ID != '' }} + run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID" || true + + - name: policy_set.py + run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG" || true + + - name: policy.py + if: ${{ env.TFE_POLICY_NAME != '' }} + run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME" || true + + - name: project.py + run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG" || true + + - name: query_run.py + if: ${{ env.TFE_WORKSPACE_NAME != '' }} + run: .venv/bin/python examples/query_run.py || true + + - name: registry_module.py + run: .venv/bin/python examples/registry_module.py || true + + - name: registry_provider_version.py + if: ${{ env.TFE_REG_PROV_NS != '' && env.TFE_REG_PROV_NAME != '' }} + run: | + .venv/bin/python examples/registry_provider_version.py \ + --organization "$TFE_ORG" \ + --namespace "$TFE_REG_PROV_NS" \ + --name "$TFE_REG_PROV_NAME" || true + + - name: registry_provider.py + run: .venv/bin/python examples/registry_provider.py || true + + - name: reserved_tag_key.py + run: .venv/bin/python examples/reserved_tag_key.py || true + + - name: run_events.py + if: ${{ env.TFE_RUN_ID != '' }} + run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID" || true + + - name: run_task.py + run: .venv/bin/python examples/run_task.py --org "$TFE_ORG" || true + + - name: run_trigger.py + run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG" || true + + - name: run.py + run: .venv/bin/python examples/run.py --organization "$TFE_ORG" || true + + - name: ssh_keys.py + if: ${{ env.SSH_PRIVATE_KEY != '' }} + run: .venv/bin/python examples/ssh_keys.py || true + + - name: state_versions.py + if: ${{ env.TFE_WORKSPACE_ID != '' && env.TFE_WORKSPACE_NAME != '' }} + run: | + .venv/bin/python examples/state_versions.py \ + --org "$TFE_ORG" \ + --workspace "$TFE_WORKSPACE_NAME" \ + --workspace-id "$TFE_WORKSPACE_ID" || true + + - name: variable_sets.py + run: .venv/bin/python examples/variable_sets.py || true + + - name: variables.py + if: ${{ env.TFE_WORKSPACE_ID != '' }} + run: .venv/bin/python examples/variables.py || true + + - name: workspace_resources.py + if: ${{ env.TFE_WORKSPACE_ID != '' }} + run: | + .venv/bin/python examples/workspace_resources.py \ + --list \ + --workspace-id "$TFE_WORKSPACE_ID" \ + --page-size 10 || true + + - name: workspace.py + run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list || true diff --git a/Makefile b/Makefile index 22ccc83..91d61b8 100644 --- a/Makefile +++ b/Makefile @@ -9,42 +9,18 @@ VENV_PIP := $(VENV)/bin/pip help: @echo "Available targets:" - @echo " venv Create virtual environment" - @echo " activate Show command to activate virtual environment" - @echo " install Install package dependencies" - @echo " dev-install Install package and development dependencies" - @echo " fmt Format code" - @echo " fmt-check Check code formatting" - @echo " lint Run linting" - @echo " check Run format check + lint + type check" - @echo " type-check Run type checking" - @echo " test Run unit tests + all example files" - @echo " clean Clean build artifacts and cache" - @echo " all Run clean + dev-install + fmt + lint + test" - @echo "" - @echo "Required env vars:" - @echo " TFE_TOKEN API token" - @echo " TFE_ORG Organization name" - @echo "" - @echo "Optional env vars (examples skip cleanly if not set):" - @echo " TFE_ADDRESS TFE address (default: https://app.terraform.io)" - @echo " TFE_WORKSPACE_ID Workspace ID" - @echo " -- needed by: configuration_version, notification_configuration," - @echo " variables, workspace_resources, state_versions" - @echo " TFE_WORKSPACE_NAME Workspace name" - @echo " -- needed by: notification_configuration, state_versions" - @echo " TFE_APPLY_ID Apply ID -- needed by: apply" - @echo " TFE_PLAN_ID Plan ID -- needed by: plan" - @echo " TFE_RUN_ID Run ID -- needed by: policy_check, run_events" - @echo " TFE_TASK_STAGE_ID Task stage ID -- needed by: policy_evaluation" - @echo " TFE_POLICY_SET_ID Policy set ID -- needed by: policy_set_parameter" - @echo " TFE_POLICY_NAME Policy name -- needed by: policy" - @echo " TFE_REG_PROV_NS Registry provider namespace -- needed by: registry_provider_version" - @echo " TFE_REG_PROV_NAME Registry provider name -- needed by: registry_provider_version" - @echo " SSH_PRIVATE_KEY SSH private key -- needed by: ssh_keys" - @echo " OAUTH_CLIENT_GITHUB_TOKEN GitHub token (optional, enables GitHub tests in oauth_client)" - @echo " WEBHOOK_URL Webhook URL -- used by: notification_configuration" - @echo " TEAMS_WEBHOOK_URL Teams URL -- used by: notification_configuration" + @echo " venv Create virtual environment" + @echo " activate Show command to activate virtual environment" + @echo " install Install package dependencies" + @echo " dev-install Install package and development dependencies" + @echo " fmt Format code" + @echo " fmt-check Check code formatting" + @echo " lint Run linting" + @echo " check Run format check + lint + type check" + @echo " type-check Run type checking" + @echo " test Run unit tests" + @echo " clean Clean build artifacts and cache" + @echo " all Run clean + dev-install + fmt + lint + test" $(VENV)/bin/activate: pyproject.toml $(PYTHON) -m venv $(VENV) @@ -83,220 +59,7 @@ type-check: $(VENV_PYTHON) -m mypy $(SRC_DIR) test: - @echo "Checking required environment variables..." - @if [ -z "$${TFE_TOKEN}" ] || [ -z "$${TFE_ORG}" ]; then \ - echo "ERROR: TFE_TOKEN and TFE_ORG must be set"; \ - exit 1; \ - fi - - @echo "" - @echo "========================================" - @echo "Running unit tests..." - @echo "========================================" - $(VENV_PYTHON) -m pytest -v tests/ - - @echo "" - @echo "========================================" - @echo "Running example files..." - @echo "========================================" - - @echo "" - @echo "--- agent.py ---" - -$(VENV_PYTHON) examples/agent.py - - @echo "" - @echo "--- agent_pool.py ---" - -$(VENV_PYTHON) examples/agent_pool.py - - @echo "" - @echo "--- apply.py ---" - @if [ -z "$${TFE_APPLY_ID}" ]; then \ - echo "SKIPPED: set TFE_APPLY_ID to run apply.py"; \ - else \ - $(VENV_PYTHON) examples/apply.py --apply-id "$${TFE_APPLY_ID}" || true; \ - fi - - @echo "" - @echo "--- configuration_version.py ---" - @if [ -z "$${TFE_WORKSPACE_ID}" ]; then \ - echo "SKIPPED: set TFE_WORKSPACE_ID to run configuration_version.py"; \ - else \ - $(VENV_PYTHON) examples/configuration_version.py || true; \ - fi - - @echo "" - @echo "--- notification_configuration.py ---" - @if [ -z "$${TFE_WORKSPACE_ID}" ] && [ -z "$${TFE_WORKSPACE_NAME}" ]; then \ - echo "SKIPPED: set TFE_WORKSPACE_ID or TFE_WORKSPACE_NAME to run notification_configuration.py"; \ - else \ - $(VENV_PYTHON) examples/notification_configuration.py || true; \ - fi - - @echo "" - @echo "--- oauth_client.py ---" - -$(VENV_PYTHON) examples/oauth_client.py - - @echo "" - @echo "--- oauth_token.py ---" - -$(VENV_PYTHON) examples/oauth_token.py - - @echo "" - @echo "--- org.py ---" - -$(VENV_PYTHON) examples/org.py - - @echo "" - @echo "--- organization_membership.py ---" - -$(VENV_PYTHON) examples/organization_membership.py - - @echo "" - @echo "--- plan.py ---" - @if [ -z "$${TFE_PLAN_ID}" ]; then \ - echo "SKIPPED: set TFE_PLAN_ID to run plan.py"; \ - else \ - $(VENV_PYTHON) examples/plan.py --plan-id "$${TFE_PLAN_ID}" || true; \ - fi - - @echo "" - @echo "--- policy_check.py ---" - @if [ -z "$${TFE_RUN_ID}" ]; then \ - echo "SKIPPED: set TFE_RUN_ID to run policy_check.py"; \ - else \ - $(VENV_PYTHON) examples/policy_check.py --run-id "$${TFE_RUN_ID}" || true; \ - fi - - @echo "" - @echo "--- policy_evaluation.py ---" - @if [ -z "$${TFE_TASK_STAGE_ID}" ]; then \ - echo "SKIPPED: set TFE_TASK_STAGE_ID to run policy_evaluation.py"; \ - else \ - $(VENV_PYTHON) examples/policy_evaluation.py \ - --task-stage-id "$${TFE_TASK_STAGE_ID}" || true; \ - fi - - @echo "" - @echo "--- policy_set_parameter.py ---" - @if [ -z "$${TFE_POLICY_SET_ID}" ]; then \ - echo "SKIPPED: set TFE_POLICY_SET_ID to run policy_set_parameter.py"; \ - else \ - $(VENV_PYTHON) examples/policy_set_parameter.py \ - --policy-set-id "$${TFE_POLICY_SET_ID}" || true; \ - fi - - @echo "" - @echo "--- policy_set.py ---" - -$(VENV_PYTHON) examples/policy_set.py --org "$${TFE_ORG}" - - @echo "" - @echo "--- policy.py ---" - @if [ -z "$${TFE_POLICY_NAME}" ]; then \ - echo "SKIPPED: set TFE_POLICY_NAME to run policy.py"; \ - else \ - $(VENV_PYTHON) examples/policy.py \ - --org "$${TFE_ORG}" \ - --policy-name "$${TFE_POLICY_NAME}" || true; \ - fi - - @echo "" - @echo "--- project.py ---" - -$(VENV_PYTHON) examples/project.py --list --organization "$${TFE_ORG}" - - @echo "" - @echo "--- query_run.py ---" - -$(VENV_PYTHON) examples/query_run.py - - @echo "" - @echo "--- registry_module.py ---" - -$(VENV_PYTHON) examples/registry_module.py - - @echo "" - @echo "--- registry_provider_version.py ---" - @if [ -z "$${TFE_REG_PROV_NS}" ] || [ -z "$${TFE_REG_PROV_NAME}" ]; then \ - echo "SKIPPED: set TFE_REG_PROV_NS and TFE_REG_PROV_NAME to run registry_provider_version.py"; \ - else \ - $(VENV_PYTHON) examples/registry_provider_version.py \ - --organization "$${TFE_ORG}" \ - --namespace "$${TFE_REG_PROV_NS}" \ - --name "$${TFE_REG_PROV_NAME}" || true; \ - fi - - @echo "" - @echo "--- registry_provider.py ---" - -$(VENV_PYTHON) examples/registry_provider.py - - @echo "" - @echo "--- reserved_tag_key.py ---" - -$(VENV_PYTHON) examples/reserved_tag_key.py - - @echo "" - @echo "--- run_events.py ---" - @if [ -z "$${TFE_RUN_ID}" ]; then \ - echo "SKIPPED: set TFE_RUN_ID to run run_events.py"; \ - else \ - $(VENV_PYTHON) examples/run_events.py --run-id "$${TFE_RUN_ID}" || true; \ - fi - - @echo "" - @echo "--- run_task.py ---" - -$(VENV_PYTHON) examples/run_task.py --org "$${TFE_ORG}" - - @echo "" - @echo "--- run_trigger.py ---" - -$(VENV_PYTHON) examples/run_trigger.py --org "$${TFE_ORG}" - - @echo "" - @echo "--- run.py ---" - -$(VENV_PYTHON) examples/run.py --organization "$${TFE_ORG}" - - @echo "" - @echo "--- ssh_keys.py ---" - @if [ -z "$${SSH_PRIVATE_KEY}" ]; then \ - echo "SKIPPED: set SSH_PRIVATE_KEY to run ssh_keys.py"; \ - else \ - $(VENV_PYTHON) examples/ssh_keys.py || true; \ - fi - - @echo "" - @echo "--- state_versions.py ---" - @if [ -z "$${TFE_WORKSPACE_ID}" ] || [ -z "$${TFE_WORKSPACE_NAME}" ]; then \ - echo "SKIPPED: set TFE_WORKSPACE_ID and TFE_WORKSPACE_NAME to run state_versions.py"; \ - else \ - $(VENV_PYTHON) examples/state_versions.py \ - --org "$${TFE_ORG}" \ - --workspace "$${TFE_WORKSPACE_NAME}" \ - --workspace-id "$${TFE_WORKSPACE_ID}" || true; \ - fi - - @echo "" - @echo "--- variable_sets.py ---" - -$(VENV_PYTHON) examples/variable_sets.py - - @echo "" - @echo "--- variables.py ---" - @if [ -z "$${TFE_WORKSPACE_ID}" ]; then \ - echo "SKIPPED: set TFE_WORKSPACE_ID to run variables.py"; \ - else \ - $(VENV_PYTHON) examples/variables.py || true; \ - fi - - @echo "" - @echo "--- workspace_resources.py ---" - @if [ -z "$${TFE_WORKSPACE_ID}" ]; then \ - echo "SKIPPED: set TFE_WORKSPACE_ID to run workspace_resources.py"; \ - else \ - $(VENV_PYTHON) examples/workspace_resources.py \ - --list \ - --workspace-id "$${TFE_WORKSPACE_ID}" \ - --page-size 10 || true; \ - fi - - @echo "" - @echo "--- workspace.py ---" - -$(VENV_PYTHON) examples/workspace.py --org "$${TFE_ORG}" --list - - @echo "" - @echo "========================================" - @echo "All examples completed." - @echo "========================================" + $(VENV_PYTHON) -m pytest -v clean: find . -type f -name "*.pyc" -delete @@ -307,5 +70,4 @@ clean: find . -type d -name ".ruff_cache" -exec rm -rf {} + rm -rf build/ dist/ $(VENV) -all: clean dev-install fmt lint test - +all: clean dev-install fmt lint test \ No newline at end of file From 96990169a6860884c1d9118bb3eb4f00d997e4e9 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 00:56:44 +0530 Subject: [PATCH 08/19] intgeration-test.yml, configuration_version and query/-run --- .github/workflows/integration-test.yml | 62 +++++++++++++------------- examples/configuration_version.py | 2 +- examples/query_run.py | 4 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 1060b58..65436e6 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -72,67 +72,67 @@ jobs: run: make dev-install - name: agent.py - run: .venv/bin/python examples/agent.py || true + run: .venv/bin/python examples/agent.py || - name: agent_pool.py - run: .venv/bin/python examples/agent_pool.py || true + run: .venv/bin/python examples/agent_pool.py || - name: apply.py if: ${{ env.TFE_APPLY_ID != '' }} - run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID" || true + run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID" || - name: configuration_version.py if: ${{ env.TFE_WORKSPACE_ID != '' }} - run: .venv/bin/python examples/configuration_version.py || true + run: .venv/bin/python examples/configuration_version.py || - name: notification_configuration.py if: ${{ env.TFE_WORKSPACE_ID != '' || env.TFE_WORKSPACE_NAME != '' }} - run: .venv/bin/python examples/notification_configuration.py || true + run: .venv/bin/python examples/notification_configuration.py || - name: oauth_client.py - run: .venv/bin/python examples/oauth_client.py || true + run: .venv/bin/python examples/oauth_client.py || - name: oauth_token.py - run: .venv/bin/python examples/oauth_token.py || true + run: .venv/bin/python examples/oauth_token.py || - name: org.py - run: .venv/bin/python examples/org.py || true + run: .venv/bin/python examples/org.py || - name: organization_membership.py - run: .venv/bin/python examples/organization_membership.py || true + run: .venv/bin/python examples/organization_membership.py || - name: plan.py if: ${{ env.TFE_PLAN_ID != '' }} - run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID" || true + run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID" || - name: policy_check.py if: ${{ env.TFE_RUN_ID != '' }} - run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID" || true + run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID" || - name: policy_evaluation.py if: ${{ env.TFE_TASK_STAGE_ID != '' }} - run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID" || true + run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID" || - name: policy_set_parameter.py if: ${{ env.TFE_POLICY_SET_ID != '' }} - run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID" || true + run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID" || - name: policy_set.py - run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG" || true + run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG" || - name: policy.py if: ${{ env.TFE_POLICY_NAME != '' }} - run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME" || true + run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME" || - name: project.py - run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG" || true + run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG" || - name: query_run.py if: ${{ env.TFE_WORKSPACE_NAME != '' }} - run: .venv/bin/python examples/query_run.py || true + run: .venv/bin/python examples/query_run.py || - name: registry_module.py - run: .venv/bin/python examples/registry_module.py || true + run: .venv/bin/python examples/registry_module.py || - name: registry_provider_version.py if: ${{ env.TFE_REG_PROV_NS != '' && env.TFE_REG_PROV_NAME != '' }} @@ -140,30 +140,30 @@ jobs: .venv/bin/python examples/registry_provider_version.py \ --organization "$TFE_ORG" \ --namespace "$TFE_REG_PROV_NS" \ - --name "$TFE_REG_PROV_NAME" || true + --name "$TFE_REG_PROV_NAME" || - name: registry_provider.py - run: .venv/bin/python examples/registry_provider.py || true + run: .venv/bin/python examples/registry_provider.py || - name: reserved_tag_key.py - run: .venv/bin/python examples/reserved_tag_key.py || true + run: .venv/bin/python examples/reserved_tag_key.py || - name: run_events.py if: ${{ env.TFE_RUN_ID != '' }} - run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID" || true + run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID" || - name: run_task.py - run: .venv/bin/python examples/run_task.py --org "$TFE_ORG" || true + run: .venv/bin/python examples/run_task.py --org "$TFE_ORG" || - name: run_trigger.py - run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG" || true + run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG" || - name: run.py - run: .venv/bin/python examples/run.py --organization "$TFE_ORG" || true + run: .venv/bin/python examples/run.py --organization "$TFE_ORG" || - name: ssh_keys.py if: ${{ env.SSH_PRIVATE_KEY != '' }} - run: .venv/bin/python examples/ssh_keys.py || true + run: .venv/bin/python examples/ssh_keys.py || - name: state_versions.py if: ${{ env.TFE_WORKSPACE_ID != '' && env.TFE_WORKSPACE_NAME != '' }} @@ -171,14 +171,14 @@ jobs: .venv/bin/python examples/state_versions.py \ --org "$TFE_ORG" \ --workspace "$TFE_WORKSPACE_NAME" \ - --workspace-id "$TFE_WORKSPACE_ID" || true + --workspace-id "$TFE_WORKSPACE_ID" || - name: variable_sets.py - run: .venv/bin/python examples/variable_sets.py || true + run: .venv/bin/python examples/variable_sets.py || - name: variables.py if: ${{ env.TFE_WORKSPACE_ID != '' }} - run: .venv/bin/python examples/variables.py || true + run: .venv/bin/python examples/variables.py || - name: workspace_resources.py if: ${{ env.TFE_WORKSPACE_ID != '' }} @@ -186,7 +186,7 @@ jobs: .venv/bin/python examples/workspace_resources.py \ --list \ --workspace-id "$TFE_WORKSPACE_ID" \ - --page-size 10 || true + --page-size 10 || - name: workspace.py - run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list || true + run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list || diff --git a/examples/configuration_version.py b/examples/configuration_version.py index b894c11..8645df1 100644 --- a/examples/configuration_version.py +++ b/examples/configuration_version.py @@ -178,7 +178,7 @@ def main(): # Initialize the TFE client client = TFEClient(TFEConfig.from_env()) - workspace_id = "ws-zLgDCHFz9mBfri2Q" # Replace with your workspace ID + workspace_id = os.getenv("TFE_WORKSPACE_ID") # Replace with your workspace ID # Variables to store created resources for dependent tests created_cv_id = None diff --git a/examples/query_run.py b/examples/query_run.py index 1007dcc..5019543 100644 --- a/examples/query_run.py +++ b/examples/query_run.py @@ -37,8 +37,8 @@ def get_client_and_workspace(): """Initialize client and get workspace ID.""" client = TFEClient(TFEConfig.from_env()) - organization = os.getenv("TFE_ORG", "aayush-test") - workspace_name = "query-test" # Default workspace for testing + organization = os.getenv("TFE_ORG") + workspace_name = os.getenv("TFE_WORKSPACE_NAME") # Default workspace for testing # Get workspace workspace = client.workspaces.read(workspace_name, organization=organization) From 65a08aa7e876f438b037569701118b3ce586c017 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 00:58:22 +0530 Subject: [PATCH 09/19] Updated integration-test to remove true --- .github/workflows/integration-test.yml | 60 +++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 65436e6..93046b9 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -72,67 +72,67 @@ jobs: run: make dev-install - name: agent.py - run: .venv/bin/python examples/agent.py || + run: .venv/bin/python examples/agent.py - name: agent_pool.py - run: .venv/bin/python examples/agent_pool.py || + run: .venv/bin/python examples/agent_pool.py - name: apply.py if: ${{ env.TFE_APPLY_ID != '' }} - run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID" || + run: .venv/bin/python examples/apply.py --apply-id "$TFE_APPLY_ID" - name: configuration_version.py if: ${{ env.TFE_WORKSPACE_ID != '' }} - run: .venv/bin/python examples/configuration_version.py || + run: .venv/bin/python examples/configuration_version.py - name: notification_configuration.py if: ${{ env.TFE_WORKSPACE_ID != '' || env.TFE_WORKSPACE_NAME != '' }} - run: .venv/bin/python examples/notification_configuration.py || + run: .venv/bin/python examples/notification_configuration.py - name: oauth_client.py - run: .venv/bin/python examples/oauth_client.py || + run: .venv/bin/python examples/oauth_client.py - name: oauth_token.py - run: .venv/bin/python examples/oauth_token.py || + run: .venv/bin/python examples/oauth_token.py - name: org.py - run: .venv/bin/python examples/org.py || + run: .venv/bin/python examples/org.py - name: organization_membership.py - run: .venv/bin/python examples/organization_membership.py || + run: .venv/bin/python examples/organization_membership.py - name: plan.py if: ${{ env.TFE_PLAN_ID != '' }} - run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID" || + run: .venv/bin/python examples/plan.py --plan-id "$TFE_PLAN_ID" - name: policy_check.py if: ${{ env.TFE_RUN_ID != '' }} - run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID" || + run: .venv/bin/python examples/policy_check.py --run-id "$TFE_RUN_ID" - name: policy_evaluation.py if: ${{ env.TFE_TASK_STAGE_ID != '' }} - run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID" || + run: .venv/bin/python examples/policy_evaluation.py --task-stage-id "$TFE_TASK_STAGE_ID" - name: policy_set_parameter.py if: ${{ env.TFE_POLICY_SET_ID != '' }} - run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID" || + run: .venv/bin/python examples/policy_set_parameter.py --policy-set-id "$TFE_POLICY_SET_ID" - name: policy_set.py - run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG" || + run: .venv/bin/python examples/policy_set.py --org "$TFE_ORG" - name: policy.py if: ${{ env.TFE_POLICY_NAME != '' }} - run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME" || + run: .venv/bin/python examples/policy.py --org "$TFE_ORG" --policy-name "$TFE_POLICY_NAME" - name: project.py - run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG" || + run: .venv/bin/python examples/project.py --list --organization "$TFE_ORG" - name: query_run.py if: ${{ env.TFE_WORKSPACE_NAME != '' }} - run: .venv/bin/python examples/query_run.py || + run: .venv/bin/python examples/query_run.py - name: registry_module.py - run: .venv/bin/python examples/registry_module.py || + run: .venv/bin/python examples/registry_module.py - name: registry_provider_version.py if: ${{ env.TFE_REG_PROV_NS != '' && env.TFE_REG_PROV_NAME != '' }} @@ -140,30 +140,30 @@ jobs: .venv/bin/python examples/registry_provider_version.py \ --organization "$TFE_ORG" \ --namespace "$TFE_REG_PROV_NS" \ - --name "$TFE_REG_PROV_NAME" || + --name "$TFE_REG_PROV_NAME" - name: registry_provider.py - run: .venv/bin/python examples/registry_provider.py || + run: .venv/bin/python examples/registry_provider.py - name: reserved_tag_key.py - run: .venv/bin/python examples/reserved_tag_key.py || + run: .venv/bin/python examples/reserved_tag_key.py - name: run_events.py if: ${{ env.TFE_RUN_ID != '' }} - run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID" || + run: .venv/bin/python examples/run_events.py --run-id "$TFE_RUN_ID" - name: run_task.py - run: .venv/bin/python examples/run_task.py --org "$TFE_ORG" || + run: .venv/bin/python examples/run_task.py --org "$TFE_ORG" - name: run_trigger.py - run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG" || + run: .venv/bin/python examples/run_trigger.py --org "$TFE_ORG" - name: run.py - run: .venv/bin/python examples/run.py --organization "$TFE_ORG" || + run: .venv/bin/python examples/run.py --organization "$TFE_ORG" - name: ssh_keys.py if: ${{ env.SSH_PRIVATE_KEY != '' }} - run: .venv/bin/python examples/ssh_keys.py || + run: .venv/bin/python examples/ssh_keys.py - name: state_versions.py if: ${{ env.TFE_WORKSPACE_ID != '' && env.TFE_WORKSPACE_NAME != '' }} @@ -171,14 +171,14 @@ jobs: .venv/bin/python examples/state_versions.py \ --org "$TFE_ORG" \ --workspace "$TFE_WORKSPACE_NAME" \ - --workspace-id "$TFE_WORKSPACE_ID" || + --workspace-id "$TFE_WORKSPACE_ID" - name: variable_sets.py - run: .venv/bin/python examples/variable_sets.py || + run: .venv/bin/python examples/variable_sets.py - name: variables.py if: ${{ env.TFE_WORKSPACE_ID != '' }} - run: .venv/bin/python examples/variables.py || + run: .venv/bin/python examples/variables.py - name: workspace_resources.py if: ${{ env.TFE_WORKSPACE_ID != '' }} @@ -189,4 +189,4 @@ jobs: --page-size 10 || - name: workspace.py - run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list || + run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list From 6093e2188e829c5ec60bfce35819ff8d4fd093df Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 01:00:54 +0530 Subject: [PATCH 10/19] Updated integration-test, configuration-version and query_run --- examples/configuration_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/configuration_version.py b/examples/configuration_version.py index 8645df1..72d03bf 100644 --- a/examples/configuration_version.py +++ b/examples/configuration_version.py @@ -178,7 +178,7 @@ def main(): # Initialize the TFE client client = TFEClient(TFEConfig.from_env()) - workspace_id = os.getenv("TFE_WORKSPACE_ID") # Replace with your workspace ID + workspace_id = os.getenv("TFE_WORKSPACE_ID") # Replace with your workspace ID # Variables to store created resources for dependent tests created_cv_id = None From 22937565450687e39d415e28ae8d91e662e6ad33 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 01:02:38 +0530 Subject: [PATCH 11/19] have kepttrue on for oauth client and token --- .github/workflows/integration-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 93046b9..ebb0fc1 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -90,10 +90,10 @@ jobs: run: .venv/bin/python examples/notification_configuration.py - name: oauth_client.py - run: .venv/bin/python examples/oauth_client.py + run: .venv/bin/python examples/oauth_client.py || true - name: oauth_token.py - run: .venv/bin/python examples/oauth_token.py + run: .venv/bin/python examples/oauth_token.py || true - name: org.py run: .venv/bin/python examples/org.py From 58c256393cb963ceccd21d1cd0dd9ed497e108c7 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 02:26:46 +0530 Subject: [PATCH 12/19] Updated integration-test.yml --- .github/workflows/integration-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index ebb0fc1..f1307e6 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -186,7 +186,7 @@ jobs: .venv/bin/python examples/workspace_resources.py \ --list \ --workspace-id "$TFE_WORKSPACE_ID" \ - --page-size 10 || + --page-size 10 - name: workspace.py run: .venv/bin/python examples/workspace.py --org "$TFE_ORG" --list From bab9c41bb65b80b417ff4f10c0e59eb698edcefb Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 04:35:36 +0530 Subject: [PATCH 13/19] Updated integration-test.yml for oauth-token.py --- .github/workflows/integration-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index f1307e6..56d2b48 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -90,7 +90,7 @@ jobs: run: .venv/bin/python examples/notification_configuration.py - name: oauth_client.py - run: .venv/bin/python examples/oauth_client.py || true + run: .venv/bin/python examples/oauth_client.py - name: oauth_token.py run: .venv/bin/python examples/oauth_token.py || true From bf8f476acb038f0d755496c40252cd50f94cff6c Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 04:41:14 +0530 Subject: [PATCH 14/19] Updated integration-test.yml for oauth-token.py --- .github/workflows/integration-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 56d2b48..a19001f 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -93,7 +93,7 @@ jobs: run: .venv/bin/python examples/oauth_client.py - name: oauth_token.py - run: .venv/bin/python examples/oauth_token.py || true + run: .venv/bin/python examples/oauth_token.py - name: org.py run: .venv/bin/python examples/org.py From aeb7025d612b58b1942f80c9b6532faa63b5357c Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 05:24:29 +0530 Subject: [PATCH 15/19] made changes to example files notification_configuration and registry_provider --- examples/notification_configuration.py | 6 +++--- examples/registry_provider.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/notification_configuration.py b/examples/notification_configuration.py index 07e1b85..454cdec 100644 --- a/examples/notification_configuration.py +++ b/examples/notification_configuration.py @@ -37,8 +37,8 @@ def main(): # Resolve organization and workspace from environment variables org_name = os.environ["TFE_ORG"] - workspace_name = os.getenv("TFE_WORKSPACE_NAME", "test-api") - workspace_id = os.getenv("TFE_WORKSPACE_ID", "") + workspace_name = os.environ["TFE_WORKSPACE_NAME"] + workspace_id = os.environ["TFE_WORKSPACE_ID"] if not workspace_id: print(f"Looking up workspace '{workspace_name}' in org '{org_name}'...") ws = client.workspaces.read(workspace_name, organization=org_name) @@ -46,7 +46,7 @@ def main(): print(f"Resolved workspace ID: {workspace_id}") print(f"Using workspace: {workspace_name} (ID: {workspace_id})") - team_id = os.getenv("TFE_TEAM_ID", "team-example123456789") + team_id = os.environ["TFE_TEAM_ID"] if team_id == "team-example123456789": print("Using fake team ID for demonstration (teams may require paid plan)") else: diff --git a/examples/registry_provider.py b/examples/registry_provider.py index ee6b569..e4de81d 100644 --- a/examples/registry_provider.py +++ b/examples/registry_provider.py @@ -40,7 +40,7 @@ def get_client_and_org(): """Initialize client and get organization name.""" client = TFEClient() - organization_name = os.getenv("TFE_ORGANIZATION", "aayush-test") + organization_name = os.environ["TFE_ORG"] return client, organization_name From f2d121c7f2f6ef49b195bd72c3241855bd62ae11 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 09:23:38 +0530 Subject: [PATCH 16/19] made changes to example files notification_configuration and integrationion.yml --- .github/workflows/integration-test.yml | 1 + examples/notification_configuration.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index a19001f..13fedbe 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -46,6 +46,7 @@ jobs: TFE_ADDRESS: ${{ secrets.TFE_ADDRESS }} TFE_WORKSPACE_ID: ${{ secrets.TFE_WORKSPACE_ID }} TFE_WORKSPACE_NAME: ${{ secrets.TFE_WORKSPACE_NAME }} + TFE_TEAM_ID: ${{ secrets.TFE_TEAM_ID }} TFE_RUN_ID: ${{ secrets.TFE_RUN_ID }} TFE_APPLY_ID: ${{ secrets.TFE_APPLY_ID }} TFE_PLAN_ID: ${{ secrets.TFE_PLAN_ID }} diff --git a/examples/notification_configuration.py b/examples/notification_configuration.py index 454cdec..178c130 100644 --- a/examples/notification_configuration.py +++ b/examples/notification_configuration.py @@ -37,8 +37,8 @@ def main(): # Resolve organization and workspace from environment variables org_name = os.environ["TFE_ORG"] - workspace_name = os.environ["TFE_WORKSPACE_NAME"] - workspace_id = os.environ["TFE_WORKSPACE_ID"] + workspace_name = os.getenv("TFE_WORKSPACE_NAME") + workspace_id = os.getenv("TFE_WORKSPACE_ID") if not workspace_id: print(f"Looking up workspace '{workspace_name}' in org '{org_name}'...") ws = client.workspaces.read(workspace_name, organization=org_name) @@ -46,7 +46,7 @@ def main(): print(f"Resolved workspace ID: {workspace_id}") print(f"Using workspace: {workspace_name} (ID: {workspace_id})") - team_id = os.environ["TFE_TEAM_ID"] + team_id = os.getenv("TFE_TEAM_ID") if team_id == "team-example123456789": print("Using fake team ID for demonstration (teams may require paid plan)") else: From eccc98e5fee19915bcba4fecd61363afa09277cf Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 09:23:43 +0530 Subject: [PATCH 17/19] made changes to example files notification_configuration and integrationion.yml --- examples/organization_membership.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/organization_membership.py b/examples/organization_membership.py index d93071c..a442910 100644 --- a/examples/organization_membership.py +++ b/examples/organization_membership.py @@ -28,7 +28,7 @@ def main(): """Demonstrate organization membership list functionality.""" - organization_name = "aayush-test" + organization_name = os.environ["TFE_ORG"] # Initialize the client (reads TFE_TOKEN and TFE_ADDRESS from environment) try: @@ -272,13 +272,13 @@ def main(): from pytfe.models import OrganizationMembershipCreateOptions, Team # Replace with a valid email for your organization - new_member_email = "sivaselvan.i@hashicorp.com" + new_member_email = os.getenv("TEST_MEMBER_EMAIL") # Create membership with teams (uncomment to use) from pytfe.models import OrganizationAccess team = Team( - id="team-dx24FR9xQUuwNTHA", + id = os.environ["TFE_TEAM_ID"] organization_access=OrganizationAccess(read_workspaces=True), ) # Replace with actual team ID create_options = OrganizationMembershipCreateOptions( From 5c5e75c01227fd56048dad1820f31871c1a08937 Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 11:44:23 +0530 Subject: [PATCH 18/19] Updated organization_mebership and respectiev integration tests --- .github/workflows/integration-test.yml | 2 ++ examples/organization_membership.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 13fedbe..91901e3 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -59,6 +59,8 @@ jobs: OAUTH_CLIENT_GITHUB_TOKEN: ${{ secrets.OAUTH_CLIENT_GITHUB_TOKEN }} WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} + TEST_MEMBER_EMAIL: ${{ secrets.TEST_MEMBER_EMAIL }} + TEAM_MEMBERSHIP_ID: ${{secretS.TEAM_MEBERSHIP_ID}} steps: - name: Checkout code diff --git a/examples/organization_membership.py b/examples/organization_membership.py index a442910..4ead3c3 100644 --- a/examples/organization_membership.py +++ b/examples/organization_membership.py @@ -13,7 +13,7 @@ Usage: python examples/organization_membership.py """ - +import os import sys from pytfe import TFEClient @@ -28,7 +28,8 @@ def main(): """Demonstrate organization membership list functionality.""" - organization_name = os.environ["TFE_ORG"] + organization_name = os.getenv("TFE_ORG") + team_id = os.getenv("TFE_TEAM_ID") # Initialize the client (reads TFE_TOKEN and TFE_ADDRESS from environment) try: @@ -278,7 +279,7 @@ def main(): from pytfe.models import OrganizationAccess team = Team( - id = os.environ["TFE_TEAM_ID"] + id=team_id, organization_access=OrganizationAccess(read_workspaces=True), ) # Replace with actual team ID create_options = OrganizationMembershipCreateOptions( @@ -300,7 +301,7 @@ def main(): try: from pytfe.errors import NotFound - membership_id = "ou-9mG77c6uE5GScg9k" # Replace with actual membership ID + membership_id = os.getenv("TFE_MEMBERSHIP_ID") # Replace with actual membership ID print(f"Attempting to delete membership: {membership_id}") client.organization_memberships.delete(membership_id) From 7095e73f1b5fe99d8429f02e9d2204a9968fb60f Mon Sep 17 00:00:00 2001 From: KshitijaChoudhari Date: Fri, 10 Apr 2026 11:46:51 +0530 Subject: [PATCH 19/19] formatted organization_mebership --- examples/organization_membership.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/organization_membership.py b/examples/organization_membership.py index 4ead3c3..1b7c332 100644 --- a/examples/organization_membership.py +++ b/examples/organization_membership.py @@ -13,6 +13,7 @@ Usage: python examples/organization_membership.py """ + import os import sys @@ -301,7 +302,9 @@ def main(): try: from pytfe.errors import NotFound - membership_id = os.getenv("TFE_MEMBERSHIP_ID") # Replace with actual membership ID + membership_id = os.getenv( + "TFE_MEMBERSHIP_ID" + ) # Replace with actual membership ID print(f"Attempting to delete membership: {membership_id}") client.organization_memberships.delete(membership_id)