policies
Creates, updates, deletes, gets or lists a policies resource.
Overview
| Name | policies |
| Type | Resource |
| Id | cloudflare.page_shield.policies |
Fields
The following fields are returned by SELECT queries:
- get
- list
Get a Page Shield policy response
| Name | Datatype | Description |
|---|---|---|
id | string | Identifier (example: 023e105f4ecef8ad9ca31a8372d0c353) |
action | string | The action to take if the expression matches (allow, log, add_reporting_directives) (example: allow) |
description | string | A description for the policy (example: Checkout page CSP policy) |
enabled | boolean | Whether the policy is enabled |
expression | string | The 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")) |
value | string | The policy which will be applied (example: script-src 'none';) |
List Page Shield policies response
| Name | Datatype | Description |
|---|---|---|
id | string | Identifier (example: 023e105f4ecef8ad9ca31a8372d0c353) |
action | string | The action to take if the expression matches (allow, log, add_reporting_directives) (example: allow) |
description | string | A description for the policy (example: Checkout page CSP policy) |
enabled | boolean | Whether the policy is enabled |
expression | string | The 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")) |
value | string | The policy which will be applied (example: script-src 'none';) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | zone_id, policy_id | Fetches a Page Shield policy by ID. | |
list | select | zone_id | Lists all Page Shield policies. | |
create | insert | zone_id, description, action, expression, enabled, value | Create a Page Shield policy. | |
update | replace | zone_id, policy_id | Update a Page Shield policy by ID. | |
delete | delete | zone_id, policy_id | Delete 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.
| Name | Datatype | Description |
|---|---|---|
policy_id | string | The Access policy ID. |
zone_id | string | The Cloudflare zone ID. |
SELECT examples
- get
- list
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
;
Lists all Page Shield policies.
SELECT
id,
action,
description,
enabled,
expression,
value
FROM cloudflare.page_shield.policies
WHERE zone_id = '{{ zone_id }}' -- required
;
INSERT examples
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: policies
props:
- name: zone_id
value: "{{ zone_id }}"
description: Required parameter for the policies resource.
- name: action
value: "{{ action }}"
description: |
The action to take if the expression matches
valid_values: ['allow', 'log', 'add_reporting_directives']
- name: description
value: "{{ description }}"
description: |
A description for the policy
- name: enabled
value: {{ enabled }}
description: |
Whether the policy is enabled
- name: expression
value: "{{ expression }}"
description: |
The expression which must match for the policy to be applied, using the Cloudflare Firewall rule expression syntax
- name: value
value: "{{ value }}"
description: |
The policy which will be applied
REPLACE examples
- update
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
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
;