Skip to content

Parity with Agent Pool creation API - relationships with workspaces, projecs, stacks, modules. #100

@benjamin-lykins

Description

@benjamin-lykins

Use-cases

Create or Update agent pools to allow more granular scoping.

Attempted Solutions

Attempted to create an agent pool with a workspace attached - pool created, but workspace did not attach.

Proposal

Bring parity between python-tfe and existing API payloads.

Currently

As of now, work so far is limited to only organization wide or workspace.

class AgentPoolCreateOptions(BaseModel):
    """Options for creating an agent pool."""

    # Required: A name to identify the agent pool
    name: str
    # Optional: Whether the agent pool is organization scoped
    organization_scoped: bool | None = None
    # Optional: Allowed workspace policy
    allowed_workspace_policy: AgentPoolAllowedWorkspacePolicy | None = None


class AgentPoolUpdateOptions(BaseModel):
    """Options for updating an agent pool."""

    # Optional: A name to identify the agent pool
    name: str | None = None
    # Optional: Whether the agent pool is organization scoped
    organization_scoped: bool | None = None
    # Optional: Allowed workspace policy
    allowed_workspace_policy: AgentPoolAllowedWorkspacePolicy | None = None

I'm not sure if we need the excluded options, I will have to see how that works.

Proposed

class AgentPoolCreateOptions(BaseModel):
    """Options for creating an agent pool."""

    # Required: A name to identify the agent pool
    name: str
    # Optional: Whether the agent pool is organization scoped
    organization_scoped: bool | None = None
    # Optional: Allowed workspace policy
    allowed_workspace_policy: AgentPoolAllowedWorkspacePolicy | None = None
    # Optional: Allowed project policy
    allowed_project_policy: AgentPoolAllowedProjectPolicy | None = None
    # Optional: List of workspace IDs that are allowed to use this agent pool
    allowed_workspace_ids: list[str] = Field(default_factory=list)
    # Optional: List of project IDs that are allowed to use this agent pool
    allowed_project_ids: list[str] = Field(default_factory=list)
    # Optional: List of workspace IDs excluded from using this agent pool
    excluded_workspace_ids: list[str] = Field(default_factory=list)
    # Optional: HCP Terraform feature only
    allowed_stack_ids: list[str] = Field(default_factory=list)
    # Optional: HCP Terraform feature only
    excluded_stack_ids: list[str] = Field(default_factory=list)
    # Optional: HCP Terraform premium feature only
    allowed_module_ids: list[str] = Field(default_factory=list)
    # Optional: HCP Terraform premium feature only
    excluded_module_ids: list[str] = Field(default_factory=list)


class AgentPoolUpdateOptions(BaseModel):
    """Options for updating an agent pool."""

    # Optional: A name to identify the agent pool
    name: str | None = None
    # Optional: Whether the agent pool is organization scoped
    organization_scoped: bool | None = None
    # Optional: Allowed workspace policy
    allowed_workspace_policy: AgentPoolAllowedWorkspacePolicy | None = None
    # Optional: List of workspace IDs that are allowed to use this agent pool
    allowed_workspace_ids: list[str] | None = None
    # Optional: List of project IDs that are allowed to use this agent pool
    allowed_project_ids: list[str] | None = None
    # Optional: List of workspace IDs excluded from using this agent pool
    excluded_workspace_ids: list[str] | None = None
    # Optional: List of stack IDs that are allowed to use this agent pool (HCP Terraform only)
    allowed_stack_ids: list[str] | None = None
    # Optional: List of stack IDs excluded from using this agent pool (HCP Terraform only)
    excluded_stack_ids: list[str] | None = None
    # Optional: List of registry module IDs allowed to use this agent pool (enterprise-testing only)
    allowed_module_ids: list[str] | None = None
    # Optional: List of registry module IDs excluded from using this agent pool (enterprise-testing only)
    excluded_module_ids: list[str] | None = None

Tasks

  • Workspace relationship (Needs fixed, some of the work is there.)
  • Project relationship (Should be addressed sooner, since it is more common to assign pools to projects.)
  • Stack relationship (HCP Terraform only for now, but soon TFE support)
  • Module Registry (HCP Terraform and Premium Subscription feature)

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions