FirebaseRules
import { FirebaseRules } from "https://googleapis.deno.dev/v1/firebaserules:v1.ts";
Creates and manages rules that determine when a Firebase Rules-enabled service should permit a request.
§Methods
Create a Release
. Release names should reflect the developer's
deployment practices. For example, the release name may include the
environment name, application name, application version, or any other name
meaningful to the developer. Once a Release
refers to a Ruleset
, the
rules can be enforced by Firebase Rules-enabled services. More than one
Release
may be 'live' concurrently. Consider the following three
Release
names for projects/foo
and the Ruleset
to which they refer.
Release Name -> Ruleset Name * projects/foo/releases/prod ->
projects/foo/rulesets/uuid123 * projects/foo/releases/prod/beta ->
projects/foo/rulesets/uuid123 * projects/foo/releases/prod/v23 ->
projects/foo/rulesets/uuid456 The relationships reflect a Ruleset
rollout
in progress. The prod
and prod/beta
releases refer to the same
Ruleset
. However, prod/v23
refers to a new Ruleset
. The Ruleset
reference for a Release
may be updated using the UpdateRelease method.
Required. Resource name for the project which owns this Release
. Format: projects/{project_id}
Get the Release
executable to use when enforcing rules.
Required. Resource name of the Release
. Format: projects/{project_id}/releases/{release_id}
List the Release
values for a project. This list may optionally be
filtered by Release
name, Ruleset
name, TestSuite
name, or any
combination thereof.
Required. Resource name for the project. Format: projects/{project_id}
Update a Release
via PATCH. Only updates to ruleset_name
will be
honored. Release
rename is not supported. To create a Release
use the
CreateRelease method.
Required. Resource name for the project which owns this Release
. Format: projects/{project_id}
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.
Required. Resource name for Project which owns this Ruleset
. Format: projects/{project_id}
List Ruleset
metadata only and optionally filter the results by
Ruleset
name. The full Source
contents of a Ruleset
may be retrieved
with GetRuleset.
Required. Resource name for the project. Format: projects/{project_id}
Test Source
for syntactic and semantic correctness. Issues present, if
any, will be returned to the caller with a description, severity, and
source location. The test method may be executed with Source
or a
Ruleset
name. Passing Source
is useful for unit testing new rules.
Passing a Ruleset
name is useful for regression testing an existing rule.
The following is an example of Source
that permits users to upload images
to a bucket bearing their user id and matching the correct metadata:
Example // Users are allowed to subscribe and unsubscribe to the blog.
service firebase.storage { match /users/{userId}/images/{imageName} { allow
write: if userId == request.auth.uid && (imageName.matches('.png$') ||
imageName.matches('.jpg$')) && resource.mimeType.matches('^image/') } }
Required. Tests may either provide source
or a Ruleset
resource name. For tests against source
, the resource name must refer to the project: Format: projects/{project_id}
For tests against a Ruleset
, this must be the Ruleset
resource name: Format: projects/{project_id}/rulesets/{ruleset_id}