Skip to content

Commit 5a3b0aa

Browse files
rwhoggpandirigoog
authored andcommitted
Add new Firestore index and database options (GoogleCloudPlatform#13600)
1 parent 848b211 commit 5a3b0aa

6 files changed

+129
-2
lines changed

mmv1/products/firestore/Database.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ examples:
124124
- 'project'
125125
- 'etag'
126126
- 'deletion_policy'
127+
- name: 'firestore_database_enterprise'
128+
primary_resource_id: 'enterprise-db'
129+
vars:
130+
database_id: 'database-id'
131+
delete_protection_state: 'DELETE_PROTECTION_ENABLED'
132+
test_env_vars:
133+
project_id: 'PROJECT_NAME'
134+
ignore_read_extra:
135+
- 'project'
136+
- 'etag'
137+
- 'deletion_policy'
127138
virtual_fields:
128139
- name: 'deletion_policy'
129140
description: |
@@ -166,6 +177,17 @@ properties:
166177
enum_values:
167178
- 'FIRESTORE_NATIVE'
168179
- 'DATASTORE_MODE'
180+
- name: 'databaseEdition'
181+
type: Enum
182+
description: |
183+
The database edition.
184+
required: false
185+
default_from_api: true
186+
# Picking a database edition is an irreversible decision
187+
immutable: true
188+
enum_values:
189+
- 'STANDARD'
190+
- 'ENTERPRISE'
169191
- name: 'concurrencyMode'
170192
type: Enum
171193
description: |

mmv1/products/firestore/Index.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ examples:
8181
database_id: 'database-id'
8282
test_env_vars:
8383
project_id: 'PROJECT_NAME'
84+
- name: 'firestore_index_mongodb_compatible_scope'
85+
primary_resource_id: 'my-index'
86+
vars:
87+
database_id: 'database-id-mongodb-compatible'
88+
test_env_vars:
89+
project_id: 'PROJECT_NAME'
90+
- name: 'firestore_index_sparse_any'
91+
primary_resource_id: 'my-index'
92+
vars:
93+
database_id: 'database-id-sparse-any'
94+
test_env_vars:
95+
project_id: 'PROJECT_NAME'
8496
parameters:
8597
properties:
8698
- name: 'name'
@@ -119,6 +131,28 @@ properties:
119131
enum_values:
120132
- 'ANY_API'
121133
- 'DATASTORE_MODE_API'
134+
- 'MONGODB_COMPATIBLE_API'
135+
- name: 'density'
136+
type: Enum
137+
description: |
138+
The density configuration for this index.
139+
immutable: true
140+
default_from_api: true
141+
enum_values:
142+
- SPARSE_ALL
143+
- SPARSE_ANY
144+
- DENSE
145+
- name: 'multikey'
146+
type: Boolean
147+
default_value: false
148+
description:
149+
Optional. Whether the index is multikey. By default, the index
150+
is not multikey. For non-multikey indexes, none of the paths in the
151+
index definition reach or traverse an array, except via an explicit
152+
array index. For multikey indexes, at most one of the paths in the index
153+
definition reach or traverse an array, except via an explicit array
154+
index. Violations will result in errors. Note this field only applies to
155+
indexes with MONGODB_COMPATIBLE_API ApiScope.
122156
- name: 'fields'
123157
type: Array
124158
description: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "google_firestore_database" "{{$.PrimaryResourceId}}" {
2+
project = "{{index $.TestEnvVars "project_id"}}"
3+
name = "{{index $.Vars "database_id"}}"
4+
location_id = "nam5"
5+
type = "FIRESTORE_NATIVE"
6+
database_edition = "ENTERPRISE"
7+
deletion_policy = "DELETE"
8+
}

mmv1/templates/terraform/examples/firestore_index_datastore_mode.tf.tmpl

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ resource "google_firestore_database" "database" {
99
}
1010

1111
resource "google_firestore_index" "{{$.PrimaryResourceId}}" {
12-
project = "{{index $.TestEnvVars "project_id"}}"
12+
project = "{{index $.TestEnvVars "project_id"}}"
1313
database = google_firestore_database.database.name
1414
collection = "atestcollection"
1515

1616
query_scope = "COLLECTION_RECURSIVE"
17-
api_scope = "DATASTORE_MODE_API"
17+
api_scope = "DATASTORE_MODE_API"
18+
density = "SPARSE_ALL"
1819

1920
fields {
2021
field_path = "name"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
resource "google_firestore_database" "database" {
2+
project = "{{index $.TestEnvVars "project_id"}}"
3+
name = "{{index $.Vars "database_id"}}"
4+
location_id = "nam5"
5+
type = "FIRESTORE_NATIVE"
6+
database_edition = "ENTERPRISE"
7+
8+
delete_protection_state = "DELETE_PROTECTION_DISABLED"
9+
deletion_policy = "DELETE"
10+
}
11+
12+
resource "google_firestore_index" "{{$.PrimaryResourceId}}" {
13+
project = "{{index $.TestEnvVars "project_id"}}"
14+
database = google_firestore_database.database.name
15+
collection = "atestcollection"
16+
17+
api_scope = "MONGODB_COMPATIBLE_API"
18+
query_scope = "COLLECTION_GROUP"
19+
multikey = true
20+
density = "DENSE"
21+
22+
fields {
23+
field_path = "name"
24+
order = "ASCENDING"
25+
}
26+
27+
fields {
28+
field_path = "description"
29+
order = "DESCENDING"
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
resource "google_firestore_database" "database" {
2+
project = "{{index $.TestEnvVars "project_id"}}"
3+
name = "{{index $.Vars "database_id"}}"
4+
location_id = "nam5"
5+
type = "FIRESTORE_NATIVE"
6+
database_edition = "ENTERPRISE"
7+
8+
delete_protection_state = "DELETE_PROTECTION_DISABLED"
9+
deletion_policy = "DELETE"
10+
}
11+
12+
resource "google_firestore_index" "{{$.PrimaryResourceId}}" {
13+
project = "{{index $.TestEnvVars "project_id"}}"
14+
database = google_firestore_database.database.name
15+
collection = "atestcollection"
16+
17+
api_scope = "MONGODB_COMPATIBLE_API"
18+
query_scope = "COLLECTION_GROUP"
19+
multikey = true
20+
density = "SPARSE_ANY"
21+
22+
fields {
23+
field_path = "name"
24+
order = "ASCENDING"
25+
}
26+
27+
fields {
28+
field_path = "description"
29+
order = "DESCENDING"
30+
}
31+
}

0 commit comments

Comments
 (0)