diff --git a/examples/variable_sets.py b/examples/variable_sets.py index 85749f91..4a6ca505 100644 --- a/examples/variable_sets.py +++ b/examples/variable_sets.py @@ -15,7 +15,8 @@ import os -from pytfe.types import ( +from pytfe import TFEClient, TFEConfig +from pytfe.models import ( CategoryType, Parent, Project, @@ -24,6 +25,7 @@ VariableSetCreateOptions, VariableSetIncludeOpt, VariableSetListOptions, + VariableSetReadOptions, VariableSetRemoveFromProjectsOptions, VariableSetRemoveFromWorkspacesOptions, VariableSetUpdateOptions, @@ -31,10 +33,9 @@ VariableSetVariableListOptions, VariableSetVariableUpdateOptions, Workspace, + WorkspaceListOptions, ) -from pytfe import TFEClient, TFEConfig - def variable_set_example(): """Demonstrate Variable Set operations.""" @@ -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) @@ -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] ) diff --git a/src/pytfe/models/__init__.py b/src/pytfe/models/__init__.py index b08b26b8..f3eb33bc 100644 --- a/src/pytfe/models/__init__.py +++ b/src/pytfe/models/__init__.py @@ -137,7 +137,13 @@ EnforcementLevel, PolicyKind, ) -from .project import Project +from .project import ( + Project, + ProjectAddTagBindingsOptions, + ProjectCreateOptions, + ProjectListOptions, + ProjectUpdateOptions, +) # ── Query Runs ──────────────────────────────────────────────────────────────── from .query_run import ( @@ -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, @@ -423,6 +450,10 @@ "OrganizationCreateOptions", "OrganizationUpdateOptions", "Project", + "ProjectAddTagBindingsOptions", + "ProjectCreateOptions", + "ProjectListOptions", + "ProjectUpdateOptions", "DataRetentionPolicy", "DataRetentionPolicyChoice", "DataRetentionPolicyDeleteOlder", @@ -434,6 +465,7 @@ "Tag", "TagBinding", "TagList", + "CategoryType", "Variable", "VariableCreateOptions", "VariableListOptions", @@ -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 diff --git a/src/pytfe/resources/registry_module.py b/src/pytfe/resources/registry_module.py index 8daf49e9..b65d4d8c 100644 --- a/src/pytfe/resources/registry_module.py +++ b/src/pytfe/resources/registry_module.py @@ -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: @@ -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 diff --git a/src/pytfe/resources/workspaces.py b/src/pytfe/resources/workspaces.py index 2f600b00..81b49f5f 100644 --- a/src/pytfe/resources/workspaces.py +++ b/src/pytfe/resources/workspaces.py @@ -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): @@ -588,7 +588,7 @@ 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() @@ -596,7 +596,7 @@ def delete_by_id(self, workspace_id: str) -> None: 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): @@ -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() diff --git a/src/pytfe/utils.py b/src/pytfe/utils.py index 9adf58d3..d6e9b385 100644 --- a/src/pytfe/utils.py +++ b/src/pytfe/utils.py @@ -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 @@ -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 @@ -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 ( diff --git a/tests/units/test_reserved_tag_key.py b/tests/units/test_reserved_tag_key.py index 12cbc50d..490a93a9 100644 --- a/tests/units/test_reserved_tag_key.py +++ b/tests/units/test_reserved_tag_key.py @@ -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: diff --git a/tests/units/test_ssh_keys.py b/tests/units/test_ssh_keys.py index 057b9ac8..55008464 100644 --- a/tests/units/test_ssh_keys.py +++ b/tests/units/test_ssh_keys.py @@ -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: