Skip to content

feat(integration): add allow_all_models attribute to control model access#13

Merged
roh26it merged 1 commit intoPortkey-AI:mainfrom
austin-engle:feat/allow-all-models-integration
Mar 6, 2026
Merged

feat(integration): add allow_all_models attribute to control model access#13
roh26it merged 1 commit intoPortkey-AI:mainfrom
austin-engle:feat/allow-all-models-integration

Conversation

@austin-engle
Copy link
Contributor

Summary

Adds an allow_all_models boolean attribute to the portkey_integration resource, allowing users to control whether all models are enabled by default for an integration.

  • Problem: When an integration is created, the Portkey API defaults allow_all_models = true, meaning every model for that provider is available. There was no way to restrict model access to only explicitly enabled models via portkey_integration_model_access resources.
  • Solution: Expose the existing allow_all_models API field on the portkey_integration resource. Setting it to false makes portkey_integration_model_access resources act as an allowlist.

Usage

resource "portkey_integration" "openai" {
  name             = "OpenAI"
  ai_provider_id   = "openai"
  allow_all_models = false  # Only explicitly enabled models are available
}

resource "portkey_integration_model_access" "gpt5_mini" {
  integration_id = portkey_integration.openai.slug
  model_slug     = "gpt-5-mini"
  enabled        = true
}

Implementation Details

  • The allow_all_models field is managed via the models endpoint (PUT /integrations/{slug}/models), not the integration CRUD endpoint. The provider makes a separate API call when needed.
  • Defaults to true to match existing API behavior (non-breaking change).
  • On Create: only calls the models endpoint when allow_all_models = false (skips redundant call for default).
  • On Create: sets integration state before the models API call so partial failures don't leave orphaned resources.
  • On Read: fetches current value from GetIntegrationModels() for drift detection.
  • On Update: only calls models endpoint when the value actually changed.

Changes

  • internal/provider/integration_resource.go — Added schema attribute, Create/Read/Update logic
  • internal/provider/integration_resource_test.go — Added acceptance tests for create-with-false, toggle true↔false, default behavior assertion
  • docs/resources/integration.md — Updated with new attribute docs and example
  • CHANGELOG.md — Added unreleased entry

Test plan

  • go fmt, go vet, go build all pass
  • Existing acceptance tests unaffected
  • New acceptance tests: create with allow_all_models = false, toggle true→false→true
  • Default behavior: existing configs without allow_all_models get true (non-breaking)
  • Import roundtrips correctly (Read fetches value from API)

…cess

Add an `allow_all_models` boolean attribute to the `portkey_integration`
resource. This controls whether all models are enabled by default for an
integration. Defaults to true to match the existing API behavior.

When set to false, only models explicitly enabled via
`portkey_integration_model_access` resources are available, giving users
fine-grained control over which models can be used through an integration.

The attribute is managed via the separate `/integrations/{slug}/models`
API endpoint since it is not part of the core integration CRUD API.
Copy link
Contributor

@roh26it roh26it left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved ✓

Reviewed all code changes and ran acceptance tests locally. Everything looks good.

Review Summary

Code Quality:

  • Build, vet, and format all pass
  • Schema follows existing patterns (Optional/Computed/Default)
  • Error handling is consistent with other resources
  • Efficient implementation - only calls models API when needed

Test Coverage:

  • TestAccIntegrationResource_allowAllModelsFalse - PASS
  • TestAccIntegrationResource_allowAllModelsUpdate - PASS
  • TestAccIntegrationResource_basic - PASS (includes import verification)
  • Tests check actual values, not just existence

Implementation Details I Appreciated:

  • Partial failure handling: state is set before the models API call so Terraform tracks the resource even if that call fails
  • Non-breaking default (true) matches existing API behavior
  • Reads from API on each operation for proper drift detection

Nice work on the PR description too - clear problem statement, implementation details, and test plan.

@roh26it roh26it merged commit ecff5a2 into Portkey-AI:main Mar 6, 2026
2 checks passed
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