Skip to main content

rulesets

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

Overview

Namerulesets
TypeResource
Idfirebase.rules.rulesets

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOutput only. Name of the Ruleset. The ruleset_id is auto generated by the service. Format: projects/{project_id}/rulesets/{ruleset_id}
attachmentPointstringImmutable. Intended resource to which this Ruleset should be released. May be left blank to signify the resource associated with the default release. Expected format: firestore.googleapis.com/projects//databases/
createTimestring (google-datetime)Output only. Time the Ruleset was created.
metadataobjectOutput only. The metadata for this ruleset. (id: Metadata)
sourceobjectRequired. Source for the Ruleset. (id: Source)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, rulesetsIdGet a Ruleset by name including the full Source contents.
listselectprojectsIdfilter, pageSize, pageTokenList Ruleset metadata only and optionally filter the results by Ruleset name. The full Source contents of a Ruleset may be retrieved with GetRuleset.
createinsertprojectsIdCreate a Ruleset from Source. The Ruleset is given a unique generated name which is returned to the caller. Source containing syntactic or semantics errors will result in an error response indicating the first error encountered. For a detailed view of Source issues, use TestRuleset.
deletedeleteprojectsId, rulesetsIdDelete a Ruleset by resource name. If the Ruleset is referenced by a Release the operation will fail.

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
projectsIdstring
rulesetsIdstring
filterstring
pageSizeinteger (int32)
pageTokenstring

SELECT examples

Get a Ruleset by name including the full Source contents.

SELECT
name,
attachmentPoint,
createTime,
metadata,
source
FROM firebase.rules.rulesets
WHERE projectsId = '{{ projectsId }}' -- required
AND rulesetsId = '{{ rulesetsId }}' -- required;

INSERT examples

Create a Ruleset from Source. The Ruleset is given a unique generated name which is returned to the caller. Source containing syntactic or semantics errors will result in an error response indicating the first error encountered. For a detailed view of Source issues, use TestRuleset.

INSERT INTO firebase.rules.rulesets (
data__source,
data__attachmentPoint,
projectsId
)
SELECT
'{{ source }}',
'{{ attachmentPoint }}',
'{{ projectsId }}'
RETURNING
name,
attachmentPoint,
createTime,
metadata,
source
;

DELETE examples

Delete a Ruleset by resource name. If the Ruleset is referenced by a Release the operation will fail.

DELETE FROM firebase.rules.rulesets
WHERE projectsId = '{{ projectsId }}' --required
AND rulesetsId = '{{ rulesetsId }}' --required;