feat(ai-gateway): add guardrails property to resource and data sources#7104
Open
fabiogermann wants to merge 1 commit into
Open
feat(ai-gateway): add guardrails property to resource and data sources#7104fabiogermann wants to merge 1 commit into
fabiogermann wants to merge 1 commit into
Conversation
Add guardrails support to the cloudflare_ai_gateway resource, single data source, and list data source, mirroring the pattern used by the existing dlp field. guardrails is a SingleNestedAttribute containing prompt and response MapAttributes (string→string), where values are validated as BLOCK or FLAG. The map shape matches the Cloudflare API payload directly and tolerates new hazard codes without provider changes. The resource write path is unaffected by cloudflare-go/v6 not yet having Guardrails on its typed params, because the provider serialises the body via apijson.MarshalRoot on the tfsdk model directly.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes being requested
Add
guardrailsproperty to thecloudflare_ai_gatewayresource, single data source (cloudflare_ai_gateway), and list data source (cloudflare_ai_gateways), mirroring the pattern used by the existingdlpfield.What changed
guardrailsis aSingleNestedAttribute(optional on the resource, computed on data sources)MapAttributefields -promptandresponse- each mapping hazard codes (e.g.S1-S13,P1) to an action string ("BLOCK"or"FLAG")mapvalidator.ValueStringsAreenforces theBLOCK/FLAGenum on all valuesFiles changed
internal/services/ai_gateway/schema.goguardrailsSingleNestedAttributewithmapvalidatorinternal/services/ai_gateway/model.goAIGatewayGuardrailsModelstruct and field onAIGatewayModelinternal/services/ai_gateway/data_source_schema.goguardrailsattributeinternal/services/ai_gateway/data_source_model.goAIGatewayGuardrailsDataSourceModeland fieldinternal/services/ai_gateway/list_data_source_schema.goguardrailsattributeinternal/services/ai_gateway/list_data_source_model.goAIGatewaysGuardrailsDataSourceModeland fieldExample HCL
Acceptance test run results
Steps to run acceptance tests
pre-existing test suite
Test output
All schema parity tests pass locally:
Additional context & links
guardrails:cloudflare-go/v6v6.10.0 lackingGuardrailson its typed params — the resource serialises the request body viaapijson.MarshalRooton the tfsdk model directly, bypassing the SDK's param structs entirely.