Skip to main content

policies

Creates, updates, deletes, gets or lists a policies resource.

Overview

Namepolicies
TypeResource
Idcloudflare.page_shield.policies

Fields

The following fields are returned by SELECT queries:

Get a Page Shield policy response

NameDatatypeDescription
idstringIdentifier (example: 023e105f4ecef8ad9ca31a8372d0c353)
actionstringThe action to take if the expression matches (allow, log, add_reporting_directives) (example: allow)
descriptionstringA description for the policy (example: Checkout page CSP policy)
enabledbooleanWhether the policy is enabled
expressionstringThe expression which must match for the policy to be applied, using the Cloudflare Firewall rule expression syntax (example: ends_with(http.request.uri.path, "/checkout"))
valuestringThe policy which will be applied (example: script-src 'none';)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectzone_id, policy_idFetches a Page Shield policy by ID.
listselectzone_idLists all Page Shield policies.
createinsertzone_id, description, action, expression, enabled, valueCreate a Page Shield policy.
updatereplacezone_id, policy_idUpdate a Page Shield policy by ID.
deletedeletezone_id, policy_idDelete a Page Shield policy by ID.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
policy_idstringThe Access policy ID.
zone_idstringThe Cloudflare zone ID.

SELECT examples

Fetches a Page Shield policy by ID.

SELECT
id,
action,
description,
enabled,
expression,
value
FROM cloudflare.page_shield.policies
WHERE zone_id = '{{ zone_id }}' -- required
AND policy_id = '{{ policy_id }}' -- required
;

INSERT examples

Create a Page Shield policy.

INSERT INTO cloudflare.page_shield.policies (
action,
description,
enabled,
expression,
value,
zone_id
)
SELECT
'{{ action }}' /* required */,
'{{ description }}' /* required */,
{{ enabled }} /* required */,
'{{ expression }}' /* required */,
'{{ value }}' /* required */,
'{{ zone_id }}'
RETURNING
errors,
messages,
result,
success
;

REPLACE examples

Update a Page Shield policy by ID.

REPLACE cloudflare.page_shield.policies
SET
action = '{{ action }}',
description = '{{ description }}',
enabled = {{ enabled }},
expression = '{{ expression }}',
value = '{{ value }}'
WHERE
zone_id = '{{ zone_id }}' --required
AND policy_id = '{{ policy_id }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Delete a Page Shield policy by ID.

DELETE FROM cloudflare.page_shield.policies
WHERE zone_id = '{{ zone_id }}' --required
AND policy_id = '{{ policy_id }}' --required
;