Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions examples/variable_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

import os

from pytfe.types import (
from pytfe import TFEClient, TFEConfig
from pytfe.models import (
CategoryType,
Parent,
Project,
Expand All @@ -24,17 +25,17 @@
VariableSetCreateOptions,
VariableSetIncludeOpt,
VariableSetListOptions,
VariableSetReadOptions,
VariableSetRemoveFromProjectsOptions,
VariableSetRemoveFromWorkspacesOptions,
VariableSetUpdateOptions,
VariableSetVariableCreateOptions,
VariableSetVariableListOptions,
VariableSetVariableUpdateOptions,
Workspace,
WorkspaceListOptions,
)

from pytfe import TFEClient, TFEConfig


def variable_set_example():
"""Demonstrate Variable Set operations."""
Expand Down Expand Up @@ -193,8 +194,6 @@ def variable_set_example():
print("7. Workspace operations example...")
try:
# List some workspaces first
from pytfe.types import WorkspaceListOptions

workspace_options = WorkspaceListOptions(page_size=5)
workspaces = list(
client.workspaces.list(org_name, options=workspace_options)
Expand Down Expand Up @@ -272,8 +271,6 @@ def variable_set_example():

# 9. Read the variable set with includes
print("9. Reading variable set with includes...")
from pytfe.types import VariableSetReadOptions

read_options = VariableSetReadOptions(
include=[VariableSetIncludeOpt.VARS, VariableSetIncludeOpt.WORKSPACES]
)
Expand Down
51 changes: 50 additions & 1 deletion src/pytfe/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@
EnforcementLevel,
PolicyKind,
)
from .project import Project
from .project import (
Project,
ProjectAddTagBindingsOptions,
ProjectCreateOptions,
ProjectListOptions,
ProjectUpdateOptions,
)

# ── Query Runs ────────────────────────────────────────────────────────────────
from .query_run import (
Expand Down Expand Up @@ -271,12 +277,33 @@

# Variables
from .variable import (
CategoryType,
Variable,
VariableCreateOptions,
VariableListOptions,
VariableUpdateOptions,
)

# ── Variable Sets ──────────────────────────────────────────────────────────────
from .variable_set import (
Parent,
VariableSet,
VariableSetApplyToProjectsOptions,
VariableSetApplyToWorkspacesOptions,
VariableSetCreateOptions,
VariableSetIncludeOpt,
VariableSetListOptions,
VariableSetReadOptions,
VariableSetRemoveFromProjectsOptions,
VariableSetRemoveFromWorkspacesOptions,
VariableSetUpdateOptions,
VariableSetUpdateWorkspacesOptions,
VariableSetVariable,
VariableSetVariableCreateOptions,
VariableSetVariableListOptions,
VariableSetVariableUpdateOptions,
)

# Workspaces
from .workspace import (
LockedByChoice,
Expand Down Expand Up @@ -423,6 +450,10 @@
"OrganizationCreateOptions",
"OrganizationUpdateOptions",
"Project",
"ProjectAddTagBindingsOptions",
Comment thread
KshitijaChoudhari marked this conversation as resolved.
"ProjectCreateOptions",
"ProjectListOptions",
"ProjectUpdateOptions",
"DataRetentionPolicy",
"DataRetentionPolicyChoice",
"DataRetentionPolicyDeleteOlder",
Expand All @@ -434,6 +465,7 @@
"Tag",
"TagBinding",
"TagList",
"CategoryType",
"Variable",
"VariableCreateOptions",
"VariableListOptions",
Expand Down Expand Up @@ -556,6 +588,23 @@
"PolicySetUpdateOptions",
"PolicyKind",
"EnforcementLevel",
# Variable Sets
"Parent",
"VariableSet",
"VariableSetApplyToProjectsOptions",
"VariableSetApplyToWorkspacesOptions",
"VariableSetCreateOptions",
"VariableSetIncludeOpt",
"VariableSetListOptions",
"VariableSetReadOptions",
"VariableSetRemoveFromProjectsOptions",
"VariableSetRemoveFromWorkspacesOptions",
"VariableSetUpdateOptions",
"VariableSetUpdateWorkspacesOptions",
"VariableSetVariable",
"VariableSetVariableCreateOptions",
"VariableSetVariableListOptions",
"VariableSetVariableUpdateOptions",
]

# Rebuild models with forward references after all models are loaded
Expand Down
4 changes: 2 additions & 2 deletions src/pytfe/resources/registry_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def create_with_vcs_connection(
}
}

# Determine the URL based on options - exactly like Go implementation
# Determine the URL based on options
if options.vcs_repo.oauth_token_id and not options.vcs_repo.branch:
path = "/api/v2/registry-modules"
else:
Expand All @@ -157,7 +157,7 @@ def create_with_vcs_connection(
)
path = f"/api/v2/organizations/{options.vcs_repo.organization_name}/registry-modules/vcs"

# Validate agent execution mode like Go implementation
# Validate agent execution mode for API requirements
if (
options.test_config
and options.test_config.agent_execution_mode == AgentExecutionMode.REMOTE
Expand Down
8 changes: 4 additions & 4 deletions src/pytfe/resources/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def _build_workspace_payload(

def delete(self, workspace: str, *, organization: str) -> None:
"""Delete workspace by organization and workspace name."""
# Validate parameters (similar to Go implementation)
# Validate parameters for proper API usage
if not valid_string_id(organization):
raise InvalidOrgError()
if not valid_string_id(workspace):
Expand All @@ -588,15 +588,15 @@ def delete(self, workspace: str, *, organization: str) -> None:

def delete_by_id(self, workspace_id: str) -> None:
"""Delete workspace by workspace ID."""
# Validate parameters (similar to Go implementation)
# Validate parameters for proper API usage
if not valid_string_id(workspace_id):
raise InvalidWorkspaceIDError()

self.t.request("DELETE", f"/api/v2/workspaces/{workspace_id}")

def safe_delete(self, workspace: str, *, organization: str) -> None:
"""Safely delete workspace by organization and name."""
# Validate parameters (similar to Go implementation)
# Validate parameters for proper API usage
if not valid_string_id(organization):
raise InvalidOrgError()
if not valid_string_id(workspace):
Expand All @@ -609,7 +609,7 @@ def safe_delete(self, workspace: str, *, organization: str) -> None:

def safe_delete_by_id(self, workspace_id: str) -> None:
"""Safely delete workspace by workspace ID."""
# Validate parameters (similar to Go implementation)
# Validate parameters for proper API usage
if not valid_string_id(workspace_id):
raise InvalidWorkspaceIDError()

Expand Down
6 changes: 3 additions & 3 deletions src/pytfe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def has_tags_regex_defined(vcs_repo: VCSRepo | None) -> bool:

def validate_workspace_create_options(options: WorkspaceCreateOptions) -> None:
"""
Validate workspace create options similar to Go implementation.
Validate workspace create options for proper API usage.
Raises specific validation errors if validation fails.
"""
# Check required name
Expand Down Expand Up @@ -179,7 +179,7 @@ def validate_workspace_create_options(options: WorkspaceCreateOptions) -> None:

def validate_workspace_update_options(options: WorkspaceUpdateOptions) -> None:
"""
Validate workspace update options similar to Go implementation.
Validate workspace update options for proper API usage.
Raises specific validation errors if validation fails.
"""
# Check name format if provided
Expand Down Expand Up @@ -216,7 +216,7 @@ def validate_workspace_update_options(options: WorkspaceUpdateOptions) -> None:

def validate_oauth_client_create_options(options: OAuthClientCreateOptions) -> None:
"""
Validate OAuth client create options similar to Go implementation.
Validate OAuth client create options for proper API usage.
Raises specific validation errors if validation fails.
"""
from .errors import (
Expand Down
8 changes: 4 additions & 4 deletions tests/units/test_reserved_tag_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

import pytest

from src.pytfe._http import HTTPTransport
from src.pytfe.errors import (
from pytfe._http import HTTPTransport
from pytfe.errors import (
InvalidOrgError,
ValidationError,
)
from src.pytfe.models.reserved_tag_key import (
from pytfe.models.reserved_tag_key import (
ReservedTagKeyCreateOptions,
ReservedTagKeyListOptions,
ReservedTagKeyUpdateOptions,
)
from src.pytfe.resources.reserved_tag_key import ReservedTagKey
from pytfe.resources.reserved_tag_key import ReservedTagKey


class TestReservedTagKeyParsing:
Expand Down
8 changes: 4 additions & 4 deletions tests/units/test_ssh_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

import pytest

from src.pytfe._http import HTTPTransport
from src.pytfe.errors import (
from pytfe._http import HTTPTransport
from pytfe.errors import (
InvalidOrgError,
InvalidSSHKeyIDError,
)
from src.pytfe.models.ssh_key import (
from pytfe.models.ssh_key import (
SSHKeyCreateOptions,
SSHKeyUpdateOptions,
)
from src.pytfe.resources.ssh_keys import SSHKeys
from pytfe.resources.ssh_keys import SSHKeys


class TestSSHKeyParsing:
Expand Down
Loading