Skip to content

Commit 13e4259

Browse files
trehanshakuntGAnujJhunjhunwala
authored andcommitted
Fix rebase conflicts
Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. It's a fully managed, serverless database that supports mobile, web, and server development. This change adds Firestore as a source in toolbox
1 parent 5029f87 commit 13e4259

30 files changed

+4417
-0
lines changed

.ci/integration.cloudbuild.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,26 @@ steps:
445445
"Valkey" \
446446
valkey \
447447
valkey
448+
449+
- id: "firestore"
450+
name: golang:1
451+
waitFor: ["compile-test-binary"]
452+
entrypoint: /bin/bash
453+
env:
454+
- "GOPATH=/gopath"
455+
- "FIRESTORE_PROJECT=$PROJECT_ID"
456+
- "SERVICE_ACCOUNT_EMAIL=$SERVICE_ACCOUNT_EMAIL"
457+
secretEnv: ["CLIENT_ID"]
458+
volumes:
459+
- name: "go"
460+
path: "/gopath"
461+
args:
462+
- -c
463+
- |
464+
.ci/test_with_coverage.sh \
465+
"Firestore" \
466+
firestore \
467+
firestore
448468
449469

450470
availableSecrets:

cmd/root.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ import (
5353
_ "github.com/googleapis/genai-toolbox/internal/tools/couchbase"
5454
_ "github.com/googleapis/genai-toolbox/internal/tools/dataplex/dataplexsearchentries"
5555
_ "github.com/googleapis/genai-toolbox/internal/tools/dgraph"
56+
_ "github.com/googleapis/genai-toolbox/internal/tools/firestore/firestoredeletedocuments"
57+
_ "github.com/googleapis/genai-toolbox/internal/tools/firestore/firestoregetdocuments"
58+
_ "github.com/googleapis/genai-toolbox/internal/tools/firestore/firestoregetrules"
59+
_ "github.com/googleapis/genai-toolbox/internal/tools/firestore/firestorelistcollections"
60+
_ "github.com/googleapis/genai-toolbox/internal/tools/firestore/firestorequerycollection"
61+
_ "github.com/googleapis/genai-toolbox/internal/tools/firestore/firestorevalidaterules"
5662
_ "github.com/googleapis/genai-toolbox/internal/tools/http"
5763
_ "github.com/googleapis/genai-toolbox/internal/tools/mssql/mssqlexecutesql"
5864
_ "github.com/googleapis/genai-toolbox/internal/tools/mssql/mssqlsql"
@@ -79,6 +85,7 @@ import (
7985
_ "github.com/googleapis/genai-toolbox/internal/sources/couchbase"
8086
_ "github.com/googleapis/genai-toolbox/internal/sources/dataplex"
8187
_ "github.com/googleapis/genai-toolbox/internal/sources/dgraph"
88+
_ "github.com/googleapis/genai-toolbox/internal/sources/firestore"
8289
_ "github.com/googleapis/genai-toolbox/internal/sources/http"
8390
_ "github.com/googleapis/genai-toolbox/internal/sources/mssql"
8491
_ "github.com/googleapis/genai-toolbox/internal/sources/mysql"

cmd/root_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,11 @@ func TestPrebuiltTools(t *testing.T) {
11661166
cloudsqlpg_config, _ := prebuiltconfigs.Get("cloud-sql-postgres")
11671167
cloudsqlmysql_config, _ := prebuiltconfigs.Get("cloud-sql-mysql")
11681168
cloudsqlmssql_config, _ := prebuiltconfigs.Get("cloud-sql-mssql")
1169+
<<<<<<< HEAD
11691170
dataplex_config, _ := prebuiltconfigs.Get("dataplex")
1171+
=======
1172+
firestoreconfig, _ := prebuiltconfigs.Get("firestore")
1173+
>>>>>>> 2bb790e (feat: Add Firestore as Source (#786))
11701174
postgresconfig, _ := prebuiltconfigs.Get("postgres")
11711175
spanner_config, _ := prebuiltconfigs.Get("spanner")
11721176
spannerpg_config, _ := prebuiltconfigs.Get("spanner-postgres")
@@ -1239,6 +1243,16 @@ func TestPrebuiltTools(t *testing.T) {
12391243
},
12401244
},
12411245
},
1246+
{
1247+
name: "firestore prebuilt tools",
1248+
in: firestoreconfig,
1249+
wantToolset: server.ToolsetConfigs{
1250+
"firestore-database-tools": tools.ToolsetConfig{
1251+
Name: "firestore-database-tools",
1252+
ToolNames: []string{"firestore-get-documents", "firestore-list-collections", "firestore-delete-documents", "firestore-query-collection", "firestore-get-rules", "firestore-validate-rules"},
1253+
},
1254+
},
1255+
},
12421256
{
12431257
name: "postgres prebuilt tools",
12441258
in: postgresconfig,
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: "Firestore"
3+
type: docs
4+
weight: 1
5+
description: >
6+
Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. It's a fully managed, serverless database that supports mobile, web, and server development.
7+
8+
---
9+
10+
# Firestore Source
11+
12+
[Firestore][firestore-docs] is a NoSQL document database built for automatic
13+
scaling, high performance, and ease of application development. While the
14+
Firestore interface has many of the same features as traditional databases,
15+
as a NoSQL database it differs from them in the way it describes relationships
16+
between data objects.
17+
18+
If you are new to Firestore, you can [create a database and learn the
19+
basics][firestore-quickstart].
20+
21+
[firestore-docs]: https://cloud.google.com/firestore/docs
22+
[firestore-quickstart]: https://cloud.google.com/firestore/docs/quickstart-servers
23+
24+
## Requirements
25+
26+
### IAM Permissions
27+
28+
Firestore uses [Identity and Access Management (IAM)][iam-overview] to control
29+
user and group access to Firestore resources. Toolbox will use your [Application
30+
Default Credentials (ADC)][adc] to authorize and authenticate when interacting
31+
with [Firestore][firestore-docs].
32+
33+
In addition to [setting the ADC for your server][set-adc], you need to ensure
34+
the IAM identity has been given the correct IAM permissions for accessing
35+
Firestore. Common roles include:
36+
- `roles/datastore.user` - Read and write access to Firestore
37+
- `roles/datastore.viewer` - Read-only access to Firestore
38+
39+
See [Firestore access control][firestore-iam] for more information on
40+
applying IAM permissions and roles to an identity.
41+
42+
[iam-overview]: https://cloud.google.com/firestore/docs/security/iam
43+
[adc]: https://cloud.google.com/docs/authentication#adc
44+
[set-adc]: https://cloud.google.com/docs/authentication/provide-credentials-adc
45+
[firestore-iam]: https://cloud.google.com/firestore/docs/security/iam
46+
47+
### Database Selection
48+
49+
Firestore allows you to create multiple databases within a single project. Each
50+
database is isolated from the others and has its own set of documents and
51+
collections. If you don't specify a database in your configuration, the default
52+
database named `(default)` will be used.
53+
54+
## Example
55+
56+
```yaml
57+
sources:
58+
my-firestore-source:
59+
kind: "firestore"
60+
project: "my-project-id"
61+
# database: "my-database" # Optional, defaults to "(default)"
62+
```
63+
64+
## Reference
65+
66+
| **field** | **type** | **required** | **description** |
67+
|-----------|:--------:|:------------:|----------------------------------------------------------------------------------------------------------|
68+
| kind | string | true | Must be "firestore". |
69+
| project | string | true | Id of the GCP project that contains the Firestore database (e.g. "my-project-id"). |
70+
| database | string | false | Name of the Firestore database to connect to. Defaults to "(default)" if not specified. |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: "Firestore"
3+
type: docs
4+
weight: 1
5+
description: >
6+
Tools that work with Firestore Sources.
7+
---
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "firestore-delete-documents"
3+
type: docs
4+
weight: 1
5+
description: >
6+
A "firestore-delete-documents" tool deletes multiple documents from Firestore by their paths.
7+
aliases:
8+
- /resources/tools/firestore-delete-documents
9+
---
10+
11+
## About
12+
13+
A `firestore-delete-documents` tool deletes multiple documents from Firestore by their paths.
14+
It's compatible with the following sources:
15+
16+
- [firestore](../sources/firestore.md)
17+
18+
`firestore-delete-documents` takes one input parameter `documentPaths` which is an array of
19+
document paths to delete. The tool uses Firestore's BulkWriter for efficient batch deletion
20+
and returns the success status for each document.
21+
22+
## Example
23+
24+
```yaml
25+
tools:
26+
delete_user_documents:
27+
kind: firestore-delete-documents
28+
source: my-firestore-source
29+
description: Use this tool to delete multiple documents from Firestore.
30+
```
31+
32+
## Reference
33+
34+
| **field** | **type** | **required** | **description** |
35+
|-------------|:------------------------------------------:|:------------:|--------------------------------------------------------------------------------------------------|
36+
| kind | string | true | Must be "firestore-delete-documents". |
37+
| source | string | true | Name of the Firestore source to delete documents from. |
38+
| description | string | true | Description of the tool that is passed to the LLM. |
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "firestore-get-documents"
3+
type: docs
4+
weight: 1
5+
description: >
6+
A "firestore-get-documents" tool retrieves multiple documents from Firestore by their paths.
7+
aliases:
8+
- /resources/tools/firestore-get-documents
9+
---
10+
11+
## About
12+
13+
A `firestore-get-documents` tool retrieves multiple documents from Firestore by their paths.
14+
It's compatible with the following sources:
15+
16+
- [firestore](../sources/firestore.md)
17+
18+
`firestore-get-documents` takes one input parameter `documentPaths` which is an array of
19+
document paths, and returns the documents' data along with metadata such as existence status,
20+
creation time, update time, and read time.
21+
22+
## Example
23+
24+
```yaml
25+
tools:
26+
get_user_documents:
27+
kind: firestore-get-documents
28+
source: my-firestore-source
29+
description: Use this tool to retrieve multiple documents from Firestore.
30+
```
31+
32+
## Reference
33+
34+
| **field** | **type** | **required** | **description** |
35+
|-------------|:------------------------------------------:|:------------:|--------------------------------------------------------------------------------------------------|
36+
| kind | string | true | Must be "firestore-get-documents". |
37+
| source | string | true | Name of the Firestore source to retrieve documents from. |
38+
| description | string | true | Description of the tool that is passed to the LLM. |
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "firestore-get-rules"
3+
type: docs
4+
weight: 1
5+
description: >
6+
A "firestore-get-rules" tool retrieves the active Firestore security rules for the current project.
7+
aliases:
8+
- /resources/tools/firestore-get-rules
9+
---
10+
11+
## About
12+
13+
A `firestore-get-rules` tool retrieves the active [Firestore security rules](https://firebase.google.com/docs/firestore/security/get-started) for the current project.
14+
It's compatible with the following sources:
15+
16+
- [firestore](../sources/firestore.md)
17+
18+
`firestore-get-rules` takes no input parameters and returns the security rules content along with metadata
19+
such as the ruleset name, and timestamps.
20+
21+
## Example
22+
23+
```yaml
24+
tools:
25+
get_firestore_rules:
26+
kind: firestore-get-rules
27+
source: my-firestore-source
28+
description: Use this tool to retrieve the active Firestore security rules.
29+
```
30+
31+
## Reference
32+
33+
| **field** | **type** | **required** | **description** |
34+
|-------------|:------------------------------------------:|:------------:|--------------------------------------------------------------------------------------------------|
35+
| kind | string | true | Must be "firestore-get-rules". |
36+
| source | string | true | Name of the Firestore source to retrieve rules from. |
37+
| description | string | true | Description of the tool that is passed to the LLM. |
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "firestore-list-collections"
3+
type: docs
4+
weight: 1
5+
description: >
6+
A "firestore-list-collections" tool lists collections in Firestore, either at the root level or as subcollections of a document.
7+
aliases:
8+
- /resources/tools/firestore-list-collections
9+
---
10+
11+
## About
12+
13+
A `firestore-list-collections` tool lists [collections](https://firebase.google.com/docs/firestore/data-model#collections) in Firestore, either at the root level or as [subcollections](https://firebase.google.com/docs/firestore/data-model#subcollections) of a specific document.
14+
It's compatible with the following sources:
15+
16+
- [firestore](../sources/firestore.md)
17+
18+
`firestore-list-collections` takes an optional `parentPath` parameter to specify a document
19+
path. If provided, it lists all subcollections of that document. If not provided, it lists
20+
all root-level collections in the database.
21+
22+
## Example
23+
24+
```yaml
25+
tools:
26+
list_firestore_collections:
27+
kind: firestore-list-collections
28+
source: my-firestore-source
29+
description: Use this tool to list collections in Firestore.
30+
```
31+
32+
## Reference
33+
34+
| **field** | **type** | **required** | **description** |
35+
|-------------|:------------------------------------------:|:------------:|--------------------------------------------------------------------------------------------------|
36+
| kind | string | true | Must be "firestore-list-collections". |
37+
| source | string | true | Name of the Firestore source to list collections from. |
38+
| description | string | true | Description of the tool that is passed to the LLM. |

0 commit comments

Comments
 (0)