From 658c95244e58f8a9b3db76b161bda94c2982e345 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Wed, 14 Feb 2024 15:52:53 -0500 Subject: [PATCH 01/45] Pipeline operations AST --- google-cloud-firestore/pom.xml | 76 +++++++++++++++ .../com/google/cloud/firestore/Pipeline.kt | 27 ++++++ .../cloud/firestore/pipeline/Expressions.kt | 3 + .../cloud/firestore/pipeline/Operations.kt | 93 +++++++++++++++++++ 4 files changed, 199 insertions(+) create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt diff --git a/google-cloud-firestore/pom.xml b/google-cloud-firestore/pom.xml index 5219d90c1..b065677b3 100644 --- a/google-cloud-firestore/pom.xml +++ b/google-cloud-firestore/pom.xml @@ -16,6 +16,7 @@ google-cloud-firestore + 1.9.22 @@ -173,6 +174,17 @@ 3.14.0 test + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + @@ -214,6 +226,70 @@ org.codehaus.mojo flatten-maven-plugin + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + src/main/java + target/generated-sources/annotations + + + + + test-compile + test-compile + + test-compile + + + + src/test/java + target/generated-test-sources/test-annotations + + + + + + 1.8 + + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + none + + + default-testCompile + none + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt new file mode 100644 index 000000000..d93016556 --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -0,0 +1,27 @@ +package com.google.cloud.firestore + +import com.google.cloud.firestore.pipeline.Collection +import com.google.cloud.firestore.pipeline.CollectionGroup +import com.google.cloud.firestore.pipeline.Operation + +class Pipeline { + private val operations: MutableList = mutableListOf() + + private constructor(collection: Collection) { + operations.add(collection) + } + private constructor(group: CollectionGroup) { + operations.add(group) + } + companion object { + @JvmStatic + fun from(collectionName: String): Pipeline { + return Pipeline(Collection(collectionName)) + } + + @JvmStatic + fun fromCollectionGroup(group: String): Pipeline { + return Pipeline(CollectionGroup(group)) + } + } +} diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt new file mode 100644 index 000000000..e76574491 --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -0,0 +1,3 @@ +package com.google.cloud.firestore.pipeline + +interface Expr {} diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt new file mode 100644 index 000000000..6ef333fec --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -0,0 +1,93 @@ +package com.google.cloud.firestore.pipeline + +import com.google.cloud.firestore.FieldPath +import com.google.cloud.firestore.Pipeline + +interface Operation {} + +data class Collection(val path: String): Operation +data class CollectionGroup(val path: String): Operation + +data class Project(val projections: Map): Operation +data class AddFields(val additions: Map): Operation +data class RemoveFields(val removals: List): Operation +data class Filter(val condition: Expr): Operation +data class Offset(val offset: Int): Operation +data class Limit(val limit: Int): Operation +data class Union(val pipeline: Pipeline, val distinct: Boolean): Operation + +data class Group(val fields: Map, val accumulators: Map) + +data class FindNearest(val property: FieldPath, + val vector: Array, + val options: FindNearestOptions): Operation { + enum class Similarity { + EUCLIDEAN, + COSINE, + DOT_PRODUCT + } + + data class FindNearestOptions(val similarity: Similarity, val limit: Long, val output: FieldPath) {} +} + +sealed interface JoinCondition { + data class Expression(val expr: Expr): JoinCondition + data class Using(val fields: Set): JoinCondition +} + +data class Join(val type: Type, + val condition: JoinCondition, + val alias: FieldPath, + val otherPipeline: Pipeline, + val otherAlias: FieldPath): Operation { + enum class Type { + CROSS, + INNER, + FULL, + LEFT, + RIGHT + } +} + +data class SemiJoin(val type: Type, + val condition: JoinCondition, + val alias: FieldPath, + val otherPipeline: Pipeline, + val otherAlias: FieldPath): Operation { + enum class Type { + LEFT_SEMI, + RIGHT_SEMI, + LEFT_ANTI_SEMI, + RIGHT_ANTI_SEMI, + } +} + +data class Ordering(val expr: Expr, val dir: Direction = Direction.ASC) { + enum class Direction { + ASC, + DESC + } +} + +data class Sort(val orders: List, + val density: Density = Density.UNSPECIFIED, + val truncation: Truncation = Truncation.UNSPECIFIED): Operation { + enum class Density{ + UNSPECIFIED, + REQUIRED + } + + enum class Truncation { + UNSPECIFIED, + DISABLED + } +} + +data class Unnest(val mode: Mode, val field: FieldPath): Operation { + enum class Mode { + FULL_REPLACE, + MERGE_PREFER_NEST, + MERGE_PREFER_PARENT; + } +} + From 4ab3382463cbc2b7a5f98edc25cecccf28b45cdb Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 15 Feb 2024 11:26:42 -0500 Subject: [PATCH 02/45] Getting ready for fluent api --- .../com/google/cloud/firestore/Pipeline.kt | 13 ++++ .../cloud/firestore/pipeline/Expressions.kt | 70 ++++++++++++++++++- .../cloud/firestore/pipeline/Operations.kt | 34 +++++---- 3 files changed, 103 insertions(+), 14 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index d93016556..03e11f9d4 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -2,11 +2,15 @@ package com.google.cloud.firestore import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup +import com.google.cloud.firestore.pipeline.Database import com.google.cloud.firestore.pipeline.Operation class Pipeline { private val operations: MutableList = mutableListOf() + private constructor(db: Database) { + operations.add(db) + } private constructor(collection: Collection) { operations.add(collection) } @@ -23,5 +27,14 @@ class Pipeline { fun fromCollectionGroup(group: String): Pipeline { return Pipeline(CollectionGroup(group)) } + + @JvmStatic + fun entireDatabase(): Pipeline { + return Pipeline(Database()) + } } + + // Fluent API + + } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index e76574491..7535bc789 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -1,3 +1,71 @@ package com.google.cloud.firestore.pipeline -interface Expr {} +import com.google.firestore.v1.Value + +sealed interface Expr { + data class Constant(val value: Value): Expr {} + data class FieldReference(val field: String): Expr {} + + data class ListOfExprs(val exprs: List): Expr {} + + sealed class Function(val name: String, val params: Map?) : Expr { + data class Equal(val left: Expr, val right: Expr) : Function("equal", mapOf("left" to left, "right" to right)) + data class NotEqual(val left: Expr, val right: Expr) : Function("not_equal", mapOf("left" to left, "right" to right)) + data class GreaterThan(val left: Expr, val right: Expr) : Function("greater_than", mapOf("left" to left, "right" to right)) + data class GreaterThanOrEqual(val left: Expr, val right: Expr) : Function("greater_than_equal", mapOf("left" to left, "right" to right)) + data class In(val left: Expr, val others: List) : Function("in", mapOf("left" to left, "others" to ListOfExprs(others))) // For 'in' + data class LessThan(val left: Expr, val right: Expr) : Function("less_than", mapOf("left" to left, "right" to right)) + data class LessThanOrEqual(val left: Expr, val right: Expr) : Function("less_than_equal", mapOf("left" to left, "right" to right)) + data class NotIn(val left: Expr, val others: List) : Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))) // For 'not in' + data class And(val conditions: List) : Function("and", mapOf("conditions" to ListOfExprs(conditions))) + data class Or(val conditions: List) : Function("or", mapOf("conditions" to ListOfExprs(conditions))) + data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)) + data class Exists(val current: FieldReference) : Function("exists", mapOf("current" to current)) + + data class MapGet(val map: Expr, val key: String) : Function("map_get", mapOf("map" to map, "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()))) + + data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", mapOf("array" to array, "element" to element)) + data class ArrayContainsAny(val array: Expr, val elements: List) : Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))) + data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)) + data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)) + + data class Sum(val value: Expr) : Function("sum", mapOf("value" to value)) + data class Avg(val value: Expr) : Function("avg", mapOf("value" to value)) + data class Count(val value: Expr) : Function("count", mapOf("value" to value)) + + data class CosineDistance(val vector1: Expr, val vector2: Expr) : Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + data class HasAncestor(val child: Expr, val ancestor: Expr): Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)) + data class Raw(val n: String, val ps: Map?): Function(n, ps) + } + + // Infix functions returning Function subclasses + infix fun equal(other: Expr): Function = Function.Equal(this, other) + infix fun notEqual(other: Expr): Function = Function.NotEqual(this, other) + infix fun greaterThan(other: Expr): Function = Function.GreaterThan(this, other) + infix fun greaterThanOrEqual(other: Expr): Function = Function.GreaterThanOrEqual(this, other) + fun inAny(left: Expr, vararg other: Expr): Function = Function.In(left, other.toList()) + infix fun lessThan(other: Expr): Function = Function.LessThan(this, other) + infix fun lessThanOrEqual(other: Expr): Function = Function.LessThanOrEqual(this, other) + fun notInAny(left: Expr, vararg other: Expr): Function = Function.NotIn(left, other.toList()) + infix fun and(other: Expr): Function = Function.And(listOf(this, other)) + fun and(vararg other: Expr): Function = Function.And(listOf(this) + other.toList()) + infix fun or(other: Expr): Function = Function.Or(listOf(this, other)) + fun or(vararg other: Expr): Function = Function.Or(listOf(this) + other.toList()) + fun exists(): Function = Function.Exists(this as FieldReference) + + infix fun mapGet(key: String): Function = Function.MapGet(this, key) + infix fun arrayContains(element: Expr): Function = Function.ArrayContains(this, element) + fun arrayContainsAny(vararg elements: Expr): Function = Function.ArrayContainsAny(this, elements.toList()) + fun isNaN(): Function = Function.IsNaN(this) + fun isNull(): Function = Function.IsNull(this) + infix fun not(other: Expr): Function = Function.Not(this) // Likely use 'this' if 'not' is unary + fun sum(): Function = Function.Sum(this) + fun avg(): Function = Function.Avg(this) + fun count(): Function = Function.Count(this) + infix fun cosineDistance(other: Expr): Function = Function.CosineDistance(this, other) + infix fun euclideanDistance(other: Expr): Function = Function.EuclideanDistance(this, other) + infix fun hasAncestor(ancestor: Expr): Function = Function.HasAncestor(this, ancestor) + + fun function(name: String, params: Map?): Function = Function.Raw(name, params) +} diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 6ef333fec..252ae8373 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -1,24 +1,32 @@ package com.google.cloud.firestore.pipeline -import com.google.cloud.firestore.FieldPath import com.google.cloud.firestore.Pipeline interface Operation {} +data class Field internal constructor(val path: String) { + companion object { + fun of(path: String): Field { + return Field(path) + } + } +} + +class Database(): Operation data class Collection(val path: String): Operation data class CollectionGroup(val path: String): Operation -data class Project(val projections: Map): Operation -data class AddFields(val additions: Map): Operation -data class RemoveFields(val removals: List): Operation +data class Project(val projections: Map): Operation +data class AddFields(val additions: Map): Operation +data class RemoveFields(val removals: List): Operation data class Filter(val condition: Expr): Operation data class Offset(val offset: Int): Operation data class Limit(val limit: Int): Operation data class Union(val pipeline: Pipeline, val distinct: Boolean): Operation -data class Group(val fields: Map, val accumulators: Map) +data class Group(val fields: Map, val accumulators: Map) -data class FindNearest(val property: FieldPath, +data class FindNearest(val property: Field, val vector: Array, val options: FindNearestOptions): Operation { enum class Similarity { @@ -27,19 +35,19 @@ data class FindNearest(val property: FieldPath, DOT_PRODUCT } - data class FindNearestOptions(val similarity: Similarity, val limit: Long, val output: FieldPath) {} + data class FindNearestOptions(val similarity: Similarity, val limit: Long, val output: Field) {} } sealed interface JoinCondition { data class Expression(val expr: Expr): JoinCondition - data class Using(val fields: Set): JoinCondition + data class Using(val fields: Set): JoinCondition } data class Join(val type: Type, val condition: JoinCondition, - val alias: FieldPath, + val alias: Field, val otherPipeline: Pipeline, - val otherAlias: FieldPath): Operation { + val otherAlias: Field): Operation { enum class Type { CROSS, INNER, @@ -51,9 +59,9 @@ data class Join(val type: Type, data class SemiJoin(val type: Type, val condition: JoinCondition, - val alias: FieldPath, + val alias: Field, val otherPipeline: Pipeline, - val otherAlias: FieldPath): Operation { + val otherAlias: Field): Operation { enum class Type { LEFT_SEMI, RIGHT_SEMI, @@ -83,7 +91,7 @@ data class Sort(val orders: List, } } -data class Unnest(val mode: Mode, val field: FieldPath): Operation { +data class Unnest(val mode: Mode, val field: Field): Operation { enum class Mode { FULL_REPLACE, MERGE_PREFER_NEST, From a3d72341a7d73d014a0d2e94641182ea092bdbf2 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 15 Feb 2024 13:24:14 -0500 Subject: [PATCH 03/45] Basic fluent --- .../com/google/cloud/firestore/Pipeline.kt | 193 ++++++++++++++++++ .../cloud/firestore/pipeline/Operations.kt | 4 +- 2 files changed, 196 insertions(+), 1 deletion(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 03e11f9d4..873c0d238 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -1,9 +1,27 @@ package com.google.cloud.firestore +import com.google.cloud.firestore.pipeline.AddFields import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup import com.google.cloud.firestore.pipeline.Database +import com.google.cloud.firestore.pipeline.Expr +import com.google.cloud.firestore.pipeline.Field +import com.google.cloud.firestore.pipeline.Filter +import com.google.cloud.firestore.pipeline.FindNearest +import com.google.cloud.firestore.pipeline.Group +import com.google.cloud.firestore.pipeline.Join +import com.google.cloud.firestore.pipeline.JoinCondition +import com.google.cloud.firestore.pipeline.Limit +import com.google.cloud.firestore.pipeline.Offset import com.google.cloud.firestore.pipeline.Operation +import com.google.cloud.firestore.pipeline.Ordering +import com.google.cloud.firestore.pipeline.Project +import com.google.cloud.firestore.pipeline.RawOperation +import com.google.cloud.firestore.pipeline.RemoveFields +import com.google.cloud.firestore.pipeline.SemiJoin +import com.google.cloud.firestore.pipeline.Sort +import com.google.cloud.firestore.pipeline.Union +import com.google.cloud.firestore.pipeline.Unnest class Pipeline { private val operations: MutableList = mutableListOf() @@ -11,12 +29,15 @@ class Pipeline { private constructor(db: Database) { operations.add(db) } + private constructor(collection: Collection) { operations.add(collection) } + private constructor(group: CollectionGroup) { operations.add(group) } + companion object { @JvmStatic fun from(collectionName: String): Pipeline { @@ -36,5 +57,177 @@ class Pipeline { // Fluent API + fun project(projections: Map): Pipeline { + operations.add(Project(projections)) + return this + } + + fun addFields(additions: Map): Pipeline { + operations.add(AddFields(additions)) + return this + } + + fun removeFields(removals: List): Pipeline { + operations.add(RemoveFields(removals)) + return this + } + + fun filter(condition: Expr): Pipeline { + operations.add(Filter(condition)) + return this + } + + fun offset(offset: Int): Pipeline { + operations.add(Offset(offset)) + return this + } + + fun limit(limit: Int): Pipeline { + operations.add(Limit(limit)) + return this + } + + fun union(pipeline: Pipeline, distinct: Boolean): Pipeline { + operations.add(Union(pipeline, distinct)) + return this + } + + fun group(fields: Map, accumulators: Map): Pipeline { + operations.add(Group(fields, accumulators)) + return this + } + + fun findNearest( + property: Field, + vector: Array, + options: FindNearest.FindNearestOptions + ): Pipeline { + operations.add(FindNearest(property, vector, options)) + return this + } + + fun innerJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add(Join(Join.Type.INNER, condition, alias, otherPipeline, otherAlias)) + return this + } + fun crossJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add(Join(Join.Type.CROSS, condition, alias, otherPipeline, otherAlias)) + return this + } + + fun fullJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add(Join(Join.Type.FULL, condition, alias, otherPipeline, otherAlias)) + return this + } + + fun leftJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add(Join(Join.Type.LEFT, condition, alias, otherPipeline, otherAlias)) + return this + } + + fun rightJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add(Join(Join.Type.RIGHT, condition, alias, otherPipeline, otherAlias)) + return this + } + + fun leftSemiJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add(SemiJoin(SemiJoin.Type.LEFT_SEMI, condition, alias, otherPipeline, otherAlias)) + return this + } + + fun rightSemiJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add(SemiJoin(SemiJoin.Type.RIGHT_SEMI, condition, alias, otherPipeline, otherAlias)) + return this + } + + fun leftAntiSemiJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add( + SemiJoin( + SemiJoin.Type.LEFT_ANTI_SEMI, + condition, + alias, + otherPipeline, + otherAlias + ) + ) + return this + } + + fun rightAntiSemiJoin( + condition: JoinCondition, + alias: Field, + otherPipeline: Pipeline, + otherAlias: Field + ): Pipeline { + operations.add( + SemiJoin( + SemiJoin.Type.RIGHT_ANTI_SEMI, + condition, + alias, + otherPipeline, + otherAlias + ) + ) + return this + } + + fun sort( + orders: List, + density: Sort.Density = Sort.Density.UNSPECIFIED, + truncation: Sort.Truncation = Sort.Truncation.UNSPECIFIED + ): Pipeline { + operations.add(Sort(orders, density, truncation)) + return this + } + + fun unnest(mode: Unnest.Mode, field: Field): Pipeline { + operations.add(Unnest(mode, field)) + return this + } + + fun rawOperation(name: String, params: Map? = null): Pipeline { + operations.add(RawOperation(name, params)) + return this + } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 252ae8373..8a7ef68c8 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -24,7 +24,7 @@ data class Offset(val offset: Int): Operation data class Limit(val limit: Int): Operation data class Union(val pipeline: Pipeline, val distinct: Boolean): Operation -data class Group(val fields: Map, val accumulators: Map) +data class Group(val fields: Map, val accumulators: Map): Operation data class FindNearest(val property: Field, val vector: Array, @@ -99,3 +99,5 @@ data class Unnest(val mode: Mode, val field: Field): Operation { } } +data class RawOperation(val name: String, val params: Map?): Operation + From a837f62e482d2e3d03fb85265b23f836b20c0854 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Sat, 17 Feb 2024 16:11:28 -0500 Subject: [PATCH 04/45] Joins too --- .../com/google/cloud/firestore/Pipeline.kt | 94 +++++++++++++------ .../cloud/firestore/pipeline/Expressions.kt | 46 +++++---- .../cloud/firestore/pipeline/Operations.kt | 6 +- 3 files changed, 94 insertions(+), 52 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 873c0d238..b4602602e 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -16,26 +16,31 @@ import com.google.cloud.firestore.pipeline.Offset import com.google.cloud.firestore.pipeline.Operation import com.google.cloud.firestore.pipeline.Ordering import com.google.cloud.firestore.pipeline.Project +import com.google.cloud.firestore.pipeline.Projectable import com.google.cloud.firestore.pipeline.RawOperation import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.SemiJoin import com.google.cloud.firestore.pipeline.Sort -import com.google.cloud.firestore.pipeline.Union +import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest class Pipeline { private val operations: MutableList = mutableListOf() + private var name: String private constructor(db: Database) { operations.add(db) + name = "(database)" } private constructor(collection: Collection) { operations.add(collection) + name = collection.path } private constructor(group: CollectionGroup) { operations.add(group) + name = group.path } companion object { @@ -57,22 +62,44 @@ class Pipeline { // Fluent API + fun withName(name: String) { + this.name = name + } + fun project(projections: Map): Pipeline { operations.add(Project(projections)) return this } + // Sugar for project + fun project(vararg fields: Field): Pipeline { + return this + } + + fun project(vararg exprs: Expr.ExprAsAlias): Pipeline { + return this + } + + fun project(vararg projections: Projectable): Pipeline { + return this + } + fun addFields(additions: Map): Pipeline { operations.add(AddFields(additions)) return this } - fun removeFields(removals: List): Pipeline { - operations.add(RemoveFields(removals)) + // Sugar + fun addFields(vararg additions: Expr.ExprAsAlias): Pipeline { return this } - fun filter(condition: Expr): Pipeline { + fun removeFields(vararg removals: Field): Pipeline { + operations.add(RemoveFields(removals.toList())) + return this + } + + fun filter(condition: Expr.Function.ProducingBoolean): Pipeline { operations.add(Filter(condition)) return this } @@ -87,8 +114,8 @@ class Pipeline { return this } - fun union(pipeline: Pipeline, distinct: Boolean): Pipeline { - operations.add(Union(pipeline, distinct)) + fun unionWith(pipeline: Pipeline, distinct: Boolean): Pipeline { + operations.add(UnionWith(pipeline, distinct)) return this } @@ -107,60 +134,60 @@ class Pipeline { } fun innerJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add(Join(Join.Type.INNER, condition, alias, otherPipeline, otherAlias)) return this } fun crossJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add(Join(Join.Type.CROSS, condition, alias, otherPipeline, otherAlias)) return this } fun fullJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add(Join(Join.Type.FULL, condition, alias, otherPipeline, otherAlias)) return this } fun leftJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add(Join(Join.Type.LEFT, condition, alias, otherPipeline, otherAlias)) return this } fun rightJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add(Join(Join.Type.RIGHT, condition, alias, otherPipeline, otherAlias)) return this } fun leftSemiJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add(SemiJoin(SemiJoin.Type.LEFT_SEMI, condition, alias, otherPipeline, otherAlias)) return this @@ -177,10 +204,10 @@ class Pipeline { } fun leftAntiSemiJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add( SemiJoin( @@ -195,10 +222,10 @@ class Pipeline { } fun rightAntiSemiJoin( - condition: JoinCondition, - alias: Field, otherPipeline: Pipeline, - otherAlias: Field + condition: JoinCondition, + alias: Field = Field.of(this.name), + otherAlias: Field = Field.of(otherPipeline.name) ): Pipeline { operations.add( SemiJoin( @@ -221,7 +248,12 @@ class Pipeline { return this } - fun unnest(mode: Unnest.Mode, field: Field): Pipeline { + // Sugar + fun sort(vararg orders: Ordering): Pipeline { + return this + } + + fun unnest(field: Field, mode: Unnest.Mode = Unnest.Mode.FULL_REPLACE ): Pipeline { operations.add(Unnest(mode, field)) return this } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 7535bc789..af56b8bc9 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -2,32 +2,38 @@ package com.google.cloud.firestore.pipeline import com.google.firestore.v1.Value +interface Projectable + + sealed interface Expr { - data class Constant(val value: Value): Expr {} + data class Constant(val value: Value): Expr, Projectable {} data class FieldReference(val field: String): Expr {} data class ListOfExprs(val exprs: List): Expr {} + data class ExprAsAlias(val current: Expr, val alias: String): Expr, Projectable {} + sealed class Function(val name: String, val params: Map?) : Expr { - data class Equal(val left: Expr, val right: Expr) : Function("equal", mapOf("left" to left, "right" to right)) - data class NotEqual(val left: Expr, val right: Expr) : Function("not_equal", mapOf("left" to left, "right" to right)) - data class GreaterThan(val left: Expr, val right: Expr) : Function("greater_than", mapOf("left" to left, "right" to right)) - data class GreaterThanOrEqual(val left: Expr, val right: Expr) : Function("greater_than_equal", mapOf("left" to left, "right" to right)) - data class In(val left: Expr, val others: List) : Function("in", mapOf("left" to left, "others" to ListOfExprs(others))) // For 'in' - data class LessThan(val left: Expr, val right: Expr) : Function("less_than", mapOf("left" to left, "right" to right)) - data class LessThanOrEqual(val left: Expr, val right: Expr) : Function("less_than_equal", mapOf("left" to left, "right" to right)) - data class NotIn(val left: Expr, val others: List) : Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))) // For 'not in' - data class And(val conditions: List) : Function("and", mapOf("conditions" to ListOfExprs(conditions))) - data class Or(val conditions: List) : Function("or", mapOf("conditions" to ListOfExprs(conditions))) - data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)) - data class Exists(val current: FieldReference) : Function("exists", mapOf("current" to current)) + interface ProducingBoolean + data class Equal(val left: Expr, val right: Expr) : Function("equal", mapOf("left" to left, "right" to right)), ProducingBoolean + data class NotEqual(val left: Expr, val right: Expr) : Function("not_equal", mapOf("left" to left, "right" to right)), ProducingBoolean + data class GreaterThan(val left: Expr, val right: Expr) : Function("greater_than", mapOf("left" to left, "right" to right)), ProducingBoolean + data class GreaterThanOrEqual(val left: Expr, val right: Expr) : Function("greater_than_equal", mapOf("left" to left, "right" to right)), ProducingBoolean + data class In(val left: Expr, val others: List) : Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), ProducingBoolean // For 'in' + data class LessThan(val left: Expr, val right: Expr) : Function("less_than", mapOf("left" to left, "right" to right)), ProducingBoolean + data class LessThanOrEqual(val left: Expr, val right: Expr) : Function("less_than_equal", mapOf("left" to left, "right" to right)), ProducingBoolean + data class NotIn(val left: Expr, val others: List) : Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), ProducingBoolean // For 'not in' + data class And(val conditions: List) : Function("and", mapOf("conditions" to ListOfExprs(conditions))), ProducingBoolean + data class Or(val conditions: List) : Function("or", mapOf("conditions" to ListOfExprs(conditions))), ProducingBoolean + data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), ProducingBoolean + data class Exists(val current: FieldReference) : Function("exists", mapOf("current" to current)), ProducingBoolean data class MapGet(val map: Expr, val key: String) : Function("map_get", mapOf("map" to map, "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()))) - data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", mapOf("array" to array, "element" to element)) - data class ArrayContainsAny(val array: Expr, val elements: List) : Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))) - data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)) - data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)) + data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", mapOf("array" to array, "element" to element)), ProducingBoolean + data class ArrayContainsAny(val array: Expr, val elements: List) : Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), ProducingBoolean + data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)), ProducingBoolean + data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), ProducingBoolean data class Sum(val value: Expr) : Function("sum", mapOf("value" to value)) data class Avg(val value: Expr) : Function("avg", mapOf("value" to value)) @@ -35,7 +41,7 @@ sealed interface Expr { data class CosineDistance(val vector1: Expr, val vector2: Expr) : Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) - data class HasAncestor(val child: Expr, val ancestor: Expr): Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)) + data class HasAncestor(val child: Expr, val ancestor: Expr): Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)), ProducingBoolean data class Raw(val n: String, val ps: Map?): Function(n, ps) } @@ -68,4 +74,8 @@ sealed interface Expr { infix fun hasAncestor(ancestor: Expr): Function = Function.HasAncestor(this, ancestor) fun function(name: String, params: Map?): Function = Function.Raw(name, params) + + fun withAlias(alias: String): ExprAsAlias { + return ExprAsAlias(this, alias) + } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 8a7ef68c8..40e8d376f 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -4,7 +4,7 @@ import com.google.cloud.firestore.Pipeline interface Operation {} -data class Field internal constructor(val path: String) { +data class Field internal constructor(val path: String): Projectable { companion object { fun of(path: String): Field { return Field(path) @@ -19,10 +19,10 @@ data class CollectionGroup(val path: String): Operation data class Project(val projections: Map): Operation data class AddFields(val additions: Map): Operation data class RemoveFields(val removals: List): Operation -data class Filter(val condition: Expr): Operation +data class Filter(val condition: Expr.Function.ProducingBoolean): Operation data class Offset(val offset: Int): Operation data class Limit(val limit: Int): Operation -data class Union(val pipeline: Pipeline, val distinct: Boolean): Operation +data class UnionWith(val pipeline: Pipeline, val distinct: Boolean): Operation data class Group(val fields: Map, val accumulators: Map): Operation From c8e7854e4993dcb15e8d1e5ab4fa054d087543be Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 20 Feb 2024 10:01:17 -0500 Subject: [PATCH 05/45] Some fixups, and group bys --- .../com/google/cloud/firestore/Pipeline.kt | 15 +- .../cloud/firestore/pipeline/Expressions.kt | 235 ++++++++++++++---- .../cloud/firestore/pipeline/Operations.kt | 34 +-- .../cloud/firestore/it/ITPipelineTest.java | 99 ++++++++ .../cloud/firestore/it/PipelineKTTest.kt | 16 ++ 5 files changed, 321 insertions(+), 78 deletions(-) create mode 100644 google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java create mode 100644 google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index b4602602e..41f12d52e 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -5,7 +5,8 @@ import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup import com.google.cloud.firestore.pipeline.Database import com.google.cloud.firestore.pipeline.Expr -import com.google.cloud.firestore.pipeline.Field +import com.google.cloud.firestore.pipeline.Expr.Field +import com.google.cloud.firestore.pipeline.Fields import com.google.cloud.firestore.pipeline.Filter import com.google.cloud.firestore.pipeline.FindNearest import com.google.cloud.firestore.pipeline.Group @@ -99,7 +100,7 @@ class Pipeline { return this } - fun filter(condition: Expr.Function.ProducingBoolean): Pipeline { + fun filter(condition: Expr.Function.FilterCondition): Pipeline { operations.add(Filter(condition)) return this } @@ -124,6 +125,16 @@ class Pipeline { return this } + fun group(by: Fields, vararg accumulators: Expr.AccumulatorTarget): Pipeline { + // operations.add(Group(fields, accumulators)) + return this + } + + fun group(by: Projectable, vararg accumulators: Expr.AccumulatorTarget): Pipeline { + // operations.add(Group(fields, accumulators)) + return this + } + fun findNearest( property: Field, vector: Array, diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index af56b8bc9..85279024d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -4,78 +4,203 @@ import com.google.firestore.v1.Value interface Projectable +// Convenient class for internal usage +internal data class ListOfExprs(val conditions: List): Expr +internal data class ListOfConditions(val conditions: List): Expr, Expr.Function.FilterCondition {} + +data class Fields(val fs: List) { + companion object { + @JvmStatic + fun of(vararg f: String): Fields { + return Fields(f.map(Expr.Field.Companion::of)) + } + } +} sealed interface Expr { - data class Constant(val value: Value): Expr, Projectable {} - data class FieldReference(val field: String): Expr {} + data class Constant internal constructor(val value: Any): Expr { + companion object { + @JvmStatic + fun of(value: Any): Constant { + return Constant(value) + } + } + } + data class Field(val field: String): Expr, Projectable { + companion object { + @JvmStatic + fun of(path: String): Field { + return Field(path) + } + } + } - data class ListOfExprs(val exprs: List): Expr {} data class ExprAsAlias(val current: Expr, val alias: String): Expr, Projectable {} + data class AccumulatorTarget(val current: Function.Accumulator, val target: String): Expr, Function.Accumulator {} + sealed class Function(val name: String, val params: Map?) : Expr { - interface ProducingBoolean - data class Equal(val left: Expr, val right: Expr) : Function("equal", mapOf("left" to left, "right" to right)), ProducingBoolean - data class NotEqual(val left: Expr, val right: Expr) : Function("not_equal", mapOf("left" to left, "right" to right)), ProducingBoolean - data class GreaterThan(val left: Expr, val right: Expr) : Function("greater_than", mapOf("left" to left, "right" to right)), ProducingBoolean - data class GreaterThanOrEqual(val left: Expr, val right: Expr) : Function("greater_than_equal", mapOf("left" to left, "right" to right)), ProducingBoolean - data class In(val left: Expr, val others: List) : Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), ProducingBoolean // For 'in' - data class LessThan(val left: Expr, val right: Expr) : Function("less_than", mapOf("left" to left, "right" to right)), ProducingBoolean - data class LessThanOrEqual(val left: Expr, val right: Expr) : Function("less_than_equal", mapOf("left" to left, "right" to right)), ProducingBoolean - data class NotIn(val left: Expr, val others: List) : Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), ProducingBoolean // For 'not in' - data class And(val conditions: List) : Function("and", mapOf("conditions" to ListOfExprs(conditions))), ProducingBoolean - data class Or(val conditions: List) : Function("or", mapOf("conditions" to ListOfExprs(conditions))), ProducingBoolean - data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), ProducingBoolean - data class Exists(val current: FieldReference) : Function("exists", mapOf("current" to current)), ProducingBoolean + interface FilterCondition { + infix fun and(other: FilterCondition)= Function.And(listOf(this, other)) + fun and(vararg other: FilterCondition)= Function.And(listOf(this) + other.toList()) + + // Or and Not are restricted as a companion/static function + // infix fun or(other: Expr)= Function.Or(listOf(this, other)) + // fun or(vararg other: Expr)= Function.Or(listOf(this) + other.toList()) + // infix fun not(other: Expr)= Function.Not(this) + } + + interface Accumulator { + fun toField(target: String) = AccumulatorTarget(this, target) + } + + data class Equal internal constructor(val left: Expr, val right: Expr) : Function("equal", mapOf("left" to left, "right" to right)), FilterCondition + data class NotEqual(val left: Expr, val right: Expr) : Function("not_equal", mapOf("left" to left, "right" to right)), FilterCondition + data class GreaterThan(val left: Expr, val right: Expr) : Function("greater_than", mapOf("left" to left, "right" to right)), FilterCondition + data class GreaterThanOrEqual(val left: Expr, val right: Expr) : Function("greater_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + data class In(val left: Expr, val others: List) : Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), FilterCondition // For 'in' + data class LessThan(val left: Expr, val right: Expr) : Function("less_than", mapOf("left" to left, "right" to right)), FilterCondition + data class LessThanOrEqual(val left: Expr, val right: Expr) : Function("less_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + data class NotIn(val left: Expr, val others: List) : Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), FilterCondition // For 'not in' + data class And(val conditions: List) : Function("and", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + data class Or(val conditions: List) : Function("or", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), FilterCondition + data class Exists(val current: Field) : Function("exists", mapOf("current" to current)), FilterCondition data class MapGet(val map: Expr, val key: String) : Function("map_get", mapOf("map" to map, "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()))) - data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", mapOf("array" to array, "element" to element)), ProducingBoolean - data class ArrayContainsAny(val array: Expr, val elements: List) : Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), ProducingBoolean - data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)), ProducingBoolean - data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), ProducingBoolean + data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", mapOf("array" to array, "element" to element)), FilterCondition + data class ArrayContainsAny(val array: Expr, val elements: List) : Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), FilterCondition + data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)), FilterCondition + data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), FilterCondition - data class Sum(val value: Expr) : Function("sum", mapOf("value" to value)) - data class Avg(val value: Expr) : Function("avg", mapOf("value" to value)) - data class Count(val value: Expr) : Function("count", mapOf("value" to value)) + data class Sum(val value: Expr) : Function("sum", mapOf("value" to value)), Accumulator + data class Avg(val value: Expr) : Function("avg", mapOf("value" to value)), Accumulator + data class Count(val value: Expr) : Function("count", mapOf("value" to value)), Accumulator data class CosineDistance(val vector1: Expr, val vector2: Expr) : Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) - data class HasAncestor(val child: Expr, val ancestor: Expr): Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)), ProducingBoolean + data class HasAncestor(val child: Expr, val ancestor: Expr): Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)), FilterCondition data class Raw(val n: String, val ps: Map?): Function(n, ps) } // Infix functions returning Function subclasses - infix fun equal(other: Expr): Function = Function.Equal(this, other) - infix fun notEqual(other: Expr): Function = Function.NotEqual(this, other) - infix fun greaterThan(other: Expr): Function = Function.GreaterThan(this, other) - infix fun greaterThanOrEqual(other: Expr): Function = Function.GreaterThanOrEqual(this, other) - fun inAny(left: Expr, vararg other: Expr): Function = Function.In(left, other.toList()) - infix fun lessThan(other: Expr): Function = Function.LessThan(this, other) - infix fun lessThanOrEqual(other: Expr): Function = Function.LessThanOrEqual(this, other) - fun notInAny(left: Expr, vararg other: Expr): Function = Function.NotIn(left, other.toList()) - infix fun and(other: Expr): Function = Function.And(listOf(this, other)) - fun and(vararg other: Expr): Function = Function.And(listOf(this) + other.toList()) - infix fun or(other: Expr): Function = Function.Or(listOf(this, other)) - fun or(vararg other: Expr): Function = Function.Or(listOf(this) + other.toList()) - fun exists(): Function = Function.Exists(this as FieldReference) - - infix fun mapGet(key: String): Function = Function.MapGet(this, key) - infix fun arrayContains(element: Expr): Function = Function.ArrayContains(this, element) - fun arrayContainsAny(vararg elements: Expr): Function = Function.ArrayContainsAny(this, elements.toList()) - fun isNaN(): Function = Function.IsNaN(this) - fun isNull(): Function = Function.IsNull(this) - infix fun not(other: Expr): Function = Function.Not(this) // Likely use 'this' if 'not' is unary - fun sum(): Function = Function.Sum(this) - fun avg(): Function = Function.Avg(this) - fun count(): Function = Function.Count(this) - infix fun cosineDistance(other: Expr): Function = Function.CosineDistance(this, other) - infix fun euclideanDistance(other: Expr): Function = Function.EuclideanDistance(this, other) - infix fun hasAncestor(ancestor: Expr): Function = Function.HasAncestor(this, ancestor) - - fun function(name: String, params: Map?): Function = Function.Raw(name, params) - - fun withAlias(alias: String): ExprAsAlias { - return ExprAsAlias(this, alias) + infix fun equal(other: Expr) = Function.Equal(this, other) + infix fun notEqual(other: Expr) = Function.NotEqual(this, other) + infix fun greaterThan(other: Expr)= Function.GreaterThan(this, other) + infix fun greaterThanOrEqual(other: Expr)= Function.GreaterThanOrEqual(this, other) + fun inAny(vararg other: Expr)= Function.In(this, other.toList()) + infix fun lessThan(other: Expr)= Function.LessThan(this, other) + infix fun lessThanOrEqual(other: Expr)= Function.LessThanOrEqual(this, other) + fun notInAny(left: Expr, vararg other: Expr)= Function.NotIn(left, other.toList()) + + + fun exists()= Function.Exists(this as Field) + + infix fun mapGet(key: String)= Function.MapGet(this, key) + infix fun arrayContains(element: Expr)= Function.ArrayContains(this, element) + fun arrayContainsAny(vararg elements: Expr)= Function.ArrayContainsAny(this, elements.toList()) + fun isNaN()= Function.IsNaN(this) + fun isNull()= Function.IsNull(this) + fun sum()= Function.Sum(this) + fun avg()= Function.Avg(this) + fun count()= Function.Count(this) + infix fun cosineDistance(other: Expr)= Function.CosineDistance(this, other) + infix fun cosineDistance(other: DoubleArray)= Function.CosineDistance(this, Constant.of(other)) + infix fun euclideanDistance(other: Expr)= Function.EuclideanDistance(this, other) + infix fun euclideanDistance(other: DoubleArray)= Function.EuclideanDistance(this, Constant.of(other)) + infix fun hasAncestor(ancestor: Expr)= Function.HasAncestor(this, ancestor) + + fun asAlias(alias: String): ExprAsAlias = ExprAsAlias(this, alias) + + companion object { + @JvmStatic + fun equal(left: Expr, right: Expr) = Function.Equal(left, right) + + @JvmStatic + fun notEqual(left: Expr, right: Expr)= Function.NotEqual(left, right) + + @JvmStatic + fun greaterThan(left: Expr, right: Expr)= Function.GreaterThan(left, right) + + @JvmStatic + fun greaterThanOrEqual(left: Expr, right: Expr)= Function.GreaterThanOrEqual(left, right) + + @JvmStatic + fun inAny(left: Expr, vararg other: Expr)= Function.In(left, other.toList()) + + @JvmStatic + fun lessThan(left: Expr, right: Expr)= Function.LessThan(left, right) + + @JvmStatic + fun lessThanOrEqual(left: Expr, right: Expr)= Function.LessThanOrEqual(left, right) + + @JvmStatic + fun notInAny(left: Expr, vararg other: Expr)= Function.NotIn(left, other.toList()) + + @JvmStatic + fun and(left: Function.FilterCondition, right: Function.FilterCondition)= Function.And(listOf(left, right)) + + @JvmStatic + fun and(left: Function.FilterCondition, vararg other: Function.FilterCondition)= Function.And(listOf(left) + other.toList()) + + @JvmStatic + fun or(left: Function.FilterCondition, right: Function.FilterCondition)= Function.Or(listOf(left, right)) + + @JvmStatic + fun or(left: Function.FilterCondition, vararg other: Function.FilterCondition)= Function.Or(listOf(left) + other.toList()) + + @JvmStatic + fun exists(expr: Field)= Function.Exists(expr) + + @JvmStatic + fun mapGet(expr: Expr, key: String)= Function.MapGet(expr, key) + + @JvmStatic + fun arrayContains(expr: Expr, element: Expr)= Function.ArrayContains(expr, element) + + @JvmStatic + fun arrayContainsAny(expr: Expr, vararg elements: Expr)= Function.ArrayContainsAny(expr, elements.toList()) + + @JvmStatic + fun isNaN(expr: Expr)= Function.IsNaN(expr) + + @JvmStatic + fun isNull(expr: Expr)= Function.IsNull(expr) + + @JvmStatic + fun not(expr: Expr)= Function.Not(expr) + + @JvmStatic + fun sum(expr: Expr)= Function.Sum(expr) + + @JvmStatic + fun avg(expr: Expr)= Function.Avg(expr) + + @JvmStatic + fun count(expr: Expr)= Function.Count(expr) + + @JvmStatic + fun cosineDistance(expr: Expr, other: Expr)= Function.CosineDistance(expr, other) + + @JvmStatic + fun cosineDistance(expr: Expr, other: DoubleArray)= Function.CosineDistance(expr, Constant.of(other)) + + @JvmStatic + fun euclideanDistance(expr: Expr, other: Expr)= Function.EuclideanDistance(expr, other) + + @JvmStatic + fun euclideanDistance(expr: Expr, other: DoubleArray)= Function.EuclideanDistance(expr, Constant.of(other)) + + @JvmStatic + fun hasAncestor(expr: Expr, ancestor: Expr)= Function.HasAncestor(expr, ancestor) + + @JvmStatic + fun asAlias(expr: Expr, alias: String): ExprAsAlias = ExprAsAlias(expr, alias) + + @JvmStatic + fun function(name: String, params: Map?)= Function.Raw(name, params) } + } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 40e8d376f..985a8522f 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -4,29 +4,21 @@ import com.google.cloud.firestore.Pipeline interface Operation {} -data class Field internal constructor(val path: String): Projectable { - companion object { - fun of(path: String): Field { - return Field(path) - } - } -} - class Database(): Operation data class Collection(val path: String): Operation data class CollectionGroup(val path: String): Operation -data class Project(val projections: Map): Operation -data class AddFields(val additions: Map): Operation -data class RemoveFields(val removals: List): Operation -data class Filter(val condition: Expr.Function.ProducingBoolean): Operation +data class Project(val projections: Map): Operation +data class AddFields(val additions: Map): Operation +data class RemoveFields(val removals: List): Operation +data class Filter(val condition: Expr.Function.FilterCondition): Operation data class Offset(val offset: Int): Operation data class Limit(val limit: Int): Operation data class UnionWith(val pipeline: Pipeline, val distinct: Boolean): Operation -data class Group(val fields: Map, val accumulators: Map): Operation +data class Group(val fields: Map, val accumulators: Map): Operation -data class FindNearest(val property: Field, +data class FindNearest(val property: Expr.Field, val vector: Array, val options: FindNearestOptions): Operation { enum class Similarity { @@ -35,19 +27,19 @@ data class FindNearest(val property: Field, DOT_PRODUCT } - data class FindNearestOptions(val similarity: Similarity, val limit: Long, val output: Field) {} + data class FindNearestOptions(val similarity: Similarity, val limit: Long, val output: Expr.Field) {} } sealed interface JoinCondition { data class Expression(val expr: Expr): JoinCondition - data class Using(val fields: Set): JoinCondition + data class Using(val fields: Set): JoinCondition } data class Join(val type: Type, val condition: JoinCondition, - val alias: Field, + val alias: Expr.Field, val otherPipeline: Pipeline, - val otherAlias: Field): Operation { + val otherAlias: Expr.Field): Operation { enum class Type { CROSS, INNER, @@ -59,9 +51,9 @@ data class Join(val type: Type, data class SemiJoin(val type: Type, val condition: JoinCondition, - val alias: Field, + val alias: Expr.Field, val otherPipeline: Pipeline, - val otherAlias: Field): Operation { + val otherAlias: Expr.Field): Operation { enum class Type { LEFT_SEMI, RIGHT_SEMI, @@ -91,7 +83,7 @@ data class Sort(val orders: List, } } -data class Unnest(val mode: Mode, val field: Field): Operation { +data class Unnest(val mode: Mode, val field: Expr.Field): Operation { enum class Mode { FULL_REPLACE, MERGE_PREFER_NEST, diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java new file mode 100644 index 000000000..5b1d69006 --- /dev/null +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -0,0 +1,99 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + + +import static com.google.cloud.firestore.pipeline.Expr.avg; +import static com.google.cloud.firestore.pipeline.Expr.not; +import static com.google.cloud.firestore.pipeline.Expr.or; + +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.Pipeline; +import com.google.cloud.firestore.pipeline.Expr; +import com.google.cloud.firestore.pipeline.Expr.Constant; +import com.google.cloud.firestore.pipeline.Expr.Field; +import com.google.cloud.firestore.pipeline.Fields; +import org.junit.Before; +import org.junit.Test; + +public class ITPipelineTest { + + protected Firestore firestore; + + @Before + public void before() throws Exception { + firestore = FirestoreOptions.newBuilder().build().getService(); + } + + @Test + public void pipelineWithDb() throws Exception { + Pipeline p = Pipeline.entireDatabase(); + } + + @Test + public void projections() throws Exception { + Pipeline p = Pipeline.from("coll1") + .project( + Field.of("foo"), + Constant.of("emptyValue").asAlias("emptyField"), + Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") + ); + } + + @Test + public void addRemoveFields() throws Exception { + Pipeline p = Pipeline.from("coll1") + .addFields( + Constant.of("emptyValue").asAlias("emptyField"), + Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") + ) + .removeFields(Field.of("emptyField")); + } + + @Test + public void filters() throws Exception { + Pipeline p = Pipeline.fromCollectionGroup("coll1") + .filter(Field.of("foo").equal(Constant.of(42))) + .filter(or(Field.of("bar").lessThan(Constant.of(100)), + Constant.of("value").equal(Field.of("key")) + )) + .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + } + + @Test + public void inFilters() throws Exception { + Pipeline p = Pipeline.fromCollectionGroup("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))); + } + + @Test + public void groupBy() throws Exception { + Pipeline p = Pipeline.from("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))) + .group(Fields.of("given_name", "family_name"), + avg(Field.of("score")).toField("avg_score_1")) + // Equivalent but more fluency + .group(Fields.of("given_name", "family_name"), + Field.of("score").avg().toField("avg_score_2")) + ; + } +} diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt new file mode 100644 index 000000000..db0aac7c5 --- /dev/null +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt @@ -0,0 +1,16 @@ +package com.google.cloud.firestore.it + +import com.google.cloud.firestore.Pipeline +import com.google.cloud.firestore.pipeline.Expr +import com.google.cloud.firestore.pipeline.Expr.Companion.equal +import com.google.cloud.firestore.pipeline.Expr.Companion.or +import com.google.cloud.firestore.pipeline.Expr.Field +import com.google.cloud.firestore.pipeline.Expr.Constant + +class PipelineKTTest { + fun pipeline() { + Pipeline.from("test") + .filter(Field.of("foo").equal(Expr.Constant.of(42))) + .filter(or(Field.of("abc").lessThan(Constant.of(100)))) + } +} From c5a01a61fac8e2c094b557e1fea2bbf8807e3b27 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 20 Feb 2024 11:11:04 -0500 Subject: [PATCH 06/45] joins but nicer --- .../com/google/cloud/firestore/Pipeline.kt | 149 ++++++------------ .../cloud/firestore/pipeline/Expressions.kt | 7 +- .../cloud/firestore/pipeline/Operations.kt | 13 +- .../cloud/firestore/it/ITPipelineTest.java | 32 +++- .../cloud/firestore/it/PipelineKTTest.kt | 16 -- 5 files changed, 79 insertions(+), 138 deletions(-) delete mode 100644 google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 41f12d52e..767e5c0c6 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -11,7 +11,6 @@ import com.google.cloud.firestore.pipeline.Filter import com.google.cloud.firestore.pipeline.FindNearest import com.google.cloud.firestore.pipeline.Group import com.google.cloud.firestore.pipeline.Join -import com.google.cloud.firestore.pipeline.JoinCondition import com.google.cloud.firestore.pipeline.Limit import com.google.cloud.firestore.pipeline.Offset import com.google.cloud.firestore.pipeline.Operation @@ -20,13 +19,36 @@ import com.google.cloud.firestore.pipeline.Project import com.google.cloud.firestore.pipeline.Projectable import com.google.cloud.firestore.pipeline.RawOperation import com.google.cloud.firestore.pipeline.RemoveFields -import com.google.cloud.firestore.pipeline.SemiJoin import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest +class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { + fun accumulate(vararg accumulator: Expr.AccumulatorTarget): Pipeline { + // TODO: this.p.operations.add() + return this.p; + } +} + +class JoiningPipeline internal constructor(val left: Pipeline, val right: Pipeline, val join: Join.Type) { + fun on(condition: Expr.Function): Pipeline { + // TODO: this.p.operations.add() + return left; + } + + fun on(vararg field: Field): Pipeline { + // TODO: this.p.operations.add() + return left + } + + fun on(field: Fields): Pipeline { + // TODO: this.p.operations.add() + return left + } +} + class Pipeline { - private val operations: MutableList = mutableListOf() + internal val operations: MutableList = mutableListOf() private var name: String private constructor(db: Database) { @@ -61,6 +83,10 @@ class Pipeline { } } + fun fieldOf(name: String): Field { + return Field(name, this); + } + // Fluent API fun withName(name: String) { @@ -125,19 +151,19 @@ class Pipeline { return this } - fun group(by: Fields, vararg accumulators: Expr.AccumulatorTarget): Pipeline { + fun group(by: Fields): GroupingPipeline{ // operations.add(Group(fields, accumulators)) - return this + return GroupingPipeline(this, /*TODO*/) } - fun group(by: Projectable, vararg accumulators: Expr.AccumulatorTarget): Pipeline { + fun group(by: Projectable): GroupingPipeline{ // operations.add(Group(fields, accumulators)) - return this + return GroupingPipeline(this, /*TODO*/) } fun findNearest( property: Field, - vector: Array, + vector: DoubleArray, options: FindNearest.FindNearestOptions ): Pipeline { operations.add(FindNearest(property, vector, options)) @@ -145,110 +171,23 @@ class Pipeline { } fun innerJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add(Join(Join.Type.INNER, condition, alias, otherPipeline, otherAlias)) - return this - } - - fun crossJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add(Join(Join.Type.CROSS, condition, alias, otherPipeline, otherAlias)) - return this - } + otherPipeline: Pipeline + ) = JoiningPipeline(this, otherPipeline, Join.Type.INNER) + fun crossJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.CROSS) - fun fullJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add(Join(Join.Type.FULL, condition, alias, otherPipeline, otherAlias)) - return this - } + fun fullJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.FULL) - fun leftJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add(Join(Join.Type.LEFT, condition, alias, otherPipeline, otherAlias)) - return this - } + fun leftJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.LEFT) - fun rightJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add(Join(Join.Type.RIGHT, condition, alias, otherPipeline, otherAlias)) - return this - } + fun rightJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.RIGHT) - fun leftSemiJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add(SemiJoin(SemiJoin.Type.LEFT_SEMI, condition, alias, otherPipeline, otherAlias)) - return this - } + fun leftSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.LEFT_SEMI) - fun rightSemiJoin( - condition: JoinCondition, - alias: Field, - otherPipeline: Pipeline, - otherAlias: Field - ): Pipeline { - operations.add(SemiJoin(SemiJoin.Type.RIGHT_SEMI, condition, alias, otherPipeline, otherAlias)) - return this - } + fun rightSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_SEMI) - fun leftAntiSemiJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add( - SemiJoin( - SemiJoin.Type.LEFT_ANTI_SEMI, - condition, - alias, - otherPipeline, - otherAlias - ) - ) - return this - } + fun leftAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.LEFT_ANTI_SEMI) - fun rightAntiSemiJoin( - otherPipeline: Pipeline, - condition: JoinCondition, - alias: Field = Field.of(this.name), - otherAlias: Field = Field.of(otherPipeline.name) - ): Pipeline { - operations.add( - SemiJoin( - SemiJoin.Type.RIGHT_ANTI_SEMI, - condition, - alias, - otherPipeline, - otherAlias - ) - ) - return this - } + fun rightAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_ANTI_SEMI) fun sort( orders: List, diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 85279024d..f99e0a9d0 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -1,5 +1,6 @@ package com.google.cloud.firestore.pipeline +import com.google.cloud.firestore.Pipeline import com.google.firestore.v1.Value interface Projectable @@ -26,13 +27,17 @@ sealed interface Expr { } } } - data class Field(val field: String): Expr, Projectable { + data class Field(val field: String, var pipeline: Pipeline? = null): Expr, Projectable { companion object { @JvmStatic fun of(path: String): Field { return Field(path) } } + + fun withPrefix(prefix: String): Field { + return this + } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 985a8522f..698a5c20b 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -19,7 +19,7 @@ data class UnionWith(val pipeline: Pipeline, val distinct: Boolean): Operation data class Group(val fields: Map, val accumulators: Map): Operation data class FindNearest(val property: Expr.Field, - val vector: Array, + val vector: DoubleArray, val options: FindNearestOptions): Operation { enum class Similarity { EUCLIDEAN, @@ -45,16 +45,7 @@ data class Join(val type: Type, INNER, FULL, LEFT, - RIGHT - } -} - -data class SemiJoin(val type: Type, - val condition: JoinCondition, - val alias: Expr.Field, - val otherPipeline: Pipeline, - val otherAlias: Expr.Field): Operation { - enum class Type { + RIGHT, LEFT_SEMI, RIGHT_SEMI, LEFT_ANTI_SEMI, diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 5b1d69006..91a3c23d7 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -17,6 +17,7 @@ package com.google.cloud.firestore.it; +import static com.google.cloud.firestore.pipeline.Expr.and; import static com.google.cloud.firestore.pipeline.Expr.avg; import static com.google.cloud.firestore.pipeline.Expr.not; import static com.google.cloud.firestore.pipeline.Expr.or; @@ -28,6 +29,8 @@ import com.google.cloud.firestore.pipeline.Expr.Constant; import com.google.cloud.firestore.pipeline.Expr.Field; import com.google.cloud.firestore.pipeline.Fields; +import com.google.cloud.firestore.pipeline.FindNearest.FindNearestOptions; +import com.google.cloud.firestore.pipeline.FindNearest.Similarity; import org.junit.Before; import org.junit.Test; @@ -89,11 +92,30 @@ public void groupBy() throws Exception { .filter(Field.of("foo").inAny( Constant.of(42), Field.of("bar"))) - .group(Fields.of("given_name", "family_name"), - avg(Field.of("score")).toField("avg_score_1")) + .group(Fields.of("given_name", "family_name")) + .accumulate(avg(Field.of("score")).toField("avg_score_1")) // Equivalent but more fluency - .group(Fields.of("given_name", "family_name"), - Field.of("score").avg().toField("avg_score_2")) - ; + .group(Fields.of("given_name", "family_name")) + .accumulate(Field.of("score").avg().toField("avg_score_2")); + } + + @Test + public void joins() throws Exception { + Pipeline p = Pipeline.from("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))); + Pipeline pipe = Pipeline.from("users") + .findNearest(Field.of("embedding"), new double[]{1.0,2.0}, + new FindNearestOptions(Similarity.COSINE, 1000, Field.of("distance"))) + .innerJoin(p) + .on(and( + Field.of("foo").equal(p.fieldOf("bar")), + p.fieldOf("requirement").greaterThan(Field.of("distance")))); + + Pipeline another = Pipeline.from("users") + .innerJoin(p) + .on(Fields.of("foo", "bar")) + .project(Field.of("*").withPrefix("left"), p.fieldOf("*").withPrefix("right")); } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt deleted file mode 100644 index db0aac7c5..000000000 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/PipelineKTTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.google.cloud.firestore.it - -import com.google.cloud.firestore.Pipeline -import com.google.cloud.firestore.pipeline.Expr -import com.google.cloud.firestore.pipeline.Expr.Companion.equal -import com.google.cloud.firestore.pipeline.Expr.Companion.or -import com.google.cloud.firestore.pipeline.Expr.Field -import com.google.cloud.firestore.pipeline.Expr.Constant - -class PipelineKTTest { - fun pipeline() { - Pipeline.from("test") - .filter(Field.of("foo").equal(Expr.Constant.of(42))) - .filter(or(Field.of("abc").lessThan(Constant.of(100)))) - } -} From 191eb44121c97d16275ce1f1d1a68506467a0ced Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 22 Feb 2024 12:03:42 -0500 Subject: [PATCH 07/45] address feedback --- .../com/google/cloud/firestore/Pipeline.kt | 78 ++++-- .../cloud/firestore/pipeline/Expressions.kt | 227 +++++++++++------- .../cloud/firestore/pipeline/Operations.kt | 113 ++++++--- .../cloud/firestore/it/ITPipelineTest.java | 49 +++- 4 files changed, 313 insertions(+), 154 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 767e5c0c6..2fde85a0a 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -5,10 +5,12 @@ import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup import com.google.cloud.firestore.pipeline.Database import com.google.cloud.firestore.pipeline.Expr +import com.google.cloud.firestore.pipeline.Expr.AllFields import com.google.cloud.firestore.pipeline.Expr.Field import com.google.cloud.firestore.pipeline.Fields import com.google.cloud.firestore.pipeline.Filter import com.google.cloud.firestore.pipeline.FindNearest +import com.google.cloud.firestore.pipeline.GenericOperation import com.google.cloud.firestore.pipeline.Group import com.google.cloud.firestore.pipeline.Join import com.google.cloud.firestore.pipeline.Limit @@ -17,23 +19,26 @@ import com.google.cloud.firestore.pipeline.Operation import com.google.cloud.firestore.pipeline.Ordering import com.google.cloud.firestore.pipeline.Project import com.google.cloud.firestore.pipeline.Projectable -import com.google.cloud.firestore.pipeline.RawOperation import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { - fun accumulate(vararg accumulator: Expr.AccumulatorTarget): Pipeline { + fun aggregate(vararg aggregator: Expr.AggregateorTarget): Pipeline { // TODO: this.p.operations.add() - return this.p; + return this.p } } -class JoiningPipeline internal constructor(val left: Pipeline, val right: Pipeline, val join: Join.Type) { +class JoiningPipeline internal constructor( + val left: Pipeline, + val right: Pipeline, + val join: Join.Type +) { fun on(condition: Expr.Function): Pipeline { // TODO: this.p.operations.add() - return left; + return left } fun on(vararg field: Field): Pipeline { @@ -68,7 +73,17 @@ class Pipeline { companion object { @JvmStatic - fun from(collectionName: String): Pipeline { + fun from(source: CollectionReference): Pipeline { + return Pipeline(Collection(source.path)) + } + + @JvmStatic + fun from(source: com.google.cloud.firestore.CollectionGroup): Pipeline { + return Pipeline(CollectionGroup(source.options.collectionId)) + } + + @JvmStatic + fun fromCollection(collectionName: String): Pipeline { return Pipeline(Collection(collectionName)) } @@ -78,13 +93,17 @@ class Pipeline { } @JvmStatic - fun entireDatabase(): Pipeline { + fun fromDatabase(): Pipeline { return Pipeline(Database()) } } fun fieldOf(name: String): Field { - return Field(name, this); + return Field(name, this) + } + + fun fieldOfAll(): AllFields { + return AllFields(this) } // Fluent API @@ -151,14 +170,20 @@ class Pipeline { return this } - fun group(by: Fields): GroupingPipeline{ + fun group(by: Fields): GroupingPipeline { // operations.add(Group(fields, accumulators)) - return GroupingPipeline(this, /*TODO*/) + return GroupingPipeline(this /*TODO*/) } - fun group(by: Projectable): GroupingPipeline{ + fun group(by: Projectable): GroupingPipeline { // operations.add(Group(fields, accumulators)) - return GroupingPipeline(this, /*TODO*/) + return GroupingPipeline(this /*TODO*/) + } + + fun aggregate(vararg aggregator: Expr.AggregateorTarget): Pipeline { + // operations.add(Group()) + // operations.add(aggregator) + return this } fun findNearest( @@ -173,21 +198,30 @@ class Pipeline { fun innerJoin( otherPipeline: Pipeline ) = JoiningPipeline(this, otherPipeline, Join.Type.INNER) - fun crossJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.CROSS) - fun fullJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.FULL) + fun crossJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.CROSS) + + fun fullJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.FULL) - fun leftJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.LEFT) + fun leftJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.LEFT) - fun rightJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.RIGHT) + fun rightJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.RIGHT) - fun leftSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.LEFT_SEMI) + fun leftSemiJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.LEFT_SEMI) - fun rightSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_SEMI) + fun rightSemiJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_SEMI) - fun leftAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.LEFT_ANTI_SEMI) + fun leftAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.LEFT_ANTI_SEMI) - fun rightAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_ANTI_SEMI) + fun rightAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = + JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_ANTI_SEMI) fun sort( orders: List, @@ -203,13 +237,13 @@ class Pipeline { return this } - fun unnest(field: Field, mode: Unnest.Mode = Unnest.Mode.FULL_REPLACE ): Pipeline { + fun unnest(field: Field, mode: Unnest.Mode = Unnest.Mode.FULL_REPLACE): Pipeline { operations.add(Unnest(mode, field)) return this } fun rawOperation(name: String, params: Map? = null): Pipeline { - operations.add(RawOperation(name, params)) + operations.add(GenericOperation(name, params)) return this } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index f99e0a9d0..8fde3349f 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -6,8 +6,9 @@ import com.google.firestore.v1.Value interface Projectable // Convenient class for internal usage -internal data class ListOfExprs(val conditions: List): Expr -internal data class ListOfConditions(val conditions: List): Expr, Expr.Function.FilterCondition {} +internal data class ListOfExprs(val conditions: List) : Expr +internal data class ListOfConditions(val conditions: List) : Expr, + Expr.Function.FilterCondition data class Fields(val fs: List) { companion object { @@ -19,7 +20,7 @@ data class Fields(val fs: List) { } sealed interface Expr { - data class Constant internal constructor(val value: Any): Expr { + data class Constant internal constructor(val value: Any) : Expr { companion object { @JvmStatic fun of(value: Any): Constant { @@ -27,28 +28,38 @@ sealed interface Expr { } } } - data class Field(val field: String, var pipeline: Pipeline? = null): Expr, Projectable { + + data class Field(val field: String, var pipeline: Pipeline? = null) : Expr, Projectable { companion object { @JvmStatic fun of(path: String): Field { return Field(path) } + + @JvmStatic + fun ofAll(): AllFields { + return AllFields() + } } + } + + data class AllFields(var pipeline: Pipeline? = null) : Expr, Projectable { - fun withPrefix(prefix: String): Field { + fun withPrefix(prefix: String): AllFields { return this } } - data class ExprAsAlias(val current: Expr, val alias: String): Expr, Projectable {} + data class ExprAsAlias(val current: Expr, val alias: String) : Expr, Projectable - data class AccumulatorTarget(val current: Function.Accumulator, val target: String): Expr, Function.Accumulator {} + data class AggregateorTarget(val current: Function.Accumulator, val target: String) : Expr, + Function.Accumulator sealed class Function(val name: String, val params: Map?) : Expr { interface FilterCondition { - infix fun and(other: FilterCondition)= Function.And(listOf(this, other)) - fun and(vararg other: FilterCondition)= Function.And(listOf(this) + other.toList()) + infix fun and(other: FilterCondition) = And(listOf(this, other)) + fun and(vararg other: FilterCondition) = And(listOf(this) + other.toList()) // Or and Not are restricted as a companion/static function // infix fun or(other: Expr)= Function.Or(listOf(this, other)) @@ -57,65 +68,110 @@ sealed interface Expr { } interface Accumulator { - fun toField(target: String) = AccumulatorTarget(this, target) + fun toField(target: String) = AggregateorTarget(this, target) } - data class Equal internal constructor(val left: Expr, val right: Expr) : Function("equal", mapOf("left" to left, "right" to right)), FilterCondition - data class NotEqual(val left: Expr, val right: Expr) : Function("not_equal", mapOf("left" to left, "right" to right)), FilterCondition - data class GreaterThan(val left: Expr, val right: Expr) : Function("greater_than", mapOf("left" to left, "right" to right)), FilterCondition - data class GreaterThanOrEqual(val left: Expr, val right: Expr) : Function("greater_than_equal", mapOf("left" to left, "right" to right)), FilterCondition - data class In(val left: Expr, val others: List) : Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), FilterCondition // For 'in' - data class LessThan(val left: Expr, val right: Expr) : Function("less_than", mapOf("left" to left, "right" to right)), FilterCondition - data class LessThanOrEqual(val left: Expr, val right: Expr) : Function("less_than_equal", mapOf("left" to left, "right" to right)), FilterCondition - data class NotIn(val left: Expr, val others: List) : Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), FilterCondition // For 'not in' - data class And(val conditions: List) : Function("and", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition - data class Or(val conditions: List) : Function("or", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition - data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), FilterCondition - data class Exists(val current: Field) : Function("exists", mapOf("current" to current)), FilterCondition - - data class MapGet(val map: Expr, val key: String) : Function("map_get", mapOf("map" to map, "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()))) - - data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", mapOf("array" to array, "element" to element)), FilterCondition - data class ArrayContainsAny(val array: Expr, val elements: List) : Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), FilterCondition + data class Equal internal constructor(val left: Expr, val right: Expr) : + Function("equal", mapOf("left" to left, "right" to right)), FilterCondition + + data class NotEqual(val left: Expr, val right: Expr) : + Function("not_equal", mapOf("left" to left, "right" to right)), FilterCondition + + data class GreaterThan(val left: Expr, val right: Expr) : + Function("greater_than", mapOf("left" to left, "right" to right)), FilterCondition + + data class GreaterThanOrEqual(val left: Expr, val right: Expr) : + Function("greater_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + + data class In(val left: Expr, val others: List) : + Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), + FilterCondition // For 'in' + + data class LessThan(val left: Expr, val right: Expr) : + Function("less_than", mapOf("left" to left, "right" to right)), FilterCondition + + data class LessThanOrEqual(val left: Expr, val right: Expr) : + Function("less_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + + data class NotIn(val left: Expr, val others: List) : + Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), + FilterCondition // For 'not in' + + data class And(val conditions: List) : + Function("and", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + + data class Or(val conditions: List) : + Function("or", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + + data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), + FilterCondition + + data class Exists(val current: Field) : Function("exists", mapOf("current" to current)), + FilterCondition + + data class MapGet(val map: Expr, val key: String) : Function( + "map_get", + mapOf( + "map" to map, + "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()) + ) + ) + + data class ArrayContains(val array: Expr, val element: Expr) : + Function("array_contains", mapOf("array" to array, "element" to element)), FilterCondition + + data class ArrayContainsAny(val array: Expr, val elements: List) : + Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), + FilterCondition + data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)), FilterCondition - data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), FilterCondition + data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), + FilterCondition data class Sum(val value: Expr) : Function("sum", mapOf("value" to value)), Accumulator data class Avg(val value: Expr) : Function("avg", mapOf("value" to value)), Accumulator data class Count(val value: Expr) : Function("count", mapOf("value" to value)), Accumulator - data class CosineDistance(val vector1: Expr, val vector2: Expr) : Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) - data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) - data class HasAncestor(val child: Expr, val ancestor: Expr): Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)), FilterCondition - data class Raw(val n: String, val ps: Map?): Function(n, ps) + data class CosineDistance(val vector1: Expr, val vector2: Expr) : + Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + + data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : + Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + + data class HasAncestor(val child: Expr, val ancestor: Expr) : + Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)), FilterCondition + + data class Generic(val n: String, val ps: Map?) : Function(n, ps) } // Infix functions returning Function subclasses infix fun equal(other: Expr) = Function.Equal(this, other) infix fun notEqual(other: Expr) = Function.NotEqual(this, other) - infix fun greaterThan(other: Expr)= Function.GreaterThan(this, other) - infix fun greaterThanOrEqual(other: Expr)= Function.GreaterThanOrEqual(this, other) - fun inAny(vararg other: Expr)= Function.In(this, other.toList()) - infix fun lessThan(other: Expr)= Function.LessThan(this, other) - infix fun lessThanOrEqual(other: Expr)= Function.LessThanOrEqual(this, other) - fun notInAny(left: Expr, vararg other: Expr)= Function.NotIn(left, other.toList()) - - - fun exists()= Function.Exists(this as Field) - - infix fun mapGet(key: String)= Function.MapGet(this, key) - infix fun arrayContains(element: Expr)= Function.ArrayContains(this, element) - fun arrayContainsAny(vararg elements: Expr)= Function.ArrayContainsAny(this, elements.toList()) - fun isNaN()= Function.IsNaN(this) - fun isNull()= Function.IsNull(this) - fun sum()= Function.Sum(this) - fun avg()= Function.Avg(this) - fun count()= Function.Count(this) - infix fun cosineDistance(other: Expr)= Function.CosineDistance(this, other) - infix fun cosineDistance(other: DoubleArray)= Function.CosineDistance(this, Constant.of(other)) - infix fun euclideanDistance(other: Expr)= Function.EuclideanDistance(this, other) - infix fun euclideanDistance(other: DoubleArray)= Function.EuclideanDistance(this, Constant.of(other)) - infix fun hasAncestor(ancestor: Expr)= Function.HasAncestor(this, ancestor) + infix fun greaterThan(other: Expr) = Function.GreaterThan(this, other) + infix fun greaterThanOrEqual(other: Expr) = Function.GreaterThanOrEqual(this, other) + fun inAny(vararg other: Expr) = Function.In(this, other.toList()) + infix fun lessThan(other: Expr) = Function.LessThan(this, other) + infix fun lessThanOrEqual(other: Expr) = Function.LessThanOrEqual(this, other) + fun notInAny(left: Expr, vararg other: Expr) = Function.NotIn(left, other.toList()) + + + fun exists() = Function.Exists(this as Field) + + infix fun mapGet(key: String) = Function.MapGet(this, key) + infix fun arrayContains(element: Expr) = Function.ArrayContains(this, element) + fun arrayContainsAny(vararg elements: Expr) = Function.ArrayContainsAny(this, elements.toList()) + fun isNaN() = Function.IsNaN(this) + fun isNull() = Function.IsNull(this) + fun sum() = Function.Sum(this) + fun avg() = Function.Avg(this) + fun count() = Function.Count(this) + infix fun cosineDistance(other: Expr) = Function.CosineDistance(this, other) + infix fun cosineDistance(other: DoubleArray) = Function.CosineDistance(this, Constant.of(other)) + infix fun euclideanDistance(other: Expr) = Function.EuclideanDistance(this, other) + infix fun euclideanDistance(other: DoubleArray) = + Function.EuclideanDistance(this, Constant.of(other)) + + infix fun hasAncestor(ancestor: Expr) = Function.HasAncestor(this, ancestor) fun asAlias(alias: String): ExprAsAlias = ExprAsAlias(this, alias) @@ -124,88 +180,95 @@ sealed interface Expr { fun equal(left: Expr, right: Expr) = Function.Equal(left, right) @JvmStatic - fun notEqual(left: Expr, right: Expr)= Function.NotEqual(left, right) + fun notEqual(left: Expr, right: Expr) = Function.NotEqual(left, right) @JvmStatic - fun greaterThan(left: Expr, right: Expr)= Function.GreaterThan(left, right) + fun greaterThan(left: Expr, right: Expr) = Function.GreaterThan(left, right) @JvmStatic - fun greaterThanOrEqual(left: Expr, right: Expr)= Function.GreaterThanOrEqual(left, right) + fun greaterThanOrEqual(left: Expr, right: Expr) = Function.GreaterThanOrEqual(left, right) @JvmStatic - fun inAny(left: Expr, vararg other: Expr)= Function.In(left, other.toList()) + fun inAny(left: Expr, vararg other: Expr) = Function.In(left, other.toList()) @JvmStatic - fun lessThan(left: Expr, right: Expr)= Function.LessThan(left, right) + fun lessThan(left: Expr, right: Expr) = Function.LessThan(left, right) @JvmStatic - fun lessThanOrEqual(left: Expr, right: Expr)= Function.LessThanOrEqual(left, right) + fun lessThanOrEqual(left: Expr, right: Expr) = Function.LessThanOrEqual(left, right) @JvmStatic - fun notInAny(left: Expr, vararg other: Expr)= Function.NotIn(left, other.toList()) + fun notInAny(left: Expr, vararg other: Expr) = Function.NotIn(left, other.toList()) @JvmStatic - fun and(left: Function.FilterCondition, right: Function.FilterCondition)= Function.And(listOf(left, right)) + fun and(left: Function.FilterCondition, right: Function.FilterCondition) = + Function.And(listOf(left, right)) @JvmStatic - fun and(left: Function.FilterCondition, vararg other: Function.FilterCondition)= Function.And(listOf(left) + other.toList()) + fun and(left: Function.FilterCondition, vararg other: Function.FilterCondition) = + Function.And(listOf(left) + other.toList()) @JvmStatic - fun or(left: Function.FilterCondition, right: Function.FilterCondition)= Function.Or(listOf(left, right)) + fun or(left: Function.FilterCondition, right: Function.FilterCondition) = + Function.Or(listOf(left, right)) @JvmStatic - fun or(left: Function.FilterCondition, vararg other: Function.FilterCondition)= Function.Or(listOf(left) + other.toList()) + fun or(left: Function.FilterCondition, vararg other: Function.FilterCondition) = + Function.Or(listOf(left) + other.toList()) @JvmStatic - fun exists(expr: Field)= Function.Exists(expr) + fun exists(expr: Field) = Function.Exists(expr) @JvmStatic - fun mapGet(expr: Expr, key: String)= Function.MapGet(expr, key) + fun mapGet(expr: Expr, key: String) = Function.MapGet(expr, key) @JvmStatic - fun arrayContains(expr: Expr, element: Expr)= Function.ArrayContains(expr, element) + fun arrayContains(expr: Expr, element: Expr) = Function.ArrayContains(expr, element) @JvmStatic - fun arrayContainsAny(expr: Expr, vararg elements: Expr)= Function.ArrayContainsAny(expr, elements.toList()) + fun arrayContainsAny(expr: Expr, vararg elements: Expr) = + Function.ArrayContainsAny(expr, elements.toList()) @JvmStatic - fun isNaN(expr: Expr)= Function.IsNaN(expr) + fun isNaN(expr: Expr) = Function.IsNaN(expr) @JvmStatic - fun isNull(expr: Expr)= Function.IsNull(expr) + fun isNull(expr: Expr) = Function.IsNull(expr) @JvmStatic - fun not(expr: Expr)= Function.Not(expr) + fun not(expr: Expr) = Function.Not(expr) @JvmStatic - fun sum(expr: Expr)= Function.Sum(expr) + fun sum(expr: Expr) = Function.Sum(expr) @JvmStatic - fun avg(expr: Expr)= Function.Avg(expr) + fun avg(expr: Expr) = Function.Avg(expr) @JvmStatic - fun count(expr: Expr)= Function.Count(expr) + fun count(expr: Expr) = Function.Count(expr) @JvmStatic - fun cosineDistance(expr: Expr, other: Expr)= Function.CosineDistance(expr, other) + fun cosineDistance(expr: Expr, other: Expr) = Function.CosineDistance(expr, other) @JvmStatic - fun cosineDistance(expr: Expr, other: DoubleArray)= Function.CosineDistance(expr, Constant.of(other)) + fun cosineDistance(expr: Expr, other: DoubleArray) = + Function.CosineDistance(expr, Constant.of(other)) @JvmStatic - fun euclideanDistance(expr: Expr, other: Expr)= Function.EuclideanDistance(expr, other) + fun euclideanDistance(expr: Expr, other: Expr) = Function.EuclideanDistance(expr, other) @JvmStatic - fun euclideanDistance(expr: Expr, other: DoubleArray)= Function.EuclideanDistance(expr, Constant.of(other)) + fun euclideanDistance(expr: Expr, other: DoubleArray) = + Function.EuclideanDistance(expr, Constant.of(other)) @JvmStatic - fun hasAncestor(expr: Expr, ancestor: Expr)= Function.HasAncestor(expr, ancestor) + fun hasAncestor(expr: Expr, ancestor: Expr) = Function.HasAncestor(expr, ancestor) @JvmStatic fun asAlias(expr: Expr, alias: String): ExprAsAlias = ExprAsAlias(expr, alias) @JvmStatic - fun function(name: String, params: Map?)= Function.Raw(name, params) + fun function(name: String, params: Map?) = Function.Generic(name, params) } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 698a5c20b..663c39314 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -2,44 +2,69 @@ package com.google.cloud.firestore.pipeline import com.google.cloud.firestore.Pipeline -interface Operation {} - -class Database(): Operation -data class Collection(val path: String): Operation -data class CollectionGroup(val path: String): Operation - -data class Project(val projections: Map): Operation -data class AddFields(val additions: Map): Operation -data class RemoveFields(val removals: List): Operation -data class Filter(val condition: Expr.Function.FilterCondition): Operation -data class Offset(val offset: Int): Operation -data class Limit(val limit: Int): Operation -data class UnionWith(val pipeline: Pipeline, val distinct: Boolean): Operation - -data class Group(val fields: Map, val accumulators: Map): Operation - -data class FindNearest(val property: Expr.Field, - val vector: DoubleArray, - val options: FindNearestOptions): Operation { - enum class Similarity { - EUCLIDEAN, - COSINE, - DOT_PRODUCT +interface Operation + +class Database : Operation +data class Collection(val path: String) : Operation +data class CollectionGroup(val path: String) : Operation + +data class Project(val projections: Map) : Operation +data class AddFields(val additions: Map) : Operation +data class RemoveFields(val removals: List) : Operation +data class Filter(val condition: Expr.Function.FilterCondition) : Operation +data class Offset(val offset: Int) : Operation +data class Limit(val limit: Int) : Operation +data class UnionWith(val pipeline: Pipeline, val distinct: Boolean) : Operation + +data class Group(val fields: Map, val accumulators: Map) : + Operation + +data class FindNearest( + val property: Expr.Field, + val vector: DoubleArray, + val options: FindNearestOptions +) : Operation { + sealed interface Similarity { + data object Euclidean : Similarity + data object Cosine : Similarity + data object DotProduct : Similarity + + class GenericSimilarity(val name: String) : Similarity + + companion object { + @JvmStatic + fun euclidean() = Euclidean + + @JvmStatic + fun cosine() = Cosine + + @JvmStatic + fun dotProduct() = DotProduct + + @JvmStatic + fun generic(name: String) = GenericSimilarity(name) + } } - data class FindNearestOptions(val similarity: Similarity, val limit: Long, val output: Expr.Field) {} + data class FindNearestOptions( + val similarity: Similarity, + val limit: Long, + val output: Expr.Field + ) } sealed interface JoinCondition { - data class Expression(val expr: Expr): JoinCondition - data class Using(val fields: Set): JoinCondition + data class Expression(val expr: Expr) : JoinCondition + data class Using(val fields: Set) : JoinCondition } -data class Join(val type: Type, - val condition: JoinCondition, - val alias: Expr.Field, - val otherPipeline: Pipeline, - val otherAlias: Expr.Field): Operation { +data class Join( + val type: Type, + val condition: JoinCondition, + val alias: Expr.Field, + val otherPipeline: Pipeline, + val otherAlias: Expr.Field +) : Operation { enum class Type { CROSS, INNER, @@ -58,12 +83,26 @@ data class Ordering(val expr: Expr, val dir: Direction = Direction.ASC) { ASC, DESC } + + companion object { + @JvmStatic + fun of(expr: Expr, dir: Direction = Direction.ASC): Ordering { + return Ordering(expr, dir) + } + + @JvmStatic + fun of(expr: Expr): Ordering { + return Ordering(expr, Direction.ASC) + } + } } -data class Sort(val orders: List, - val density: Density = Density.UNSPECIFIED, - val truncation: Truncation = Truncation.UNSPECIFIED): Operation { - enum class Density{ +data class Sort( + val orders: List, + val density: Density = Density.UNSPECIFIED, + val truncation: Truncation = Truncation.UNSPECIFIED +) : Operation { + enum class Density { UNSPECIFIED, REQUIRED } @@ -74,7 +113,7 @@ data class Sort(val orders: List, } } -data class Unnest(val mode: Mode, val field: Expr.Field): Operation { +data class Unnest(val mode: Mode, val field: Expr.Field) : Operation { enum class Mode { FULL_REPLACE, MERGE_PREFER_NEST, @@ -82,5 +121,5 @@ data class Unnest(val mode: Mode, val field: Expr.Field): Operation { } } -data class RawOperation(val name: String, val params: Map?): Operation +data class GenericOperation(val name: String, val params: Map?) : Operation diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 91a3c23d7..61e6819ec 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -19,18 +19,20 @@ import static com.google.cloud.firestore.pipeline.Expr.and; import static com.google.cloud.firestore.pipeline.Expr.avg; +import static com.google.cloud.firestore.pipeline.Expr.cosineDistance; import static com.google.cloud.firestore.pipeline.Expr.not; import static com.google.cloud.firestore.pipeline.Expr.or; import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; import com.google.cloud.firestore.Pipeline; -import com.google.cloud.firestore.pipeline.Expr; import com.google.cloud.firestore.pipeline.Expr.Constant; import com.google.cloud.firestore.pipeline.Expr.Field; import com.google.cloud.firestore.pipeline.Fields; import com.google.cloud.firestore.pipeline.FindNearest.FindNearestOptions; import com.google.cloud.firestore.pipeline.FindNearest.Similarity; +import com.google.cloud.firestore.pipeline.Ordering; +import com.google.cloud.firestore.pipeline.Ordering.Direction; import org.junit.Before; import org.junit.Test; @@ -45,12 +47,12 @@ public void before() throws Exception { @Test public void pipelineWithDb() throws Exception { - Pipeline p = Pipeline.entireDatabase(); + Pipeline p = Pipeline.fromDatabase(); } @Test public void projections() throws Exception { - Pipeline p = Pipeline.from("coll1") + Pipeline p = Pipeline.fromCollection("coll1") .project( Field.of("foo"), Constant.of("emptyValue").asAlias("emptyField"), @@ -60,7 +62,7 @@ public void projections() throws Exception { @Test public void addRemoveFields() throws Exception { - Pipeline p = Pipeline.from("coll1") + Pipeline p = Pipeline.fromCollection("coll1") .addFields( Constant.of("emptyValue").asAlias("emptyField"), Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") @@ -88,34 +90,55 @@ public void inFilters() throws Exception { @Test public void groupBy() throws Exception { - Pipeline p = Pipeline.from("coll1") + Pipeline p = Pipeline.fromCollection("coll1") .filter(Field.of("foo").inAny( Constant.of(42), Field.of("bar"))) .group(Fields.of("given_name", "family_name")) - .accumulate(avg(Field.of("score")).toField("avg_score_1")) + .aggregate(avg(Field.of("score")).toField("avg_score_1")) // Equivalent but more fluency .group(Fields.of("given_name", "family_name")) - .accumulate(Field.of("score").avg().toField("avg_score_2")); + .aggregate(Field.of("score").avg().toField("avg_score_2")); + } + + @Test + public void aggregateWithoutGrouping() throws Exception { + Pipeline p = Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))) + .aggregate(avg(Field.of("score")).toField("avg_score_1")); } @Test public void joins() throws Exception { - Pipeline p = Pipeline.from("coll1") + Pipeline p = Pipeline.fromCollection("coll1") .filter(Field.of("foo").inAny( Constant.of(42), Field.of("bar"))); - Pipeline pipe = Pipeline.from("users") - .findNearest(Field.of("embedding"), new double[]{1.0,2.0}, - new FindNearestOptions(Similarity.COSINE, 1000, Field.of("distance"))) + Pipeline pipe = Pipeline.fromCollection("users") + .findNearest(Field.of("embedding"), new double[]{1.0, 2.0}, + new FindNearestOptions(Similarity.euclidean(), 1000, Field.of("distance"))) .innerJoin(p) .on(and( Field.of("foo").equal(p.fieldOf("bar")), p.fieldOf("requirement").greaterThan(Field.of("distance")))); - Pipeline another = Pipeline.from("users") + Pipeline another = Pipeline.fromCollection("users") .innerJoin(p) .on(Fields.of("foo", "bar")) - .project(Field.of("*").withPrefix("left"), p.fieldOf("*").withPrefix("right")); + .project(Field.ofAll().withPrefix("left"), p.fieldOfAll().withPrefix("right")); + } + + @Test + public void sorts() throws Exception { + Pipeline p = Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))) + .sort(Ordering.of(Field.of("rank")), + Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESC)) + .limit(100); } } From 27f274896ee534998887bfcc274266a2322d5bec Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Fri, 23 Feb 2024 11:27:54 -0500 Subject: [PATCH 08/45] pagination and others --- .../com/google/cloud/firestore/Firestore.java | 2 + .../google/cloud/firestore/FirestoreImpl.java | 5 +++ .../com/google/cloud/firestore/Pipeline.kt | 43 ++++++++++++++++++- .../cloud/firestore/pipeline/Expressions.kt | 6 +-- .../cloud/firestore/it/ITPipelineTest.java | 17 ++++++++ 5 files changed, 68 insertions(+), 5 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java index 5bbb1164a..48e977892 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java @@ -287,6 +287,8 @@ void getAll( @Nonnull FirestoreBundle.Builder bundleBuilder(@Nonnull String bundleId); + ApiFuture execute(Pipeline pipeline); + /** * Closes the gRPC channels associated with this instance and frees up their resources. This * method blocks until all channels are closed. Once this method is called, this Firestore client diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java index 1fab69e97..bc4f45bf2 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -408,6 +408,11 @@ public FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId) { return new FirestoreBundle.Builder(id); } + @Override + public ApiFuture execute(Pipeline pipeline) { + return null; + } + /** Returns the name of the Firestore project associated with this client. */ @Override public String getDatabaseName() { diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 2fde85a0a..d408f4e2f 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -25,7 +25,7 @@ import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { - fun aggregate(vararg aggregator: Expr.AggregateorTarget): Pipeline { + fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { // TODO: this.p.operations.add() return this.p } @@ -52,6 +52,36 @@ class JoiningPipeline internal constructor( } } +class PaginatingPipeline internal constructor( + val p: Pipeline, + pageSize: Int, + orders: Array +) { + fun firstPage(): Pipeline { + return this.p + } + + fun page(n:Int): Pipeline { + return this.p + } + + fun startAt(result: PipelineResult): Pipeline { + return this.p + } + + fun startAfter(result: PipelineResult): Pipeline { + return this.p + } + + fun endAt(result: PipelineResult): Pipeline { + return this.p + } + + fun endBefore(result: PipelineResult): Pipeline { + return this.p + } +} + class Pipeline { internal val operations: MutableList = mutableListOf() private var name: String @@ -180,7 +210,7 @@ class Pipeline { return GroupingPipeline(this /*TODO*/) } - fun aggregate(vararg aggregator: Expr.AggregateorTarget): Pipeline { + fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { // operations.add(Group()) // operations.add(aggregator) return this @@ -242,8 +272,17 @@ class Pipeline { return this } + fun paginate(pageSize: Int, vararg orders: Ordering): PaginatingPipeline { + return PaginatingPipeline(this, pageSize, orders) + } + fun rawOperation(name: String, params: Map? = null): Pipeline { operations.add(GenericOperation(name, params)) return this } } + +// placeholder for now +class PipelineResult { + +} diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 8fde3349f..a45d126fd 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -53,8 +53,8 @@ sealed interface Expr { data class ExprAsAlias(val current: Expr, val alias: String) : Expr, Projectable - data class AggregateorTarget(val current: Function.Accumulator, val target: String) : Expr, - Function.Accumulator + data class AggregatorTarget(val current: Function.Accumulator, val target: String) : Expr, + Function.Accumulator sealed class Function(val name: String, val params: Map?) : Expr { interface FilterCondition { @@ -68,7 +68,7 @@ sealed interface Expr { } interface Accumulator { - fun toField(target: String) = AggregateorTarget(this, target) + fun toField(target: String) = AggregatorTarget(this, target) } data class Equal internal constructor(val left: Expr, val right: Expr) : diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 61e6819ec..7aed53e50 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -25,7 +25,9 @@ import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.PaginatingPipeline; import com.google.cloud.firestore.Pipeline; +import com.google.cloud.firestore.PipelineResult; import com.google.cloud.firestore.pipeline.Expr.Constant; import com.google.cloud.firestore.pipeline.Expr.Field; import com.google.cloud.firestore.pipeline.Fields; @@ -141,4 +143,19 @@ public void sorts() throws Exception { Direction.DESC)) .limit(100); } + + @Test + public void pagination() throws Exception { + PaginatingPipeline p = Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))) + .paginate(100, Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESC)); + + PipelineResult result = firestore.execute(p.firstPage()).get(); + PipelineResult second = firestore.execute(p.startAfter(result)).get(); + // potentially expensive but possible + PipelineResult page100 = firestore.execute(p.page(100)).get(); + } } From 55ace39c57464f6b9ec1970548c1613c90e53d65 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 26 Feb 2024 10:47:16 -0500 Subject: [PATCH 09/45] minor adds --- .../main/java/com/google/cloud/firestore/Pipeline.kt | 11 +++++++++++ .../google/cloud/firestore/pipeline/Expressions.kt | 10 +--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index d408f4e2f..1c4eb16d8 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -1,5 +1,6 @@ package com.google.cloud.firestore +import com.google.api.core.ApiFuture import com.google.cloud.firestore.pipeline.AddFields import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup @@ -126,6 +127,11 @@ class Pipeline { fun fromDatabase(): Pipeline { return Pipeline(Database()) } + + @JvmStatic + fun fromDocuments(vararg doc:Any): Pipeline { + return Pipeline(Database()) + } } fun fieldOf(name: String): Field { @@ -280,6 +286,11 @@ class Pipeline { operations.add(GenericOperation(name, params)) return this } + + // alternative to db.execute, more fluent. + fun execute(db: Firestore): ApiFuture? { + return null + } } // placeholder for now diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index a45d126fd..c22ed8690 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -57,15 +57,7 @@ sealed interface Expr { Function.Accumulator sealed class Function(val name: String, val params: Map?) : Expr { - interface FilterCondition { - infix fun and(other: FilterCondition) = And(listOf(this, other)) - fun and(vararg other: FilterCondition) = And(listOf(this) + other.toList()) - - // Or and Not are restricted as a companion/static function - // infix fun or(other: Expr)= Function.Or(listOf(this, other)) - // fun or(vararg other: Expr)= Function.Or(listOf(this) + other.toList()) - // infix fun not(other: Expr)= Function.Not(this) - } + interface FilterCondition interface Accumulator { fun toField(target: String) = AggregatorTarget(this, target) From 56c3a41f7ec7d6a8de93a88738f1cde10563da84 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 27 Feb 2024 10:15:10 -0500 Subject: [PATCH 10/45] adding more sugar to improve brevity --- .../cloud/firestore/pipeline/Expressions.kt | 52 ++++++++++++++++--- .../cloud/firestore/it/ITPipelineTest.java | 22 ++++++++ 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index c22ed8690..e2c25d105 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -10,7 +10,7 @@ internal data class ListOfExprs(val conditions: List) : Expr internal data class ListOfConditions(val conditions: List) : Expr, Expr.Function.FilterCondition -data class Fields(val fs: List) { +data class Fields(val fs: List) : Projectable { companion object { @JvmStatic fun of(vararg f: String): Fields { @@ -23,7 +23,27 @@ sealed interface Expr { data class Constant internal constructor(val value: Any) : Expr { companion object { @JvmStatic - fun of(value: Any): Constant { + fun of(value: String): Constant { + return Constant(value) + } + + @JvmStatic + fun of(value: Number): Constant { + return Constant(value) + } + + @JvmStatic + fun ofArray(value: Iterable): Constant { + return Constant(value) + } + + @JvmStatic + fun ofMap(value: Map): Constant { + return Constant(value) + } + + @JvmStatic + fun ofVector(value: DoubleArray): Constant { return Constant(value) } } @@ -158,10 +178,11 @@ sealed interface Expr { fun avg() = Function.Avg(this) fun count() = Function.Count(this) infix fun cosineDistance(other: Expr) = Function.CosineDistance(this, other) - infix fun cosineDistance(other: DoubleArray) = Function.CosineDistance(this, Constant.of(other)) + infix fun cosineDistance(other: DoubleArray) = + Function.CosineDistance(this, Constant.ofVector(other)) infix fun euclideanDistance(other: Expr) = Function.EuclideanDistance(this, other) infix fun euclideanDistance(other: DoubleArray) = - Function.EuclideanDistance(this, Constant.of(other)) + Function.EuclideanDistance(this, Constant.ofVector(other)) infix fun hasAncestor(ancestor: Expr) = Function.HasAncestor(this, ancestor) @@ -171,6 +192,18 @@ sealed interface Expr { @JvmStatic fun equal(left: Expr, right: Expr) = Function.Equal(left, right) + // sugar, first argument is assumed to be a field. + @JvmStatic + fun equal(left: String, right: Expr) = Function.Equal(Field.of(left), right) + + // sugar, first argument is assumed to be a field, and second argument is assumed to a simple + // scalar constant. + @JvmStatic + fun equal(left: String, right: String) = Function.Equal(Field.of(left), Constant.of(right)) + + @JvmStatic + fun equal(left: String, right: Number) = Function.Equal(Field.of(left), Constant.of(right)) + @JvmStatic fun notEqual(left: Expr, right: Expr) = Function.NotEqual(left, right) @@ -186,6 +219,13 @@ sealed interface Expr { @JvmStatic fun lessThan(left: Expr, right: Expr) = Function.LessThan(left, right) + @JvmStatic + fun lessThan(left: String, right: String) = + Function.LessThan(Field.of(left), Constant.of(right)) + + @JvmStatic + fun lessThan(left: String, right: Number) = + Function.LessThan(Field.of(left), Constant.of(right)) @JvmStatic fun lessThanOrEqual(left: Expr, right: Expr) = Function.LessThanOrEqual(left, right) @@ -244,14 +284,14 @@ sealed interface Expr { @JvmStatic fun cosineDistance(expr: Expr, other: DoubleArray) = - Function.CosineDistance(expr, Constant.of(other)) + Function.CosineDistance(expr, Constant.ofVector(other)) @JvmStatic fun euclideanDistance(expr: Expr, other: Expr) = Function.EuclideanDistance(expr, other) @JvmStatic fun euclideanDistance(expr: Expr, other: DoubleArray) = - Function.EuclideanDistance(expr, Constant.of(other)) + Function.EuclideanDistance(expr, Constant.ofVector(other)) @JvmStatic fun hasAncestor(expr: Expr, ancestor: Expr) = Function.HasAncestor(expr, ancestor) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 7aed53e50..2878576c2 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -20,6 +20,8 @@ import static com.google.cloud.firestore.pipeline.Expr.and; import static com.google.cloud.firestore.pipeline.Expr.avg; import static com.google.cloud.firestore.pipeline.Expr.cosineDistance; +import static com.google.cloud.firestore.pipeline.Expr.equal; +import static com.google.cloud.firestore.pipeline.Expr.lessThan; import static com.google.cloud.firestore.pipeline.Expr.not; import static com.google.cloud.firestore.pipeline.Expr.or; @@ -60,6 +62,19 @@ public void projections() throws Exception { Constant.of("emptyValue").asAlias("emptyField"), Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") ); + + // More compact + p = Pipeline.fromCollection("coll1") + .project( + Fields.of("foo", "bar", "baz"), + Constant.of(42).asAlias("emptyField") + ); + p = Pipeline.fromCollection("coll1") + // basically an addField + .project( + Field.ofAll(), + Constant.of(42).asAlias("emptyField") + ); } @Test @@ -80,6 +95,13 @@ public void filters() throws Exception { Constant.of("value").equal(Field.of("key")) )) .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + + p = Pipeline.fromCollectionGroup("coll1") + .filter(equal("foo", 42)) + .filter(or(lessThan("bar", 100), + equal("key", Constant.of("value")) + )) + .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); } @Test From a5a90ab6a376269d1f28adb90ab57f778d92c80f Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Wed, 28 Feb 2024 09:59:37 -0500 Subject: [PATCH 11/45] address some feedback --- .../cloud/firestore/pipeline/Expressions.kt | 1 + .../cloud/firestore/pipeline/Operations.kt | 9 +++++++ .../cloud/firestore/it/ITPipelineTest.java | 26 +++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index e2c25d105..791d60cea 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -74,6 +74,7 @@ sealed interface Expr { data class ExprAsAlias(val current: Expr, val alias: String) : Expr, Projectable data class AggregatorTarget(val current: Function.Accumulator, val target: String) : Expr, + Projectable, Function.Accumulator sealed class Function(val name: String, val params: Map?) : Expr { diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 663c39314..4eda29256 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -94,6 +94,15 @@ data class Ordering(val expr: Expr, val dir: Direction = Direction.ASC) { fun of(expr: Expr): Ordering { return Ordering(expr, Direction.ASC) } + + @JvmStatic + fun ascending(expr: Expr): Ordering { + return Ordering(expr, Direction.ASC) + } + @JvmStatic + fun descending(expr: Expr): Ordering { + return Ordering(expr, Direction.DESC) + } } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 2878576c2..2e5547245 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -24,6 +24,8 @@ import static com.google.cloud.firestore.pipeline.Expr.lessThan; import static com.google.cloud.firestore.pipeline.Expr.not; import static com.google.cloud.firestore.pipeline.Expr.or; +import static com.google.cloud.firestore.pipeline.Ordering.ascending; +import static com.google.cloud.firestore.pipeline.Ordering.descending; import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; @@ -164,6 +166,15 @@ public void sorts() throws Exception { Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)) .limit(100); + + // equivalent but more concise. + p = Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))) + .sort(ascending(Field.of("rank")), + descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) + .limit(100); } @Test @@ -180,4 +191,19 @@ public void pagination() throws Exception { // potentially expensive but possible PipelineResult page100 = firestore.execute(p.page(100)).get(); } + + @Test + public void fluentAllTheWay() throws Exception { + PaginatingPipeline p = Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny( + Constant.of(42), + Field.of("bar"))) + .paginate(100, Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESC)); + + PipelineResult result = p.firstPage().execute(firestore).get(); + PipelineResult second = p.startAfter(result).execute(firestore).get(); + // potentially expensive but possible + PipelineResult page100 = p.page(100).execute(firestore).get(); + } } From 424ac43aa6595295ed5d7b4605043a064175297d Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Wed, 28 Feb 2024 10:22:46 -0500 Subject: [PATCH 12/45] support fromData --- .../src/main/java/com/google/cloud/firestore/Pipeline.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 1c4eb16d8..6684f0179 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -129,7 +129,12 @@ class Pipeline { } @JvmStatic - fun fromDocuments(vararg doc:Any): Pipeline { + fun fromDocuments(vararg docPath :String): Pipeline { + return Pipeline(Database()) + } + + @JvmStatic + fun fromData(vararg doc: Map>): Pipeline { return Pipeline(Database()) } } From 4d8a20567a5c1eda4a89eb465508eca03f62b3b9 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 7 Mar 2024 11:13:02 -0500 Subject: [PATCH 13/45] pipeline result basic --- .../com/google/cloud/firestore/Pipeline.kt | 158 +++++++++++++- .../cloud/firestore/it/ITPipelineTest.java | 197 +++++++++--------- 2 files changed, 255 insertions(+), 100 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 6684f0179..8e45f046c 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -1,6 +1,7 @@ package com.google.cloud.firestore import com.google.api.core.ApiFuture +import com.google.cloud.Timestamp import com.google.cloud.firestore.pipeline.AddFields import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup @@ -24,6 +25,13 @@ import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest +import com.google.common.base.Preconditions +import com.google.firestore.v1.Document +import com.google.firestore.v1.Value +import com.google.firestore.v1.Write +import java.util.Date +import java.util.Objects +import javax.annotation.Nonnull class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { @@ -298,7 +306,153 @@ class Pipeline { } } -// placeholder for now -class PipelineResult { +data class PipelineResult // Elevated access level for mocking. +internal constructor( + private val rpcContext: FirestoreRpcContext<*>, + val reference: DocumentReference?, + val protoFields: Map?, + val readTime: Timestamp?, + val updateTime: Timestamp?, + val createTime: Timestamp? +) { + val id: String? + get() = reference?.id + + fun valid(): Boolean { + return protoFields != null + } + + val data: Map? + /** + * Returns the fields of the document as a Map or null if the document doesn't exist. Field values + * will be converted to their native Java representation. + * + * @return The fields of the document as a Map or null if the document doesn't exist. + */ + get() { + if (protoFields == null) { + return null + } + + val decodedFields: MutableMap = HashMap() + for ((key, value) in protoFields) { + val decodedValue = UserDataConverter.decodeValue(rpcContext, value) + decodedFields[key] = decodedValue + } + return decodedFields + } + + /** + * Returns the contents of the result converted to a POJO or null if the document doesn't exist. + * + * @param valueType The Java class to create + * @return The contents of the result in an object of type T or null if the document doesn't + * exist. + */ + fun toObject(@Nonnull valueType: Class): T? { + val data = data + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result does not + * exist. + * + * @param field the path to the field. + * @return true iff the field exists. + */ + fun contains(field: String): Boolean { + return contains(FieldPath.fromDotSeparatedString(field)) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result is invalid. + * + * @param fieldPath the path to the field. + * @return true iff the field exists. + */ + fun contains(fieldPath: FieldPath): Boolean { + return this.extractField(fieldPath) != null + } + + fun get(field: String): Any? { + return get(FieldPath.fromDotSeparatedString(field)) + } + + fun get(field: String?, valueType: Class): T? { + return get(FieldPath.fromDotSeparatedString(field), valueType) + } + + fun get(fieldPath: FieldPath): Any? { + val value = extractField(fieldPath) ?: return null + + return UserDataConverter.decodeValue(rpcContext, value) + } + + fun get(fieldPath: FieldPath, valueType: Class): T? { + val data = get(fieldPath) + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + fun extractField(fieldPath: FieldPath): Value? { + var value: Value? = null + + if (protoFields != null) { + val components: Iterator = fieldPath.segments.iterator() + value = protoFields[components.next()] + + while (value != null && components.hasNext()) { + if (value.valueTypeCase != Value.ValueTypeCase.MAP_VALUE) { + return null + } + value = value.mapValue.getFieldsOrDefault(components.next(), null) + } + } + + return value + } + + fun getBoolean(field: String): Boolean? { + return get(field) as Boolean? + } + + fun getDouble(field: String): Double? { + val number = get(field) as Number? + return number?.toDouble() + } + + fun getString(field: String): String? { + return get(field) as String? + } + + fun getLong(field: String): Long? { + val number = get(field) as Number? + return number?.toLong() + } + + fun getDate(field: String): Date? { + val timestamp = getTimestamp(field) + return timestamp?.toDate() + } + + fun getTimestamp(field: String): Timestamp? { + return get(field) as Timestamp? + } + + fun getBlob(field: String): Blob? { + return get(field) as Blob? + } + + fun getGeoPoint(field: String): GeoPoint? { + return get(field) as GeoPoint? + } + val isEmpty: Boolean + get() = protoFields == null || protoFields.isEmpty() } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 2e5547245..ac0b4f5ad 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -16,7 +16,6 @@ package com.google.cloud.firestore.it; - import static com.google.cloud.firestore.pipeline.Expr.and; import static com.google.cloud.firestore.pipeline.Expr.avg; import static com.google.cloud.firestore.pipeline.Expr.cosineDistance; @@ -58,133 +57,133 @@ public void pipelineWithDb() throws Exception { @Test public void projections() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .project( - Field.of("foo"), - Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") - ); + Pipeline p = + Pipeline.fromCollection("coll1") + .project( + Field.of("foo"), + Constant.of("emptyValue").asAlias("emptyField"), + Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")); // More compact - p = Pipeline.fromCollection("coll1") - .project( - Fields.of("foo", "bar", "baz"), - Constant.of(42).asAlias("emptyField") - ); - p = Pipeline.fromCollection("coll1") - // basically an addField - .project( - Field.ofAll(), - Constant.of(42).asAlias("emptyField") - ); + p = + Pipeline.fromCollection("coll1") + .project(Fields.of("foo", "bar", "baz"), Constant.of(42).asAlias("emptyField")); + p = + Pipeline.fromCollection("coll1") + // basically an addField + .project(Field.ofAll(), Constant.of(42).asAlias("emptyField")); } @Test public void addRemoveFields() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .addFields( - Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") - ) - .removeFields(Field.of("emptyField")); + Pipeline p = + Pipeline.fromCollection("coll1") + .addFields( + Constant.of("emptyValue").asAlias("emptyField"), + Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")) + .removeFields(Field.of("emptyField")); } @Test public void filters() throws Exception { - Pipeline p = Pipeline.fromCollectionGroup("coll1") - .filter(Field.of("foo").equal(Constant.of(42))) - .filter(or(Field.of("bar").lessThan(Constant.of(100)), - Constant.of("value").equal(Field.of("key")) - )) - .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); - - p = Pipeline.fromCollectionGroup("coll1") - .filter(equal("foo", 42)) - .filter(or(lessThan("bar", 100), - equal("key", Constant.of("value")) - )) - .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + Pipeline p = + Pipeline.fromCollectionGroup("coll1") + .filter(Field.of("foo").equal(Constant.of(42))) + .filter( + or( + Field.of("bar").lessThan(Constant.of(100)), + Constant.of("value").equal(Field.of("key")))) + .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + + p = + Pipeline.fromCollectionGroup("coll1") + .filter(equal("foo", 42)) + .filter(or(lessThan("bar", 100), equal("key", Constant.of("value")))) + .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); } @Test public void inFilters() throws Exception { - Pipeline p = Pipeline.fromCollectionGroup("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))); + Pipeline p = + Pipeline.fromCollectionGroup("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))); } @Test public void groupBy() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .group(Fields.of("given_name", "family_name")) - .aggregate(avg(Field.of("score")).toField("avg_score_1")) - // Equivalent but more fluency - .group(Fields.of("given_name", "family_name")) - .aggregate(Field.of("score").avg().toField("avg_score_2")); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .group(Fields.of("given_name", "family_name")) + .aggregate(avg(Field.of("score")).toField("avg_score_1")) + // Equivalent but more fluency + .group(Fields.of("given_name", "family_name")) + .aggregate(Field.of("score").avg().toField("avg_score_2")); } @Test public void aggregateWithoutGrouping() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .aggregate(avg(Field.of("score")).toField("avg_score_1")); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .aggregate(avg(Field.of("score")).toField("avg_score_1")); } @Test public void joins() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))); - Pipeline pipe = Pipeline.fromCollection("users") - .findNearest(Field.of("embedding"), new double[]{1.0, 2.0}, - new FindNearestOptions(Similarity.euclidean(), 1000, Field.of("distance"))) - .innerJoin(p) - .on(and( - Field.of("foo").equal(p.fieldOf("bar")), - p.fieldOf("requirement").greaterThan(Field.of("distance")))); - - Pipeline another = Pipeline.fromCollection("users") - .innerJoin(p) - .on(Fields.of("foo", "bar")) - .project(Field.ofAll().withPrefix("left"), p.fieldOfAll().withPrefix("right")); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))); + Pipeline pipe = + Pipeline.fromCollection("users") + .findNearest( + Field.of("embedding"), + new double[] {1.0, 2.0}, + new FindNearestOptions(Similarity.euclidean(), 1000, Field.of("distance"))) + .innerJoin(p) + .on( + and( + Field.of("foo").equal(p.fieldOf("bar")), + p.fieldOf("requirement").greaterThan(Field.of("distance")))); + + Pipeline another = + Pipeline.fromCollection("users") + .innerJoin(p) + .on(Fields.of("foo", "bar")) + .project(Field.ofAll().withPrefix("left"), p.fieldOfAll().withPrefix("right")); } @Test public void sorts() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .sort(Ordering.of(Field.of("rank")), - Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)) - .limit(100); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .sort( + Ordering.of(Field.of("rank")), + Ordering.of( + cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)) + .limit(100); // equivalent but more concise. - p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .sort(ascending(Field.of("rank")), - descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) - .limit(100); + p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .sort( + ascending(Field.of("rank")), + descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) + .limit(100); } @Test public void pagination() throws Exception { - PaginatingPipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .paginate(100, Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)); + PaginatingPipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .paginate( + 100, + Ordering.of( + cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESC)); PipelineResult result = firestore.execute(p.firstPage()).get(); PipelineResult second = firestore.execute(p.startAfter(result)).get(); @@ -194,12 +193,14 @@ public void pagination() throws Exception { @Test public void fluentAllTheWay() throws Exception { - PaginatingPipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .paginate(100, Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)); + PaginatingPipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .paginate( + 100, + Ordering.of( + cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESC)); PipelineResult result = p.firstPage().execute(firestore).get(); PipelineResult second = p.startAfter(result).execute(firestore).get(); From 9119b95da6f3912bfc97e7f3bfbdcf4a16aeb831 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 7 Mar 2024 13:41:15 -0500 Subject: [PATCH 14/45] execute --- .../com/google/cloud/firestore/Pipeline.kt | 168 +----------------- .../google/cloud/firestore/PipelineResult.kt | 159 +++++++++++++++++ 2 files changed, 166 insertions(+), 161 deletions(-) create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 8e45f046c..9a732da0e 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -1,7 +1,8 @@ package com.google.cloud.firestore import com.google.api.core.ApiFuture -import com.google.cloud.Timestamp +import com.google.api.core.ApiFutures +import com.google.api.gax.rpc.ApiStreamObserver import com.google.cloud.firestore.pipeline.AddFields import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup @@ -25,13 +26,6 @@ import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest -import com.google.common.base.Preconditions -import com.google.firestore.v1.Document -import com.google.firestore.v1.Value -import com.google.firestore.v1.Write -import java.util.Date -import java.util.Objects -import javax.annotation.Nonnull class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { @@ -295,164 +289,16 @@ class Pipeline { return PaginatingPipeline(this, pageSize, orders) } - fun rawOperation(name: String, params: Map? = null): Pipeline { + fun genericOperation(name: String, params: Map? = null): Pipeline { operations.add(GenericOperation(name, params)) return this } - // alternative to db.execute, more fluent. - fun execute(db: Firestore): ApiFuture? { - return null - } -} - -data class PipelineResult // Elevated access level for mocking. -internal constructor( - private val rpcContext: FirestoreRpcContext<*>, - val reference: DocumentReference?, - val protoFields: Map?, - val readTime: Timestamp?, - val updateTime: Timestamp?, - val createTime: Timestamp? -) { - val id: String? - get() = reference?.id - - fun valid(): Boolean { - return protoFields != null - } - - val data: Map? - /** - * Returns the fields of the document as a Map or null if the document doesn't exist. Field values - * will be converted to their native Java representation. - * - * @return The fields of the document as a Map or null if the document doesn't exist. - */ - get() { - if (protoFields == null) { - return null - } - - val decodedFields: MutableMap = HashMap() - for ((key, value) in protoFields) { - val decodedValue = UserDataConverter.decodeValue(rpcContext, value) - decodedFields[key] = decodedValue - } - return decodedFields - } - - /** - * Returns the contents of the result converted to a POJO or null if the document doesn't exist. - * - * @param valueType The Java class to create - * @return The contents of the result in an object of type T or null if the document doesn't - * exist. - */ - fun toObject(@Nonnull valueType: Class): T? { - val data = data - return if (data == null) null else CustomClassMapper.convertToCustomClass( - data, valueType, - reference - ) + fun execute(db: Firestore): ApiFuture> { + return ApiFutures.immediateFuture(listOf(PipelineResult()).iterator()) } - /** - * Returns whether or not the field exists in the result. Returns false if the result does not - * exist. - * - * @param field the path to the field. - * @return true iff the field exists. - */ - fun contains(field: String): Boolean { - return contains(FieldPath.fromDotSeparatedString(field)) + fun execute(db: Firestore, observer: ApiStreamObserver): Unit { } - - /** - * Returns whether or not the field exists in the result. Returns false if the result is invalid. - * - * @param fieldPath the path to the field. - * @return true iff the field exists. - */ - fun contains(fieldPath: FieldPath): Boolean { - return this.extractField(fieldPath) != null - } - - fun get(field: String): Any? { - return get(FieldPath.fromDotSeparatedString(field)) - } - - fun get(field: String?, valueType: Class): T? { - return get(FieldPath.fromDotSeparatedString(field), valueType) - } - - fun get(fieldPath: FieldPath): Any? { - val value = extractField(fieldPath) ?: return null - - return UserDataConverter.decodeValue(rpcContext, value) - } - - fun get(fieldPath: FieldPath, valueType: Class): T? { - val data = get(fieldPath) - return if (data == null) null else CustomClassMapper.convertToCustomClass( - data, valueType, - reference - ) - } - - fun extractField(fieldPath: FieldPath): Value? { - var value: Value? = null - - if (protoFields != null) { - val components: Iterator = fieldPath.segments.iterator() - value = protoFields[components.next()] - - while (value != null && components.hasNext()) { - if (value.valueTypeCase != Value.ValueTypeCase.MAP_VALUE) { - return null - } - value = value.mapValue.getFieldsOrDefault(components.next(), null) - } - } - - return value - } - - fun getBoolean(field: String): Boolean? { - return get(field) as Boolean? - } - - fun getDouble(field: String): Double? { - val number = get(field) as Number? - return number?.toDouble() - } - - fun getString(field: String): String? { - return get(field) as String? - } - - fun getLong(field: String): Long? { - val number = get(field) as Number? - return number?.toLong() - } - - fun getDate(field: String): Date? { - val timestamp = getTimestamp(field) - return timestamp?.toDate() - } - - fun getTimestamp(field: String): Timestamp? { - return get(field) as Timestamp? - } - - fun getBlob(field: String): Blob? { - return get(field) as Blob? - } - - fun getGeoPoint(field: String): GeoPoint? { - return get(field) as GeoPoint? - } - - val isEmpty: Boolean - get() = protoFields == null || protoFields.isEmpty() } + diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt new file mode 100644 index 000000000..6dae35e11 --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -0,0 +1,159 @@ +package com.google.cloud.firestore + +import com.google.cloud.Timestamp +import com.google.firestore.v1.Value +import java.util.Date +import javax.annotation.Nonnull + +data class PipelineResult // Elevated access level for mocking. +internal constructor( + private val rpcContext: FirestoreRpcContext<*>?, + val reference: DocumentReference?, + val protoFields: Map?, + val readTime: Timestamp?, + val updateTime: Timestamp?, + val createTime: Timestamp? +) { + constructor() : this(null, null, null, null, null, null) + + val id: String? + get() = reference?.id + + fun valid(): Boolean { + return protoFields != null + } + + val data: Map? + /** + * Returns the fields of the document as a Map or null if the document doesn't exist. Field values + * will be converted to their native Java representation. + * + * @return The fields of the document as a Map or null if the document doesn't exist. + */ + get() { + if (protoFields == null) { + return null + } + + val decodedFields: MutableMap = HashMap() + for ((key, value) in protoFields) { + val decodedValue = UserDataConverter.decodeValue(rpcContext, value) + decodedFields[key] = decodedValue + } + return decodedFields + } + + /** + * Returns the contents of the result converted to a POJO or null if the document doesn't exist. + * + * @param valueType The Java class to create + * @return The contents of the result in an object of type T or null if the document doesn't + * exist. + */ + fun toObject(@Nonnull valueType: Class): T? { + val data = data + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result does not + * exist. + * + * @param field the path to the field. + * @return true iff the field exists. + */ + fun contains(field: String): Boolean { + return contains(FieldPath.fromDotSeparatedString(field)) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result is invalid. + * + * @param fieldPath the path to the field. + * @return true iff the field exists. + */ + fun contains(fieldPath: FieldPath): Boolean { + return this.extractField(fieldPath) != null + } + + fun get(field: String): Any? { + return get(FieldPath.fromDotSeparatedString(field)) + } + + fun get(field: String?, valueType: Class): T? { + return get(FieldPath.fromDotSeparatedString(field), valueType) + } + + fun get(fieldPath: FieldPath): Any? { + val value = extractField(fieldPath) ?: return null + + return UserDataConverter.decodeValue(rpcContext, value) + } + + fun get(fieldPath: FieldPath, valueType: Class): T? { + val data = get(fieldPath) + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + fun extractField(fieldPath: FieldPath): Value? { + var value: Value? = null + + if (protoFields != null) { + val components: Iterator = fieldPath.segments.iterator() + value = protoFields[components.next()] + + while (value != null && components.hasNext()) { + if (value.valueTypeCase != Value.ValueTypeCase.MAP_VALUE) { + return null + } + value = value.mapValue.getFieldsOrDefault(components.next(), null) + } + } + + return value + } + + fun getBoolean(field: String): Boolean? { + return get(field) as Boolean? + } + + fun getDouble(field: String): Double? { + val number = get(field) as Number? + return number?.toDouble() + } + + fun getString(field: String): String? { + return get(field) as String? + } + + fun getLong(field: String): Long? { + val number = get(field) as Number? + return number?.toLong() + } + + fun getDate(field: String): Date? { + val timestamp = getTimestamp(field) + return timestamp?.toDate() + } + + fun getTimestamp(field: String): Timestamp? { + return get(field) as Timestamp? + } + + fun getBlob(field: String): Blob? { + return get(field) as Blob? + } + + fun getGeoPoint(field: String): GeoPoint? { + return get(field) as GeoPoint? + } + + val isEmpty: Boolean + get() = protoFields == null || protoFields.isEmpty() +} From 3aa73de8069f7b24b1c2bbaf753089a80c7e2b33 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 11 Mar 2024 11:42:52 -0400 Subject: [PATCH 15/45] fixing compilation error and add some high level comments --- .../com/google/cloud/firestore/Firestore.java | 3 +- .../google/cloud/firestore/FirestoreImpl.java | 3 +- .../com/google/cloud/firestore/Pipeline.kt | 31 +++++++++++++++++++ .../cloud/firestore/it/ITPipelineTest.java | 13 ++++---- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java index 48e977892..1b925057d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java @@ -24,6 +24,7 @@ import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import kotlin.collections.Iterator; /** Represents a Firestore Database and is the entry point for all Firestore operations */ @InternalExtensionOnly @@ -287,7 +288,7 @@ void getAll( @Nonnull FirestoreBundle.Builder bundleBuilder(@Nonnull String bundleId); - ApiFuture execute(Pipeline pipeline); + ApiFuture> execute(Pipeline pipeline); /** * Closes the gRPC channels associated with this instance and frees up their resources. This diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java index bc4f45bf2..e1ff9d964 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -48,6 +48,7 @@ import java.util.Random; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import kotlin.collections.Iterator; import org.threeten.bp.Duration; /** @@ -409,7 +410,7 @@ public FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId) { } @Override - public ApiFuture execute(Pipeline pipeline) { + public ApiFuture> execute(Pipeline pipeline) { return null; } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 9a732da0e..48a7da3b3 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -85,6 +85,37 @@ class PaginatingPipeline internal constructor( } } +/** + * The Pipeline class provides a flexible and expressive framework for building complex data transformation + * and query pipelines for Firestore. + * + * A pipeline takes data sources such as Firestore collections, collection groups, or even in-memory data, and + * applies a series of operations that are chained together, each operation takes the output from the last + * operation (or the data source) and produces an output for the next operation (or as the final output of the pipeline). + * + * Usage Examples: + * + * **1. Projecting Specific Fields and Renaming:** + * ```java + * Pipeline pipeline = Pipeline.fromCollection("users") + * // Select 'name' and 'email' fields, create 'userAge' which is renamed from field 'age'. + * .project(Fields.of("name", "email"), Field.of("age").asAlias("userAge")) + * ``` + * + * **2. Filtering and Sorting:** + * ```java + * Pipeline pipeline = Pipeline.fromCollectionGroup("reviews") + * .filter(Field.of("rating").greaterThan(Expr.Constant.of(3))) // High ratings + * .sort(Ordering.of("timestamp").descending()); + * ``` + * + * **3. Aggregation with Grouping:** + * ```java + * Pipeline pipeline = Pipeline.fromCollection("orders") + * .group(Field.of("customerId")) + * .aggregate(count(Field.of("orderId")).asAlias("orderCount")); + * ``` + */ class Pipeline { internal val operations: MutableList = mutableListOf() private var name: String diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index ac0b4f5ad..7ab2af51e 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -38,6 +38,7 @@ import com.google.cloud.firestore.pipeline.FindNearest.Similarity; import com.google.cloud.firestore.pipeline.Ordering; import com.google.cloud.firestore.pipeline.Ordering.Direction; +import java.util.Iterator; import org.junit.Before; import org.junit.Test; @@ -185,10 +186,10 @@ public void pagination() throws Exception { cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)); - PipelineResult result = firestore.execute(p.firstPage()).get(); - PipelineResult second = firestore.execute(p.startAfter(result)).get(); + Iterator result = firestore.execute(p.firstPage()).get(); + Iterator second = firestore.execute(p.startAfter(result.next())).get(); // potentially expensive but possible - PipelineResult page100 = firestore.execute(p.page(100)).get(); + Iterator page100 = firestore.execute(p.page(100)).get(); } @Test @@ -202,9 +203,9 @@ public void fluentAllTheWay() throws Exception { cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)); - PipelineResult result = p.firstPage().execute(firestore).get(); - PipelineResult second = p.startAfter(result).execute(firestore).get(); + Iterator result = p.firstPage().execute(firestore).get(); + Iterator second = p.startAfter(result.next()).execute(firestore).get(); // potentially expensive but possible - PipelineResult page100 = p.page(100).execute(firestore).get(); + Iterator page100 = p.page(100).execute(firestore).get(); } } From b5837916cb7114f4d7f2e8c52bf1e2cd682d5779 Mon Sep 17 00:00:00 2001 From: wuandy Date: Mon, 11 Mar 2024 18:55:39 +0000 Subject: [PATCH 16/45] setup nix for idx --- .idx/.gitignore | 2 ++ .idx/dev.nix | 17 +++++++++++++++++ .vscode/settings.json | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 .idx/.gitignore create mode 100644 .idx/dev.nix create mode 100644 .vscode/settings.json diff --git a/.idx/.gitignore b/.idx/.gitignore new file mode 100644 index 000000000..96be05fb6 --- /dev/null +++ b/.idx/.gitignore @@ -0,0 +1,2 @@ + +gc/ diff --git a/.idx/dev.nix b/.idx/dev.nix new file mode 100644 index 000000000..90de3c080 --- /dev/null +++ b/.idx/dev.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: { + + # Which nixpkgs channel to use. + channel = "stable-23.11"; # or "unstable" + + # Use https://search.nixos.org/packages to find packages + packages = [ + pkgs.jdk11 # Or jdk8, jdk17, etc. - match your project's requirements + pkgs.maven + pkgs.kotlin + ]; + + # Sets environment variables in the workspace + env = { + SOME_ENV_VAR = "hello"; + }; +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..7b016a89f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file From 7216745f7733719ebfff30b1e141cba130b525cc Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 11 Mar 2024 14:57:24 -0400 Subject: [PATCH 17/45] tweaks --- .../src/main/java/com/google/cloud/firestore/Pipeline.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 48a7da3b3..6816412bf 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -93,6 +93,9 @@ class PaginatingPipeline internal constructor( * applies a series of operations that are chained together, each operation takes the output from the last * operation (or the data source) and produces an output for the next operation (or as the final output of the pipeline). * + * NOTE: the chained operations are not a prescription of exactly how Firestore will execute the pipeline, + * instead Firestore only guarantee the result is the same as if the chained operations are executed in order. + * * Usage Examples: * * **1. Projecting Specific Fields and Renaming:** From c46601f96f870b876174d8a15c908dc1e510c1b8 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 7 Mar 2024 11:13:02 -0500 Subject: [PATCH 18/45] pipeline result basic --- .../com/google/cloud/firestore/Pipeline.kt | 158 +++++++++++++- .../cloud/firestore/it/ITPipelineTest.java | 197 +++++++++--------- 2 files changed, 255 insertions(+), 100 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 6684f0179..8e45f046c 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -1,6 +1,7 @@ package com.google.cloud.firestore import com.google.api.core.ApiFuture +import com.google.cloud.Timestamp import com.google.cloud.firestore.pipeline.AddFields import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup @@ -24,6 +25,13 @@ import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest +import com.google.common.base.Preconditions +import com.google.firestore.v1.Document +import com.google.firestore.v1.Value +import com.google.firestore.v1.Write +import java.util.Date +import java.util.Objects +import javax.annotation.Nonnull class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { @@ -298,7 +306,153 @@ class Pipeline { } } -// placeholder for now -class PipelineResult { +data class PipelineResult // Elevated access level for mocking. +internal constructor( + private val rpcContext: FirestoreRpcContext<*>, + val reference: DocumentReference?, + val protoFields: Map?, + val readTime: Timestamp?, + val updateTime: Timestamp?, + val createTime: Timestamp? +) { + val id: String? + get() = reference?.id + + fun valid(): Boolean { + return protoFields != null + } + + val data: Map? + /** + * Returns the fields of the document as a Map or null if the document doesn't exist. Field values + * will be converted to their native Java representation. + * + * @return The fields of the document as a Map or null if the document doesn't exist. + */ + get() { + if (protoFields == null) { + return null + } + + val decodedFields: MutableMap = HashMap() + for ((key, value) in protoFields) { + val decodedValue = UserDataConverter.decodeValue(rpcContext, value) + decodedFields[key] = decodedValue + } + return decodedFields + } + + /** + * Returns the contents of the result converted to a POJO or null if the document doesn't exist. + * + * @param valueType The Java class to create + * @return The contents of the result in an object of type T or null if the document doesn't + * exist. + */ + fun toObject(@Nonnull valueType: Class): T? { + val data = data + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result does not + * exist. + * + * @param field the path to the field. + * @return true iff the field exists. + */ + fun contains(field: String): Boolean { + return contains(FieldPath.fromDotSeparatedString(field)) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result is invalid. + * + * @param fieldPath the path to the field. + * @return true iff the field exists. + */ + fun contains(fieldPath: FieldPath): Boolean { + return this.extractField(fieldPath) != null + } + + fun get(field: String): Any? { + return get(FieldPath.fromDotSeparatedString(field)) + } + + fun get(field: String?, valueType: Class): T? { + return get(FieldPath.fromDotSeparatedString(field), valueType) + } + + fun get(fieldPath: FieldPath): Any? { + val value = extractField(fieldPath) ?: return null + + return UserDataConverter.decodeValue(rpcContext, value) + } + + fun get(fieldPath: FieldPath, valueType: Class): T? { + val data = get(fieldPath) + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + fun extractField(fieldPath: FieldPath): Value? { + var value: Value? = null + + if (protoFields != null) { + val components: Iterator = fieldPath.segments.iterator() + value = protoFields[components.next()] + + while (value != null && components.hasNext()) { + if (value.valueTypeCase != Value.ValueTypeCase.MAP_VALUE) { + return null + } + value = value.mapValue.getFieldsOrDefault(components.next(), null) + } + } + + return value + } + + fun getBoolean(field: String): Boolean? { + return get(field) as Boolean? + } + + fun getDouble(field: String): Double? { + val number = get(field) as Number? + return number?.toDouble() + } + + fun getString(field: String): String? { + return get(field) as String? + } + + fun getLong(field: String): Long? { + val number = get(field) as Number? + return number?.toLong() + } + + fun getDate(field: String): Date? { + val timestamp = getTimestamp(field) + return timestamp?.toDate() + } + + fun getTimestamp(field: String): Timestamp? { + return get(field) as Timestamp? + } + + fun getBlob(field: String): Blob? { + return get(field) as Blob? + } + + fun getGeoPoint(field: String): GeoPoint? { + return get(field) as GeoPoint? + } + val isEmpty: Boolean + get() = protoFields == null || protoFields.isEmpty() } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 2e5547245..ac0b4f5ad 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -16,7 +16,6 @@ package com.google.cloud.firestore.it; - import static com.google.cloud.firestore.pipeline.Expr.and; import static com.google.cloud.firestore.pipeline.Expr.avg; import static com.google.cloud.firestore.pipeline.Expr.cosineDistance; @@ -58,133 +57,133 @@ public void pipelineWithDb() throws Exception { @Test public void projections() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .project( - Field.of("foo"), - Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") - ); + Pipeline p = + Pipeline.fromCollection("coll1") + .project( + Field.of("foo"), + Constant.of("emptyValue").asAlias("emptyField"), + Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")); // More compact - p = Pipeline.fromCollection("coll1") - .project( - Fields.of("foo", "bar", "baz"), - Constant.of(42).asAlias("emptyField") - ); - p = Pipeline.fromCollection("coll1") - // basically an addField - .project( - Field.ofAll(), - Constant.of(42).asAlias("emptyField") - ); + p = + Pipeline.fromCollection("coll1") + .project(Fields.of("foo", "bar", "baz"), Constant.of(42).asAlias("emptyField")); + p = + Pipeline.fromCollection("coll1") + // basically an addField + .project(Field.ofAll(), Constant.of(42).asAlias("emptyField")); } @Test public void addRemoveFields() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .addFields( - Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance") - ) - .removeFields(Field.of("emptyField")); + Pipeline p = + Pipeline.fromCollection("coll1") + .addFields( + Constant.of("emptyValue").asAlias("emptyField"), + Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")) + .removeFields(Field.of("emptyField")); } @Test public void filters() throws Exception { - Pipeline p = Pipeline.fromCollectionGroup("coll1") - .filter(Field.of("foo").equal(Constant.of(42))) - .filter(or(Field.of("bar").lessThan(Constant.of(100)), - Constant.of("value").equal(Field.of("key")) - )) - .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); - - p = Pipeline.fromCollectionGroup("coll1") - .filter(equal("foo", 42)) - .filter(or(lessThan("bar", 100), - equal("key", Constant.of("value")) - )) - .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + Pipeline p = + Pipeline.fromCollectionGroup("coll1") + .filter(Field.of("foo").equal(Constant.of(42))) + .filter( + or( + Field.of("bar").lessThan(Constant.of(100)), + Constant.of("value").equal(Field.of("key")))) + .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + + p = + Pipeline.fromCollectionGroup("coll1") + .filter(equal("foo", 42)) + .filter(or(lessThan("bar", 100), equal("key", Constant.of("value")))) + .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); } @Test public void inFilters() throws Exception { - Pipeline p = Pipeline.fromCollectionGroup("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))); + Pipeline p = + Pipeline.fromCollectionGroup("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))); } @Test public void groupBy() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .group(Fields.of("given_name", "family_name")) - .aggregate(avg(Field.of("score")).toField("avg_score_1")) - // Equivalent but more fluency - .group(Fields.of("given_name", "family_name")) - .aggregate(Field.of("score").avg().toField("avg_score_2")); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .group(Fields.of("given_name", "family_name")) + .aggregate(avg(Field.of("score")).toField("avg_score_1")) + // Equivalent but more fluency + .group(Fields.of("given_name", "family_name")) + .aggregate(Field.of("score").avg().toField("avg_score_2")); } @Test public void aggregateWithoutGrouping() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .aggregate(avg(Field.of("score")).toField("avg_score_1")); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .aggregate(avg(Field.of("score")).toField("avg_score_1")); } @Test public void joins() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))); - Pipeline pipe = Pipeline.fromCollection("users") - .findNearest(Field.of("embedding"), new double[]{1.0, 2.0}, - new FindNearestOptions(Similarity.euclidean(), 1000, Field.of("distance"))) - .innerJoin(p) - .on(and( - Field.of("foo").equal(p.fieldOf("bar")), - p.fieldOf("requirement").greaterThan(Field.of("distance")))); - - Pipeline another = Pipeline.fromCollection("users") - .innerJoin(p) - .on(Fields.of("foo", "bar")) - .project(Field.ofAll().withPrefix("left"), p.fieldOfAll().withPrefix("right")); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))); + Pipeline pipe = + Pipeline.fromCollection("users") + .findNearest( + Field.of("embedding"), + new double[] {1.0, 2.0}, + new FindNearestOptions(Similarity.euclidean(), 1000, Field.of("distance"))) + .innerJoin(p) + .on( + and( + Field.of("foo").equal(p.fieldOf("bar")), + p.fieldOf("requirement").greaterThan(Field.of("distance")))); + + Pipeline another = + Pipeline.fromCollection("users") + .innerJoin(p) + .on(Fields.of("foo", "bar")) + .project(Field.ofAll().withPrefix("left"), p.fieldOfAll().withPrefix("right")); } @Test public void sorts() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .sort(Ordering.of(Field.of("rank")), - Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)) - .limit(100); + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .sort( + Ordering.of(Field.of("rank")), + Ordering.of( + cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)) + .limit(100); // equivalent but more concise. - p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .sort(ascending(Field.of("rank")), - descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) - .limit(100); + p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .sort( + ascending(Field.of("rank")), + descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) + .limit(100); } @Test public void pagination() throws Exception { - PaginatingPipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .paginate(100, Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)); + PaginatingPipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .paginate( + 100, + Ordering.of( + cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESC)); PipelineResult result = firestore.execute(p.firstPage()).get(); PipelineResult second = firestore.execute(p.startAfter(result)).get(); @@ -194,12 +193,14 @@ public void pagination() throws Exception { @Test public void fluentAllTheWay() throws Exception { - PaginatingPipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny( - Constant.of(42), - Field.of("bar"))) - .paginate(100, Ordering.of(cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)); + PaginatingPipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .paginate( + 100, + Ordering.of( + cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESC)); PipelineResult result = p.firstPage().execute(firestore).get(); PipelineResult second = p.startAfter(result).execute(firestore).get(); From 99e906776ac457412ae3566ac865707e7cb282e2 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 7 Mar 2024 13:41:15 -0500 Subject: [PATCH 19/45] execute --- .../com/google/cloud/firestore/Pipeline.kt | 168 +----------------- .../google/cloud/firestore/PipelineResult.kt | 159 +++++++++++++++++ 2 files changed, 166 insertions(+), 161 deletions(-) create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 8e45f046c..9a732da0e 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -1,7 +1,8 @@ package com.google.cloud.firestore import com.google.api.core.ApiFuture -import com.google.cloud.Timestamp +import com.google.api.core.ApiFutures +import com.google.api.gax.rpc.ApiStreamObserver import com.google.cloud.firestore.pipeline.AddFields import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup @@ -25,13 +26,6 @@ import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.UnionWith import com.google.cloud.firestore.pipeline.Unnest -import com.google.common.base.Preconditions -import com.google.firestore.v1.Document -import com.google.firestore.v1.Value -import com.google.firestore.v1.Write -import java.util.Date -import java.util.Objects -import javax.annotation.Nonnull class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { @@ -295,164 +289,16 @@ class Pipeline { return PaginatingPipeline(this, pageSize, orders) } - fun rawOperation(name: String, params: Map? = null): Pipeline { + fun genericOperation(name: String, params: Map? = null): Pipeline { operations.add(GenericOperation(name, params)) return this } - // alternative to db.execute, more fluent. - fun execute(db: Firestore): ApiFuture? { - return null - } -} - -data class PipelineResult // Elevated access level for mocking. -internal constructor( - private val rpcContext: FirestoreRpcContext<*>, - val reference: DocumentReference?, - val protoFields: Map?, - val readTime: Timestamp?, - val updateTime: Timestamp?, - val createTime: Timestamp? -) { - val id: String? - get() = reference?.id - - fun valid(): Boolean { - return protoFields != null - } - - val data: Map? - /** - * Returns the fields of the document as a Map or null if the document doesn't exist. Field values - * will be converted to their native Java representation. - * - * @return The fields of the document as a Map or null if the document doesn't exist. - */ - get() { - if (protoFields == null) { - return null - } - - val decodedFields: MutableMap = HashMap() - for ((key, value) in protoFields) { - val decodedValue = UserDataConverter.decodeValue(rpcContext, value) - decodedFields[key] = decodedValue - } - return decodedFields - } - - /** - * Returns the contents of the result converted to a POJO or null if the document doesn't exist. - * - * @param valueType The Java class to create - * @return The contents of the result in an object of type T or null if the document doesn't - * exist. - */ - fun toObject(@Nonnull valueType: Class): T? { - val data = data - return if (data == null) null else CustomClassMapper.convertToCustomClass( - data, valueType, - reference - ) + fun execute(db: Firestore): ApiFuture> { + return ApiFutures.immediateFuture(listOf(PipelineResult()).iterator()) } - /** - * Returns whether or not the field exists in the result. Returns false if the result does not - * exist. - * - * @param field the path to the field. - * @return true iff the field exists. - */ - fun contains(field: String): Boolean { - return contains(FieldPath.fromDotSeparatedString(field)) + fun execute(db: Firestore, observer: ApiStreamObserver): Unit { } - - /** - * Returns whether or not the field exists in the result. Returns false if the result is invalid. - * - * @param fieldPath the path to the field. - * @return true iff the field exists. - */ - fun contains(fieldPath: FieldPath): Boolean { - return this.extractField(fieldPath) != null - } - - fun get(field: String): Any? { - return get(FieldPath.fromDotSeparatedString(field)) - } - - fun get(field: String?, valueType: Class): T? { - return get(FieldPath.fromDotSeparatedString(field), valueType) - } - - fun get(fieldPath: FieldPath): Any? { - val value = extractField(fieldPath) ?: return null - - return UserDataConverter.decodeValue(rpcContext, value) - } - - fun get(fieldPath: FieldPath, valueType: Class): T? { - val data = get(fieldPath) - return if (data == null) null else CustomClassMapper.convertToCustomClass( - data, valueType, - reference - ) - } - - fun extractField(fieldPath: FieldPath): Value? { - var value: Value? = null - - if (protoFields != null) { - val components: Iterator = fieldPath.segments.iterator() - value = protoFields[components.next()] - - while (value != null && components.hasNext()) { - if (value.valueTypeCase != Value.ValueTypeCase.MAP_VALUE) { - return null - } - value = value.mapValue.getFieldsOrDefault(components.next(), null) - } - } - - return value - } - - fun getBoolean(field: String): Boolean? { - return get(field) as Boolean? - } - - fun getDouble(field: String): Double? { - val number = get(field) as Number? - return number?.toDouble() - } - - fun getString(field: String): String? { - return get(field) as String? - } - - fun getLong(field: String): Long? { - val number = get(field) as Number? - return number?.toLong() - } - - fun getDate(field: String): Date? { - val timestamp = getTimestamp(field) - return timestamp?.toDate() - } - - fun getTimestamp(field: String): Timestamp? { - return get(field) as Timestamp? - } - - fun getBlob(field: String): Blob? { - return get(field) as Blob? - } - - fun getGeoPoint(field: String): GeoPoint? { - return get(field) as GeoPoint? - } - - val isEmpty: Boolean - get() = protoFields == null || protoFields.isEmpty() } + diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt new file mode 100644 index 000000000..6dae35e11 --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -0,0 +1,159 @@ +package com.google.cloud.firestore + +import com.google.cloud.Timestamp +import com.google.firestore.v1.Value +import java.util.Date +import javax.annotation.Nonnull + +data class PipelineResult // Elevated access level for mocking. +internal constructor( + private val rpcContext: FirestoreRpcContext<*>?, + val reference: DocumentReference?, + val protoFields: Map?, + val readTime: Timestamp?, + val updateTime: Timestamp?, + val createTime: Timestamp? +) { + constructor() : this(null, null, null, null, null, null) + + val id: String? + get() = reference?.id + + fun valid(): Boolean { + return protoFields != null + } + + val data: Map? + /** + * Returns the fields of the document as a Map or null if the document doesn't exist. Field values + * will be converted to their native Java representation. + * + * @return The fields of the document as a Map or null if the document doesn't exist. + */ + get() { + if (protoFields == null) { + return null + } + + val decodedFields: MutableMap = HashMap() + for ((key, value) in protoFields) { + val decodedValue = UserDataConverter.decodeValue(rpcContext, value) + decodedFields[key] = decodedValue + } + return decodedFields + } + + /** + * Returns the contents of the result converted to a POJO or null if the document doesn't exist. + * + * @param valueType The Java class to create + * @return The contents of the result in an object of type T or null if the document doesn't + * exist. + */ + fun toObject(@Nonnull valueType: Class): T? { + val data = data + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result does not + * exist. + * + * @param field the path to the field. + * @return true iff the field exists. + */ + fun contains(field: String): Boolean { + return contains(FieldPath.fromDotSeparatedString(field)) + } + + /** + * Returns whether or not the field exists in the result. Returns false if the result is invalid. + * + * @param fieldPath the path to the field. + * @return true iff the field exists. + */ + fun contains(fieldPath: FieldPath): Boolean { + return this.extractField(fieldPath) != null + } + + fun get(field: String): Any? { + return get(FieldPath.fromDotSeparatedString(field)) + } + + fun get(field: String?, valueType: Class): T? { + return get(FieldPath.fromDotSeparatedString(field), valueType) + } + + fun get(fieldPath: FieldPath): Any? { + val value = extractField(fieldPath) ?: return null + + return UserDataConverter.decodeValue(rpcContext, value) + } + + fun get(fieldPath: FieldPath, valueType: Class): T? { + val data = get(fieldPath) + return if (data == null) null else CustomClassMapper.convertToCustomClass( + data, valueType, + reference + ) + } + + fun extractField(fieldPath: FieldPath): Value? { + var value: Value? = null + + if (protoFields != null) { + val components: Iterator = fieldPath.segments.iterator() + value = protoFields[components.next()] + + while (value != null && components.hasNext()) { + if (value.valueTypeCase != Value.ValueTypeCase.MAP_VALUE) { + return null + } + value = value.mapValue.getFieldsOrDefault(components.next(), null) + } + } + + return value + } + + fun getBoolean(field: String): Boolean? { + return get(field) as Boolean? + } + + fun getDouble(field: String): Double? { + val number = get(field) as Number? + return number?.toDouble() + } + + fun getString(field: String): String? { + return get(field) as String? + } + + fun getLong(field: String): Long? { + val number = get(field) as Number? + return number?.toLong() + } + + fun getDate(field: String): Date? { + val timestamp = getTimestamp(field) + return timestamp?.toDate() + } + + fun getTimestamp(field: String): Timestamp? { + return get(field) as Timestamp? + } + + fun getBlob(field: String): Blob? { + return get(field) as Blob? + } + + fun getGeoPoint(field: String): GeoPoint? { + return get(field) as GeoPoint? + } + + val isEmpty: Boolean + get() = protoFields == null || protoFields.isEmpty() +} From f20e409df78c9fffbeb7298f38dfc0da3d934f1f Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 11 Mar 2024 11:42:52 -0400 Subject: [PATCH 20/45] fixing compilation error and add some high level comments --- .../com/google/cloud/firestore/Firestore.java | 3 +- .../google/cloud/firestore/FirestoreImpl.java | 3 +- .../com/google/cloud/firestore/Pipeline.kt | 31 +++++++++++++++++++ .../cloud/firestore/it/ITPipelineTest.java | 13 ++++---- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java index 48e977892..1b925057d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java @@ -24,6 +24,7 @@ import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import kotlin.collections.Iterator; /** Represents a Firestore Database and is the entry point for all Firestore operations */ @InternalExtensionOnly @@ -287,7 +288,7 @@ void getAll( @Nonnull FirestoreBundle.Builder bundleBuilder(@Nonnull String bundleId); - ApiFuture execute(Pipeline pipeline); + ApiFuture> execute(Pipeline pipeline); /** * Closes the gRPC channels associated with this instance and frees up their resources. This diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java index bc4f45bf2..e1ff9d964 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -48,6 +48,7 @@ import java.util.Random; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import kotlin.collections.Iterator; import org.threeten.bp.Duration; /** @@ -409,7 +410,7 @@ public FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId) { } @Override - public ApiFuture execute(Pipeline pipeline) { + public ApiFuture> execute(Pipeline pipeline) { return null; } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 9a732da0e..48a7da3b3 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -85,6 +85,37 @@ class PaginatingPipeline internal constructor( } } +/** + * The Pipeline class provides a flexible and expressive framework for building complex data transformation + * and query pipelines for Firestore. + * + * A pipeline takes data sources such as Firestore collections, collection groups, or even in-memory data, and + * applies a series of operations that are chained together, each operation takes the output from the last + * operation (or the data source) and produces an output for the next operation (or as the final output of the pipeline). + * + * Usage Examples: + * + * **1. Projecting Specific Fields and Renaming:** + * ```java + * Pipeline pipeline = Pipeline.fromCollection("users") + * // Select 'name' and 'email' fields, create 'userAge' which is renamed from field 'age'. + * .project(Fields.of("name", "email"), Field.of("age").asAlias("userAge")) + * ``` + * + * **2. Filtering and Sorting:** + * ```java + * Pipeline pipeline = Pipeline.fromCollectionGroup("reviews") + * .filter(Field.of("rating").greaterThan(Expr.Constant.of(3))) // High ratings + * .sort(Ordering.of("timestamp").descending()); + * ``` + * + * **3. Aggregation with Grouping:** + * ```java + * Pipeline pipeline = Pipeline.fromCollection("orders") + * .group(Field.of("customerId")) + * .aggregate(count(Field.of("orderId")).asAlias("orderCount")); + * ``` + */ class Pipeline { internal val operations: MutableList = mutableListOf() private var name: String diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index ac0b4f5ad..7ab2af51e 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -38,6 +38,7 @@ import com.google.cloud.firestore.pipeline.FindNearest.Similarity; import com.google.cloud.firestore.pipeline.Ordering; import com.google.cloud.firestore.pipeline.Ordering.Direction; +import java.util.Iterator; import org.junit.Before; import org.junit.Test; @@ -185,10 +186,10 @@ public void pagination() throws Exception { cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)); - PipelineResult result = firestore.execute(p.firstPage()).get(); - PipelineResult second = firestore.execute(p.startAfter(result)).get(); + Iterator result = firestore.execute(p.firstPage()).get(); + Iterator second = firestore.execute(p.startAfter(result.next())).get(); // potentially expensive but possible - PipelineResult page100 = firestore.execute(p.page(100)).get(); + Iterator page100 = firestore.execute(p.page(100)).get(); } @Test @@ -202,9 +203,9 @@ public void fluentAllTheWay() throws Exception { cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)); - PipelineResult result = p.firstPage().execute(firestore).get(); - PipelineResult second = p.startAfter(result).execute(firestore).get(); + Iterator result = p.firstPage().execute(firestore).get(); + Iterator second = p.startAfter(result.next()).execute(firestore).get(); // potentially expensive but possible - PipelineResult page100 = p.page(100).execute(firestore).get(); + Iterator page100 = p.page(100).execute(firestore).get(); } } From 742d3c4035b3640973712c445d5995a78d7c7cf7 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 11 Mar 2024 14:57:24 -0400 Subject: [PATCH 21/45] tweaks --- .../src/main/java/com/google/cloud/firestore/Pipeline.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 48a7da3b3..6816412bf 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -93,6 +93,9 @@ class PaginatingPipeline internal constructor( * applies a series of operations that are chained together, each operation takes the output from the last * operation (or the data source) and produces an output for the next operation (or as the final output of the pipeline). * + * NOTE: the chained operations are not a prescription of exactly how Firestore will execute the pipeline, + * instead Firestore only guarantee the result is the same as if the chained operations are executed in order. + * * Usage Examples: * * **1. Projecting Specific Fields and Renaming:** From 7c67e997c119b191c732d55a8d0d22d7c8f94d6e Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 11 Mar 2024 15:46:03 -0400 Subject: [PATCH 22/45] fix errors --- .../java/com/google/cloud/firestore/pipeline/Expressions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 791d60cea..a5bee8ace 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -165,7 +165,7 @@ sealed interface Expr { fun inAny(vararg other: Expr) = Function.In(this, other.toList()) infix fun lessThan(other: Expr) = Function.LessThan(this, other) infix fun lessThanOrEqual(other: Expr) = Function.LessThanOrEqual(this, other) - fun notInAny(left: Expr, vararg other: Expr) = Function.NotIn(left, other.toList()) + fun notInAny(vararg other: Expr) = Function.NotIn(this, other.toList()) fun exists() = Function.Exists(this as Field) From ba521a0678b45c9df5065d0b8ebe75e7a21de5ac Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 12 Mar 2024 10:54:15 -0400 Subject: [PATCH 23/45] fix errors --- .../com/google/cloud/firestore/Firestore.java | 2 +- .../google/cloud/firestore/FirestoreImpl.java | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java index 1b925057d..ac552d80d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java @@ -21,10 +21,10 @@ import com.google.api.core.InternalExtensionOnly; import com.google.api.gax.rpc.ApiStreamObserver; import com.google.cloud.Service; +import java.util.Iterator; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import kotlin.collections.Iterator; /** Represents a Firestore Database and is the entry point for all Firestore operations */ @InternalExtensionOnly diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java index e1ff9d964..32ef27b6b 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -18,6 +18,7 @@ import com.google.api.core.ApiClock; import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; import com.google.api.core.NanoClock; import com.google.api.core.SettableApiFuture; import com.google.api.gax.rpc.ApiStreamObserver; @@ -29,6 +30,8 @@ import com.google.api.gax.rpc.StreamController; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.Timestamp; +import com.google.cloud.firestore.Transaction.AsyncFunction; +import com.google.cloud.firestore.Transaction.Function; import com.google.cloud.firestore.spi.v1.FirestoreRpc; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; @@ -43,12 +46,12 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import kotlin.collections.Iterator; import org.threeten.bp.Duration; /** @@ -365,7 +368,7 @@ public CollectionGroup collectionGroup(@Nonnull final String collectionId) { @Nonnull @Override - public ApiFuture runTransaction(@Nonnull final Transaction.Function updateFunction) { + public ApiFuture runTransaction(@Nonnull final Function updateFunction) { return runAsyncTransaction( new TransactionAsyncAdapter<>(updateFunction), TransactionOptions.create()); } @@ -373,7 +376,7 @@ public ApiFuture runTransaction(@Nonnull final Transaction.Function up @Nonnull @Override public ApiFuture runTransaction( - @Nonnull final Transaction.Function updateFunction, + @Nonnull final Function updateFunction, @Nonnull TransactionOptions transactionOptions) { return runAsyncTransaction(new TransactionAsyncAdapter<>(updateFunction), transactionOptions); } @@ -381,14 +384,14 @@ public ApiFuture runTransaction( @Nonnull @Override public ApiFuture runAsyncTransaction( - @Nonnull final Transaction.AsyncFunction updateFunction) { + @Nonnull final AsyncFunction updateFunction) { return runAsyncTransaction(updateFunction, TransactionOptions.create()); } @Nonnull @Override public ApiFuture runAsyncTransaction( - @Nonnull final Transaction.AsyncFunction updateFunction, + @Nonnull final AsyncFunction updateFunction, @Nonnull TransactionOptions transactionOptions) { TransactionRunner transactionRunner = @@ -411,7 +414,7 @@ public FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId) { @Override public ApiFuture> execute(Pipeline pipeline) { - return null; + return ApiFutures.immediateFuture(null); } /** Returns the name of the Firestore project associated with this client. */ @@ -497,10 +500,10 @@ public void shutdownNow() { closed = true; } - private static class TransactionAsyncAdapter implements Transaction.AsyncFunction { - private final Transaction.Function syncFunction; + private static class TransactionAsyncAdapter implements AsyncFunction { + private final Function syncFunction; - public TransactionAsyncAdapter(Transaction.Function syncFunction) { + public TransactionAsyncAdapter(Function syncFunction) { this.syncFunction = syncFunction; } From 6ae7b13093466b861d1ee7f75d290a34752f38be Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 12 Mar 2024 16:14:52 -0400 Subject: [PATCH 24/45] Add function composition example. --- .../google/cloud/firestore/FirestoreImpl.java | 6 ++---- .../cloud/firestore/pipeline/Expressions.kt | 16 +++++++++++++++ .../cloud/firestore/it/ITPipelineTest.java | 20 +++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java index 32ef27b6b..618b27d0d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -376,15 +376,13 @@ public ApiFuture runTransaction(@Nonnull final Function updateFunction @Nonnull @Override public ApiFuture runTransaction( - @Nonnull final Function updateFunction, - @Nonnull TransactionOptions transactionOptions) { + @Nonnull final Function updateFunction, @Nonnull TransactionOptions transactionOptions) { return runAsyncTransaction(new TransactionAsyncAdapter<>(updateFunction), transactionOptions); } @Nonnull @Override - public ApiFuture runAsyncTransaction( - @Nonnull final AsyncFunction updateFunction) { + public ApiFuture runAsyncTransaction(@Nonnull final AsyncFunction updateFunction) { return runAsyncTransaction(updateFunction, TransactionOptions.create()); } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index a5bee8ace..f1ebc6d76 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -145,6 +145,11 @@ sealed interface Expr { data class Avg(val value: Expr) : Function("avg", mapOf("value" to value)), Accumulator data class Count(val value: Expr) : Function("count", mapOf("value" to value)), Accumulator + // String manipulation + data class Concat(val value: List) : Function("concat", mapOf("value" to ListOfExprs(value))) + data class Trim(val value: Expr) : Function("trim", mapOf("value" to value)) + data class ToLower(val value: Expr) : Function("toLower", mapOf("value" to value)) + data class CosineDistance(val vector1: Expr, val vector2: Expr) : Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) @@ -178,6 +183,10 @@ sealed interface Expr { fun sum() = Function.Sum(this) fun avg() = Function.Avg(this) fun count() = Function.Count(this) + + fun toLower() = Function.Count(this) + fun trim() = Function.Count(this) + infix fun cosineDistance(other: Expr) = Function.CosineDistance(this, other) infix fun cosineDistance(other: DoubleArray) = Function.CosineDistance(this, Constant.ofVector(other)) @@ -280,6 +289,13 @@ sealed interface Expr { @JvmStatic fun count(expr: Expr) = Function.Count(expr) + @JvmStatic + fun concat(vararg expr: Expr) = Function.Concat(expr.toList()) + @JvmStatic + fun trim(expr: Expr) = Function.Trim(expr) + @JvmStatic + fun toLower(expr: Expr) = Function.ToLower(expr) + @JvmStatic fun cosineDistance(expr: Expr, other: Expr) = Function.CosineDistance(expr, other) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 7ab2af51e..3c5889e96 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -18,11 +18,14 @@ import static com.google.cloud.firestore.pipeline.Expr.and; import static com.google.cloud.firestore.pipeline.Expr.avg; +import static com.google.cloud.firestore.pipeline.Expr.concat; import static com.google.cloud.firestore.pipeline.Expr.cosineDistance; import static com.google.cloud.firestore.pipeline.Expr.equal; import static com.google.cloud.firestore.pipeline.Expr.lessThan; import static com.google.cloud.firestore.pipeline.Expr.not; import static com.google.cloud.firestore.pipeline.Expr.or; +import static com.google.cloud.firestore.pipeline.Expr.toLower; +import static com.google.cloud.firestore.pipeline.Expr.trim; import static com.google.cloud.firestore.pipeline.Ordering.ascending; import static com.google.cloud.firestore.pipeline.Ordering.descending; @@ -33,6 +36,7 @@ import com.google.cloud.firestore.PipelineResult; import com.google.cloud.firestore.pipeline.Expr.Constant; import com.google.cloud.firestore.pipeline.Expr.Field; +import com.google.cloud.firestore.pipeline.Expr.Function; import com.google.cloud.firestore.pipeline.Fields; import com.google.cloud.firestore.pipeline.FindNearest.FindNearestOptions; import com.google.cloud.firestore.pipeline.FindNearest.Similarity; @@ -208,4 +212,20 @@ public void fluentAllTheWay() throws Exception { // potentially expensive but possible Iterator page100 = p.page(100).execute(firestore).get(); } + + @Test + public void functionComposition() throws Exception { + // A normalized value by joining the first and last name, triming surrounding whitespace and + // convert to lower case + Function normalized = concat(Field.of("first_name"), Constant.of(" "), Field.of("last_name")); + normalized = trim(normalized); + normalized = toLower(normalized); + + Pipeline p = + Pipeline.fromCollection("users") + .filter( + or( + normalized.equal(Constant.of("john smith")), + normalized.equal(Constant.of("alice baker")))); + } } From c1825e0a65a3c2672baa3d68ef575bed7d66fb33 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Wed, 13 Mar 2024 14:28:08 -0400 Subject: [PATCH 25/45] build into a single jar --- google-cloud-firestore/pom.xml | 8 ++++++++ .../com/google/cloud/firestore/pipeline/Expressions.kt | 1 + 2 files changed, 9 insertions(+) diff --git a/google-cloud-firestore/pom.xml b/google-cloud-firestore/pom.xml index b065677b3..8bf510d36 100644 --- a/google-cloud-firestore/pom.xml +++ b/google-cloud-firestore/pom.xml @@ -262,6 +262,14 @@ 1.8 + + maven-assembly-plugin + + + jar-with-dependencies + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index f1ebc6d76..c8bb8ed90 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -184,6 +184,7 @@ sealed interface Expr { fun avg() = Function.Avg(this) fun count() = Function.Count(this) + fun concatWith(vararg expr: Expr) = Function.Concat(listOf(this) + expr.toList()) fun toLower() = Function.Count(this) fun trim() = Function.Count(this) From 0fe5faa26e082129357183ab2f227cf1e5895e49 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Fri, 15 Mar 2024 11:42:33 -0400 Subject: [PATCH 26/45] better aliasing for joins --- .../main/java/com/google/cloud/firestore/Pipeline.kt | 9 --------- .../com/google/cloud/firestore/pipeline/Expressions.kt | 10 ++++++++++ .../com/google/cloud/firestore/it/ITPipelineTest.java | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 6816412bf..cb79fed2e 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -174,15 +174,6 @@ class Pipeline { return Pipeline(Database()) } } - - fun fieldOf(name: String): Field { - return Field(name, this) - } - - fun fieldOfAll(): AllFields { - return AllFields(this) - } - // Fluent API fun withName(name: String) { diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index c8bb8ed90..fe15b7eb1 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -60,6 +60,16 @@ sealed interface Expr { fun ofAll(): AllFields { return AllFields() } + + @JvmStatic + fun fromPipeline(pipeline: Pipeline, path: String): Field { + return Field(path) + } + + @JvmStatic + fun allFromPipeline(pipeline: Pipeline): AllFields { + return AllFields() + } } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 3c5889e96..681ef3ba5 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -148,14 +148,15 @@ public void joins() throws Exception { .innerJoin(p) .on( and( - Field.of("foo").equal(p.fieldOf("bar")), - p.fieldOf("requirement").greaterThan(Field.of("distance")))); + Field.of("foo").equal(Field.fromPipeline(p, "bar")), + Field.fromPipeline(p, "requirement").greaterThan(Field.of("distance")))); Pipeline another = Pipeline.fromCollection("users") .innerJoin(p) .on(Fields.of("foo", "bar")) - .project(Field.ofAll().withPrefix("left"), p.fieldOfAll().withPrefix("right")); + .project( + Field.ofAll().withPrefix("left"), Field.allFromPipeline(p).withPrefix("right")); } @Test From 7ab3099212cc8ec145d41a7590e3db0885285150 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 18 Mar 2024 15:57:41 -0400 Subject: [PATCH 27/45] add stuff to support challenges --- .../com/google/cloud/firestore/Pipeline.kt | 13 +++-- .../cloud/firestore/pipeline/Expressions.kt | 52 +++++++++++++------ .../cloud/firestore/pipeline/Operations.kt | 4 +- .../cloud/firestore/it/ITPipelineTest.java | 1 + 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index cb79fed2e..6f5925c39 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -8,7 +8,6 @@ import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup import com.google.cloud.firestore.pipeline.Database import com.google.cloud.firestore.pipeline.Expr -import com.google.cloud.firestore.pipeline.Expr.AllFields import com.google.cloud.firestore.pipeline.Expr.Field import com.google.cloud.firestore.pipeline.Fields import com.google.cloud.firestore.pipeline.Filter @@ -25,7 +24,8 @@ import com.google.cloud.firestore.pipeline.Projectable import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.UnionWith -import com.google.cloud.firestore.pipeline.Unnest +import com.google.cloud.firestore.pipeline.UnnestArray +import com.google.cloud.firestore.pipeline.UnnestMap class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { @@ -305,8 +305,13 @@ class Pipeline { return this } - fun unnest(field: Field, mode: Unnest.Mode = Unnest.Mode.FULL_REPLACE): Pipeline { - operations.add(Unnest(mode, field)) + fun unnestMap(field: Field, mode: UnnestMap.Mode = UnnestMap.Mode.FULL_REPLACE): Pipeline { + operations.add(UnnestMap(mode, field)) + return this + } + + fun unnestArray(field: Field): Pipeline { + operations.add(UnnestArray(field)) return this } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index fe15b7eb1..4e538a2d8 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -32,6 +32,11 @@ sealed interface Expr { return Constant(value) } + @JvmStatic + fun of(value: Any): Constant { + return Constant(value) + } + @JvmStatic fun ofArray(value: Iterable): Constant { return Constant(value) @@ -51,6 +56,8 @@ sealed interface Expr { data class Field(val field: String, var pipeline: Pipeline? = null) : Expr, Projectable { companion object { + const val DOCUMENT_ID: String = "__path__" + @JvmStatic fun of(path: String): Field { return Field(path) @@ -83,15 +90,24 @@ sealed interface Expr { data class ExprAsAlias(val current: Expr, val alias: String) : Expr, Projectable - data class AggregatorTarget(val current: Function.Accumulator, val target: String) : Expr, - Projectable, - Function.Accumulator + data class AggregatorTarget(val current: Function.Accumulator, val target: String, + override var distinct: Boolean + ) : Expr, + Projectable, + Function.Accumulator sealed class Function(val name: String, val params: Map?) : Expr { interface FilterCondition interface Accumulator { - fun toField(target: String) = AggregatorTarget(this, target) + var distinct: Boolean + + fun distinct(on: Boolean): Accumulator { + this.distinct = on + return this + } + + fun toField(target: String) = AggregatorTarget(this, target, this.distinct) } data class Equal internal constructor(val left: Expr, val right: Expr) : @@ -151,14 +167,15 @@ sealed interface Expr { data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), FilterCondition - data class Sum(val value: Expr) : Function("sum", mapOf("value" to value)), Accumulator - data class Avg(val value: Expr) : Function("avg", mapOf("value" to value)), Accumulator - data class Count(val value: Expr) : Function("count", mapOf("value" to value)), Accumulator + data class Sum(val value: Expr, override var distinct: Boolean) : Function("sum", mapOf("value" to value)), Accumulator + data class Avg(val value: Expr, override var distinct: Boolean) : Function("avg", mapOf("value" to value)), Accumulator + data class Count(val value: Expr, override var distinct: Boolean) : Function("count", mapOf("value" to value)), Accumulator // String manipulation data class Concat(val value: List) : Function("concat", mapOf("value" to ListOfExprs(value))) data class Trim(val value: Expr) : Function("trim", mapOf("value" to value)) data class ToLower(val value: Expr) : Function("toLower", mapOf("value" to value)) + data class StartWith(val value: Expr, val query: Expr) : Function("startWith", mapOf("value" to value)), FilterCondition data class CosineDistance(val vector1: Expr, val vector2: Expr) : Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) @@ -190,13 +207,15 @@ sealed interface Expr { fun arrayContainsAny(vararg elements: Expr) = Function.ArrayContainsAny(this, elements.toList()) fun isNaN() = Function.IsNaN(this) fun isNull() = Function.IsNull(this) - fun sum() = Function.Sum(this) - fun avg() = Function.Avg(this) - fun count() = Function.Count(this) + fun sum() = Function.Sum(this, false) + fun avg() = Function.Avg(this, false) + fun count() = Function.Count(this, false) fun concatWith(vararg expr: Expr) = Function.Concat(listOf(this) + expr.toList()) - fun toLower() = Function.Count(this) - fun trim() = Function.Count(this) + fun toLower() = Function.ToLower(this) + fun trim() = Function.Trim(this) + + fun startsWith(expr: Expr) = Function.StartWith(this, expr) infix fun cosineDistance(other: Expr) = Function.CosineDistance(this, other) infix fun cosineDistance(other: DoubleArray) = @@ -292,13 +311,13 @@ sealed interface Expr { fun not(expr: Expr) = Function.Not(expr) @JvmStatic - fun sum(expr: Expr) = Function.Sum(expr) + fun sum(expr: Expr) = Function.Sum(expr, false) @JvmStatic - fun avg(expr: Expr) = Function.Avg(expr) + fun avg(expr: Expr) = Function.Avg(expr, false) @JvmStatic - fun count(expr: Expr) = Function.Count(expr) + fun count(expr: Expr) = Function.Count(expr, false) @JvmStatic fun concat(vararg expr: Expr) = Function.Concat(expr.toList()) @@ -307,6 +326,9 @@ sealed interface Expr { @JvmStatic fun toLower(expr: Expr) = Function.ToLower(expr) + @JvmStatic + fun startWith(left: Expr, right: Expr) = Function.StartWith(left, right) + @JvmStatic fun cosineDistance(expr: Expr, other: Expr) = Function.CosineDistance(expr, other) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt index 4eda29256..ec22a250b 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt @@ -122,7 +122,7 @@ data class Sort( } } -data class Unnest(val mode: Mode, val field: Expr.Field) : Operation { +data class UnnestMap(val mode: Mode, val field: Expr.Field) : Operation { enum class Mode { FULL_REPLACE, MERGE_PREFER_NEST, @@ -130,5 +130,7 @@ data class Unnest(val mode: Mode, val field: Expr.Field) : Operation { } } +data class UnnestArray(val field: Expr.Field) : Operation + data class GenericOperation(val name: String, val params: Map?) : Operation diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 681ef3ba5..da6c6710b 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -64,6 +64,7 @@ public void pipelineWithDb() throws Exception { public void projections() throws Exception { Pipeline p = Pipeline.fromCollection("coll1") + .unnestMap(Field.of("foo")) .project( Field.of("foo"), Constant.of("emptyValue").asAlias("emptyField"), From 57f0b745cd619af993c2bcabb9d95316fd681fdf Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 8 Apr 2024 10:47:42 -0400 Subject: [PATCH 28/45] edits --- .../src/main/java/com/google/cloud/firestore/Pipeline.kt | 1 + .../test/java/com/google/cloud/firestore/it/ITPipelineTest.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 6f5925c39..5309c4f21 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -305,6 +305,7 @@ class Pipeline { return this } + @JvmOverloads fun unnestMap(field: Field, mode: UnnestMap.Mode = UnnestMap.Mode.FULL_REPLACE): Pipeline { operations.add(UnnestMap(mode, field)) return this diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index da6c6710b..681ef3ba5 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -64,7 +64,6 @@ public void pipelineWithDb() throws Exception { public void projections() throws Exception { Pipeline p = Pipeline.fromCollection("coll1") - .unnestMap(Field.of("foo")) .project( Field.of("foo"), Constant.of("emptyValue").asAlias("emptyField"), From 0629026d27782bf824955d8ad8b55bc55f20aee2 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 9 Apr 2024 14:47:52 -0400 Subject: [PATCH 29/45] Initial PP pipeline api --- .../com/google/cloud/firestore/Pipeline.kt | 186 +------ .../google/cloud/firestore/PipelineResult.kt | 3 +- .../cloud/firestore/pipeline/Expressions.kt | 509 ++++++++++-------- .../cloud/firestore/pipeline/Operations.kt | 136 ----- .../google/cloud/firestore/pipeline/Stages.kt | 93 ++++ .../cloud/firestore/it/ITPipelineTest.java | 104 +--- .../proto/google/firestore/v1/document.proto | 113 ++++ .../proto/google/firestore/v1/firestore.proto | 86 +++ .../proto/google/firestore/v1/pipeline.proto | 26 + 9 files changed, 633 insertions(+), 623 deletions(-) delete mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt create mode 100644 proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 5309c4f21..7c5a39cf7 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -3,57 +3,20 @@ package com.google.cloud.firestore import com.google.api.core.ApiFuture import com.google.api.core.ApiFutures import com.google.api.gax.rpc.ApiStreamObserver -import com.google.cloud.firestore.pipeline.AddFields +import com.google.cloud.firestore.pipeline.AggregatorTarget import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup -import com.google.cloud.firestore.pipeline.Database -import com.google.cloud.firestore.pipeline.Expr -import com.google.cloud.firestore.pipeline.Expr.Field -import com.google.cloud.firestore.pipeline.Fields +import com.google.cloud.firestore.pipeline.Field import com.google.cloud.firestore.pipeline.Filter import com.google.cloud.firestore.pipeline.FindNearest -import com.google.cloud.firestore.pipeline.GenericOperation -import com.google.cloud.firestore.pipeline.Group -import com.google.cloud.firestore.pipeline.Join +import com.google.cloud.firestore.pipeline.Function +import com.google.cloud.firestore.pipeline.GenericStage import com.google.cloud.firestore.pipeline.Limit import com.google.cloud.firestore.pipeline.Offset -import com.google.cloud.firestore.pipeline.Operation import com.google.cloud.firestore.pipeline.Ordering -import com.google.cloud.firestore.pipeline.Project import com.google.cloud.firestore.pipeline.Projectable -import com.google.cloud.firestore.pipeline.RemoveFields import com.google.cloud.firestore.pipeline.Sort -import com.google.cloud.firestore.pipeline.UnionWith -import com.google.cloud.firestore.pipeline.UnnestArray -import com.google.cloud.firestore.pipeline.UnnestMap - -class GroupingPipeline internal constructor(val p: Pipeline, vararg val by: Projectable) { - fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { - // TODO: this.p.operations.add() - return this.p - } -} - -class JoiningPipeline internal constructor( - val left: Pipeline, - val right: Pipeline, - val join: Join.Type -) { - fun on(condition: Expr.Function): Pipeline { - // TODO: this.p.operations.add() - return left - } - - fun on(vararg field: Field): Pipeline { - // TODO: this.p.operations.add() - return left - } - - fun on(field: Fields): Pipeline { - // TODO: this.p.operations.add() - return left - } -} +import com.google.cloud.firestore.pipeline.Stage class PaginatingPipeline internal constructor( val p: Pipeline, @@ -64,10 +27,6 @@ class PaginatingPipeline internal constructor( return this.p } - fun page(n:Int): Pipeline { - return this.p - } - fun startAt(result: PipelineResult): Pipeline { return this.p } @@ -120,21 +79,16 @@ class PaginatingPipeline internal constructor( * ``` */ class Pipeline { - internal val operations: MutableList = mutableListOf() + private val stages: MutableList = mutableListOf() private var name: String - private constructor(db: Database) { - operations.add(db) - name = "(database)" - } - private constructor(collection: Collection) { - operations.add(collection) + stages.add(collection) name = collection.path } private constructor(group: CollectionGroup) { - operations.add(group) + stages.add(group) name = group.path } @@ -158,97 +112,28 @@ class Pipeline { fun fromCollectionGroup(group: String): Pipeline { return Pipeline(CollectionGroup(group)) } - - @JvmStatic - fun fromDatabase(): Pipeline { - return Pipeline(Database()) - } - - @JvmStatic - fun fromDocuments(vararg docPath :String): Pipeline { - return Pipeline(Database()) - } - - @JvmStatic - fun fromData(vararg doc: Map>): Pipeline { - return Pipeline(Database()) - } - } - // Fluent API - - fun withName(name: String) { - this.name = name - } - - fun project(projections: Map): Pipeline { - operations.add(Project(projections)) - return this - } - - // Sugar for project - fun project(vararg fields: Field): Pipeline { - return this - } - - fun project(vararg exprs: Expr.ExprAsAlias): Pipeline { - return this } fun project(vararg projections: Projectable): Pipeline { return this } - fun addFields(additions: Map): Pipeline { - operations.add(AddFields(additions)) - return this - } - - // Sugar - fun addFields(vararg additions: Expr.ExprAsAlias): Pipeline { - return this - } - - fun removeFields(vararg removals: Field): Pipeline { - operations.add(RemoveFields(removals.toList())) - return this - } - - fun filter(condition: Expr.Function.FilterCondition): Pipeline { - operations.add(Filter(condition)) + fun filter(condition: Function.FilterCondition): Pipeline { + stages.add(Filter(condition)) return this } fun offset(offset: Int): Pipeline { - operations.add(Offset(offset)) + stages.add(Offset(offset)) return this } fun limit(limit: Int): Pipeline { - operations.add(Limit(limit)) - return this - } - - fun unionWith(pipeline: Pipeline, distinct: Boolean): Pipeline { - operations.add(UnionWith(pipeline, distinct)) + stages.add(Limit(limit)) return this } - fun group(fields: Map, accumulators: Map): Pipeline { - operations.add(Group(fields, accumulators)) - return this - } - - fun group(by: Fields): GroupingPipeline { - // operations.add(Group(fields, accumulators)) - return GroupingPipeline(this /*TODO*/) - } - - fun group(by: Projectable): GroupingPipeline { - // operations.add(Group(fields, accumulators)) - return GroupingPipeline(this /*TODO*/) - } - - fun aggregate(vararg aggregator: Expr.AggregatorTarget): Pipeline { + fun aggregate(vararg aggregator: AggregatorTarget): Pipeline { // operations.add(Group()) // operations.add(aggregator) return this @@ -259,44 +144,16 @@ class Pipeline { vector: DoubleArray, options: FindNearest.FindNearestOptions ): Pipeline { - operations.add(FindNearest(property, vector, options)) + stages.add(FindNearest(property, vector, options)) return this } - fun innerJoin( - otherPipeline: Pipeline - ) = JoiningPipeline(this, otherPipeline, Join.Type.INNER) - - fun crossJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.CROSS) - - fun fullJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.FULL) - - fun leftJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.LEFT) - - fun rightJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.RIGHT) - - fun leftSemiJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.LEFT_SEMI) - - fun rightSemiJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_SEMI) - - fun leftAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.LEFT_ANTI_SEMI) - - fun rightAntiSemiJoin(otherPipeline: Pipeline): JoiningPipeline = - JoiningPipeline(this, otherPipeline, Join.Type.RIGHT_ANTI_SEMI) - fun sort( orders: List, density: Sort.Density = Sort.Density.UNSPECIFIED, truncation: Sort.Truncation = Sort.Truncation.UNSPECIFIED ): Pipeline { - operations.add(Sort(orders, density, truncation)) + stages.add(Sort(orders, density, truncation)) return this } @@ -305,23 +162,12 @@ class Pipeline { return this } - @JvmOverloads - fun unnestMap(field: Field, mode: UnnestMap.Mode = UnnestMap.Mode.FULL_REPLACE): Pipeline { - operations.add(UnnestMap(mode, field)) - return this - } - - fun unnestArray(field: Field): Pipeline { - operations.add(UnnestArray(field)) - return this - } - fun paginate(pageSize: Int, vararg orders: Ordering): PaginatingPipeline { return PaginatingPipeline(this, pageSize, orders) } fun genericOperation(name: String, params: Map? = null): Pipeline { - operations.add(GenericOperation(name, params)) + stages.add(GenericStage(name, params)) return this } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt index 6dae35e11..9bf617c74 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -5,8 +5,7 @@ import com.google.firestore.v1.Value import java.util.Date import javax.annotation.Nonnull -data class PipelineResult // Elevated access level for mocking. -internal constructor( +data class PipelineResult internal constructor( private val rpcContext: FirestoreRpcContext<*>?, val reference: DocumentReference?, val protoFields: Map?, diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 4e538a2d8..56fc06462 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -1,356 +1,417 @@ package com.google.cloud.firestore.pipeline import com.google.cloud.firestore.Pipeline +import com.google.cloud.firestore.pipeline.Function.ArrayContains +import com.google.cloud.firestore.pipeline.Function.ArrayContainsAny +import com.google.cloud.firestore.pipeline.Function.Avg +import com.google.cloud.firestore.pipeline.Function.CosineDistance +import com.google.cloud.firestore.pipeline.Function.Count +import com.google.cloud.firestore.pipeline.Function.DotProductDistance +import com.google.cloud.firestore.pipeline.Function.Equal +import com.google.cloud.firestore.pipeline.Function.EuclideanDistance +import com.google.cloud.firestore.pipeline.Function.GreaterThan +import com.google.cloud.firestore.pipeline.Function.GreaterThanOrEqual +import com.google.cloud.firestore.pipeline.Function.In +import com.google.cloud.firestore.pipeline.Function.IsNaN +import com.google.cloud.firestore.pipeline.Function.IsNull +import com.google.cloud.firestore.pipeline.Function.LessThan +import com.google.cloud.firestore.pipeline.Function.LessThanOrEqual +import com.google.cloud.firestore.pipeline.Function.MapGet +import com.google.cloud.firestore.pipeline.Function.NotEqual +import com.google.cloud.firestore.pipeline.Function.NotIn +import com.google.cloud.firestore.pipeline.Function.Sum import com.google.firestore.v1.Value -interface Projectable +sealed interface Projectable + +sealed interface Expr { + // Infix functions returning Function subclasses + infix fun equal(other: Expr) = Equal(this, other) + infix fun equal(other: Number) = Equal(this, Constant.of(other)) + infix fun equal(other: String) = Equal(this, Constant.of(other)) + infix fun equal(other: Any) = Equal(this, Constant.of(other)) + infix fun notEqual(other: Expr) = NotEqual(this, other) + infix fun notEqual(other: Number) = NotEqual(this, Constant.of(other)) + infix fun notEqual(other: String) = NotEqual(this, Constant.of(other)) + infix fun notEqual(other: Any) = NotEqual(this, Constant.of(other)) + infix fun greaterThan(other: Expr) = GreaterThan(this, other) + infix fun greaterThan(other: Number) = GreaterThan(this, Constant.of(other)) + infix fun greaterThan(other: String) = GreaterThan(this, Constant.of(other)) + infix fun greaterThan(other: Any) = GreaterThan(this, Constant.of(other)) + infix fun greaterThanOrEqual(other: Expr) = GreaterThanOrEqual(this, other) + infix fun greaterThanOrEqual(other: Number) = GreaterThanOrEqual(this, Constant.of(other)) + infix fun greaterThanOrEqual(other: String) = GreaterThanOrEqual(this, Constant.of(other)) + infix fun greaterThanOrEqual(other: Any) = GreaterThanOrEqual(this, Constant.of(other)) + infix fun lessThan(other: Expr) = LessThan(this, other) + infix fun lessThan(other: Number) = LessThan(this, Constant.of(other)) + infix fun lessThan(other: String) = LessThan(this, Constant.of(other)) + infix fun lessThan(other: Any) = LessThan(this, Constant.of(other)) + infix fun lessThanOrEqual(other: Expr) = LessThanOrEqual(this, other) + infix fun lessThanOrEqual(other: Number) = LessThanOrEqual(this, Constant.of(other)) + infix fun lessThanOrEqual(other: String) = LessThanOrEqual(this, Constant.of(other)) + infix fun lessThanOrEqual(other: Any) = LessThanOrEqual(this, Constant.of(other)) + fun inAny(vararg other: Expr) = In(this, other.toList()) + fun notInAny(vararg other: Expr) = NotIn(this, other.toList()) + + infix fun mapGet(key: String) = MapGet(this, key) + + infix fun arrayContains(element: Expr) = ArrayContains(this, element) + infix fun arrayContains(element: Number) = ArrayContains(this, Constant.of(element)) + infix fun arrayContains(element: String) = ArrayContains(this, Constant.of(element)) + infix fun arrayContains(element: Any) = ArrayContains(this, Constant.of(element)) + fun arrayContainsAny(vararg elements: Expr) = ArrayContainsAny(this, elements.toList()) + fun isNaN() = IsNaN(this) + fun isNull() = IsNull(this) + fun sum() = Sum(this, false) + fun avg() = Avg(this, false) + fun count() = Count(this, false) + + infix fun cosineDistance(other: Expr) = CosineDistance(this, other) + infix fun cosineDistance(other: DoubleArray) = + CosineDistance(this, Constant.ofVector(other)) + + infix fun euclideanDistance(other: Expr) = EuclideanDistance(this, other) + infix fun euclideanDistance(other: DoubleArray) = + EuclideanDistance(this, Constant.ofVector(other)) + + infix fun dotProductDistance(other: Expr) = DotProductDistance(this, other) + infix fun dotProductDistance(other: DoubleArray) = + DotProductDistance(this, Constant.ofVector(other)) + + fun asAlias(alias: String): Projectable = ExprAsAlias(this, alias) +} // Convenient class for internal usage internal data class ListOfExprs(val conditions: List) : Expr -internal data class ListOfConditions(val conditions: List) : Expr, - Expr.Function.FilterCondition - -data class Fields(val fs: List) : Projectable { +internal data class ListOfConditions(val conditions: List) : Expr, + Function.FilterCondition +data class Constant internal constructor(val value: Any) : Expr { companion object { @JvmStatic - fun of(vararg f: String): Fields { - return Fields(f.map(Expr.Field.Companion::of)) + fun of(value: String): Constant { + return Constant(value) + } + + @JvmStatic + fun of(value: Number): Constant { + return Constant(value) + } + + @JvmStatic + fun of(value: Any): Constant { + return Constant(value) + } + + @JvmStatic + fun ofArray(value: Iterable): Constant { + return Constant(value) + } + + @JvmStatic + fun ofMap(value: Map): Constant { + return Constant(value) + } + + @JvmStatic + fun ofVector(value: DoubleArray): Constant { + return Constant(value) } } } -sealed interface Expr { - data class Constant internal constructor(val value: Any) : Expr { - companion object { - @JvmStatic - fun of(value: String): Constant { - return Constant(value) - } - - @JvmStatic - fun of(value: Number): Constant { - return Constant(value) - } - - @JvmStatic - fun of(value: Any): Constant { - return Constant(value) - } - - @JvmStatic - fun ofArray(value: Iterable): Constant { - return Constant(value) - } - - @JvmStatic - fun ofMap(value: Map): Constant { - return Constant(value) - } - - @JvmStatic - fun ofVector(value: DoubleArray): Constant { - return Constant(value) - } +data class Field internal constructor(val field: String, var pipeline: Pipeline? = null) : Expr, + Projectable { + companion object { + const val DOCUMENT_ID: String = "__path__" + + @JvmStatic + fun of(path: String): Field { + return Field(path) } } - data class Field(val field: String, var pipeline: Pipeline? = null) : Expr, Projectable { - companion object { - const val DOCUMENT_ID: String = "__path__" - - @JvmStatic - fun of(path: String): Field { - return Field(path) - } - - @JvmStatic - fun ofAll(): AllFields { - return AllFields() - } - - @JvmStatic - fun fromPipeline(pipeline: Pipeline, path: String): Field { - return Field(path) - } - - @JvmStatic - fun allFromPipeline(pipeline: Pipeline): AllFields { - return AllFields() - } + fun exists() = Function.Exists(this) +} + +data class Fields internal constructor(val fs: List? = null) : Expr, Projectable { + companion object { + @JvmStatic + fun of(f1: String, vararg f: String): Fields { + return Fields(listOf(Field.of(f1)) + f.map(Field.Companion::of)) + } + + @JvmStatic + fun ofAll(): Fields { + return Fields(null) } } +} + +internal data class ExprAsAlias(val current: Expr, val alias: String) : Expr, Projectable + +data class AggregatorTarget internal constructor( + val current: Function.Accumulator, val target: String, + override var distinct: Boolean +) : Expr, + Projectable, + Function.Accumulator + +sealed class Function(val name: String, val params: Map?) : Expr { + interface FilterCondition - data class AllFields(var pipeline: Pipeline? = null) : Expr, Projectable { + interface Accumulator { + var distinct: Boolean - fun withPrefix(prefix: String): AllFields { + fun distinct(on: Boolean): Accumulator { + this.distinct = on return this } + + fun toField(target: String) = AggregatorTarget(this, target, this.distinct) } + data class Equal internal constructor(val left: Expr, val right: Expr) : + Function("equal", mapOf("left" to left, "right" to right)), FilterCondition - data class ExprAsAlias(val current: Expr, val alias: String) : Expr, Projectable + data class NotEqual(val left: Expr, val right: Expr) : + Function("not_equal", mapOf("left" to left, "right" to right)), FilterCondition - data class AggregatorTarget(val current: Function.Accumulator, val target: String, - override var distinct: Boolean - ) : Expr, - Projectable, - Function.Accumulator + data class GreaterThan(val left: Expr, val right: Expr) : + Function("greater_than", mapOf("left" to left, "right" to right)), FilterCondition - sealed class Function(val name: String, val params: Map?) : Expr { - interface FilterCondition + data class GreaterThanOrEqual(val left: Expr, val right: Expr) : + Function("greater_than_equal", mapOf("left" to left, "right" to right)), FilterCondition - interface Accumulator { - var distinct: Boolean + data class In(val left: Expr, val others: List) : + Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), + FilterCondition // For 'in' - fun distinct(on: Boolean): Accumulator { - this.distinct = on - return this - } + data class LessThan(val left: Expr, val right: Expr) : + Function("less_than", mapOf("left" to left, "right" to right)), FilterCondition - fun toField(target: String) = AggregatorTarget(this, target, this.distinct) - } + data class LessThanOrEqual(val left: Expr, val right: Expr) : + Function("less_than_equal", mapOf("left" to left, "right" to right)), FilterCondition - data class Equal internal constructor(val left: Expr, val right: Expr) : - Function("equal", mapOf("left" to left, "right" to right)), FilterCondition + data class NotIn(val left: Expr, val others: List) : + Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), + FilterCondition // For 'not in' - data class NotEqual(val left: Expr, val right: Expr) : - Function("not_equal", mapOf("left" to left, "right" to right)), FilterCondition + data class And(val conditions: List) : + Function("and", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition - data class GreaterThan(val left: Expr, val right: Expr) : - Function("greater_than", mapOf("left" to left, "right" to right)), FilterCondition + data class Or(val conditions: List) : + Function("or", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition - data class GreaterThanOrEqual(val left: Expr, val right: Expr) : - Function("greater_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), + FilterCondition - data class In(val left: Expr, val others: List) : - Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), - FilterCondition // For 'in' + data class Exists(val current: Field) : Function("exists", mapOf("current" to current)), + FilterCondition - data class LessThan(val left: Expr, val right: Expr) : - Function("less_than", mapOf("left" to left, "right" to right)), FilterCondition + data class MapGet(val map: Expr, val key: String) : Function( + "map_get", + mapOf( + "map" to map, + "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()) + ) + ) - data class LessThanOrEqual(val left: Expr, val right: Expr) : - Function("less_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + data class ArrayContains(val array: Expr, val element: Expr) : + Function("array_contains", mapOf("array" to array, "element" to element)), FilterCondition - data class NotIn(val left: Expr, val others: List) : - Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), - FilterCondition // For 'not in' + data class ArrayContainsAny(val array: Expr, val elements: List) : + Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), + FilterCondition - data class And(val conditions: List) : - Function("and", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)), FilterCondition + data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), + FilterCondition - data class Or(val conditions: List) : - Function("or", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + data class Sum(val value: Expr, override var distinct: Boolean) : + Function("sum", mapOf("value" to value)), Accumulator - data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), - FilterCondition + data class Avg(val value: Expr, override var distinct: Boolean) : + Function("avg", mapOf("value" to value)), Accumulator - data class Exists(val current: Field) : Function("exists", mapOf("current" to current)), - FilterCondition + data class Count(val value: Expr, override var distinct: Boolean) : + Function("count", mapOf("value" to value)), Accumulator - data class MapGet(val map: Expr, val key: String) : Function( - "map_get", - mapOf( - "map" to map, - "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()) - ) - ) + data class CosineDistance(val vector1: Expr, val vector2: Expr) : + Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) - data class ArrayContains(val array: Expr, val element: Expr) : - Function("array_contains", mapOf("array" to array, "element" to element)), FilterCondition + data class DotProductDistance(val vector1: Expr, val vector2: Expr) : + Function("dot_product_distance", mapOf("vector1" to vector1, "vector2" to vector2)) - data class ArrayContainsAny(val array: Expr, val elements: List) : - Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), - FilterCondition + data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : + Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) - data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)), FilterCondition - data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), - FilterCondition + data class Generic(val n: String, val ps: Map?) : Function(n, ps) - data class Sum(val value: Expr, override var distinct: Boolean) : Function("sum", mapOf("value" to value)), Accumulator - data class Avg(val value: Expr, override var distinct: Boolean) : Function("avg", mapOf("value" to value)), Accumulator - data class Count(val value: Expr, override var distinct: Boolean) : Function("count", mapOf("value" to value)), Accumulator - // String manipulation - data class Concat(val value: List) : Function("concat", mapOf("value" to ListOfExprs(value))) - data class Trim(val value: Expr) : Function("trim", mapOf("value" to value)) - data class ToLower(val value: Expr) : Function("toLower", mapOf("value" to value)) - data class StartWith(val value: Expr, val query: Expr) : Function("startWith", mapOf("value" to value)), FilterCondition + companion object { + @JvmStatic + fun equal(left: Expr, right: Expr) = Equal(left, right) - data class CosineDistance(val vector1: Expr, val vector2: Expr) : - Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + @JvmStatic + fun equal(left: Expr, right: String) = Equal(left, Constant.of(right)) - data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : - Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + @JvmStatic + fun equal(left: Expr, right: Number) = Equal(left, Constant.of(right)) - data class HasAncestor(val child: Expr, val ancestor: Expr) : - Function("has_ancestor", mapOf("child" to child, "ancestor" to ancestor)), FilterCondition + @JvmStatic + fun equal(left: Expr, right: Any) = Equal(left, Constant.of(right)) - data class Generic(val n: String, val ps: Map?) : Function(n, ps) - } + @JvmStatic + fun notEqual(left: Expr, right: Expr) = NotEqual(left, right) - // Infix functions returning Function subclasses - infix fun equal(other: Expr) = Function.Equal(this, other) - infix fun notEqual(other: Expr) = Function.NotEqual(this, other) - infix fun greaterThan(other: Expr) = Function.GreaterThan(this, other) - infix fun greaterThanOrEqual(other: Expr) = Function.GreaterThanOrEqual(this, other) - fun inAny(vararg other: Expr) = Function.In(this, other.toList()) - infix fun lessThan(other: Expr) = Function.LessThan(this, other) - infix fun lessThanOrEqual(other: Expr) = Function.LessThanOrEqual(this, other) - fun notInAny(vararg other: Expr) = Function.NotIn(this, other.toList()) - - - fun exists() = Function.Exists(this as Field) - - infix fun mapGet(key: String) = Function.MapGet(this, key) - infix fun arrayContains(element: Expr) = Function.ArrayContains(this, element) - fun arrayContainsAny(vararg elements: Expr) = Function.ArrayContainsAny(this, elements.toList()) - fun isNaN() = Function.IsNaN(this) - fun isNull() = Function.IsNull(this) - fun sum() = Function.Sum(this, false) - fun avg() = Function.Avg(this, false) - fun count() = Function.Count(this, false) - - fun concatWith(vararg expr: Expr) = Function.Concat(listOf(this) + expr.toList()) - fun toLower() = Function.ToLower(this) - fun trim() = Function.Trim(this) - - fun startsWith(expr: Expr) = Function.StartWith(this, expr) - - infix fun cosineDistance(other: Expr) = Function.CosineDistance(this, other) - infix fun cosineDistance(other: DoubleArray) = - Function.CosineDistance(this, Constant.ofVector(other)) - infix fun euclideanDistance(other: Expr) = Function.EuclideanDistance(this, other) - infix fun euclideanDistance(other: DoubleArray) = - Function.EuclideanDistance(this, Constant.ofVector(other)) + @JvmStatic + fun notEqual(left: Expr, right: String) = NotEqual(left, Constant.of(right)) - infix fun hasAncestor(ancestor: Expr) = Function.HasAncestor(this, ancestor) + @JvmStatic + fun notEqual(left: Expr, right: Number) = NotEqual(left, Constant.of(right)) - fun asAlias(alias: String): ExprAsAlias = ExprAsAlias(this, alias) + @JvmStatic + fun notEqual(left: Expr, right: Any) = NotEqual(left, Constant.of(right)) - companion object { @JvmStatic - fun equal(left: Expr, right: Expr) = Function.Equal(left, right) + fun greaterThan(left: Expr, right: Expr) = GreaterThan(left, right) - // sugar, first argument is assumed to be a field. @JvmStatic - fun equal(left: String, right: Expr) = Function.Equal(Field.of(left), right) + fun greaterThan(left: Expr, right: String) = + GreaterThan(left, Constant.of(right)) - // sugar, first argument is assumed to be a field, and second argument is assumed to a simple - // scalar constant. @JvmStatic - fun equal(left: String, right: String) = Function.Equal(Field.of(left), Constant.of(right)) + fun greaterThan(left: Expr, right: Number) = + GreaterThan(left, Constant.of(right)) @JvmStatic - fun equal(left: String, right: Number) = Function.Equal(Field.of(left), Constant.of(right)) + fun greaterThan(left: Expr, right: Any) = + GreaterThan(left, Constant.of(right)) @JvmStatic - fun notEqual(left: Expr, right: Expr) = Function.NotEqual(left, right) + fun greaterThanOrEqual(left: Expr, right: Expr) = GreaterThanOrEqual(left, right) @JvmStatic - fun greaterThan(left: Expr, right: Expr) = Function.GreaterThan(left, right) + fun greaterThanOrEqual(left: Expr, right: String) = GreaterThanOrEqual(left, Constant.of(right)) @JvmStatic - fun greaterThanOrEqual(left: Expr, right: Expr) = Function.GreaterThanOrEqual(left, right) + fun greaterThanOrEqual(left: Expr, right: Number) = GreaterThanOrEqual(left, Constant.of(right)) @JvmStatic - fun inAny(left: Expr, vararg other: Expr) = Function.In(left, other.toList()) + fun greaterThanOrEqual(left: Expr, right: Any) = GreaterThanOrEqual(left, Constant.of(right)) @JvmStatic - fun lessThan(left: Expr, right: Expr) = Function.LessThan(left, right) + fun lessThan(left: Expr, right: Expr) = LessThan(left, right) @JvmStatic - fun lessThan(left: String, right: String) = - Function.LessThan(Field.of(left), Constant.of(right)) + fun lessThan(left: Expr, right: String) = LessThan(left, Constant.of(right)) @JvmStatic - fun lessThan(left: String, right: Number) = - Function.LessThan(Field.of(left), Constant.of(right)) + fun lessThan(left: Expr, right: Number) = LessThan(left, Constant.of(right)) + @JvmStatic - fun lessThanOrEqual(left: Expr, right: Expr) = Function.LessThanOrEqual(left, right) + fun lessThan(left: Expr, right: Any) = LessThan(left, Constant.of(right)) @JvmStatic - fun notInAny(left: Expr, vararg other: Expr) = Function.NotIn(left, other.toList()) + fun lessThanOrEqual(left: Expr, right: Expr) = LessThanOrEqual(left, right) @JvmStatic - fun and(left: Function.FilterCondition, right: Function.FilterCondition) = - Function.And(listOf(left, right)) + fun lessThanOrEqual(left: Expr, right: String) = LessThanOrEqual(left, Constant.of(right)) @JvmStatic - fun and(left: Function.FilterCondition, vararg other: Function.FilterCondition) = - Function.And(listOf(left) + other.toList()) + fun lessThanOrEqual(left: Expr, right: Number) = LessThanOrEqual(left, Constant.of(right)) @JvmStatic - fun or(left: Function.FilterCondition, right: Function.FilterCondition) = - Function.Or(listOf(left, right)) + fun lessThanOrEqual(left: Expr, right: Any) = LessThanOrEqual(left, Constant.of(right)) @JvmStatic - fun or(left: Function.FilterCondition, vararg other: Function.FilterCondition) = - Function.Or(listOf(left) + other.toList()) + fun inAny(left: Expr, values: List) = In(left, values) @JvmStatic - fun exists(expr: Field) = Function.Exists(expr) + fun notInAny(left: Expr, values: List) = NotIn(left, values) @JvmStatic - fun mapGet(expr: Expr, key: String) = Function.MapGet(expr, key) + fun and(left: FilterCondition, right: FilterCondition) = + And(listOf(left, right)) @JvmStatic - fun arrayContains(expr: Expr, element: Expr) = Function.ArrayContains(expr, element) + fun and(left: FilterCondition, vararg other: FilterCondition) = + And(listOf(left) + other.toList()) @JvmStatic - fun arrayContainsAny(expr: Expr, vararg elements: Expr) = - Function.ArrayContainsAny(expr, elements.toList()) + fun or(left: FilterCondition, right: FilterCondition) = + Or(listOf(left, right)) + + @JvmStatic + fun or(left: FilterCondition, vararg other: FilterCondition) = + Or(listOf(left) + other.toList()) + + @JvmStatic + fun exists(expr: Field) = Exists(expr) @JvmStatic - fun isNaN(expr: Expr) = Function.IsNaN(expr) + fun mapGet(expr: Expr, key: String) = MapGet(expr, key) @JvmStatic - fun isNull(expr: Expr) = Function.IsNull(expr) + fun arrayContains(expr: Expr, element: Expr) = ArrayContains(expr, element) @JvmStatic - fun not(expr: Expr) = Function.Not(expr) + fun arrayContains(expr: Expr, element: Number) = ArrayContains(expr, Constant.of(element)) @JvmStatic - fun sum(expr: Expr) = Function.Sum(expr, false) + fun arrayContains(expr: Expr, element: String) = ArrayContains(expr, Constant.of(element)) @JvmStatic - fun avg(expr: Expr) = Function.Avg(expr, false) + fun arrayContains(expr: Expr, element: Any) = ArrayContains(expr, Constant.of(element)) @JvmStatic - fun count(expr: Expr) = Function.Count(expr, false) + fun arrayContainsAny(expr: Expr, vararg elements: Expr) = + ArrayContainsAny(expr, elements.toList()) @JvmStatic - fun concat(vararg expr: Expr) = Function.Concat(expr.toList()) + fun isNaN(expr: Expr) = IsNaN(expr) + @JvmStatic - fun trim(expr: Expr) = Function.Trim(expr) + fun isNull(expr: Expr) = IsNull(expr) + @JvmStatic - fun toLower(expr: Expr) = Function.ToLower(expr) + fun not(expr: Expr) = Not(expr) @JvmStatic - fun startWith(left: Expr, right: Expr) = Function.StartWith(left, right) + fun sum(expr: Expr) = Sum(expr, false) @JvmStatic - fun cosineDistance(expr: Expr, other: Expr) = Function.CosineDistance(expr, other) + fun avg(expr: Expr) = Avg(expr, false) + + @JvmStatic + fun count(expr: Expr) = Count(expr, false) + + @JvmStatic + fun cosineDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) @JvmStatic fun cosineDistance(expr: Expr, other: DoubleArray) = - Function.CosineDistance(expr, Constant.ofVector(other)) + CosineDistance(expr, Constant.ofVector(other)) @JvmStatic - fun euclideanDistance(expr: Expr, other: Expr) = Function.EuclideanDistance(expr, other) + fun dotProductDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) @JvmStatic - fun euclideanDistance(expr: Expr, other: DoubleArray) = - Function.EuclideanDistance(expr, Constant.ofVector(other)) + fun dotProductDistance(expr: Expr, other: DoubleArray) = + CosineDistance(expr, Constant.ofVector(other)) @JvmStatic - fun hasAncestor(expr: Expr, ancestor: Expr) = Function.HasAncestor(expr, ancestor) + fun euclideanDistance(expr: Expr, other: Expr) = EuclideanDistance(expr, other) @JvmStatic - fun asAlias(expr: Expr, alias: String): ExprAsAlias = ExprAsAlias(expr, alias) + fun euclideanDistance(expr: Expr, other: DoubleArray) = + EuclideanDistance(expr, Constant.ofVector(other)) @JvmStatic - fun function(name: String, params: Map?) = Function.Generic(name, params) - } + fun asAlias(expr: Expr, alias: String): Projectable = ExprAsAlias(expr, alias) + @JvmStatic + fun function(name: String, params: Map?) = Generic(name, params) + } } + diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt deleted file mode 100644 index ec22a250b..000000000 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Operations.kt +++ /dev/null @@ -1,136 +0,0 @@ -package com.google.cloud.firestore.pipeline - -import com.google.cloud.firestore.Pipeline - -interface Operation - -class Database : Operation -data class Collection(val path: String) : Operation -data class CollectionGroup(val path: String) : Operation - -data class Project(val projections: Map) : Operation -data class AddFields(val additions: Map) : Operation -data class RemoveFields(val removals: List) : Operation -data class Filter(val condition: Expr.Function.FilterCondition) : Operation -data class Offset(val offset: Int) : Operation -data class Limit(val limit: Int) : Operation -data class UnionWith(val pipeline: Pipeline, val distinct: Boolean) : Operation - -data class Group(val fields: Map, val accumulators: Map) : - Operation - -data class FindNearest( - val property: Expr.Field, - val vector: DoubleArray, - val options: FindNearestOptions -) : Operation { - sealed interface Similarity { - data object Euclidean : Similarity - data object Cosine : Similarity - data object DotProduct : Similarity - - class GenericSimilarity(val name: String) : Similarity - - companion object { - @JvmStatic - fun euclidean() = Euclidean - - @JvmStatic - fun cosine() = Cosine - - @JvmStatic - fun dotProduct() = DotProduct - - @JvmStatic - fun generic(name: String) = GenericSimilarity(name) - } - } - - data class FindNearestOptions( - val similarity: Similarity, - val limit: Long, - val output: Expr.Field - ) -} - -sealed interface JoinCondition { - data class Expression(val expr: Expr) : JoinCondition - data class Using(val fields: Set) : JoinCondition -} - -data class Join( - val type: Type, - val condition: JoinCondition, - val alias: Expr.Field, - val otherPipeline: Pipeline, - val otherAlias: Expr.Field -) : Operation { - enum class Type { - CROSS, - INNER, - FULL, - LEFT, - RIGHT, - LEFT_SEMI, - RIGHT_SEMI, - LEFT_ANTI_SEMI, - RIGHT_ANTI_SEMI, - } -} - -data class Ordering(val expr: Expr, val dir: Direction = Direction.ASC) { - enum class Direction { - ASC, - DESC - } - - companion object { - @JvmStatic - fun of(expr: Expr, dir: Direction = Direction.ASC): Ordering { - return Ordering(expr, dir) - } - - @JvmStatic - fun of(expr: Expr): Ordering { - return Ordering(expr, Direction.ASC) - } - - @JvmStatic - fun ascending(expr: Expr): Ordering { - return Ordering(expr, Direction.ASC) - } - @JvmStatic - fun descending(expr: Expr): Ordering { - return Ordering(expr, Direction.DESC) - } - } -} - -data class Sort( - val orders: List, - val density: Density = Density.UNSPECIFIED, - val truncation: Truncation = Truncation.UNSPECIFIED -) : Operation { - enum class Density { - UNSPECIFIED, - REQUIRED - } - - enum class Truncation { - UNSPECIFIED, - DISABLED - } -} - -data class UnnestMap(val mode: Mode, val field: Expr.Field) : Operation { - enum class Mode { - FULL_REPLACE, - MERGE_PREFER_NEST, - MERGE_PREFER_PARENT; - } -} - -data class UnnestArray(val field: Expr.Field) : Operation - -data class GenericOperation(val name: String, val params: Map?) : Operation - diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt new file mode 100644 index 000000000..9044f192a --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -0,0 +1,93 @@ +package com.google.cloud.firestore.pipeline + +interface Stage + +internal data class Collection(val path: String) : Stage +internal data class CollectionGroup(val path: String) : Stage + +internal data class Project(val projections: Map) : Stage +internal data class Filter(val condition: Function.FilterCondition) : Stage +internal data class Offset(val offset: Int) : Stage +internal data class Limit(val limit: Int) : Stage + +data class FindNearest internal constructor( + val property: Field, + val vector: DoubleArray, + val options: FindNearestOptions +) : Stage { + sealed interface Similarity { + data object Euclidean : Similarity + data object Cosine : Similarity + data object DotProduct : Similarity + + class GenericSimilarity(val name: String) : Similarity + + companion object { + @JvmStatic + fun euclidean() = Euclidean + + @JvmStatic + fun cosine() = Cosine + + @JvmStatic + fun dotProduct() = DotProduct + + @JvmStatic + fun generic(name: String) = GenericSimilarity(name) + } + } + + data class FindNearestOptions( + val similarity: Similarity, + val limit: Long, + val output: Field? = null + ) +} + +data class Ordering internal constructor(val expr: Expr, val dir: Direction = Direction.ASC) { + enum class Direction { + ASC, + DESC + } + + companion object { + @JvmStatic + fun of(expr: Expr, dir: Direction = Direction.ASC): Ordering { + return Ordering(expr, dir) + } + + @JvmStatic + fun of(expr: Expr): Ordering { + return Ordering(expr, Direction.ASC) + } + + @JvmStatic + fun ascending(expr: Expr): Ordering { + return Ordering(expr, Direction.ASC) + } + + @JvmStatic + fun descending(expr: Expr): Ordering { + return Ordering(expr, Direction.DESC) + } + } +} + +data class Sort internal constructor( + val orders: List, + val density: Density = Density.UNSPECIFIED, + val truncation: Truncation = Truncation.UNSPECIFIED +) : Stage { + enum class Density { + UNSPECIFIED, + REQUIRED + } + + enum class Truncation { + UNSPECIFIED, + DISABLED + } +} + +data class GenericStage(val name: String, val params: Map?) : Stage + diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 681ef3ba5..2a894c021 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -16,16 +16,12 @@ package com.google.cloud.firestore.it; -import static com.google.cloud.firestore.pipeline.Expr.and; -import static com.google.cloud.firestore.pipeline.Expr.avg; -import static com.google.cloud.firestore.pipeline.Expr.concat; -import static com.google.cloud.firestore.pipeline.Expr.cosineDistance; -import static com.google.cloud.firestore.pipeline.Expr.equal; -import static com.google.cloud.firestore.pipeline.Expr.lessThan; -import static com.google.cloud.firestore.pipeline.Expr.not; -import static com.google.cloud.firestore.pipeline.Expr.or; -import static com.google.cloud.firestore.pipeline.Expr.toLower; -import static com.google.cloud.firestore.pipeline.Expr.trim; +import static com.google.cloud.firestore.pipeline.Function.avg; +import static com.google.cloud.firestore.pipeline.Function.cosineDistance; +import static com.google.cloud.firestore.pipeline.Function.equal; +import static com.google.cloud.firestore.pipeline.Function.lessThan; +import static com.google.cloud.firestore.pipeline.Function.not; +import static com.google.cloud.firestore.pipeline.Function.or; import static com.google.cloud.firestore.pipeline.Ordering.ascending; import static com.google.cloud.firestore.pipeline.Ordering.descending; @@ -34,12 +30,9 @@ import com.google.cloud.firestore.PaginatingPipeline; import com.google.cloud.firestore.Pipeline; import com.google.cloud.firestore.PipelineResult; -import com.google.cloud.firestore.pipeline.Expr.Constant; -import com.google.cloud.firestore.pipeline.Expr.Field; -import com.google.cloud.firestore.pipeline.Expr.Function; +import com.google.cloud.firestore.pipeline.Constant; +import com.google.cloud.firestore.pipeline.Field; import com.google.cloud.firestore.pipeline.Fields; -import com.google.cloud.firestore.pipeline.FindNearest.FindNearestOptions; -import com.google.cloud.firestore.pipeline.FindNearest.Similarity; import com.google.cloud.firestore.pipeline.Ordering; import com.google.cloud.firestore.pipeline.Ordering.Direction; import java.util.Iterator; @@ -55,11 +48,6 @@ public void before() throws Exception { firestore = FirestoreOptions.newBuilder().build().getService(); } - @Test - public void pipelineWithDb() throws Exception { - Pipeline p = Pipeline.fromDatabase(); - } - @Test public void projections() throws Exception { Pipeline p = @@ -67,7 +55,7 @@ public void projections() throws Exception { .project( Field.of("foo"), Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")); + Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance")); // More compact p = @@ -76,17 +64,7 @@ public void projections() throws Exception { p = Pipeline.fromCollection("coll1") // basically an addField - .project(Field.ofAll(), Constant.of(42).asAlias("emptyField")); - } - - @Test - public void addRemoveFields() throws Exception { - Pipeline p = - Pipeline.fromCollection("coll1") - .addFields( - Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")) - .removeFields(Field.of("emptyField")); + .project(Fields.ofAll(), Constant.of(42).asAlias("emptyField")); } @Test @@ -102,8 +80,9 @@ public void filters() throws Exception { p = Pipeline.fromCollectionGroup("coll1") - .filter(equal("foo", 42)) - .filter(or(lessThan("bar", 100), equal("key", Constant.of("value")))) + .filter(equal(Field.of("foo"), 42)) + .filter( + or(lessThan(Field.of("bar"), 100), equal(Field.of("key"), Constant.of("value")))) .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); } @@ -114,18 +93,6 @@ public void inFilters() throws Exception { .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))); } - @Test - public void groupBy() throws Exception { - Pipeline p = - Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) - .group(Fields.of("given_name", "family_name")) - .aggregate(avg(Field.of("score")).toField("avg_score_1")) - // Equivalent but more fluency - .group(Fields.of("given_name", "family_name")) - .aggregate(Field.of("score").avg().toField("avg_score_2")); - } - @Test public void aggregateWithoutGrouping() throws Exception { Pipeline p = @@ -134,31 +101,6 @@ public void aggregateWithoutGrouping() throws Exception { .aggregate(avg(Field.of("score")).toField("avg_score_1")); } - @Test - public void joins() throws Exception { - Pipeline p = - Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))); - Pipeline pipe = - Pipeline.fromCollection("users") - .findNearest( - Field.of("embedding"), - new double[] {1.0, 2.0}, - new FindNearestOptions(Similarity.euclidean(), 1000, Field.of("distance"))) - .innerJoin(p) - .on( - and( - Field.of("foo").equal(Field.fromPipeline(p, "bar")), - Field.fromPipeline(p, "requirement").greaterThan(Field.of("distance")))); - - Pipeline another = - Pipeline.fromCollection("users") - .innerJoin(p) - .on(Fields.of("foo", "bar")) - .project( - Field.ofAll().withPrefix("left"), Field.allFromPipeline(p).withPrefix("right")); - } - @Test public void sorts() throws Exception { Pipeline p = @@ -193,8 +135,6 @@ public void pagination() throws Exception { Iterator result = firestore.execute(p.firstPage()).get(); Iterator second = firestore.execute(p.startAfter(result.next())).get(); - // potentially expensive but possible - Iterator page100 = firestore.execute(p.page(100)).get(); } @Test @@ -210,23 +150,5 @@ public void fluentAllTheWay() throws Exception { Iterator result = p.firstPage().execute(firestore).get(); Iterator second = p.startAfter(result.next()).execute(firestore).get(); - // potentially expensive but possible - Iterator page100 = p.page(100).execute(firestore).get(); - } - - @Test - public void functionComposition() throws Exception { - // A normalized value by joining the first and last name, triming surrounding whitespace and - // convert to lower case - Function normalized = concat(Field.of("first_name"), Constant.of(" "), Field.of("last_name")); - normalized = trim(normalized); - normalized = toLower(normalized); - - Pipeline p = - Pipeline.fromCollection("users") - .filter( - or( - normalized.equal(Constant.of("john smith")), - normalized.equal(Constant.of("alice baker")))); } } diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto index a8764a1a2..1ccc93a10 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto @@ -128,6 +128,50 @@ message Value { // A map value. MapValue map_value = 6; + + + // Value which references a field. + // + // This is considered relative (vs absolute) since it only refers to a field + // and not a field within a particular document. + // + // **Requires:** + // + // * Must follow [field reference][FieldReference.field_path] limitations. + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): long term, there is no reason this type should not be + // allowed to be used on the write path. --) + string field_reference_value = 19; + + // A value that represents an unevaluated expression. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): similar to above, there is no reason to not allow + // storing expressions into the database, just no plan to support in + // the near term. + // + // This would actually be an interesting way to represent user-defined + // functions or more expressive rules-based systems. --) + Function function_value = 20; + + // A value that represents an unevaluated pipeline. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + // + // (-- NOTE(batchik): similar to above, there is no reason to not allow + // storing expressions into the database, just no plan to support in + // the near term. + // + // This would actually be an interesting way to represent user-defined + // functions or more expressive rules-based systems. --) + Pipeline pipeline_value = 21; } } @@ -147,3 +191,72 @@ message MapValue { // not exceed 1,500 bytes and cannot be empty. map fields = 1; } + +// Represents an unevaluated scalar expression. +// +// For example, the expression `like(user_name, "%alice%")` is represented as: +// +// ``` +// name: "like" +// args { field_reference: "user_name" } +// args { string_value: "%alice%" } +// ``` +// +// (-- api-linter: core::0123::resource-annotation=disabled +// aip.dev/not-precedent: this is not a One Platform API resource. --) +message Function { + // The name of the function to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + // + string name = 1; + + // Ordered list of arguments the given function expects. + repeated Value args = 2; + + // Optional named arguments that certain functions may support. + map options = 3; +} + +// A Firestore query represented as an ordered list of operations / stages. +message Pipeline { + // A single operation within a pipeline. + // + // A stage is made up of a unique name, and a list of arguments. The exact + // number of arguments & types is dependent on the stage type. + // + // To give an example, the stage `filter(state = "MD")` would be encoded as: + // + // ``` + // name: "filter" + // args { + // function_value { + // name: "eq" + // args { field_reference_value: "state" } + // args { string_value: "MD" } + // } + // } + // ``` + // + // See public documentation for the full list. + message Stage { + // The name of the stage to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + // + string name = 1; + + // Ordered list of arguments the given stage expects. + repeated Value args = 2; + + // Optional named arguments that certain functions may support. + map options = 3; + } + + // Ordered list of stages to evaluate. + repeated Stage stages = 1; +} diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto index 3b843eed5..c7dbf0c65 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto @@ -22,6 +22,7 @@ import "google/api/field_behavior.proto"; import "google/firestore/v1/aggregation_result.proto"; import "google/firestore/v1/common.proto"; import "google/firestore/v1/document.proto"; +import "google/firestore/v1/pipeline.proto"; import "google/firestore/v1/query.proto"; import "google/firestore/v1/write.proto"; import "google/protobuf/empty.proto"; @@ -139,6 +140,15 @@ service Firestore { }; } + // Executes a pipeline query. + rpc ExecutePipeline(ExecutePipelineRequest) + returns (stream ExecutePipelineResponse) { + option (google.api.http) = { + post: "/v1beta1/{database=projects/*/databases/*}:executePipeline" + body: "*" + }; + } + // Runs an aggregation query. // // Rather than producing [Document][google.firestore.v1.Document] results like @@ -614,6 +624,82 @@ message RunQueryResponse { } } +// The request for [Firestore.ExecutePipeline][]. +message ExecutePipelineRequest { + // Database identifier, in the form `projects/{project}/databases/{database}`. + string database = 1 [ + (google.api.field_behavior) = REQUIRED + ]; + + oneof pipeline_type { + // A pipelined operation. + StructuredPipeline structured_pipeline = 2; + } + + // Optional consistency arguments, defaults to strong consistency. + oneof consistency_selector { + // Run the query within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 5; + + // Execute the pipeline in a new transaction. + // + // The identifier of the newly created transaction will be returned in the + // first response on the stream. This defaults to a read-only transaction. + TransactionOptions new_transaction = 6; + + // Execute the pipeline in a snapshot transaction at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 7; + } + + // Explain / analyze options for the pipeline. + // ExplainOptions explain_options = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for [Firestore.Execute][]. +message ExecutePipelineResponse { + // Newly created transaction identifier. + // + // This field is only specified on the first response from the server when + // the request specified [ExecuteRequest.new_transaction][]. + bytes transaction = 1; + + // An ordered batch of results returned executing a pipeline. + // + // The batch size is variable, and can even be zero for when only a partial + // progress message is returned. + // + // The fields present in the returned documents are only those that were + // explicitly requested in the pipeline, this include those like + // [`__name__`][Document.name] & [`__update_time__`][Document.update_time]. + // This is explicitly a divergence from `Firestore.RunQuery` / + // `Firestore.GetDocument` RPCs which always return such fields even when they + // are not specified in the [`mask`][DocumentMask]. + repeated Document results = 2; + + // The time at which the document(s) were read. + // + // This may be monotonically increasing; in this case, the previous documents + // in the result stream are guaranteed not to have changed between their + // `execution_time` and this one. + // + // If the query returns no results, a response with `execution_time` and no + // `results` will be sent, and this represents the time at which the operation + // was run. + google.protobuf.Timestamp execution_time = 3; + + // Query explain metrics. + // + // Set on the last response when [ExecutePipelineRequest.explain_options][] + // was specified on the request. + // ExplainMetrics explain_metrics = 4; +} + // The request for // [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. message RunAggregationQueryRequest { diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto new file mode 100644 index 000000000..20f0c17be --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto @@ -0,0 +1,26 @@ + +syntax = "proto3"; +package google.firestore.v1; +import "google/firestore/v1/document.proto"; +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; +option java_multiple_files = true; +option java_package = "com.google.firestore.v1"; +option java_outer_classname = "PipelineProto"; +option objc_class_prefix = "GCFS"; +// A Firestore query represented as an ordered list of operations / stages. +// +// This is considered the top-level function which plans & executes a query. +// It is logically equivalent to `query(stages, options)`, but prevents the +// client from having to build a function wrapper. +message StructuredPipeline { + // The pipeline query to execute. + Pipeline pipeline = 1; + // Optional query-level arguments. + // + // (-- Think query statement hints. --) + // + // (-- TODO(batchik): define the api contract of using an unsupported hint --) + map options = 2; +} From a557d4dc01f10c0ca54c21e23ef5210c0438ff73 Mon Sep 17 00:00:00 2001 From: wu-hui Date: Fri, 12 Apr 2024 18:47:15 +0000 Subject: [PATCH 30/45] pull in proto change and regenerate --- README.md | 8 +- .../firestore/v1/FirestoreAdminClient.java | 1228 ++++++- .../firestore/v1/FirestoreAdminSettings.java | 130 +- .../cloud/firestore/v1/gapic_metadata.json | 27 + .../cloud/firestore/v1/package-info.java | 2 +- .../firestore/v1/stub/FirestoreAdminStub.java | 58 +- .../v1/stub/FirestoreAdminStubSettings.java | 298 +- .../GrpcFirestoreAdminCallableFactory.java | 2 +- .../v1/stub/GrpcFirestoreAdminStub.java | 307 +- ...HttpJsonFirestoreAdminCallableFactory.java | 6 +- .../v1/stub/HttpJsonFirestoreAdminStub.java | 572 ++- .../reflect-config.json | 360 ++ .../v1/FirestoreAdminClientHttpJsonTest.java | 779 ++++- .../v1/FirestoreAdminClientTest.java | 686 +++- .../firestore/v1/MockFirestoreAdmin.java | 2 +- .../firestore/v1/MockFirestoreAdminImpl.java | 203 +- .../cloud/firestore/v1/MockLocations.java | 2 +- .../cloud/firestore/v1/MockLocationsImpl.java | 2 +- .../cloud/firestore/v1/FirestoreClient.java | 42 +- .../cloud/firestore/v1/FirestoreSettings.java | 19 +- .../cloud/firestore/v1/gapic_metadata.json | 3 + .../cloud/firestore/v1/package-info.java | 2 +- .../firestore/v1/stub/FirestoreStub.java | 9 +- .../v1/stub/FirestoreStubSettings.java | 34 +- .../v1/stub/GrpcFirestoreCallableFactory.java | 2 +- .../firestore/v1/stub/GrpcFirestoreStub.java | 37 +- .../HttpJsonFirestoreCallableFactory.java | 6 +- .../v1/stub/HttpJsonFirestoreStub.java | 67 +- .../reflect-config.json | 207 ++ .../cloud/firestore/it/ITPipelineTest.java | 2 +- .../v1/FirestoreClientHttpJsonTest.java | 13 +- .../firestore/v1/FirestoreClientTest.java | 50 +- .../cloud/firestore/v1/MockFirestore.java | 2 +- .../cloud/firestore/v1/MockFirestoreImpl.java | 25 +- .../cloud/firestore/v1/MockLocations.java | 2 +- .../cloud/firestore/v1/MockLocationsImpl.java | 2 +- .../admin/v1/FirestoreAdminGrpc.java | 1195 ++++++- .../google/firestore/v1/FirestoreGrpc.java | 118 +- .../com/google/firestore/admin/v1/Backup.java | 3067 +++++++++++++++++ .../google/firestore/admin/v1/BackupName.java | 223 ++ .../firestore/admin/v1/BackupOrBuilder.java | 276 ++ .../firestore/admin/v1/BackupProto.java | 111 + .../firestore/admin/v1/BackupSchedule.java | 2256 ++++++++++++ .../admin/v1/BackupScheduleName.java | 227 ++ .../admin/v1/BackupScheduleOrBuilder.java | 264 ++ .../admin/v1/CollectionGroupName.java | 2 +- .../admin/v1/CreateBackupScheduleRequest.java | 962 ++++++ .../CreateBackupScheduleRequestOrBuilder.java | 100 + .../firestore/admin/v1/DailyRecurrence.java | 435 +++ .../admin/v1/DailyRecurrenceOrBuilder.java | 25 + .../firestore/admin/v1/DatabaseName.java | 2 +- .../firestore/admin/v1/DatabaseProto.java | 88 +- .../admin/v1/DeleteBackupRequest.java | 655 ++++ .../v1/DeleteBackupRequestOrBuilder.java | 59 + .../admin/v1/DeleteBackupScheduleRequest.java | 661 ++++ .../DeleteBackupScheduleRequestOrBuilder.java | 61 + .../google/firestore/admin/v1/FieldName.java | 2 +- .../google/firestore/admin/v1/FieldProto.java | 42 +- .../admin/v1/FirestoreAdminProto.java | 513 ++- .../firestore/admin/v1/GetBackupRequest.java | 654 ++++ .../admin/v1/GetBackupRequestOrBuilder.java | 59 + .../admin/v1/GetBackupScheduleRequest.java | 663 ++++ .../v1/GetBackupScheduleRequestOrBuilder.java | 61 + .../com/google/firestore/admin/v1/Index.java | 1869 +++++++++- .../google/firestore/admin/v1/IndexName.java | 2 +- .../google/firestore/admin/v1/IndexProto.java | 100 +- .../admin/v1/ListBackupSchedulesRequest.java | 656 ++++ .../ListBackupSchedulesRequestOrBuilder.java | 59 + .../admin/v1/ListBackupSchedulesResponse.java | 950 +++++ .../ListBackupSchedulesResponseOrBuilder.java | 78 + .../admin/v1/ListBackupsRequest.java | 676 ++++ .../admin/v1/ListBackupsRequestOrBuilder.java | 65 + .../admin/v1/ListBackupsResponse.java | 1279 +++++++ .../v1/ListBackupsResponseOrBuilder.java | 148 + .../firestore/admin/v1/LocationName.java | 192 ++ .../firestore/admin/v1/OperationProto.java | 52 +- .../firestore/admin/v1/ProjectName.java | 2 +- .../admin/v1/RestoreDatabaseMetadata.java | 1764 ++++++++++ .../v1/RestoreDatabaseMetadataOrBuilder.java | 206 ++ .../admin/v1/RestoreDatabaseRequest.java | 1103 ++++++ .../v1/RestoreDatabaseRequestOrBuilder.java | 133 + .../firestore/admin/v1/ScheduleProto.java | 131 + .../admin/v1/UpdateBackupScheduleRequest.java | 1015 ++++++ .../UpdateBackupScheduleRequestOrBuilder.java | 102 + .../firestore/admin/v1/WeeklyRecurrence.java | 606 ++++ .../admin/v1/WeeklyRecurrenceOrBuilder.java | 55 + .../google/firestore/admin/v1/backup.proto | 107 + .../firestore/admin/v1/firestore_admin.proto | 275 ++ .../google/firestore/admin/v1/index.proto | 24 + .../google/firestore/admin/v1/operation.proto | 48 +- .../google/firestore/admin/v1/schedule.proto | 93 + .../google/firestore/v1/DocumentProto.java | 104 +- .../firestore/v1/ExecutePipelineRequest.java | 1898 ++++++++++ .../v1/ExecutePipelineRequestOrBuilder.java | 211 ++ .../firestore/v1/ExecutePipelineResponse.java | 1647 +++++++++ .../v1/ExecutePipelineResponseOrBuilder.java | 202 ++ .../google/firestore/v1/ExecutionStats.java | 1305 +++++++ .../firestore/v1/ExecutionStatsOrBuilder.java | 156 + .../google/firestore/v1/ExplainMetrics.java | 1014 ++++++ .../firestore/v1/ExplainMetricsOrBuilder.java | 102 + .../google/firestore/v1/ExplainOptions.java | 557 +++ .../firestore/v1/ExplainOptionsOrBuilder.java | 45 + .../google/firestore/v1/FirestoreProto.java | 546 +-- .../com/google/firestore/v1/Function.java | 1558 +++++++++ .../firestore/v1/FunctionOrBuilder.java | 168 + .../com/google/firestore/v1/Pipeline.java | 2640 ++++++++++++++ .../firestore/v1/PipelineOrBuilder.java | 78 + .../google/firestore/v1/PipelineProto.java | 87 + .../com/google/firestore/v1/PlanSummary.java | 1019 ++++++ .../firestore/v1/PlanSummaryOrBuilder.java | 97 + .../firestore/v1/QueryProfileProto.java | 128 + .../com/google/firestore/v1/QueryProto.java | 162 +- .../firestore/v1/StructuredPipeline.java | 1177 +++++++ .../v1/StructuredPipelineOrBuilder.java | 139 + .../google/firestore/v1/StructuredQuery.java | 2229 ++++++++++++ .../v1/StructuredQueryOrBuilder.java | 53 + .../java/com/google/firestore/v1/Value.java | 1190 +++++++ .../google/firestore/v1/ValueOrBuilder.java | 209 ++ .../proto/google/firestore/v1/document.proto | 1 + .../proto/google/firestore/v1/pipeline.proto | 1 + .../proto/google/firestore/v1/query.proto | 52 + .../google/firestore/v1/query_profile.proto | 92 + 122 files changed, 47874 insertions(+), 760 deletions(-) create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Backup.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupName.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupProto.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupSchedule.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleName.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrence.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrenceOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponse.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponseOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponse.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponseOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationName.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadata.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadataOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ScheduleProto.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequest.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrence.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrenceOrBuilder.java create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/backup.proto create mode 100644 proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/schedule.proto create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequest.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequestOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponse.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponseOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStats.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStatsOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetrics.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetricsOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptions.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptionsOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Function.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FunctionOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Pipeline.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineProto.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummary.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummaryOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProfileProto.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipeline.java create mode 100644 proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipelineOrBuilder.java create mode 100644 proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query_profile.proto diff --git a/README.md b/README.md index 01a437f4c..050eb8250 100644 --- a/README.md +++ b/README.md @@ -50,20 +50,20 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.31.0') +implementation platform('com.google.cloud:libraries-bom:26.37.0') implementation 'com.google.cloud:google-cloud-firestore' ``` If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-firestore:3.16.1' +implementation 'com.google.cloud:google-cloud-firestore:3.20.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-firestore" % "3.16.1" +libraryDependencies += "com.google.cloud" % "google-cloud-firestore" % "3.20.0" ``` @@ -222,7 +222,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-firestore/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-firestore.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-firestore/3.16.1 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-firestore/3.20.0 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java index 49ceb63c4..c1f9108d3 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,12 +31,19 @@ import com.google.cloud.firestore.v1.stub.FirestoreAdminStub; import com.google.cloud.firestore.v1.stub.FirestoreAdminStubSettings; import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupName; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BackupScheduleName; import com.google.firestore.admin.v1.CollectionGroupName; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseMetadata; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; import com.google.firestore.admin.v1.DatabaseName; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseMetadata; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; @@ -46,6 +53,8 @@ import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FieldName; import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; @@ -54,13 +63,21 @@ import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexName; import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.LocationName; import com.google.firestore.admin.v1.ProjectName; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseMetadata; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; @@ -403,6 +420,174 @@ * * * + * + *

GetBackup + *

Gets information about a backup. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getBackup(GetBackupRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getBackup(BackupName name) + *

  • getBackup(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getBackupCallable() + *

+ * + * + * + *

ListBackups + *

Lists all the backups. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listBackups(ListBackupsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listBackups(LocationName parent) + *

  • listBackups(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listBackupsCallable() + *

+ * + * + * + *

DeleteBackup + *

Deletes a backup. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteBackup(DeleteBackupRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • deleteBackup(BackupName name) + *

  • deleteBackup(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteBackupCallable() + *

+ * + * + * + *

RestoreDatabase + *

Creates a new database by restoring from an existing backup. + *

The new database must be in the same cloud region or multi-region location as the existing backup. This behaves similar to [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase] except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing backup. + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. The [response][google.longrunning.Operation.response] type is the [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database is not readable or writeable until the LRO has completed. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • restoreDatabaseAsync(RestoreDatabaseRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • restoreDatabaseOperationCallable() + *

  • restoreDatabaseCallable() + *

+ * + * + * + *

CreateBackupSchedule + *

Creates a backup schedule on a database. At most two backup schedules can be configured on a database, one daily backup schedule and one weekly backup schedule. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • createBackupSchedule(CreateBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • createBackupSchedule(DatabaseName parent, BackupSchedule backupSchedule) + *

  • createBackupSchedule(String parent, BackupSchedule backupSchedule) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • createBackupScheduleCallable() + *

+ * + * + * + *

GetBackupSchedule + *

Gets information about a backup schedule. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getBackupSchedule(GetBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getBackupSchedule(BackupScheduleName name) + *

  • getBackupSchedule(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getBackupScheduleCallable() + *

+ * + * + * + *

ListBackupSchedules + *

List backup schedules. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listBackupSchedules(ListBackupSchedulesRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listBackupSchedules(DatabaseName parent) + *

  • listBackupSchedules(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listBackupSchedulesCallable() + *

+ * + * + * + *

UpdateBackupSchedule + *

Updates a backup schedule. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • updateBackupSchedule(UpdateBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • updateBackupSchedule(BackupSchedule backupSchedule, FieldMask updateMask) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • updateBackupScheduleCallable() + *

+ * + * + * + *

DeleteBackupSchedule + *

Deletes a backup schedule. + * + *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteBackupSchedule(DeleteBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • deleteBackupSchedule(BackupScheduleName name) + *

  • deleteBackupSchedule(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteBackupScheduleCallable() + *

+ * + * * * *

See the individual methods for example code. @@ -2584,6 +2769,1047 @@ public final UnaryCallable deleteDatabaseCalla return stub.deleteDatabaseCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]");
+   *   Backup response = firestoreAdminClient.getBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to fetch. + *

Format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Backup getBackup(BackupName name) { + GetBackupRequest request = + GetBackupRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString();
+   *   Backup response = firestoreAdminClient.getBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to fetch. + *

Format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Backup getBackup(String name) { + GetBackupRequest request = GetBackupRequest.newBuilder().setName(name).build(); + return getBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupRequest request =
+   *       GetBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   Backup response = firestoreAdminClient.getBackup(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Backup getBackup(GetBackupRequest request) { + return getBackupCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupRequest request =
+   *       GetBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.getBackupCallable().futureCall(request);
+   *   // Do something.
+   *   Backup response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getBackupCallable() { + return stub.getBackupCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   ListBackupsResponse response = firestoreAdminClient.listBackups(parent);
+   * }
+   * }
+ * + * @param parent Required. The location to list backups from. + *

Format is `projects/{project}/locations/{location}`. Use `{location} = '-'` to list + * backups from all locations for the given project. This allows listing backups from a single + * location or from all locations. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupsResponse listBackups(LocationName parent) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listBackups(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   ListBackupsResponse response = firestoreAdminClient.listBackups(parent);
+   * }
+   * }
+ * + * @param parent Required. The location to list backups from. + *

Format is `projects/{project}/locations/{location}`. Use `{location} = '-'` to list + * backups from all locations for the given project. This allows listing backups from a single + * location or from all locations. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupsResponse listBackups(String parent) { + ListBackupsRequest request = ListBackupsRequest.newBuilder().setParent(parent).build(); + return listBackups(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupsRequest request =
+   *       ListBackupsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .build();
+   *   ListBackupsResponse response = firestoreAdminClient.listBackups(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupsResponse listBackups(ListBackupsRequest request) { + return listBackupsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupsRequest request =
+   *       ListBackupsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.listBackupsCallable().futureCall(request);
+   *   // Do something.
+   *   ListBackupsResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable listBackupsCallable() { + return stub.listBackupsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]");
+   *   firestoreAdminClient.deleteBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to delete. + *

format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackup(BackupName name) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString();
+   *   firestoreAdminClient.deleteBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to delete. + *

format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackup(String name) { + DeleteBackupRequest request = DeleteBackupRequest.newBuilder().setName(name).build(); + deleteBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupRequest request =
+   *       DeleteBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   firestoreAdminClient.deleteBackup(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackup(DeleteBackupRequest request) { + deleteBackupCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupRequest request =
+   *       DeleteBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.deleteBackupCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteBackupCallable() { + return stub.deleteBackupCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by restoring from an existing backup. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * backup. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase] except instead of + * creating a new empty database, a new database is created with the database type, index + * configuration, and documents from an existing backup. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field + * type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database + * is not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   RestoreDatabaseRequest request =
+   *       RestoreDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   Database response = firestoreAdminClient.restoreDatabaseAsync(request).get();
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture restoreDatabaseAsync( + RestoreDatabaseRequest request) { + return restoreDatabaseOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by restoring from an existing backup. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * backup. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase] except instead of + * creating a new empty database, a new database is created with the database type, index + * configuration, and documents from an existing backup. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field + * type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database + * is not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   RestoreDatabaseRequest request =
+   *       RestoreDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.restoreDatabaseOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Database response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + restoreDatabaseOperationCallable() { + return stub.restoreDatabaseOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by restoring from an existing backup. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * backup. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase] except instead of + * creating a new empty database, a new database is created with the database type, index + * configuration, and documents from an existing backup. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field + * type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database + * is not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   RestoreDatabaseRequest request =
+   *       RestoreDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.restoreDatabaseCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable restoreDatabaseCallable() { + return stub.restoreDatabaseCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   BackupSchedule response = firestoreAdminClient.createBackupSchedule(parent, backupSchedule);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format `projects/{project}/databases/{database}` + * @param backupSchedule Required. The backup schedule to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule( + DatabaseName parent, BackupSchedule backupSchedule) { + CreateBackupScheduleRequest request = + CreateBackupScheduleRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setBackupSchedule(backupSchedule) + .build(); + return createBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   BackupSchedule response = firestoreAdminClient.createBackupSchedule(parent, backupSchedule);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format `projects/{project}/databases/{database}` + * @param backupSchedule Required. The backup schedule to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule(String parent, BackupSchedule backupSchedule) { + CreateBackupScheduleRequest request = + CreateBackupScheduleRequest.newBuilder() + .setParent(parent) + .setBackupSchedule(backupSchedule) + .build(); + return createBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateBackupScheduleRequest request =
+   *       CreateBackupScheduleRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .build();
+   *   BackupSchedule response = firestoreAdminClient.createBackupSchedule(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule(CreateBackupScheduleRequest request) { + return createBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateBackupScheduleRequest request =
+   *       CreateBackupScheduleRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.createBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   BackupSchedule response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + createBackupScheduleCallable() { + return stub.createBackupScheduleCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupScheduleName name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]");
+   *   BackupSchedule response = firestoreAdminClient.getBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(BackupScheduleName name) { + GetBackupScheduleRequest request = + GetBackupScheduleRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString();
+   *   BackupSchedule response = firestoreAdminClient.getBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(String name) { + GetBackupScheduleRequest request = GetBackupScheduleRequest.newBuilder().setName(name).build(); + return getBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupScheduleRequest request =
+   *       GetBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   BackupSchedule response = firestoreAdminClient.getBackupSchedule(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(GetBackupScheduleRequest request) { + return getBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupScheduleRequest request =
+   *       GetBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.getBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   BackupSchedule response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getBackupScheduleCallable() { + return stub.getBackupScheduleCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   ListBackupSchedulesResponse response = firestoreAdminClient.listBackupSchedules(parent);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format is `projects/{project}/databases/{database}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupSchedulesResponse listBackupSchedules(DatabaseName parent) { + ListBackupSchedulesRequest request = + ListBackupSchedulesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listBackupSchedules(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   ListBackupSchedulesResponse response = firestoreAdminClient.listBackupSchedules(parent);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format is `projects/{project}/databases/{database}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupSchedulesResponse listBackupSchedules(String parent) { + ListBackupSchedulesRequest request = + ListBackupSchedulesRequest.newBuilder().setParent(parent).build(); + return listBackupSchedules(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupSchedulesRequest request =
+   *       ListBackupSchedulesRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   ListBackupSchedulesResponse response = firestoreAdminClient.listBackupSchedules(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupSchedulesResponse listBackupSchedules(ListBackupSchedulesRequest request) { + return listBackupSchedulesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupSchedulesRequest request =
+   *       ListBackupSchedulesRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.listBackupSchedulesCallable().futureCall(request);
+   *   // Do something.
+   *   ListBackupSchedulesResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + listBackupSchedulesCallable() { + return stub.listBackupSchedulesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   BackupSchedule response =
+   *       firestoreAdminClient.updateBackupSchedule(backupSchedule, updateMask);
+   * }
+   * }
+ * + * @param backupSchedule Required. The backup schedule to update. + * @param updateMask The list of fields to be updated. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule updateBackupSchedule( + BackupSchedule backupSchedule, FieldMask updateMask) { + UpdateBackupScheduleRequest request = + UpdateBackupScheduleRequest.newBuilder() + .setBackupSchedule(backupSchedule) + .setUpdateMask(updateMask) + .build(); + return updateBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateBackupScheduleRequest request =
+   *       UpdateBackupScheduleRequest.newBuilder()
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   BackupSchedule response = firestoreAdminClient.updateBackupSchedule(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule updateBackupSchedule(UpdateBackupScheduleRequest request) { + return updateBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateBackupScheduleRequest request =
+   *       UpdateBackupScheduleRequest.newBuilder()
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.updateBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   BackupSchedule response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + updateBackupScheduleCallable() { + return stub.updateBackupScheduleCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupScheduleName name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]");
+   *   firestoreAdminClient.deleteBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(BackupScheduleName name) { + DeleteBackupScheduleRequest request = + DeleteBackupScheduleRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + deleteBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString();
+   *   firestoreAdminClient.deleteBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(String name) { + DeleteBackupScheduleRequest request = + DeleteBackupScheduleRequest.newBuilder().setName(name).build(); + deleteBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupScheduleRequest request =
+   *       DeleteBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   firestoreAdminClient.deleteBackupSchedule(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(DeleteBackupScheduleRequest request) { + deleteBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupScheduleRequest request =
+   *       DeleteBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.deleteBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteBackupScheduleCallable() { + return stub.deleteBackupScheduleCallable(); + } + @Override public final void close() { stub.close(); diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java index cd4f0a14e..476ccec67 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,15 @@ import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.cloud.firestore.v1.stub.FirestoreAdminStubSettings; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseMetadata; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseMetadata; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; @@ -45,6 +50,8 @@ import com.google.firestore.admin.v1.ExportDocumentsResponse; import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; @@ -52,12 +59,19 @@ import com.google.firestore.admin.v1.ImportDocumentsRequest; import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseMetadata; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; @@ -222,6 +236,60 @@ public UnaryCallSettings deleteDatabaseSetting return ((FirestoreAdminStubSettings) getStubSettings()).deleteDatabaseOperationSettings(); } + /** Returns the object with the settings used for calls to getBackup. */ + public UnaryCallSettings getBackupSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).getBackupSettings(); + } + + /** Returns the object with the settings used for calls to listBackups. */ + public UnaryCallSettings listBackupsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).listBackupsSettings(); + } + + /** Returns the object with the settings used for calls to deleteBackup. */ + public UnaryCallSettings deleteBackupSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteBackupSettings(); + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public UnaryCallSettings restoreDatabaseSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).restoreDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public OperationCallSettings + restoreDatabaseOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).restoreDatabaseOperationSettings(); + } + + /** Returns the object with the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings + createBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).createBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings getBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).getBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings + listBackupSchedulesSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).listBackupSchedulesSettings(); + } + + /** Returns the object with the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings + updateBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).updateBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings deleteBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteBackupScheduleSettings(); + } + public static final FirestoreAdminSettings create(FirestoreAdminStubSettings stub) throws IOException { return new FirestoreAdminSettings.Builder(stub.toBuilder()).build(); @@ -263,7 +331,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() { return FirestoreAdminStubSettings.defaultTransportChannelProvider(); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { return FirestoreAdminStubSettings.defaultApiClientHeaderProviderBuilder(); } @@ -274,7 +341,6 @@ public static Builder newBuilder() { } /** Returns a new REST builder for this class. */ - @BetaApi public static Builder newHttpJsonBuilder() { return Builder.createHttpJsonDefault(); } @@ -316,7 +382,6 @@ private static Builder createDefault() { return new Builder(FirestoreAdminStubSettings.newBuilder()); } - @BetaApi private static Builder createHttpJsonDefault() { return new Builder(FirestoreAdminStubSettings.newHttpJsonBuilder()); } @@ -454,6 +519,63 @@ public UnaryCallSettings.Builder deleteDatabas return getStubSettingsBuilder().deleteDatabaseOperationSettings(); } + /** Returns the builder for the settings used for calls to getBackup. */ + public UnaryCallSettings.Builder getBackupSettings() { + return getStubSettingsBuilder().getBackupSettings(); + } + + /** Returns the builder for the settings used for calls to listBackups. */ + public UnaryCallSettings.Builder + listBackupsSettings() { + return getStubSettingsBuilder().listBackupsSettings(); + } + + /** Returns the builder for the settings used for calls to deleteBackup. */ + public UnaryCallSettings.Builder deleteBackupSettings() { + return getStubSettingsBuilder().deleteBackupSettings(); + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public UnaryCallSettings.Builder restoreDatabaseSettings() { + return getStubSettingsBuilder().restoreDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public OperationCallSettings.Builder + restoreDatabaseOperationSettings() { + return getStubSettingsBuilder().restoreDatabaseOperationSettings(); + } + + /** Returns the builder for the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings.Builder + createBackupScheduleSettings() { + return getStubSettingsBuilder().createBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings.Builder + getBackupScheduleSettings() { + return getStubSettingsBuilder().getBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings.Builder + listBackupSchedulesSettings() { + return getStubSettingsBuilder().listBackupSchedulesSettings(); + } + + /** Returns the builder for the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings.Builder + updateBackupScheduleSettings() { + return getStubSettingsBuilder().updateBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings.Builder + deleteBackupScheduleSettings() { + return getStubSettingsBuilder().deleteBackupScheduleSettings(); + } + @Override public FirestoreAdminSettings build() throws IOException { return new FirestoreAdminSettings(this); diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json index aaa8b74b8..727ba40b1 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json @@ -10,12 +10,21 @@ "grpc": { "libraryClient": "FirestoreAdminClient", "rpcs": { + "CreateBackupSchedule": { + "methods": ["createBackupSchedule", "createBackupSchedule", "createBackupSchedule", "createBackupScheduleCallable"] + }, "CreateDatabase": { "methods": ["createDatabaseAsync", "createDatabaseAsync", "createDatabaseAsync", "createDatabaseOperationCallable", "createDatabaseCallable"] }, "CreateIndex": { "methods": ["createIndexAsync", "createIndexAsync", "createIndexAsync", "createIndexOperationCallable", "createIndexCallable"] }, + "DeleteBackup": { + "methods": ["deleteBackup", "deleteBackup", "deleteBackup", "deleteBackupCallable"] + }, + "DeleteBackupSchedule": { + "methods": ["deleteBackupSchedule", "deleteBackupSchedule", "deleteBackupSchedule", "deleteBackupScheduleCallable"] + }, "DeleteDatabase": { "methods": ["deleteDatabaseAsync", "deleteDatabaseAsync", "deleteDatabaseAsync", "deleteDatabaseOperationCallable", "deleteDatabaseCallable"] }, @@ -25,6 +34,12 @@ "ExportDocuments": { "methods": ["exportDocumentsAsync", "exportDocumentsAsync", "exportDocumentsAsync", "exportDocumentsOperationCallable", "exportDocumentsCallable"] }, + "GetBackup": { + "methods": ["getBackup", "getBackup", "getBackup", "getBackupCallable"] + }, + "GetBackupSchedule": { + "methods": ["getBackupSchedule", "getBackupSchedule", "getBackupSchedule", "getBackupScheduleCallable"] + }, "GetDatabase": { "methods": ["getDatabase", "getDatabase", "getDatabase", "getDatabaseCallable"] }, @@ -37,6 +52,12 @@ "ImportDocuments": { "methods": ["importDocumentsAsync", "importDocumentsAsync", "importDocumentsAsync", "importDocumentsOperationCallable", "importDocumentsCallable"] }, + "ListBackupSchedules": { + "methods": ["listBackupSchedules", "listBackupSchedules", "listBackupSchedules", "listBackupSchedulesCallable"] + }, + "ListBackups": { + "methods": ["listBackups", "listBackups", "listBackups", "listBackupsCallable"] + }, "ListDatabases": { "methods": ["listDatabases", "listDatabases", "listDatabases", "listDatabasesCallable"] }, @@ -46,6 +67,12 @@ "ListIndexes": { "methods": ["listIndexes", "listIndexes", "listIndexes", "listIndexesPagedCallable", "listIndexesCallable"] }, + "RestoreDatabase": { + "methods": ["restoreDatabaseAsync", "restoreDatabaseOperationCallable", "restoreDatabaseCallable"] + }, + "UpdateBackupSchedule": { + "methods": ["updateBackupSchedule", "updateBackupSchedule", "updateBackupScheduleCallable"] + }, "UpdateDatabase": { "methods": ["updateDatabaseAsync", "updateDatabaseAsync", "updateDatabaseOperationCallable", "updateDatabaseCallable"] }, diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java index aded2d748..8aa41ba08 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java index dc8279df5..26db1092a 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,15 @@ import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseMetadata; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseMetadata; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; @@ -34,6 +39,8 @@ import com.google.firestore.admin.v1.ExportDocumentsResponse; import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; @@ -41,12 +48,19 @@ import com.google.firestore.admin.v1.ImportDocumentsRequest; import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseMetadata; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; @@ -171,6 +185,48 @@ public UnaryCallable deleteDatabaseCallable() throw new UnsupportedOperationException("Not implemented: deleteDatabaseCallable()"); } + public UnaryCallable getBackupCallable() { + throw new UnsupportedOperationException("Not implemented: getBackupCallable()"); + } + + public UnaryCallable listBackupsCallable() { + throw new UnsupportedOperationException("Not implemented: listBackupsCallable()"); + } + + public UnaryCallable deleteBackupCallable() { + throw new UnsupportedOperationException("Not implemented: deleteBackupCallable()"); + } + + public OperationCallable + restoreDatabaseOperationCallable() { + throw new UnsupportedOperationException("Not implemented: restoreDatabaseOperationCallable()"); + } + + public UnaryCallable restoreDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: restoreDatabaseCallable()"); + } + + public UnaryCallable createBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: createBackupScheduleCallable()"); + } + + public UnaryCallable getBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: getBackupScheduleCallable()"); + } + + public UnaryCallable + listBackupSchedulesCallable() { + throw new UnsupportedOperationException("Not implemented: listBackupSchedulesCallable()"); + } + + public UnaryCallable updateBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: updateBackupScheduleCallable()"); + } + + public UnaryCallable deleteBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: deleteBackupScheduleCallable()"); + } + @Override public abstract void close(); } diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java index e7416e878..fbcf2bc14 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,10 +52,15 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseMetadata; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseMetadata; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; @@ -64,6 +69,8 @@ import com.google.firestore.admin.v1.ExportDocumentsResponse; import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; @@ -71,12 +78,19 @@ import com.google.firestore.admin.v1.ImportDocumentsRequest; import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseMetadata; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; @@ -165,6 +179,21 @@ public class FirestoreAdminStubSettings extends StubSettings deleteDatabaseSettings; private final OperationCallSettings deleteDatabaseOperationSettings; + private final UnaryCallSettings getBackupSettings; + private final UnaryCallSettings listBackupsSettings; + private final UnaryCallSettings deleteBackupSettings; + private final UnaryCallSettings restoreDatabaseSettings; + private final OperationCallSettings + restoreDatabaseOperationSettings; + private final UnaryCallSettings + createBackupScheduleSettings; + private final UnaryCallSettings + getBackupScheduleSettings; + private final UnaryCallSettings + listBackupSchedulesSettings; + private final UnaryCallSettings + updateBackupScheduleSettings; + private final UnaryCallSettings deleteBackupScheduleSettings; private static final PagedListDescriptor LIST_INDEXES_PAGE_STR_DESC = @@ -387,6 +416,60 @@ public UnaryCallSettings deleteDatabaseSetting return deleteDatabaseOperationSettings; } + /** Returns the object with the settings used for calls to getBackup. */ + public UnaryCallSettings getBackupSettings() { + return getBackupSettings; + } + + /** Returns the object with the settings used for calls to listBackups. */ + public UnaryCallSettings listBackupsSettings() { + return listBackupsSettings; + } + + /** Returns the object with the settings used for calls to deleteBackup. */ + public UnaryCallSettings deleteBackupSettings() { + return deleteBackupSettings; + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public UnaryCallSettings restoreDatabaseSettings() { + return restoreDatabaseSettings; + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public OperationCallSettings + restoreDatabaseOperationSettings() { + return restoreDatabaseOperationSettings; + } + + /** Returns the object with the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings + createBackupScheduleSettings() { + return createBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings getBackupScheduleSettings() { + return getBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings + listBackupSchedulesSettings() { + return listBackupSchedulesSettings; + } + + /** Returns the object with the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings + updateBackupScheduleSettings() { + return updateBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings deleteBackupScheduleSettings() { + return deleteBackupScheduleSettings; + } + public FirestoreAdminStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() @@ -462,7 +545,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( @@ -471,7 +553,6 @@ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProvider GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( @@ -529,6 +610,16 @@ protected FirestoreAdminStubSettings(Builder settingsBuilder) throws IOException updateDatabaseOperationSettings = settingsBuilder.updateDatabaseOperationSettings().build(); deleteDatabaseSettings = settingsBuilder.deleteDatabaseSettings().build(); deleteDatabaseOperationSettings = settingsBuilder.deleteDatabaseOperationSettings().build(); + getBackupSettings = settingsBuilder.getBackupSettings().build(); + listBackupsSettings = settingsBuilder.listBackupsSettings().build(); + deleteBackupSettings = settingsBuilder.deleteBackupSettings().build(); + restoreDatabaseSettings = settingsBuilder.restoreDatabaseSettings().build(); + restoreDatabaseOperationSettings = settingsBuilder.restoreDatabaseOperationSettings().build(); + createBackupScheduleSettings = settingsBuilder.createBackupScheduleSettings().build(); + getBackupScheduleSettings = settingsBuilder.getBackupScheduleSettings().build(); + listBackupSchedulesSettings = settingsBuilder.listBackupSchedulesSettings().build(); + updateBackupScheduleSettings = settingsBuilder.updateBackupScheduleSettings().build(); + deleteBackupScheduleSettings = settingsBuilder.deleteBackupScheduleSettings().build(); } /** Builder for FirestoreAdminStubSettings. */ @@ -577,6 +668,25 @@ public static class Builder extends StubSettings.Builder deleteDatabaseOperationSettings; + private final UnaryCallSettings.Builder getBackupSettings; + private final UnaryCallSettings.Builder + listBackupsSettings; + private final UnaryCallSettings.Builder deleteBackupSettings; + private final UnaryCallSettings.Builder + restoreDatabaseSettings; + private final OperationCallSettings.Builder< + RestoreDatabaseRequest, Database, RestoreDatabaseMetadata> + restoreDatabaseOperationSettings; + private final UnaryCallSettings.Builder + createBackupScheduleSettings; + private final UnaryCallSettings.Builder + getBackupScheduleSettings; + private final UnaryCallSettings.Builder + listBackupSchedulesSettings; + private final UnaryCallSettings.Builder + updateBackupScheduleSettings; + private final UnaryCallSettings.Builder + deleteBackupScheduleSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -653,6 +763,16 @@ protected Builder(ClientContext clientContext) { updateDatabaseOperationSettings = OperationCallSettings.newBuilder(); deleteDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); deleteDatabaseOperationSettings = OperationCallSettings.newBuilder(); + getBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listBackupsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + restoreDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + restoreDatabaseOperationSettings = OperationCallSettings.newBuilder(); + createBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listBackupSchedulesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( @@ -669,7 +789,16 @@ protected Builder(ClientContext clientContext) { getDatabaseSettings, listDatabasesSettings, updateDatabaseSettings, - deleteDatabaseSettings); + deleteDatabaseSettings, + getBackupSettings, + listBackupsSettings, + deleteBackupSettings, + restoreDatabaseSettings, + createBackupScheduleSettings, + getBackupScheduleSettings, + listBackupSchedulesSettings, + updateBackupScheduleSettings, + deleteBackupScheduleSettings); initDefaults(this); } @@ -697,6 +826,16 @@ protected Builder(FirestoreAdminStubSettings settings) { updateDatabaseOperationSettings = settings.updateDatabaseOperationSettings.toBuilder(); deleteDatabaseSettings = settings.deleteDatabaseSettings.toBuilder(); deleteDatabaseOperationSettings = settings.deleteDatabaseOperationSettings.toBuilder(); + getBackupSettings = settings.getBackupSettings.toBuilder(); + listBackupsSettings = settings.listBackupsSettings.toBuilder(); + deleteBackupSettings = settings.deleteBackupSettings.toBuilder(); + restoreDatabaseSettings = settings.restoreDatabaseSettings.toBuilder(); + restoreDatabaseOperationSettings = settings.restoreDatabaseOperationSettings.toBuilder(); + createBackupScheduleSettings = settings.createBackupScheduleSettings.toBuilder(); + getBackupScheduleSettings = settings.getBackupScheduleSettings.toBuilder(); + listBackupSchedulesSettings = settings.listBackupSchedulesSettings.toBuilder(); + updateBackupScheduleSettings = settings.updateBackupScheduleSettings.toBuilder(); + deleteBackupScheduleSettings = settings.deleteBackupScheduleSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( @@ -713,7 +852,16 @@ protected Builder(FirestoreAdminStubSettings settings) { getDatabaseSettings, listDatabasesSettings, updateDatabaseSettings, - deleteDatabaseSettings); + deleteDatabaseSettings, + getBackupSettings, + listBackupsSettings, + deleteBackupSettings, + restoreDatabaseSettings, + createBackupScheduleSettings, + getBackupScheduleSettings, + listBackupSchedulesSettings, + updateBackupScheduleSettings, + deleteBackupScheduleSettings); } private static Builder createDefault() { @@ -811,6 +959,51 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + builder + .getBackupSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .listBackupsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .deleteBackupSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .restoreDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .createBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .listBackupSchedulesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .updateBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .deleteBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + builder .createIndexOperationSettings() .setInitialCallSettings( @@ -977,6 +1170,30 @@ private static Builder initDefaults(Builder builder) { .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder + .restoreDatabaseOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Database.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(RestoreDatabaseMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + return builder; } @@ -1001,8 +1218,6 @@ public UnaryCallSettings.Builder createIndexSetti } /** Returns the builder for the settings used for calls to createIndex. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings.Builder createIndexOperationSettings() { return createIndexOperationSettings; @@ -1036,8 +1251,6 @@ public UnaryCallSettings.Builder updateFieldSetti } /** Returns the builder for the settings used for calls to updateField. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings.Builder updateFieldOperationSettings() { return updateFieldOperationSettings; @@ -1055,8 +1268,6 @@ public UnaryCallSettings.Builder exportDocume } /** Returns the builder for the settings used for calls to exportDocuments. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings.Builder< ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> exportDocumentsOperationSettings() { @@ -1069,8 +1280,6 @@ public UnaryCallSettings.Builder importDocume } /** Returns the builder for the settings used for calls to importDocuments. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings.Builder importDocumentsOperationSettings() { return importDocumentsOperationSettings; @@ -1082,8 +1291,6 @@ public UnaryCallSettings.Builder createDatabas } /** Returns the builder for the settings used for calls to createDatabase. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings.Builder createDatabaseOperationSettings() { return createDatabaseOperationSettings; @@ -1106,8 +1313,6 @@ public UnaryCallSettings.Builder updateDatabas } /** Returns the builder for the settings used for calls to updateDatabase. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings.Builder updateDatabaseOperationSettings() { return updateDatabaseOperationSettings; @@ -1119,13 +1324,68 @@ public UnaryCallSettings.Builder deleteDatabas } /** Returns the builder for the settings used for calls to deleteDatabase. */ - @BetaApi( - "The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings.Builder deleteDatabaseOperationSettings() { return deleteDatabaseOperationSettings; } + /** Returns the builder for the settings used for calls to getBackup. */ + public UnaryCallSettings.Builder getBackupSettings() { + return getBackupSettings; + } + + /** Returns the builder for the settings used for calls to listBackups. */ + public UnaryCallSettings.Builder + listBackupsSettings() { + return listBackupsSettings; + } + + /** Returns the builder for the settings used for calls to deleteBackup. */ + public UnaryCallSettings.Builder deleteBackupSettings() { + return deleteBackupSettings; + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public UnaryCallSettings.Builder restoreDatabaseSettings() { + return restoreDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public OperationCallSettings.Builder + restoreDatabaseOperationSettings() { + return restoreDatabaseOperationSettings; + } + + /** Returns the builder for the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings.Builder + createBackupScheduleSettings() { + return createBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings.Builder + getBackupScheduleSettings() { + return getBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings.Builder + listBackupSchedulesSettings() { + return listBackupSchedulesSettings; + } + + /** Returns the builder for the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings.Builder + updateBackupScheduleSettings() { + return updateBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings.Builder + deleteBackupScheduleSettings() { + return deleteBackupScheduleSettings; + } + /** Returns the endpoint set by the user or the the service's default endpoint. */ @Override public String getEndpoint() { diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java index 7b4c53954..e25d62192 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java index 54fdfbd6e..d0a883dc1 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,15 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.RequestParamsBuilder; import com.google.api.gax.rpc.UnaryCallable; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseMetadata; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseMetadata; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; @@ -39,6 +44,8 @@ import com.google.firestore.admin.v1.ExportDocumentsResponse; import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; @@ -46,12 +53,19 @@ import com.google.firestore.admin.v1.ImportDocumentsRequest; import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseMetadata; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; @@ -200,6 +214,93 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor getBackupMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackup") + .setRequestMarshaller(ProtoUtils.marshaller(GetBackupRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Backup.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listBackupsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackups") + .setRequestMarshaller(ProtoUtils.marshaller(ListBackupsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListBackupsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor deleteBackupMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackup") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteBackupRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + restoreDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/RestoreDatabase") + .setRequestMarshaller( + ProtoUtils.marshaller(RestoreDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + createBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + getBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(GetBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listBackupSchedulesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackupSchedules") + .setRequestMarshaller( + ProtoUtils.marshaller(ListBackupSchedulesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListBackupSchedulesResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updateBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + deleteBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + private final UnaryCallable createIndexCallable; private final OperationCallable createIndexOperationCallable; @@ -232,6 +333,20 @@ public class GrpcFirestoreAdminStub extends FirestoreAdminStub { private final UnaryCallable deleteDatabaseCallable; private final OperationCallable deleteDatabaseOperationCallable; + private final UnaryCallable getBackupCallable; + private final UnaryCallable listBackupsCallable; + private final UnaryCallable deleteBackupCallable; + private final UnaryCallable restoreDatabaseCallable; + private final OperationCallable + restoreDatabaseOperationCallable; + private final UnaryCallable + createBackupScheduleCallable; + private final UnaryCallable getBackupScheduleCallable; + private final UnaryCallable + listBackupSchedulesCallable; + private final UnaryCallable + updateBackupScheduleCallable; + private final UnaryCallable deleteBackupScheduleCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; @@ -417,6 +532,101 @@ protected GrpcFirestoreAdminStub( return builder.build(); }) .build(); + GrpcCallSettings getBackupTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getBackupMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings listBackupsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listBackupsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteBackupTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings restoreDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(restoreDatabaseMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings + createBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings getBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings + listBackupSchedulesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listBackupSchedulesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings + updateBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + "backup_schedule.name", + String.valueOf(request.getBackupSchedule().getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); this.createIndexCallable = callableFactory.createUnaryCallable( @@ -508,6 +718,49 @@ protected GrpcFirestoreAdminStub( settings.deleteDatabaseOperationSettings(), clientContext, operationsStub); + this.getBackupCallable = + callableFactory.createUnaryCallable( + getBackupTransportSettings, settings.getBackupSettings(), clientContext); + this.listBackupsCallable = + callableFactory.createUnaryCallable( + listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); + this.deleteBackupCallable = + callableFactory.createUnaryCallable( + deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); + this.restoreDatabaseCallable = + callableFactory.createUnaryCallable( + restoreDatabaseTransportSettings, settings.restoreDatabaseSettings(), clientContext); + this.restoreDatabaseOperationCallable = + callableFactory.createOperationCallable( + restoreDatabaseTransportSettings, + settings.restoreDatabaseOperationSettings(), + clientContext, + operationsStub); + this.createBackupScheduleCallable = + callableFactory.createUnaryCallable( + createBackupScheduleTransportSettings, + settings.createBackupScheduleSettings(), + clientContext); + this.getBackupScheduleCallable = + callableFactory.createUnaryCallable( + getBackupScheduleTransportSettings, + settings.getBackupScheduleSettings(), + clientContext); + this.listBackupSchedulesCallable = + callableFactory.createUnaryCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); + this.updateBackupScheduleCallable = + callableFactory.createUnaryCallable( + updateBackupScheduleTransportSettings, + settings.updateBackupScheduleSettings(), + clientContext); + this.deleteBackupScheduleCallable = + callableFactory.createUnaryCallable( + deleteBackupScheduleTransportSettings, + settings.deleteBackupScheduleSettings(), + clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -639,6 +892,58 @@ public UnaryCallable deleteDatabaseCallable() return deleteDatabaseOperationCallable; } + @Override + public UnaryCallable getBackupCallable() { + return getBackupCallable; + } + + @Override + public UnaryCallable listBackupsCallable() { + return listBackupsCallable; + } + + @Override + public UnaryCallable deleteBackupCallable() { + return deleteBackupCallable; + } + + @Override + public UnaryCallable restoreDatabaseCallable() { + return restoreDatabaseCallable; + } + + @Override + public OperationCallable + restoreDatabaseOperationCallable() { + return restoreDatabaseOperationCallable; + } + + @Override + public UnaryCallable createBackupScheduleCallable() { + return createBackupScheduleCallable; + } + + @Override + public UnaryCallable getBackupScheduleCallable() { + return getBackupScheduleCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesCallable() { + return listBackupSchedulesCallable; + } + + @Override + public UnaryCallable updateBackupScheduleCallable() { + return updateBackupScheduleCallable; + } + + @Override + public UnaryCallable deleteBackupScheduleCallable() { + return deleteBackupScheduleCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java index 6f8d4ecf6..1364aabb3 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package com.google.cloud.firestore.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.httpjson.HttpJsonCallSettings; import com.google.api.gax.httpjson.HttpJsonCallableFactory; import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; @@ -41,7 +40,6 @@ *

This class is for advanced usage. */ @Generated("by gapic-generator-java") -@BetaApi public class HttpJsonFirestoreAdminCallableFactory implements HttpJsonStubCallableFactory { @@ -73,8 +71,6 @@ public UnaryCallable createBatchingCa httpJsonCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( diff --git a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java index 7cbf5aecd..e81b9b65d 100644 --- a/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java +++ b/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; import com.google.api.HttpRule; -import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; @@ -37,10 +36,15 @@ import com.google.api.gax.rpc.RequestParamsBuilder; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseMetadata; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseMetadata; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; @@ -49,6 +53,8 @@ import com.google.firestore.admin.v1.ExportDocumentsResponse; import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; @@ -56,12 +62,19 @@ import com.google.firestore.admin.v1.ImportDocumentsRequest; import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseMetadata; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; @@ -83,22 +96,22 @@ *

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") -@BetaApi public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(ExportDocumentsResponse.getDescriptor()) - .add(UpdateDatabaseMetadata.getDescriptor()) .add(Field.getDescriptor()) - .add(Empty.getDescriptor()) + .add(RestoreDatabaseMetadata.getDescriptor()) .add(ImportDocumentsMetadata.getDescriptor()) .add(Database.getDescriptor()) + .add(FieldOperationMetadata.getDescriptor()) + .add(DeleteDatabaseMetadata.getDescriptor()) + .add(UpdateDatabaseMetadata.getDescriptor()) + .add(Empty.getDescriptor()) .add(Index.getDescriptor()) .add(CreateDatabaseMetadata.getDescriptor()) - .add(FieldOperationMetadata.getDescriptor()) .add(ExportDocumentsMetadata.getDescriptor()) .add(IndexOperationMetadata.getDescriptor()) - .add(DeleteDatabaseMetadata.getDescriptor()) .build(); private static final ApiMethodDescriptor @@ -625,6 +638,327 @@ public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub { HttpJsonOperationSnapshot.create(response)) .build(); + private static final ApiMethodDescriptor getBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackup") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backups/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Backup.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listBackupsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackups") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/backups", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListBackupsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackup") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backups/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + restoreDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/RestoreDatabase") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/databases:restore", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestoreDatabaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateBackupSchedule") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*}/backupSchedules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupSchedule", request.getBackupSchedule(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackupSchedule") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listBackupSchedulesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackupSchedules") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*}/backupSchedules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListBackupSchedulesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateBackupSchedule") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{backupSchedule.name=projects/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "backupSchedule.name", + request.getBackupSchedule().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupSchedule", request.getBackupSchedule(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackupSchedule") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + private final UnaryCallable createIndexCallable; private final OperationCallable createIndexOperationCallable; @@ -657,6 +991,20 @@ public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub { private final UnaryCallable deleteDatabaseCallable; private final OperationCallable deleteDatabaseOperationCallable; + private final UnaryCallable getBackupCallable; + private final UnaryCallable listBackupsCallable; + private final UnaryCallable deleteBackupCallable; + private final UnaryCallable restoreDatabaseCallable; + private final OperationCallable + restoreDatabaseOperationCallable; + private final UnaryCallable + createBackupScheduleCallable; + private final UnaryCallable getBackupScheduleCallable; + private final UnaryCallable + listBackupSchedulesCallable; + private final UnaryCallable + updateBackupScheduleCallable; + private final UnaryCallable deleteBackupScheduleCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; @@ -883,6 +1231,112 @@ protected HttpJsonFirestoreAdminStub( return builder.build(); }) .build(); + HttpJsonCallSettings getBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings listBackupsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listBackupsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings restoreDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restoreDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + createBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + getBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + listBackupSchedulesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listBackupSchedulesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + updateBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + "backup_schedule.name", + String.valueOf(request.getBackupSchedule().getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); this.createIndexCallable = callableFactory.createUnaryCallable( @@ -974,6 +1428,49 @@ protected HttpJsonFirestoreAdminStub( settings.deleteDatabaseOperationSettings(), clientContext, httpJsonOperationsStub); + this.getBackupCallable = + callableFactory.createUnaryCallable( + getBackupTransportSettings, settings.getBackupSettings(), clientContext); + this.listBackupsCallable = + callableFactory.createUnaryCallable( + listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); + this.deleteBackupCallable = + callableFactory.createUnaryCallable( + deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); + this.restoreDatabaseCallable = + callableFactory.createUnaryCallable( + restoreDatabaseTransportSettings, settings.restoreDatabaseSettings(), clientContext); + this.restoreDatabaseOperationCallable = + callableFactory.createOperationCallable( + restoreDatabaseTransportSettings, + settings.restoreDatabaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createBackupScheduleCallable = + callableFactory.createUnaryCallable( + createBackupScheduleTransportSettings, + settings.createBackupScheduleSettings(), + clientContext); + this.getBackupScheduleCallable = + callableFactory.createUnaryCallable( + getBackupScheduleTransportSettings, + settings.getBackupScheduleSettings(), + clientContext); + this.listBackupSchedulesCallable = + callableFactory.createUnaryCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); + this.updateBackupScheduleCallable = + callableFactory.createUnaryCallable( + updateBackupScheduleTransportSettings, + settings.updateBackupScheduleSettings(), + clientContext); + this.deleteBackupScheduleCallable = + callableFactory.createUnaryCallable( + deleteBackupScheduleTransportSettings, + settings.deleteBackupScheduleSettings(), + clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -996,6 +1493,15 @@ public static List getMethodDescriptors() { methodDescriptors.add(listDatabasesMethodDescriptor); methodDescriptors.add(updateDatabaseMethodDescriptor); methodDescriptors.add(deleteDatabaseMethodDescriptor); + methodDescriptors.add(getBackupMethodDescriptor); + methodDescriptors.add(listBackupsMethodDescriptor); + methodDescriptors.add(deleteBackupMethodDescriptor); + methodDescriptors.add(restoreDatabaseMethodDescriptor); + methodDescriptors.add(createBackupScheduleMethodDescriptor); + methodDescriptors.add(getBackupScheduleMethodDescriptor); + methodDescriptors.add(listBackupSchedulesMethodDescriptor); + methodDescriptors.add(updateBackupScheduleMethodDescriptor); + methodDescriptors.add(deleteBackupScheduleMethodDescriptor); return methodDescriptors; } @@ -1125,6 +1631,58 @@ public UnaryCallable deleteDatabaseCallable() return deleteDatabaseOperationCallable; } + @Override + public UnaryCallable getBackupCallable() { + return getBackupCallable; + } + + @Override + public UnaryCallable listBackupsCallable() { + return listBackupsCallable; + } + + @Override + public UnaryCallable deleteBackupCallable() { + return deleteBackupCallable; + } + + @Override + public UnaryCallable restoreDatabaseCallable() { + return restoreDatabaseCallable; + } + + @Override + public OperationCallable + restoreDatabaseOperationCallable() { + return restoreDatabaseOperationCallable; + } + + @Override + public UnaryCallable createBackupScheduleCallable() { + return createBackupScheduleCallable; + } + + @Override + public UnaryCallable getBackupScheduleCallable() { + return getBackupScheduleCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesCallable() { + return listBackupSchedulesCallable; + } + + @Override + public UnaryCallable updateBackupScheduleCallable() { + return updateBackupScheduleCallable; + } + + @Override + public UnaryCallable deleteBackupScheduleCallable() { + return deleteBackupScheduleCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-firestore-admin/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json b/google-cloud-firestore-admin/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json index e3b6a2e3c..4898cf2e6 100644 --- a/google-cloud-firestore-admin/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json +++ b/google-cloud-firestore-admin/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json @@ -449,6 +449,87 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.Backup", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$State", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$Stats", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$Stats$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BackupSchedule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BackupSchedule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.admin.v1.CreateDatabaseMetadata", "queryAllDeclaredConstructors": true, @@ -503,6 +584,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.DailyRecurrence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DailyRecurrence$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.admin.v1.Database", "queryAllDeclaredConstructors": true, @@ -566,6 +665,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.admin.v1.DeleteDatabaseMetadata", "queryAllDeclaredConstructors": true, @@ -809,6 +944,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.GetBackupRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetBackupRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.admin.v1.GetDatabaseRequest", "queryAllDeclaredConstructors": true, @@ -962,6 +1133,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig$FlatIndex", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig$FlatIndex$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.admin.v1.Index$QueryScope", "queryAllDeclaredConstructors": true, @@ -998,6 +1205,78 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.admin.v1.ListDatabasesRequest", "queryAllDeclaredConstructors": true, @@ -1151,6 +1430,60 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.admin.v1.UpdateDatabaseMetadata", "queryAllDeclaredConstructors": true, @@ -1205,6 +1538,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.admin.v1.WeeklyRecurrence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.WeeklyRecurrence$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.longrunning.CancelOperationRequest", "queryAllDeclaredConstructors": true, @@ -2185,5 +2536,14 @@ "allPublicMethods": true, "allDeclaredClasses": true, "allPublicClasses": true + }, + { + "name": "com.google.type.DayOfWeek", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true } ] \ No newline at end of file diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java index d5009b330..dee30271d 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,10 @@ import com.google.api.gax.rpc.testing.FakeStatusCode; import com.google.cloud.firestore.v1.stub.HttpJsonFirestoreAdminStub; import com.google.common.collect.Lists; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupName; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BackupScheduleName; import com.google.firestore.admin.v1.CollectionGroupName; import com.google.firestore.admin.v1.Database; import com.google.firestore.admin.v1.DatabaseName; @@ -38,10 +42,14 @@ import com.google.firestore.admin.v1.FieldName; import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexName; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.LocationName; import com.google.firestore.admin.v1.ProjectName; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; import com.google.longrunning.Operation; import com.google.protobuf.Any; import com.google.protobuf.Duration; @@ -1433,4 +1441,773 @@ public void deleteDatabaseExceptionTest2() throws Exception { } catch (ExecutionException e) { } } + + @Test + public void getBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest2() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest2() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + client.deleteBackup(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + + client.deleteBackup(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void restoreDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + + Database actualResponse = client.restoreDatabaseAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void restoreDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + client.restoreDatabaseAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9821/databases/database-9821"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9821/databases/database-9821"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupSchedulesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest2() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9821/databases/database-9821"; + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupSchedulesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9821/databases/database-9821"; + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupSchedule backupSchedule = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BackupSchedule actualResponse = client.updateBackupSchedule(backupSchedule, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupSchedule backupSchedule = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupSchedule(backupSchedule, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + client.deleteBackupSchedule(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + + client.deleteBackupSchedule(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java index 10081fa8c..5aebfcf41 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,30 +28,46 @@ import com.google.api.gax.rpc.InvalidArgumentException; import com.google.api.gax.rpc.StatusCode; import com.google.common.collect.Lists; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupName; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BackupScheduleName; import com.google.firestore.admin.v1.CollectionGroupName; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; import com.google.firestore.admin.v1.DatabaseName; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; import com.google.firestore.admin.v1.ExportDocumentsRequest; import com.google.firestore.admin.v1.ExportDocumentsResponse; import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FieldName; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; import com.google.firestore.admin.v1.ImportDocumentsRequest; import com.google.firestore.admin.v1.Index; import com.google.firestore.admin.v1.IndexName; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.LocationName; import com.google.firestore.admin.v1.ProjectName; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; import com.google.longrunning.Operation; @@ -1296,4 +1312,672 @@ public void deleteDatabaseExceptionTest2() throws Exception { Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } + + @Test + public void getBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupRequest actualRequest = ((GetBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest2() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupRequest actualRequest = ((GetBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupsRequest actualRequest = ((ListBackupsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest2() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupsRequest actualRequest = ((ListBackupsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + client.deleteBackup(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupRequest actualRequest = ((DeleteBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteBackup(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupRequest actualRequest = ((DeleteBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void restoreDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + + Database actualResponse = client.restoreDatabaseAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + RestoreDatabaseRequest actualRequest = ((RestoreDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getDatabaseId(), actualRequest.getDatabaseId()); + Assert.assertEquals(request.getBackup(), actualRequest.getBackup()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void restoreDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + client.restoreDatabaseAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void createBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateBackupScheduleRequest actualRequest = + ((CreateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateBackupScheduleRequest actualRequest = + ((CreateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupScheduleRequest actualRequest = ((GetBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupScheduleRequest actualRequest = ((GetBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupSchedulesRequest actualRequest = ((ListBackupSchedulesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupSchedulesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest2() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupSchedulesRequest actualRequest = ((ListBackupSchedulesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupSchedulesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BackupSchedule actualResponse = client.updateBackupSchedule(backupSchedule, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateBackupScheduleRequest actualRequest = + ((UpdateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updateBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupSchedule(backupSchedule, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + client.deleteBackupSchedule(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupScheduleRequest actualRequest = + ((DeleteBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteBackupSchedule(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupScheduleRequest actualRequest = + ((DeleteBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java index 08eb8501a..531ec17c0 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java index f35d442c4..02c02f8af 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,25 +17,38 @@ package com.google.cloud.firestore.v1; import com.google.api.core.BetaApi; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; import com.google.firestore.admin.v1.CreateDatabaseRequest; import com.google.firestore.admin.v1.CreateIndexRequest; import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; import com.google.firestore.admin.v1.DeleteDatabaseRequest; import com.google.firestore.admin.v1.DeleteIndexRequest; import com.google.firestore.admin.v1.ExportDocumentsRequest; import com.google.firestore.admin.v1.Field; import com.google.firestore.admin.v1.FirestoreAdminGrpc.FirestoreAdminImplBase; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; import com.google.firestore.admin.v1.GetDatabaseRequest; import com.google.firestore.admin.v1.GetFieldRequest; import com.google.firestore.admin.v1.GetIndexRequest; import com.google.firestore.admin.v1.ImportDocumentsRequest; import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; import com.google.firestore.admin.v1.ListDatabasesRequest; import com.google.firestore.admin.v1.ListDatabasesResponse; import com.google.firestore.admin.v1.ListFieldsRequest; import com.google.firestore.admin.v1.ListFieldsResponse; import com.google.firestore.admin.v1.ListIndexesRequest; import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; import com.google.firestore.admin.v1.UpdateDatabaseRequest; import com.google.firestore.admin.v1.UpdateFieldRequest; import com.google.longrunning.Operation; @@ -367,4 +380,192 @@ public void deleteDatabase( Exception.class.getName()))); } } + + @Override + public void getBackup(GetBackupRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Backup) { + requests.add(request); + responseObserver.onNext(((Backup) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetBackup, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Backup.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listBackups( + ListBackupsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListBackupsResponse) { + requests.add(request); + responseObserver.onNext(((ListBackupsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListBackups, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListBackupsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deleteBackup(DeleteBackupRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteBackup, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void restoreDatabase( + RestoreDatabaseRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method RestoreDatabase, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void createBackupSchedule( + CreateBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getBackupSchedule( + GetBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listBackupSchedules( + ListBackupSchedulesRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListBackupSchedulesResponse) { + requests.add(request); + responseObserver.onNext(((ListBackupSchedulesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListBackupSchedules, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListBackupSchedulesResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void updateBackupSchedule( + UpdateBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdateBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deleteBackupSchedule( + DeleteBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); + } + } } diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocations.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocations.java index f9e50dc16..10cecbc88 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocations.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocations.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java index 6e823521a..6e12a2e8d 100644 --- a/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java +++ b/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java index 5ba54936e..9cef38b6d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,8 @@ import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListCollectionIdsResponse; @@ -247,6 +249,16 @@ * * * + *

ExecutePipeline + *

Executes a pipeline query. + * + *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • executePipelineCallable() + *

+ * + * + * *

RunAggregationQuery *

Runs an aggregation query. *

Rather than producing [Document][google.firestore.v1.Document] results like [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API allows running an aggregation to produce a series of [AggregationResult][google.firestore.v1.AggregationResult] server-side. @@ -1119,6 +1131,34 @@ public final ServerStreamingCallable runQuery return stub.runQueryCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Executes a pipeline query. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ExecutePipelineRequest request =
+   *       ExecutePipelineRequest.newBuilder().setDatabase("database1789464955").build();
+   *   ServerStream stream =
+   *       firestoreClient.executePipelineCallable().call(request);
+   *   for (ExecutePipelineResponse response : stream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
+ */ + public final ServerStreamingCallable + executePipelineCallable() { + return stub.executePipelineCallable(); + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Runs an aggregation query. diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java index c5d57c5cd..687b81a60 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,8 @@ import com.google.firestore.v1.CreateDocumentRequest; import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListCollectionIdsResponse; @@ -155,6 +157,12 @@ public ServerStreamingCallSettings runQuerySe return ((FirestoreStubSettings) getStubSettings()).runQuerySettings(); } + /** Returns the object with the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings + executePipelineSettings() { + return ((FirestoreStubSettings) getStubSettings()).executePipelineSettings(); + } + /** Returns the object with the settings used for calls to runAggregationQuery. */ public ServerStreamingCallSettings runAggregationQuerySettings() { @@ -235,7 +243,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() { return FirestoreStubSettings.defaultTransportChannelProvider(); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { return FirestoreStubSettings.defaultApiClientHeaderProviderBuilder(); } @@ -246,7 +253,6 @@ public static Builder newBuilder() { } /** Returns a new REST builder for this class. */ - @BetaApi public static Builder newHttpJsonBuilder() { return Builder.createHttpJsonDefault(); } @@ -288,7 +294,6 @@ private static Builder createDefault() { return new Builder(FirestoreStubSettings.newBuilder()); } - @BetaApi private static Builder createHttpJsonDefault() { return new Builder(FirestoreStubSettings.newHttpJsonBuilder()); } @@ -359,6 +364,12 @@ public UnaryCallSettings.Builder rollbackSettings() { return getStubSettingsBuilder().runQuerySettings(); } + /** Returns the builder for the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings.Builder + executePipelineSettings() { + return getStubSettingsBuilder().executePipelineSettings(); + } + /** Returns the builder for the settings used for calls to runAggregationQuery. */ public ServerStreamingCallSettings.Builder< RunAggregationQueryRequest, RunAggregationQueryResponse> diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json index 05f7e5a5f..44b5ecb1d 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json @@ -28,6 +28,9 @@ "DeleteDocument": { "methods": ["deleteDocument", "deleteDocument", "deleteDocumentCallable"] }, + "ExecutePipeline": { + "methods": ["executePipelineCallable"] + }, "GetDocument": { "methods": ["getDocument", "getDocumentCallable"] }, diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java index 77ab24dd0..b935957ba 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java index 0b3e92eb7..f79ecb994 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,8 @@ import com.google.firestore.v1.CreateDocumentRequest; import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListCollectionIdsResponse; @@ -107,6 +109,11 @@ public ServerStreamingCallable runQueryCallab throw new UnsupportedOperationException("Not implemented: runQueryCallable()"); } + public ServerStreamingCallable + executePipelineCallable() { + throw new UnsupportedOperationException("Not implemented: executePipelineCallable()"); + } + public ServerStreamingCallable runAggregationQueryCallable() { throw new UnsupportedOperationException("Not implemented: runAggregationQueryCallable()"); diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java index f34ce9361..a92595290 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,8 @@ import com.google.firestore.v1.Cursor; import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListCollectionIdsResponse; @@ -144,6 +146,8 @@ public class FirestoreStubSettings extends StubSettings { private final UnaryCallSettings commitSettings; private final UnaryCallSettings rollbackSettings; private final ServerStreamingCallSettings runQuerySettings; + private final ServerStreamingCallSettings + executePipelineSettings; private final ServerStreamingCallSettings runAggregationQuerySettings; private final PagedCallSettings< @@ -370,6 +374,12 @@ public ServerStreamingCallSettings runQuerySe return runQuerySettings; } + /** Returns the object with the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings + executePipelineSettings() { + return executePipelineSettings; + } + /** Returns the object with the settings used for calls to runAggregationQuery. */ public ServerStreamingCallSettings runAggregationQuerySettings() { @@ -485,7 +495,6 @@ public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(FirestoreStubSettings.class)) @@ -493,7 +502,6 @@ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProvider GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(FirestoreStubSettings.class)) @@ -538,6 +546,7 @@ protected FirestoreStubSettings(Builder settingsBuilder) throws IOException { commitSettings = settingsBuilder.commitSettings().build(); rollbackSettings = settingsBuilder.rollbackSettings().build(); runQuerySettings = settingsBuilder.runQuerySettings().build(); + executePipelineSettings = settingsBuilder.executePipelineSettings().build(); runAggregationQuerySettings = settingsBuilder.runAggregationQuerySettings().build(); partitionQuerySettings = settingsBuilder.partitionQuerySettings().build(); writeSettings = settingsBuilder.writeSettings().build(); @@ -565,6 +574,9 @@ public static class Builder extends StubSettings.Builder rollbackSettings; private final ServerStreamingCallSettings.Builder runQuerySettings; + private final ServerStreamingCallSettings.Builder< + ExecutePipelineRequest, ExecutePipelineResponse> + executePipelineSettings; private final ServerStreamingCallSettings.Builder< RunAggregationQueryRequest, RunAggregationQueryResponse> runAggregationQuerySettings; @@ -606,6 +618,7 @@ public static class Builder extends StubSettings.BuildernewArrayList())); definitions.put( "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put( @@ -664,6 +677,8 @@ public static class Builder extends StubSettings.Builder rollbackSettings() { return runQuerySettings; } + /** Returns the builder for the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings.Builder + executePipelineSettings() { + return executePipelineSettings; + } + /** Returns the builder for the settings used for calls to runAggregationQuery. */ public ServerStreamingCallSettings.Builder< RunAggregationQueryRequest, RunAggregationQueryResponse> diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java index 2c1cd24a4..388351bac 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java index 0be133886..03808fdb0 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,8 @@ import com.google.firestore.v1.CreateDocumentRequest; import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListCollectionIdsResponse; @@ -159,6 +161,17 @@ public class GrpcFirestoreStub extends FirestoreStub { .setResponseMarshaller(ProtoUtils.marshaller(RunQueryResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor + executePipelineMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName("google.firestore.v1.Firestore/ExecutePipeline") + .setRequestMarshaller( + ProtoUtils.marshaller(ExecutePipelineRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ExecutePipelineResponse.getDefaultInstance())) + .build(); + private static final MethodDescriptor runAggregationQueryMethodDescriptor = MethodDescriptor.newBuilder() @@ -240,6 +253,8 @@ public class GrpcFirestoreStub extends FirestoreStub { private final UnaryCallable commitCallable; private final UnaryCallable rollbackCallable; private final ServerStreamingCallable runQueryCallable; + private final ServerStreamingCallable + executePipelineCallable; private final ServerStreamingCallable runAggregationQueryCallable; private final UnaryCallable partitionQueryCallable; @@ -388,6 +403,17 @@ protected GrpcFirestoreStub( return builder.build(); }) .build(); + GrpcCallSettings + executePipelineTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(executePipelineMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); GrpcCallSettings runAggregationQueryTransportSettings = GrpcCallSettings.newBuilder() @@ -495,6 +521,9 @@ protected GrpcFirestoreStub( this.runQueryCallable = callableFactory.createServerStreamingCallable( runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.executePipelineCallable = + callableFactory.createServerStreamingCallable( + executePipelineTransportSettings, settings.executePipelineSettings(), clientContext); this.runAggregationQueryCallable = callableFactory.createServerStreamingCallable( runAggregationQueryTransportSettings, @@ -590,6 +619,12 @@ public ServerStreamingCallable runQueryCallab return runQueryCallable; } + @Override + public ServerStreamingCallable + executePipelineCallable() { + return executePipelineCallable; + } + @Override public ServerStreamingCallable runAggregationQueryCallable() { diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java index 78400d382..c123bc7d0 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package com.google.cloud.firestore.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.httpjson.HttpJsonCallSettings; import com.google.api.gax.httpjson.HttpJsonCallableFactory; import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; @@ -41,7 +40,6 @@ *

This class is for advanced usage. */ @Generated("by gapic-generator-java") -@BetaApi public class HttpJsonFirestoreCallableFactory implements HttpJsonStubCallableFactory { @@ -73,8 +71,6 @@ public UnaryCallable createBatchingCa httpJsonCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java index 9d8ad9cfa..9b7ebafe8 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import static com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; import static com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; @@ -46,6 +45,8 @@ import com.google.firestore.v1.CreateDocumentRequest; import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListCollectionIdsResponse; @@ -80,7 +81,6 @@ *

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") -@BetaApi public class HttpJsonFirestoreStub extends FirestoreStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); @@ -432,6 +432,43 @@ public class HttpJsonFirestoreStub extends FirestoreStub { .build()) .build(); + private static final ApiMethodDescriptor + executePipelineMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/ExecutePipeline") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{database=projects/*/databases/*}:executePipeline", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ExecutePipelineResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + private static final ApiMethodDescriptor runAggregationQueryMethodDescriptor = ApiMethodDescriptor.newBuilder() @@ -640,6 +677,8 @@ public class HttpJsonFirestoreStub extends FirestoreStub { private final UnaryCallable commitCallable; private final UnaryCallable rollbackCallable; private final ServerStreamingCallable runQueryCallable; + private final ServerStreamingCallable + executePipelineCallable; private final ServerStreamingCallable runAggregationQueryCallable; private final UnaryCallable partitionQueryCallable; @@ -796,6 +835,18 @@ protected HttpJsonFirestoreStub( return builder.build(); }) .build(); + HttpJsonCallSettings + executePipelineTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(executePipelineMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); HttpJsonCallSettings runAggregationQueryTransportSettings = HttpJsonCallSettings @@ -889,6 +940,9 @@ protected HttpJsonFirestoreStub( this.runQueryCallable = callableFactory.createServerStreamingCallable( runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.executePipelineCallable = + callableFactory.createServerStreamingCallable( + executePipelineTransportSettings, settings.executePipelineSettings(), clientContext); this.runAggregationQueryCallable = callableFactory.createServerStreamingCallable( runAggregationQueryTransportSettings, @@ -933,6 +987,7 @@ public static List getMethodDescriptors() { methodDescriptors.add(commitMethodDescriptor); methodDescriptors.add(rollbackMethodDescriptor); methodDescriptors.add(runQueryMethodDescriptor); + methodDescriptors.add(executePipelineMethodDescriptor); methodDescriptors.add(runAggregationQueryMethodDescriptor); methodDescriptors.add(partitionQueryMethodDescriptor); methodDescriptors.add(listCollectionIdsMethodDescriptor); @@ -994,6 +1049,12 @@ public ServerStreamingCallable runQueryCallab return runQueryCallable; } + @Override + public ServerStreamingCallable + executePipelineCallable() { + return executePipelineCallable; + } + @Override public ServerStreamingCallable runAggregationQueryCallable() { diff --git a/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json b/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json index 3ac840905..d7f0fd007 100644 --- a/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json +++ b/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json @@ -854,6 +854,60 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.v1.ExecutePipelineRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutePipelineRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutePipelineResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutePipelineResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutionStats", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutionStats$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.v1.ExistenceFilter", "queryAllDeclaredConstructors": true, @@ -872,6 +926,60 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.v1.ExplainMetrics", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainMetrics$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Function", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Function$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.v1.GetDocumentRequest", "queryAllDeclaredConstructors": true, @@ -1052,6 +1160,60 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.v1.Pipeline", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Pipeline$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Pipeline$Stage", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Pipeline$Stage$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PlanSummary", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PlanSummary$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.v1.Precondition", "queryAllDeclaredConstructors": true, @@ -1250,6 +1412,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.v1.StructuredPipeline", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredPipeline$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.v1.StructuredQuery", "queryAllDeclaredConstructors": true, @@ -1385,6 +1565,33 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.firestore.v1.StructuredQuery$FindNearest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FindNearest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FindNearest$DistanceMeasure", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.firestore.v1.StructuredQuery$Order", "queryAllDeclaredConstructors": true, diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 2a894c021..393273237 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -55,7 +55,7 @@ public void projections() throws Exception { .project( Field.of("foo"), Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[]{1, 2, 3.0}).asAlias("distance")); + Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")); // More compact p = diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java index c92717d30..605cf0663 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -483,6 +483,17 @@ public void runQueryExceptionTest() throws Exception { mockService.addException(exception); } + @Test + public void executePipelineTest() throws Exception {} + + @Test + public void executePipelineExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + } + @Test public void runAggregationQueryTest() throws Exception {} diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java index a0c3ecd53..97400f5ad 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,8 @@ import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListCollectionIdsResponse; @@ -540,6 +542,52 @@ public void runQueryExceptionTest() throws Exception { } } + @Test + public void executePipelineTest() throws Exception { + ExecutePipelineResponse expectedResponse = + ExecutePipelineResponse.newBuilder() + .setTransaction(ByteString.EMPTY) + .addAllResults(new ArrayList()) + .setExecutionTime(Timestamp.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + ExecutePipelineRequest request = + ExecutePipelineRequest.newBuilder().setDatabase("database1789464955").build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.executePipelineCallable(); + callable.serverStreamingCall(request, responseObserver); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + public void executePipelineExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + ExecutePipelineRequest request = + ExecutePipelineRequest.newBuilder().setDatabase("database1789464955").build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.executePipelineCallable(); + callable.serverStreamingCall(request, responseObserver); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + @Test public void runAggregationQueryTest() throws Exception { RunAggregationQueryResponse expectedResponse = diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java index 055cb5c60..9086a9deb 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java index 1fb428f82..31eba7263 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,8 @@ import com.google.firestore.v1.CreateDocumentRequest; import com.google.firestore.v1.DeleteDocumentRequest; import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.FirestoreGrpc.FirestoreImplBase; import com.google.firestore.v1.GetDocumentRequest; import com.google.firestore.v1.ListCollectionIdsRequest; @@ -273,6 +275,27 @@ public void runQuery(RunQueryRequest request, StreamObserver r } } + @Override + public void executePipeline( + ExecutePipelineRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ExecutePipelineResponse) { + requests.add(request); + responseObserver.onNext(((ExecutePipelineResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ExecutePipeline, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ExecutePipelineResponse.class.getName(), + Exception.class.getName()))); + } + } + @Override public void runAggregationQuery( RunAggregationQueryRequest request, diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocations.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocations.java index f9e50dc16..10cecbc88 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocations.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocations.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java index 6e823521a..6e12a2e8d 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java b/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java index 97073f14b..69add7236 100644 --- a/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java +++ b/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java @@ -662,6 +662,419 @@ private FirestoreAdminGrpc() {} return getDeleteDatabaseMethod; } + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupRequest, com.google.firestore.admin.v1.Backup> + getGetBackupMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetBackup", + requestType = com.google.firestore.admin.v1.GetBackupRequest.class, + responseType = com.google.firestore.admin.v1.Backup.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupRequest, com.google.firestore.admin.v1.Backup> + getGetBackupMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupRequest, com.google.firestore.admin.v1.Backup> + getGetBackupMethod; + if ((getGetBackupMethod = FirestoreAdminGrpc.getGetBackupMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetBackupMethod = FirestoreAdminGrpc.getGetBackupMethod) == null) { + FirestoreAdminGrpc.getGetBackupMethod = + getGetBackupMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetBackup")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetBackupRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.Backup.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreAdminMethodDescriptorSupplier("GetBackup")) + .build(); + } + } + } + return getGetBackupMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse> + getListBackupsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListBackups", + requestType = com.google.firestore.admin.v1.ListBackupsRequest.class, + responseType = com.google.firestore.admin.v1.ListBackupsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse> + getListBackupsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse> + getListBackupsMethod; + if ((getListBackupsMethod = FirestoreAdminGrpc.getListBackupsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListBackupsMethod = FirestoreAdminGrpc.getListBackupsMethod) == null) { + FirestoreAdminGrpc.getListBackupsMethod = + getListBackupsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListBackups")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupsResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ListBackups")) + .build(); + } + } + } + return getListBackupsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty> + getDeleteBackupMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteBackup", + requestType = com.google.firestore.admin.v1.DeleteBackupRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty> + getDeleteBackupMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty> + getDeleteBackupMethod; + if ((getDeleteBackupMethod = FirestoreAdminGrpc.getDeleteBackupMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDeleteBackupMethod = FirestoreAdminGrpc.getDeleteBackupMethod) == null) { + FirestoreAdminGrpc.getDeleteBackupMethod = + getDeleteBackupMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteBackup")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DeleteBackupRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DeleteBackup")) + .build(); + } + } + } + return getDeleteBackupMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.RestoreDatabaseRequest, com.google.longrunning.Operation> + getRestoreDatabaseMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RestoreDatabase", + requestType = com.google.firestore.admin.v1.RestoreDatabaseRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.RestoreDatabaseRequest, com.google.longrunning.Operation> + getRestoreDatabaseMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.RestoreDatabaseRequest, com.google.longrunning.Operation> + getRestoreDatabaseMethod; + if ((getRestoreDatabaseMethod = FirestoreAdminGrpc.getRestoreDatabaseMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getRestoreDatabaseMethod = FirestoreAdminGrpc.getRestoreDatabaseMethod) == null) { + FirestoreAdminGrpc.getRestoreDatabaseMethod = + getRestoreDatabaseMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "RestoreDatabase")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.RestoreDatabaseRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("RestoreDatabase")) + .build(); + } + } + } + return getRestoreDatabaseMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getCreateBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateBackupSchedule", + requestType = com.google.firestore.admin.v1.CreateBackupScheduleRequest.class, + responseType = com.google.firestore.admin.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getCreateBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getCreateBackupScheduleMethod; + if ((getCreateBackupScheduleMethod = FirestoreAdminGrpc.getCreateBackupScheduleMethod) + == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getCreateBackupScheduleMethod = FirestoreAdminGrpc.getCreateBackupScheduleMethod) + == null) { + FirestoreAdminGrpc.getCreateBackupScheduleMethod = + getCreateBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "CreateBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.CreateBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("CreateBackupSchedule")) + .build(); + } + } + } + return getCreateBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getGetBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetBackupSchedule", + requestType = com.google.firestore.admin.v1.GetBackupScheduleRequest.class, + responseType = com.google.firestore.admin.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getGetBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getGetBackupScheduleMethod; + if ((getGetBackupScheduleMethod = FirestoreAdminGrpc.getGetBackupScheduleMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetBackupScheduleMethod = FirestoreAdminGrpc.getGetBackupScheduleMethod) == null) { + FirestoreAdminGrpc.getGetBackupScheduleMethod = + getGetBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("GetBackupSchedule")) + .build(); + } + } + } + return getGetBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListBackupSchedules", + requestType = com.google.firestore.admin.v1.ListBackupSchedulesRequest.class, + responseType = com.google.firestore.admin.v1.ListBackupSchedulesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod; + if ((getListBackupSchedulesMethod = FirestoreAdminGrpc.getListBackupSchedulesMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListBackupSchedulesMethod = FirestoreAdminGrpc.getListBackupSchedulesMethod) + == null) { + FirestoreAdminGrpc.getListBackupSchedulesMethod = + getListBackupSchedulesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "ListBackupSchedules")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupSchedulesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupSchedulesResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ListBackupSchedules")) + .build(); + } + } + } + return getListBackupSchedulesMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getUpdateBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "UpdateBackupSchedule", + requestType = com.google.firestore.admin.v1.UpdateBackupScheduleRequest.class, + responseType = com.google.firestore.admin.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getUpdateBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getUpdateBackupScheduleMethod; + if ((getUpdateBackupScheduleMethod = FirestoreAdminGrpc.getUpdateBackupScheduleMethod) + == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getUpdateBackupScheduleMethod = FirestoreAdminGrpc.getUpdateBackupScheduleMethod) + == null) { + FirestoreAdminGrpc.getUpdateBackupScheduleMethod = + getUpdateBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "UpdateBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("UpdateBackupSchedule")) + .build(); + } + } + } + return getUpdateBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, com.google.protobuf.Empty> + getDeleteBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteBackupSchedule", + requestType = com.google.firestore.admin.v1.DeleteBackupScheduleRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, com.google.protobuf.Empty> + getDeleteBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, com.google.protobuf.Empty> + getDeleteBackupScheduleMethod; + if ((getDeleteBackupScheduleMethod = FirestoreAdminGrpc.getDeleteBackupScheduleMethod) + == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDeleteBackupScheduleMethod = FirestoreAdminGrpc.getDeleteBackupScheduleMethod) + == null) { + FirestoreAdminGrpc.getDeleteBackupScheduleMethod = + getDeleteBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "DeleteBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DeleteBackupSchedule")) + .build(); + } + } + } + return getDeleteBackupScheduleMethod; + } + /** Creates a new async stub that supports all call types for the service */ public static FirestoreAdminStub newStub(io.grpc.Channel channel) { io.grpc.stub.AbstractStub.StubFactory factory = @@ -963,6 +1376,152 @@ default void deleteDatabase( io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( getDeleteDatabaseMethod(), responseObserver); } + + /** + * + * + *

+     * Gets information about a backup.
+     * 
+ */ + default void getBackup( + com.google.firestore.admin.v1.GetBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetBackupMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + default void listBackups( + com.google.firestore.admin.v1.ListBackupsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListBackupsMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + default void deleteBackup( + com.google.firestore.admin.v1.DeleteBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteBackupMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + default void restoreDatabase( + com.google.firestore.admin.v1.RestoreDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getRestoreDatabaseMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + default void createBackupSchedule( + com.google.firestore.admin.v1.CreateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + default void getBackupSchedule( + com.google.firestore.admin.v1.GetBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getGetBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + default void listBackupSchedules( + com.google.firestore.admin.v1.ListBackupSchedulesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListBackupSchedulesMethod(), responseObserver); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + default void updateBackupSchedule( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + default void deleteBackupSchedule( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteBackupScheduleMethod(), responseObserver); + } } /** @@ -1185,11 +1744,159 @@ public void listFields( * https://cloud.google.com/firestore/docs/manage-data/export-import * */ - public void exportDocuments( - com.google.firestore.admin.v1.ExportDocumentsRequest request, - io.grpc.stub.StreamObserver responseObserver) { + public void exportDocuments( + com.google.firestore.admin.v1.ExportDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getExportDocumentsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Imports documents into Google Cloud Firestore. Existing documents with the
+     * same name are overwritten. The import occurs in the background and its
+     * progress can be monitored and managed via the Operation resource that is
+     * created. If an ImportDocuments operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Firestore.
+     * 
+ */ + public void importDocuments( + com.google.firestore.admin.v1.ImportDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getImportDocumentsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Create a database.
+     * 
+ */ + public void createDatabase( + com.google.firestore.admin.v1.CreateDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets information about a database.
+     * 
+ */ + public void getDatabase( + com.google.firestore.admin.v1.GetDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * List all the databases in the project.
+     * 
+ */ + public void listDatabases( + com.google.firestore.admin.v1.ListDatabasesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListDatabasesMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Updates a database.
+     * 
+ */ + public void updateDatabase( + com.google.firestore.admin.v1.UpdateDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getUpdateDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a database.
+     * 
+ */ + public void deleteDatabase( + com.google.firestore.admin.v1.DeleteDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + public void getBackup( + com.google.firestore.admin.v1.GetBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetBackupMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + public void listBackups( + com.google.firestore.admin.v1.ListBackupsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListBackupsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + public void deleteBackup( + com.google.firestore.admin.v1.DeleteBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getExportDocumentsMethod(), getCallOptions()), + getChannel().newCall(getDeleteBackupMethod(), getCallOptions()), request, responseObserver); } @@ -1198,18 +1905,28 @@ public void exportDocuments( * * *
-     * Imports documents into Google Cloud Firestore. Existing documents with the
-     * same name are overwritten. The import occurs in the background and its
-     * progress can be monitored and managed via the Operation resource that is
-     * created. If an ImportDocuments operation is cancelled, it is possible
-     * that a subset of the data has already been imported to Cloud Firestore.
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
      * 
*/ - public void importDocuments( - com.google.firestore.admin.v1.ImportDocumentsRequest request, + public void restoreDatabase( + com.google.firestore.admin.v1.RestoreDatabaseRequest request, io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getImportDocumentsMethod(), getCallOptions()), + getChannel().newCall(getRestoreDatabaseMethod(), getCallOptions()), request, responseObserver); } @@ -1218,14 +1935,17 @@ public void importDocuments( * * *
-     * Create a database.
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
      * 
*/ - public void createDatabase( - com.google.firestore.admin.v1.CreateDatabaseRequest request, - io.grpc.stub.StreamObserver responseObserver) { + public void createBackupSchedule( + com.google.firestore.admin.v1.CreateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getCreateDatabaseMethod(), getCallOptions()), + getChannel().newCall(getCreateBackupScheduleMethod(), getCallOptions()), request, responseObserver); } @@ -1234,14 +1954,15 @@ public void createDatabase( * * *
-     * Gets information about a database.
+     * Gets information about a backup schedule.
      * 
*/ - public void getDatabase( - com.google.firestore.admin.v1.GetDatabaseRequest request, - io.grpc.stub.StreamObserver responseObserver) { + public void getBackupSchedule( + com.google.firestore.admin.v1.GetBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getGetDatabaseMethod(), getCallOptions()), + getChannel().newCall(getGetBackupScheduleMethod(), getCallOptions()), request, responseObserver); } @@ -1250,15 +1971,15 @@ public void getDatabase( * * *
-     * List all the databases in the project.
+     * List backup schedules.
      * 
*/ - public void listDatabases( - com.google.firestore.admin.v1.ListDatabasesRequest request, - io.grpc.stub.StreamObserver + public void listBackupSchedules( + com.google.firestore.admin.v1.ListBackupSchedulesRequest request, + io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getListDatabasesMethod(), getCallOptions()), + getChannel().newCall(getListBackupSchedulesMethod(), getCallOptions()), request, responseObserver); } @@ -1267,14 +1988,15 @@ public void listDatabases( * * *
-     * Updates a database.
+     * Updates a backup schedule.
      * 
*/ - public void updateDatabase( - com.google.firestore.admin.v1.UpdateDatabaseRequest request, - io.grpc.stub.StreamObserver responseObserver) { + public void updateBackupSchedule( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getUpdateDatabaseMethod(), getCallOptions()), + getChannel().newCall(getUpdateBackupScheduleMethod(), getCallOptions()), request, responseObserver); } @@ -1283,14 +2005,14 @@ public void updateDatabase( * * *
-     * Deletes a database.
+     * Deletes a backup schedule.
      * 
*/ - public void deleteDatabase( - com.google.firestore.admin.v1.DeleteDatabaseRequest request, - io.grpc.stub.StreamObserver responseObserver) { + public void deleteBackupSchedule( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest request, + io.grpc.stub.StreamObserver responseObserver) { io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getDeleteDatabaseMethod(), getCallOptions()), + getChannel().newCall(getDeleteBackupScheduleMethod(), getCallOptions()), request, responseObserver); } @@ -1552,6 +2274,139 @@ public com.google.longrunning.Operation deleteDatabase( return io.grpc.stub.ClientCalls.blockingUnaryCall( getChannel(), getDeleteDatabaseMethod(), getCallOptions(), request); } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + public com.google.firestore.admin.v1.Backup getBackup( + com.google.firestore.admin.v1.GetBackupRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetBackupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + public com.google.firestore.admin.v1.ListBackupsResponse listBackups( + com.google.firestore.admin.v1.ListBackupsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListBackupsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + public com.google.protobuf.Empty deleteBackup( + com.google.firestore.admin.v1.DeleteBackupRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteBackupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.longrunning.Operation restoreDatabase( + com.google.firestore.admin.v1.RestoreDatabaseRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRestoreDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule createBackupSchedule( + com.google.firestore.admin.v1.CreateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule( + com.google.firestore.admin.v1.GetBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + public com.google.firestore.admin.v1.ListBackupSchedulesResponse listBackupSchedules( + com.google.firestore.admin.v1.ListBackupSchedulesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListBackupSchedulesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule updateBackupSchedule( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public com.google.protobuf.Empty deleteBackupSchedule( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteBackupScheduleMethod(), getCallOptions(), request); + } } /** @@ -1814,6 +2669,144 @@ protected FirestoreAdminFutureStub build( return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getDeleteDatabaseMethod(), getCallOptions()), request); } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getBackup(com.google.firestore.admin.v1.GetBackupRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetBackupMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListBackupsResponse> + listBackups(com.google.firestore.admin.v1.ListBackupsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListBackupsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteBackup(com.google.firestore.admin.v1.DeleteBackupRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteBackupMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + restoreDatabase(com.google.firestore.admin.v1.RestoreDatabaseRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRestoreDatabaseMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.BackupSchedule> + createBackupSchedule(com.google.firestore.admin.v1.CreateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.BackupSchedule> + getBackupSchedule(com.google.firestore.admin.v1.GetBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + listBackupSchedules(com.google.firestore.admin.v1.ListBackupSchedulesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListBackupSchedulesMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.BackupSchedule> + updateBackupSchedule(com.google.firestore.admin.v1.UpdateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getUpdateBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteBackupSchedule(com.google.firestore.admin.v1.DeleteBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteBackupScheduleMethod(), getCallOptions()), request); + } } private static final int METHODID_CREATE_INDEX = 0; @@ -1830,6 +2823,15 @@ protected FirestoreAdminFutureStub build( private static final int METHODID_LIST_DATABASES = 11; private static final int METHODID_UPDATE_DATABASE = 12; private static final int METHODID_DELETE_DATABASE = 13; + private static final int METHODID_GET_BACKUP = 14; + private static final int METHODID_LIST_BACKUPS = 15; + private static final int METHODID_DELETE_BACKUP = 16; + private static final int METHODID_RESTORE_DATABASE = 17; + private static final int METHODID_CREATE_BACKUP_SCHEDULE = 18; + private static final int METHODID_GET_BACKUP_SCHEDULE = 19; + private static final int METHODID_LIST_BACKUP_SCHEDULES = 20; + private static final int METHODID_UPDATE_BACKUP_SCHEDULE = 21; + private static final int METHODID_DELETE_BACKUP_SCHEDULE = 22; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -1922,6 +2924,57 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv (com.google.firestore.admin.v1.DeleteDatabaseRequest) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_GET_BACKUP: + serviceImpl.getBackup( + (com.google.firestore.admin.v1.GetBackupRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_BACKUPS: + serviceImpl.listBackups( + (com.google.firestore.admin.v1.ListBackupsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_DELETE_BACKUP: + serviceImpl.deleteBackup( + (com.google.firestore.admin.v1.DeleteBackupRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_RESTORE_DATABASE: + serviceImpl.restoreDatabase( + (com.google.firestore.admin.v1.RestoreDatabaseRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_BACKUP_SCHEDULE: + serviceImpl.createBackupSchedule( + (com.google.firestore.admin.v1.CreateBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_GET_BACKUP_SCHEDULE: + serviceImpl.getBackupSchedule( + (com.google.firestore.admin.v1.GetBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_LIST_BACKUP_SCHEDULES: + serviceImpl.listBackupSchedules( + (com.google.firestore.admin.v1.ListBackupSchedulesRequest) request, + (io.grpc.stub.StreamObserver< + com.google.firestore.admin.v1.ListBackupSchedulesResponse>) + responseObserver); + break; + case METHODID_UPDATE_BACKUP_SCHEDULE: + serviceImpl.updateBackupSchedule( + (com.google.firestore.admin.v1.UpdateBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_DELETE_BACKUP_SCHEDULE: + serviceImpl.deleteBackupSchedule( + (com.google.firestore.admin.v1.DeleteBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; default: throw new AssertionError(); } @@ -2027,6 +3080,65 @@ public static final io.grpc.ServerServiceDefinition bindService(AsyncService ser new MethodHandlers< com.google.firestore.admin.v1.DeleteDatabaseRequest, com.google.longrunning.Operation>(service, METHODID_DELETE_DATABASE))) + .addMethod( + getGetBackupMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetBackupRequest, + com.google.firestore.admin.v1.Backup>(service, METHODID_GET_BACKUP))) + .addMethod( + getListBackupsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse>( + service, METHODID_LIST_BACKUPS))) + .addMethod( + getDeleteBackupMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty>( + service, METHODID_DELETE_BACKUP))) + .addMethod( + getRestoreDatabaseMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.RestoreDatabaseRequest, + com.google.longrunning.Operation>(service, METHODID_RESTORE_DATABASE))) + .addMethod( + getCreateBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule>( + service, METHODID_CREATE_BACKUP_SCHEDULE))) + .addMethod( + getGetBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule>( + service, METHODID_GET_BACKUP_SCHEDULE))) + .addMethod( + getListBackupSchedulesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse>( + service, METHODID_LIST_BACKUP_SCHEDULES))) + .addMethod( + getUpdateBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule>( + service, METHODID_UPDATE_BACKUP_SCHEDULE))) + .addMethod( + getDeleteBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, + com.google.protobuf.Empty>(service, METHODID_DELETE_BACKUP_SCHEDULE))) .build(); } @@ -2092,6 +3204,15 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getListDatabasesMethod()) .addMethod(getUpdateDatabaseMethod()) .addMethod(getDeleteDatabaseMethod()) + .addMethod(getGetBackupMethod()) + .addMethod(getListBackupsMethod()) + .addMethod(getDeleteBackupMethod()) + .addMethod(getRestoreDatabaseMethod()) + .addMethod(getCreateBackupScheduleMethod()) + .addMethod(getGetBackupScheduleMethod()) + .addMethod(getListBackupSchedulesMethod()) + .addMethod(getUpdateBackupScheduleMethod()) + .addMethod(getDeleteBackupScheduleMethod()) .build(); } } diff --git a/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java b/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java index 24bd52f05..ecdbe1c13 100644 --- a/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java +++ b/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java @@ -421,6 +421,50 @@ private FirestoreGrpc() {} return getRunQueryMethod; } + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse> + getExecutePipelineMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ExecutePipeline", + requestType = com.google.firestore.v1.ExecutePipelineRequest.class, + responseType = com.google.firestore.v1.ExecutePipelineResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse> + getExecutePipelineMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse> + getExecutePipelineMethod; + if ((getExecutePipelineMethod = FirestoreGrpc.getExecutePipelineMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getExecutePipelineMethod = FirestoreGrpc.getExecutePipelineMethod) == null) { + FirestoreGrpc.getExecutePipelineMethod = + getExecutePipelineMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ExecutePipeline")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ExecutePipelineRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ExecutePipelineResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("ExecutePipeline")) + .build(); + } + } + } + return getExecutePipelineMethod; + } + private static volatile io.grpc.MethodDescriptor< com.google.firestore.v1.RunAggregationQueryRequest, com.google.firestore.v1.RunAggregationQueryResponse> @@ -906,6 +950,21 @@ default void runQuery( io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRunQueryMethod(), responseObserver); } + /** + * + * + *
+     * Executes a pipeline query.
+     * 
+ */ + default void executePipeline( + com.google.firestore.v1.ExecutePipelineRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getExecutePipelineMethod(), responseObserver); + } + /** * * @@ -1212,6 +1271,23 @@ public void runQuery( getChannel().newCall(getRunQueryMethod(), getCallOptions()), request, responseObserver); } + /** + * + * + *
+     * Executes a pipeline query.
+     * 
+ */ + public void executePipeline( + com.google.firestore.v1.ExecutePipelineRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncServerStreamingCall( + getChannel().newCall(getExecutePipelineMethod(), getCallOptions()), + request, + responseObserver); + } + /** * * @@ -1483,6 +1559,19 @@ public java.util.Iterator runQuery( getChannel(), getRunQueryMethod(), getCallOptions(), request); } + /** + * + * + *
+     * Executes a pipeline query.
+     * 
+ */ + public java.util.Iterator executePipeline( + com.google.firestore.v1.ExecutePipelineRequest request) { + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( + getChannel(), getExecutePipelineMethod(), getCallOptions(), request); + } + /** * * @@ -1759,13 +1848,14 @@ public com.google.common.util.concurrent.ListenableFuture implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -1834,6 +1924,12 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_EXECUTE_PIPELINE: + serviceImpl.executePipeline( + (com.google.firestore.v1.ExecutePipelineRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; case METHODID_RUN_AGGREGATION_QUERY: serviceImpl.runAggregationQuery( (com.google.firestore.v1.RunAggregationQueryRequest) request, @@ -1948,6 +2044,13 @@ public static final io.grpc.ServerServiceDefinition bindService(AsyncService ser new MethodHandlers< com.google.firestore.v1.RunQueryRequest, com.google.firestore.v1.RunQueryResponse>(service, METHODID_RUN_QUERY))) + .addMethod( + getExecutePipelineMethod(), + io.grpc.stub.ServerCalls.asyncServerStreamingCall( + new MethodHandlers< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse>( + service, METHODID_EXECUTE_PIPELINE))) .addMethod( getRunAggregationQueryMethod(), io.grpc.stub.ServerCalls.asyncServerStreamingCall( @@ -2053,6 +2156,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getCommitMethod()) .addMethod(getRollbackMethod()) .addMethod(getRunQueryMethod()) + .addMethod(getExecutePipelineMethod()) .addMethod(getRunAggregationQueryMethod()) .addMethod(getPartitionQueryMethod()) .addMethod(getWriteMethod()) diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Backup.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Backup.java new file mode 100644 index 000000000..25a0b809b --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Backup.java @@ -0,0 +1,3067 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/backup.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A Backup of a Cloud Firestore Database.
+ *
+ * The backup contains all documents and index configurations for the given
+ * database at a specific point in time.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup} + */ +public final class Backup extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Backup) + BackupOrBuilder { + private static final long serialVersionUID = 0L; + // Use Backup.newBuilder() to construct. + private Backup(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Backup() { + name_ = ""; + database_ = ""; + databaseUid_ = ""; + state_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Backup(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.class, + com.google.firestore.admin.v1.Backup.Builder.class); + } + + /** + * + * + *
+   * Indicate the current state of the backup.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Backup.State} + */ + public enum State implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The state is unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + STATE_UNSPECIFIED(0), + /** + * + * + *
+     * The pending backup is still being created. Operations on the
+     * backup will be rejected in this state.
+     * 
+ * + * CREATING = 1; + */ + CREATING(1), + /** + * + * + *
+     * The backup is complete and ready to use.
+     * 
+ * + * READY = 2; + */ + READY(2), + /** + * + * + *
+     * The backup is not available at this moment.
+     * 
+ * + * NOT_AVAILABLE = 3; + */ + NOT_AVAILABLE(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * The state is unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int STATE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * The pending backup is still being created. Operations on the
+     * backup will be rejected in this state.
+     * 
+ * + * CREATING = 1; + */ + public static final int CREATING_VALUE = 1; + /** + * + * + *
+     * The backup is complete and ready to use.
+     * 
+ * + * READY = 2; + */ + public static final int READY_VALUE = 2; + /** + * + * + *
+     * The backup is not available at this moment.
+     * 
+ * + * NOT_AVAILABLE = 3; + */ + public static final int NOT_AVAILABLE_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static State valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static State forNumber(int value) { + switch (value) { + case 0: + return STATE_UNSPECIFIED; + case 1: + return CREATING; + case 2: + return READY; + case 3: + return NOT_AVAILABLE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Backup.getDescriptor().getEnumTypes().get(0); + } + + private static final State[] VALUES = values(); + + public static State valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private State(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Backup.State) + } + + public interface StatsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Backup.Stats) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Output only. Summation of the size of all documents and index entries in
+     * the backup, measured in bytes.
+     * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The sizeBytes. + */ + long getSizeBytes(); + + /** + * + * + *
+     * Output only. The total number of documents contained in the backup.
+     * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The documentCount. + */ + long getDocumentCount(); + + /** + * + * + *
+     * Output only. The total number of index entries contained in the backup.
+     * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexCount. + */ + long getIndexCount(); + } + /** + * + * + *
+   * Backup specific statistics.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup.Stats} + */ + public static final class Stats extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Backup.Stats) + StatsOrBuilder { + private static final long serialVersionUID = 0L; + // Use Stats.newBuilder() to construct. + private Stats(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Stats() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Stats(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.Stats.class, + com.google.firestore.admin.v1.Backup.Stats.Builder.class); + } + + public static final int SIZE_BYTES_FIELD_NUMBER = 1; + private long sizeBytes_ = 0L; + /** + * + * + *
+     * Output only. Summation of the size of all documents and index entries in
+     * the backup, measured in bytes.
+     * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The sizeBytes. + */ + @java.lang.Override + public long getSizeBytes() { + return sizeBytes_; + } + + public static final int DOCUMENT_COUNT_FIELD_NUMBER = 2; + private long documentCount_ = 0L; + /** + * + * + *
+     * Output only. The total number of documents contained in the backup.
+     * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The documentCount. + */ + @java.lang.Override + public long getDocumentCount() { + return documentCount_; + } + + public static final int INDEX_COUNT_FIELD_NUMBER = 3; + private long indexCount_ = 0L; + /** + * + * + *
+     * Output only. The total number of index entries contained in the backup.
+     * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexCount. + */ + @java.lang.Override + public long getIndexCount() { + return indexCount_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (sizeBytes_ != 0L) { + output.writeInt64(1, sizeBytes_); + } + if (documentCount_ != 0L) { + output.writeInt64(2, documentCount_); + } + if (indexCount_ != 0L) { + output.writeInt64(3, indexCount_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (sizeBytes_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, sizeBytes_); + } + if (documentCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, documentCount_); + } + if (indexCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(3, indexCount_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Backup.Stats)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Backup.Stats other = + (com.google.firestore.admin.v1.Backup.Stats) obj; + + if (getSizeBytes() != other.getSizeBytes()) return false; + if (getDocumentCount() != other.getDocumentCount()) return false; + if (getIndexCount() != other.getIndexCount()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SIZE_BYTES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSizeBytes()); + hash = (37 * hash) + DOCUMENT_COUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getDocumentCount()); + hash = (37 * hash) + INDEX_COUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getIndexCount()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Backup.Stats prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+     * Backup specific statistics.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup.Stats} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Backup.Stats) + com.google.firestore.admin.v1.Backup.StatsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.Stats.class, + com.google.firestore.admin.v1.Backup.Stats.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Backup.Stats.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + sizeBytes_ = 0L; + documentCount_ = 0L; + indexCount_ = 0L; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats build() { + com.google.firestore.admin.v1.Backup.Stats result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats buildPartial() { + com.google.firestore.admin.v1.Backup.Stats result = + new com.google.firestore.admin.v1.Backup.Stats(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Backup.Stats result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.sizeBytes_ = sizeBytes_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.documentCount_ = documentCount_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.indexCount_ = indexCount_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Backup.Stats) { + return mergeFrom((com.google.firestore.admin.v1.Backup.Stats) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Backup.Stats other) { + if (other == com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance()) return this; + if (other.getSizeBytes() != 0L) { + setSizeBytes(other.getSizeBytes()); + } + if (other.getDocumentCount() != 0L) { + setDocumentCount(other.getDocumentCount()); + } + if (other.getIndexCount() != 0L) { + setIndexCount(other.getIndexCount()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + sizeBytes_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + documentCount_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 24: + { + indexCount_ = input.readInt64(); + bitField0_ |= 0x00000004; + break; + } // case 24 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private long sizeBytes_; + /** + * + * + *
+       * Output only. Summation of the size of all documents and index entries in
+       * the backup, measured in bytes.
+       * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The sizeBytes. + */ + @java.lang.Override + public long getSizeBytes() { + return sizeBytes_; + } + /** + * + * + *
+       * Output only. Summation of the size of all documents and index entries in
+       * the backup, measured in bytes.
+       * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The sizeBytes to set. + * @return This builder for chaining. + */ + public Builder setSizeBytes(long value) { + + sizeBytes_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. Summation of the size of all documents and index entries in
+       * the backup, measured in bytes.
+       * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearSizeBytes() { + bitField0_ = (bitField0_ & ~0x00000001); + sizeBytes_ = 0L; + onChanged(); + return this; + } + + private long documentCount_; + /** + * + * + *
+       * Output only. The total number of documents contained in the backup.
+       * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The documentCount. + */ + @java.lang.Override + public long getDocumentCount() { + return documentCount_; + } + /** + * + * + *
+       * Output only. The total number of documents contained in the backup.
+       * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The documentCount to set. + * @return This builder for chaining. + */ + public Builder setDocumentCount(long value) { + + documentCount_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The total number of documents contained in the backup.
+       * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearDocumentCount() { + bitField0_ = (bitField0_ & ~0x00000002); + documentCount_ = 0L; + onChanged(); + return this; + } + + private long indexCount_; + /** + * + * + *
+       * Output only. The total number of index entries contained in the backup.
+       * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexCount. + */ + @java.lang.Override + public long getIndexCount() { + return indexCount_; + } + /** + * + * + *
+       * Output only. The total number of index entries contained in the backup.
+       * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The indexCount to set. + * @return This builder for chaining. + */ + public Builder setIndexCount(long value) { + + indexCount_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+       * Output only. The total number of index entries contained in the backup.
+       * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearIndexCount() { + bitField0_ = (bitField0_ & ~0x00000004); + indexCount_ = 0L; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Backup.Stats) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Backup.Stats) + private static final com.google.firestore.admin.v1.Backup.Stats DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Backup.Stats(); + } + + public static com.google.firestore.admin.v1.Backup.Stats getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Stats parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_UID_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseUid_ = ""; + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + @java.lang.Override + public java.lang.String getDatabaseUid() { + java.lang.Object ref = databaseUid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseUid_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for databaseUid. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseUidBytes() { + java.lang.Object ref = databaseUid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseUid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SNAPSHOT_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp snapshotTime_; + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the snapshotTime field is set. + */ + @java.lang.Override + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The snapshotTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSnapshotTime() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + public static final int EXPIRE_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp expireTime_; + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + @java.lang.Override + public boolean hasExpireTime() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getExpireTime() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + + public static final int STATS_FIELD_NUMBER = 6; + private com.google.firestore.admin.v1.Backup.Stats stats_; + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the stats field is set. + */ + @java.lang.Override + public boolean hasStats() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The stats. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats getStats() { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.StatsOrBuilder getStatsOrBuilder() { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } + + public static final int STATE_FIELD_NUMBER = 8; + private int state_ = 0; + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.State getState() { + com.google.firestore.admin.v1.Backup.State result = + com.google.firestore.admin.v1.Backup.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.Backup.State.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, database_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getSnapshotTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getExpireTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(6, getStats()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseUid_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, databaseUid_); + } + if (state_ != com.google.firestore.admin.v1.Backup.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(8, state_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, database_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getSnapshotTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getExpireTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getStats()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseUid_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, databaseUid_); + } + if (state_ != com.google.firestore.admin.v1.Backup.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(8, state_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Backup)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Backup other = (com.google.firestore.admin.v1.Backup) obj; + + if (!getName().equals(other.getName())) return false; + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getDatabaseUid().equals(other.getDatabaseUid())) return false; + if (hasSnapshotTime() != other.hasSnapshotTime()) return false; + if (hasSnapshotTime()) { + if (!getSnapshotTime().equals(other.getSnapshotTime())) return false; + } + if (hasExpireTime() != other.hasExpireTime()) return false; + if (hasExpireTime()) { + if (!getExpireTime().equals(other.getExpireTime())) return false; + } + if (hasStats() != other.hasStats()) return false; + if (hasStats()) { + if (!getStats().equals(other.getStats())) return false; + } + if (state_ != other.state_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + hash = (37 * hash) + DATABASE_UID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseUid().hashCode(); + if (hasSnapshotTime()) { + hash = (37 * hash) + SNAPSHOT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSnapshotTime().hashCode(); + } + if (hasExpireTime()) { + hash = (37 * hash) + EXPIRE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getExpireTime().hashCode(); + } + if (hasStats()) { + hash = (37 * hash) + STATS_FIELD_NUMBER; + hash = (53 * hash) + getStats().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Backup parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Backup prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A Backup of a Cloud Firestore Database.
+   *
+   * The backup contains all documents and index configurations for the given
+   * database at a specific point in time.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Backup) + com.google.firestore.admin.v1.BackupOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.class, + com.google.firestore.admin.v1.Backup.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Backup.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getSnapshotTimeFieldBuilder(); + getExpireTimeFieldBuilder(); + getStatsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + database_ = ""; + databaseUid_ = ""; + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + stats_ = null; + if (statsBuilder_ != null) { + statsBuilder_.dispose(); + statsBuilder_ = null; + } + state_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Backup.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup build() { + com.google.firestore.admin.v1.Backup result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup buildPartial() { + com.google.firestore.admin.v1.Backup result = new com.google.firestore.admin.v1.Backup(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Backup result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.databaseUid_ = databaseUid_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.snapshotTime_ = + snapshotTimeBuilder_ == null ? snapshotTime_ : snapshotTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.expireTime_ = expireTimeBuilder_ == null ? expireTime_ : expireTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.stats_ = statsBuilder_ == null ? stats_ : statsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.state_ = state_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Backup) { + return mergeFrom((com.google.firestore.admin.v1.Backup) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Backup other) { + if (other == com.google.firestore.admin.v1.Backup.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getDatabaseUid().isEmpty()) { + databaseUid_ = other.databaseUid_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.hasSnapshotTime()) { + mergeSnapshotTime(other.getSnapshotTime()); + } + if (other.hasExpireTime()) { + mergeExpireTime(other.getExpireTime()); + } + if (other.hasStats()) { + mergeStats(other.getStats()); + } + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getSnapshotTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 26 + case 34: + { + input.readMessage(getExpireTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 34 + case 50: + { + input.readMessage(getStatsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 58: + { + databaseUid_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 58 + case 64: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000040; + break; + } // case 64 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object database_ = ""; + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object databaseUid_ = ""; + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + public java.lang.String getDatabaseUid() { + java.lang.Object ref = databaseUid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseUid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for databaseUid. + */ + public com.google.protobuf.ByteString getDatabaseUidBytes() { + java.lang.Object ref = databaseUid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseUid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The databaseUid to set. + * @return This builder for chaining. + */ + public Builder setDatabaseUid(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + databaseUid_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseUid() { + databaseUid_ = getDefaultInstance().getDatabaseUid(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for databaseUid to set. + * @return This builder for chaining. + */ + public Builder setDatabaseUidBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + databaseUid_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp snapshotTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + snapshotTimeBuilder_; + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the snapshotTime field is set. + */ + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The snapshotTime. + */ + public com.google.protobuf.Timestamp getSnapshotTime() { + if (snapshotTimeBuilder_ == null) { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } else { + return snapshotTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + snapshotTime_ = value; + } else { + snapshotTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (snapshotTimeBuilder_ == null) { + snapshotTime_ = builderForValue.build(); + } else { + snapshotTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && snapshotTime_ != null + && snapshotTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getSnapshotTimeBuilder().mergeFrom(value); + } else { + snapshotTime_ = value; + } + } else { + snapshotTimeBuilder_.mergeFrom(value); + } + if (snapshotTime_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearSnapshotTime() { + bitField0_ = (bitField0_ & ~0x00000008); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getSnapshotTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getSnapshotTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + if (snapshotTimeBuilder_ != null) { + return snapshotTimeBuilder_.getMessageOrBuilder(); + } else { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + } + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getSnapshotTimeFieldBuilder() { + if (snapshotTimeBuilder_ == null) { + snapshotTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getSnapshotTime(), getParentForChildren(), isClean()); + snapshotTime_ = null; + } + return snapshotTimeBuilder_; + } + + private com.google.protobuf.Timestamp expireTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + expireTimeBuilder_; + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + public boolean hasExpireTime() { + return ((bitField0_ & 0x00000010) != 0); + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + public com.google.protobuf.Timestamp getExpireTime() { + if (expireTimeBuilder_ == null) { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } else { + return expireTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + expireTime_ = value; + } else { + expireTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (expireTimeBuilder_ == null) { + expireTime_ = builderForValue.build(); + } else { + expireTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && expireTime_ != null + && expireTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getExpireTimeBuilder().mergeFrom(value); + } else { + expireTime_ = value; + } + } else { + expireTimeBuilder_.mergeFrom(value); + } + if (expireTime_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearExpireTime() { + bitField0_ = (bitField0_ & ~0x00000010); + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getExpireTimeBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getExpireTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + if (expireTimeBuilder_ != null) { + return expireTimeBuilder_.getMessageOrBuilder(); + } else { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } + } + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getExpireTimeFieldBuilder() { + if (expireTimeBuilder_ == null) { + expireTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getExpireTime(), getParentForChildren(), isClean()); + expireTime_ = null; + } + return expireTimeBuilder_; + } + + private com.google.firestore.admin.v1.Backup.Stats stats_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Backup.Stats, + com.google.firestore.admin.v1.Backup.Stats.Builder, + com.google.firestore.admin.v1.Backup.StatsOrBuilder> + statsBuilder_; + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the stats field is set. + */ + public boolean hasStats() { + return ((bitField0_ & 0x00000020) != 0); + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The stats. + */ + public com.google.firestore.admin.v1.Backup.Stats getStats() { + if (statsBuilder_ == null) { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } else { + return statsBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setStats(com.google.firestore.admin.v1.Backup.Stats value) { + if (statsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + stats_ = value; + } else { + statsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setStats(com.google.firestore.admin.v1.Backup.Stats.Builder builderForValue) { + if (statsBuilder_ == null) { + stats_ = builderForValue.build(); + } else { + statsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeStats(com.google.firestore.admin.v1.Backup.Stats value) { + if (statsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && stats_ != null + && stats_ != com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance()) { + getStatsBuilder().mergeFrom(value); + } else { + stats_ = value; + } + } else { + statsBuilder_.mergeFrom(value); + } + if (stats_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearStats() { + bitField0_ = (bitField0_ & ~0x00000020); + stats_ = null; + if (statsBuilder_ != null) { + statsBuilder_.dispose(); + statsBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.firestore.admin.v1.Backup.Stats.Builder getStatsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return getStatsFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.firestore.admin.v1.Backup.StatsOrBuilder getStatsOrBuilder() { + if (statsBuilder_ != null) { + return statsBuilder_.getMessageOrBuilder(); + } else { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } + } + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Backup.Stats, + com.google.firestore.admin.v1.Backup.Stats.Builder, + com.google.firestore.admin.v1.Backup.StatsOrBuilder> + getStatsFieldBuilder() { + if (statsBuilder_ == null) { + statsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Backup.Stats, + com.google.firestore.admin.v1.Backup.Stats.Builder, + com.google.firestore.admin.v1.Backup.StatsOrBuilder>( + getStats(), getParentForChildren(), isClean()); + stats_ = null; + } + return statsBuilder_; + } + + private int state_ = 0; + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + state_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.State getState() { + com.google.firestore.admin.v1.Backup.State result = + com.google.firestore.admin.v1.Backup.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.Backup.State.UNRECOGNIZED : result; + } + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.Backup.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + state_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000040); + state_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Backup) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Backup) + private static final com.google.firestore.admin.v1.Backup DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Backup(); + } + + public static com.google.firestore.admin.v1.Backup getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Backup parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupName.java new file mode 100644 index 000000000..76cdb3473 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupName.java @@ -0,0 +1,223 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class BackupName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION_BACKUP = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/locations/{location}/backups/{backup}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + private final String backup; + + @Deprecated + protected BackupName() { + project = null; + location = null; + backup = null; + } + + private BackupName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + backup = Preconditions.checkNotNull(builder.getBackup()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getBackup() { + return backup; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static BackupName of(String project, String location, String backup) { + return newBuilder().setProject(project).setLocation(location).setBackup(backup).build(); + } + + public static String format(String project, String location, String backup) { + return newBuilder() + .setProject(project) + .setLocation(location) + .setBackup(backup) + .build() + .toString(); + } + + public static BackupName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION_BACKUP.validatedMatch( + formattedString, "BackupName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("backup")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (BackupName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION_BACKUP.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (backup != null) { + fieldMapBuilder.put("backup", backup); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION_BACKUP.instantiate( + "project", project, "location", location, "backup", backup); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + BackupName that = ((BackupName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.backup, that.backup); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(backup); + return h; + } + + /** Builder for projects/{project}/locations/{location}/backups/{backup}. */ + public static class Builder { + private String project; + private String location; + private String backup; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getBackup() { + return backup; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setBackup(String backup) { + this.backup = backup; + return this; + } + + private Builder(BackupName backupName) { + this.project = backupName.project; + this.location = backupName.location; + this.backup = backupName.backup; + } + + public BackupName build() { + return new BackupName(this); + } + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupOrBuilder.java new file mode 100644 index 000000000..8da642d41 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupOrBuilder.java @@ -0,0 +1,276 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/backup.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface BackupOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Backup) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + java.lang.String getDatabase(); + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + java.lang.String getDatabaseUid(); + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for databaseUid. + */ + com.google.protobuf.ByteString getDatabaseUidBytes(); + + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the snapshotTime field is set. + */ + boolean hasSnapshotTime(); + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The snapshotTime. + */ + com.google.protobuf.Timestamp getSnapshotTime(); + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + boolean hasExpireTime(); + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + com.google.protobuf.Timestamp getExpireTime(); + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder(); + + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the stats field is set. + */ + boolean hasStats(); + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The stats. + */ + com.google.firestore.admin.v1.Backup.Stats getStats(); + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.firestore.admin.v1.Backup.StatsOrBuilder getStatsOrBuilder(); + + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + com.google.firestore.admin.v1.Backup.State getState(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupProto.java new file mode 100644 index 000000000..deab8154c --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupProto.java @@ -0,0 +1,111 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/backup.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public final class BackupProto { + private BackupProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Backup_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n&google/firestore/admin/v1/backup.proto" + + "\022\031google.firestore.admin.v1\032\037google/api/" + + "field_behavior.proto\032\031google/api/resourc" + + "e.proto\032\037google/protobuf/timestamp.proto" + + "\"\340\004\n\006Backup\022\021\n\004name\030\001 \001(\tB\003\340A\003\022;\n\010databa" + + "se\030\002 \001(\tB)\340A\003\372A#\n!firestore.googleapis.c" + + "om/Database\022\031\n\014database_uid\030\007 \001(\tB\003\340A\003\0226" + + "\n\rsnapshot_time\030\003 \001(\0132\032.google.protobuf." + + "TimestampB\003\340A\003\0224\n\013expire_time\030\004 \001(\0132\032.go" + + "ogle.protobuf.TimestampB\003\340A\003\022;\n\005stats\030\006 " + + "\001(\0132\'.google.firestore.admin.v1.Backup.S" + + "tatsB\003\340A\003\022;\n\005state\030\010 \001(\0162\'.google.firest" + + "ore.admin.v1.Backup.StateB\003\340A\003\032W\n\005Stats\022" + + "\027\n\nsize_bytes\030\001 \001(\003B\003\340A\003\022\033\n\016document_cou" + + "nt\030\002 \001(\003B\003\340A\003\022\030\n\013index_count\030\003 \001(\003B\003\340A\003\"" + + "J\n\005State\022\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREAT" + + "ING\020\001\022\t\n\005READY\020\002\022\021\n\rNOT_AVAILABLE\020\003:^\352A[" + + "\n\037firestore.googleapis.com/Backup\0228proje" + + "cts/{project}/locations/{location}/backu" + + "ps/{backup}B\332\001\n\035com.google.firestore.adm" + + "in.v1B\013BackupProtoP\001Z9cloud.google.com/g" + + "o/firestore/apiv1/admin/adminpb;adminpb\242" + + "\002\004GCFS\252\002\037Google.Cloud.Firestore.Admin.V1" + + "\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#Goo" + + "gle::Cloud::Firestore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_Backup_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Backup_descriptor, + new java.lang.String[] { + "Name", "Database", "DatabaseUid", "SnapshotTime", "ExpireTime", "Stats", "State", + }); + internal_static_google_firestore_admin_v1_Backup_Stats_descriptor = + internal_static_google_firestore_admin_v1_Backup_descriptor.getNestedTypes().get(0); + internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Backup_Stats_descriptor, + new java.lang.String[] { + "SizeBytes", "DocumentCount", "IndexCount", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupSchedule.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupSchedule.java new file mode 100644 index 000000000..7c549cea5 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupSchedule.java @@ -0,0 +1,2256 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/schedule.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A backup schedule for a Cloud Firestore Database.
+ *
+ * This resource is owned by the database it is backing up, and is deleted along
+ * with the database. The actual backups are not though.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BackupSchedule} + */ +public final class BackupSchedule extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.BackupSchedule) + BackupScheduleOrBuilder { + private static final long serialVersionUID = 0L; + // Use BackupSchedule.newBuilder() to construct. + private BackupSchedule(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private BackupSchedule() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BackupSchedule(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BackupSchedule.class, + com.google.firestore.admin.v1.BackupSchedule.Builder.class); + } + + private int bitField0_; + private int recurrenceCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object recurrence_; + + public enum RecurrenceCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + DAILY_RECURRENCE(7), + WEEKLY_RECURRENCE(8), + RECURRENCE_NOT_SET(0); + private final int value; + + private RecurrenceCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static RecurrenceCase valueOf(int value) { + return forNumber(value); + } + + public static RecurrenceCase forNumber(int value) { + switch (value) { + case 7: + return DAILY_RECURRENCE; + case 8: + return WEEKLY_RECURRENCE; + case 0: + return RECURRENCE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public RecurrenceCase getRecurrenceCase() { + return RecurrenceCase.forNumber(recurrenceCase_); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATE_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp createTime_; + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 10; + private com.google.protobuf.Timestamp updateTime_; + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + public static final int RETENTION_FIELD_NUMBER = 6; + private com.google.protobuf.Duration retention_; + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return Whether the retention field is set. + */ + @java.lang.Override + public boolean hasRetention() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return The retention. + */ + @java.lang.Override + public com.google.protobuf.Duration getRetention() { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getRetentionOrBuilder() { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } + + public static final int DAILY_RECURRENCE_FIELD_NUMBER = 7; + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return Whether the dailyRecurrence field is set. + */ + @java.lang.Override + public boolean hasDailyRecurrence() { + return recurrenceCase_ == 7; + } + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return The dailyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDailyRecurrence() { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrenceOrBuilder getDailyRecurrenceOrBuilder() { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + + public static final int WEEKLY_RECURRENCE_FIELD_NUMBER = 8; + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return Whether the weeklyRecurrence field is set. + */ + @java.lang.Override + public boolean hasWeeklyRecurrence() { + return recurrenceCase_ == 8; + } + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return The weeklyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getWeeklyRecurrence() { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder getWeeklyRecurrenceOrBuilder() { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getCreateTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(6, getRetention()); + } + if (recurrenceCase_ == 7) { + output.writeMessage(7, (com.google.firestore.admin.v1.DailyRecurrence) recurrence_); + } + if (recurrenceCase_ == 8) { + output.writeMessage(8, (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(10, getUpdateTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getCreateTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getRetention()); + } + if (recurrenceCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.firestore.admin.v1.DailyRecurrence) recurrence_); + } + if (recurrenceCase_ == 8) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 8, (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getUpdateTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.BackupSchedule)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.BackupSchedule other = + (com.google.firestore.admin.v1.BackupSchedule) obj; + + if (!getName().equals(other.getName())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (hasRetention() != other.hasRetention()) return false; + if (hasRetention()) { + if (!getRetention().equals(other.getRetention())) return false; + } + if (!getRecurrenceCase().equals(other.getRecurrenceCase())) return false; + switch (recurrenceCase_) { + case 7: + if (!getDailyRecurrence().equals(other.getDailyRecurrence())) return false; + break; + case 8: + if (!getWeeklyRecurrence().equals(other.getWeeklyRecurrence())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + if (hasRetention()) { + hash = (37 * hash) + RETENTION_FIELD_NUMBER; + hash = (53 * hash) + getRetention().hashCode(); + } + switch (recurrenceCase_) { + case 7: + hash = (37 * hash) + DAILY_RECURRENCE_FIELD_NUMBER; + hash = (53 * hash) + getDailyRecurrence().hashCode(); + break; + case 8: + hash = (37 * hash) + WEEKLY_RECURRENCE_FIELD_NUMBER; + hash = (53 * hash) + getWeeklyRecurrence().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.BackupSchedule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A backup schedule for a Cloud Firestore Database.
+   *
+   * This resource is owned by the database it is backing up, and is deleted along
+   * with the database. The actual backups are not though.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BackupSchedule} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.BackupSchedule) + com.google.firestore.admin.v1.BackupScheduleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BackupSchedule.class, + com.google.firestore.admin.v1.BackupSchedule.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.BackupSchedule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getCreateTimeFieldBuilder(); + getUpdateTimeFieldBuilder(); + getRetentionFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + retention_ = null; + if (retentionBuilder_ != null) { + retentionBuilder_.dispose(); + retentionBuilder_ = null; + } + if (dailyRecurrenceBuilder_ != null) { + dailyRecurrenceBuilder_.clear(); + } + if (weeklyRecurrenceBuilder_ != null) { + weeklyRecurrenceBuilder_.clear(); + } + recurrenceCase_ = 0; + recurrence_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getDefaultInstanceForType() { + return com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule build() { + com.google.firestore.admin.v1.BackupSchedule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule buildPartial() { + com.google.firestore.admin.v1.BackupSchedule result = + new com.google.firestore.admin.v1.BackupSchedule(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.BackupSchedule result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.retention_ = retentionBuilder_ == null ? retention_ : retentionBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.admin.v1.BackupSchedule result) { + result.recurrenceCase_ = recurrenceCase_; + result.recurrence_ = this.recurrence_; + if (recurrenceCase_ == 7 && dailyRecurrenceBuilder_ != null) { + result.recurrence_ = dailyRecurrenceBuilder_.build(); + } + if (recurrenceCase_ == 8 && weeklyRecurrenceBuilder_ != null) { + result.recurrence_ = weeklyRecurrenceBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.BackupSchedule) { + return mergeFrom((com.google.firestore.admin.v1.BackupSchedule) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.BackupSchedule other) { + if (other == com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (other.hasRetention()) { + mergeRetention(other.getRetention()); + } + switch (other.getRecurrenceCase()) { + case DAILY_RECURRENCE: + { + mergeDailyRecurrence(other.getDailyRecurrence()); + break; + } + case WEEKLY_RECURRENCE: + { + mergeWeeklyRecurrence(other.getWeeklyRecurrence()); + break; + } + case RECURRENCE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + input.readMessage(getCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 50: + { + input.readMessage(getRetentionFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 50 + case 58: + { + input.readMessage(getDailyRecurrenceFieldBuilder().getBuilder(), extensionRegistry); + recurrenceCase_ = 7; + break; + } // case 58 + case 66: + { + input.readMessage( + getWeeklyRecurrenceFieldBuilder().getBuilder(), extensionRegistry); + recurrenceCase_ = 8; + break; + } // case 66 + case 82: + { + input.readMessage(getUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 82 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int recurrenceCase_ = 0; + private java.lang.Object recurrence_; + + public RecurrenceCase getRecurrenceCase() { + return RecurrenceCase.forNumber(recurrenceCase_); + } + + public Builder clearRecurrence() { + recurrenceCase_ = 0; + recurrence_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + if (createTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000002); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getCreateTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private com.google.protobuf.Timestamp updateTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + } else { + updateTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && updateTime_ != null + && updateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getUpdateTimeBuilder().mergeFrom(value); + } else { + updateTime_ = value; + } + } else { + updateTimeBuilder_.mergeFrom(value); + } + if (updateTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000004); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getUpdateTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private com.google.protobuf.Duration retention_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + retentionBuilder_; + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return Whether the retention field is set. + */ + public boolean hasRetention() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return The retention. + */ + public com.google.protobuf.Duration getRetention() { + if (retentionBuilder_ == null) { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } else { + return retentionBuilder_.getMessage(); + } + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder setRetention(com.google.protobuf.Duration value) { + if (retentionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + retention_ = value; + } else { + retentionBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder setRetention(com.google.protobuf.Duration.Builder builderForValue) { + if (retentionBuilder_ == null) { + retention_ = builderForValue.build(); + } else { + retentionBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder mergeRetention(com.google.protobuf.Duration value) { + if (retentionBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && retention_ != null + && retention_ != com.google.protobuf.Duration.getDefaultInstance()) { + getRetentionBuilder().mergeFrom(value); + } else { + retention_ = value; + } + } else { + retentionBuilder_.mergeFrom(value); + } + if (retention_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder clearRetention() { + bitField0_ = (bitField0_ & ~0x00000008); + retention_ = null; + if (retentionBuilder_ != null) { + retentionBuilder_.dispose(); + retentionBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public com.google.protobuf.Duration.Builder getRetentionBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getRetentionFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public com.google.protobuf.DurationOrBuilder getRetentionOrBuilder() { + if (retentionBuilder_ != null) { + return retentionBuilder_.getMessageOrBuilder(); + } else { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } + } + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + getRetentionFieldBuilder() { + if (retentionBuilder_ == null) { + retentionBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getRetention(), getParentForChildren(), isClean()); + retention_ = null; + } + return retentionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.DailyRecurrence, + com.google.firestore.admin.v1.DailyRecurrence.Builder, + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder> + dailyRecurrenceBuilder_; + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return Whether the dailyRecurrence field is set. + */ + @java.lang.Override + public boolean hasDailyRecurrence() { + return recurrenceCase_ == 7; + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return The dailyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDailyRecurrence() { + if (dailyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } else { + if (recurrenceCase_ == 7) { + return dailyRecurrenceBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder setDailyRecurrence(com.google.firestore.admin.v1.DailyRecurrence value) { + if (dailyRecurrenceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + recurrence_ = value; + onChanged(); + } else { + dailyRecurrenceBuilder_.setMessage(value); + } + recurrenceCase_ = 7; + return this; + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder setDailyRecurrence( + com.google.firestore.admin.v1.DailyRecurrence.Builder builderForValue) { + if (dailyRecurrenceBuilder_ == null) { + recurrence_ = builderForValue.build(); + onChanged(); + } else { + dailyRecurrenceBuilder_.setMessage(builderForValue.build()); + } + recurrenceCase_ = 7; + return this; + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder mergeDailyRecurrence(com.google.firestore.admin.v1.DailyRecurrence value) { + if (dailyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 7 + && recurrence_ != com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance()) { + recurrence_ = + com.google.firestore.admin.v1.DailyRecurrence.newBuilder( + (com.google.firestore.admin.v1.DailyRecurrence) recurrence_) + .mergeFrom(value) + .buildPartial(); + } else { + recurrence_ = value; + } + onChanged(); + } else { + if (recurrenceCase_ == 7) { + dailyRecurrenceBuilder_.mergeFrom(value); + } else { + dailyRecurrenceBuilder_.setMessage(value); + } + } + recurrenceCase_ = 7; + return this; + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder clearDailyRecurrence() { + if (dailyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 7) { + recurrenceCase_ = 0; + recurrence_ = null; + onChanged(); + } + } else { + if (recurrenceCase_ == 7) { + recurrenceCase_ = 0; + recurrence_ = null; + } + dailyRecurrenceBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public com.google.firestore.admin.v1.DailyRecurrence.Builder getDailyRecurrenceBuilder() { + return getDailyRecurrenceFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrenceOrBuilder getDailyRecurrenceOrBuilder() { + if ((recurrenceCase_ == 7) && (dailyRecurrenceBuilder_ != null)) { + return dailyRecurrenceBuilder_.getMessageOrBuilder(); + } else { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + } + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.DailyRecurrence, + com.google.firestore.admin.v1.DailyRecurrence.Builder, + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder> + getDailyRecurrenceFieldBuilder() { + if (dailyRecurrenceBuilder_ == null) { + if (!(recurrenceCase_ == 7)) { + recurrence_ = com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + dailyRecurrenceBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.DailyRecurrence, + com.google.firestore.admin.v1.DailyRecurrence.Builder, + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder>( + (com.google.firestore.admin.v1.DailyRecurrence) recurrence_, + getParentForChildren(), + isClean()); + recurrence_ = null; + } + recurrenceCase_ = 7; + onChanged(); + return dailyRecurrenceBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.WeeklyRecurrence, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder, + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder> + weeklyRecurrenceBuilder_; + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return Whether the weeklyRecurrence field is set. + */ + @java.lang.Override + public boolean hasWeeklyRecurrence() { + return recurrenceCase_ == 8; + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return The weeklyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getWeeklyRecurrence() { + if (weeklyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } else { + if (recurrenceCase_ == 8) { + return weeklyRecurrenceBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder setWeeklyRecurrence(com.google.firestore.admin.v1.WeeklyRecurrence value) { + if (weeklyRecurrenceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + recurrence_ = value; + onChanged(); + } else { + weeklyRecurrenceBuilder_.setMessage(value); + } + recurrenceCase_ = 8; + return this; + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder setWeeklyRecurrence( + com.google.firestore.admin.v1.WeeklyRecurrence.Builder builderForValue) { + if (weeklyRecurrenceBuilder_ == null) { + recurrence_ = builderForValue.build(); + onChanged(); + } else { + weeklyRecurrenceBuilder_.setMessage(builderForValue.build()); + } + recurrenceCase_ = 8; + return this; + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder mergeWeeklyRecurrence(com.google.firestore.admin.v1.WeeklyRecurrence value) { + if (weeklyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 8 + && recurrence_ != com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance()) { + recurrence_ = + com.google.firestore.admin.v1.WeeklyRecurrence.newBuilder( + (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_) + .mergeFrom(value) + .buildPartial(); + } else { + recurrence_ = value; + } + onChanged(); + } else { + if (recurrenceCase_ == 8) { + weeklyRecurrenceBuilder_.mergeFrom(value); + } else { + weeklyRecurrenceBuilder_.setMessage(value); + } + } + recurrenceCase_ = 8; + return this; + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder clearWeeklyRecurrence() { + if (weeklyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 8) { + recurrenceCase_ = 0; + recurrence_ = null; + onChanged(); + } + } else { + if (recurrenceCase_ == 8) { + recurrenceCase_ = 0; + recurrence_ = null; + } + weeklyRecurrenceBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public com.google.firestore.admin.v1.WeeklyRecurrence.Builder getWeeklyRecurrenceBuilder() { + return getWeeklyRecurrenceFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder getWeeklyRecurrenceOrBuilder() { + if ((recurrenceCase_ == 8) && (weeklyRecurrenceBuilder_ != null)) { + return weeklyRecurrenceBuilder_.getMessageOrBuilder(); + } else { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + } + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.WeeklyRecurrence, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder, + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder> + getWeeklyRecurrenceFieldBuilder() { + if (weeklyRecurrenceBuilder_ == null) { + if (!(recurrenceCase_ == 8)) { + recurrence_ = com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + weeklyRecurrenceBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.WeeklyRecurrence, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder, + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder>( + (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_, + getParentForChildren(), + isClean()); + recurrence_ = null; + } + recurrenceCase_ = 8; + onChanged(); + return weeklyRecurrenceBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.BackupSchedule) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.BackupSchedule) + private static final com.google.firestore.admin.v1.BackupSchedule DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.BackupSchedule(); + } + + public static com.google.firestore.admin.v1.BackupSchedule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BackupSchedule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleName.java new file mode 100644 index 000000000..def9a8fdf --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleName.java @@ -0,0 +1,227 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class BackupScheduleName implements ResourceName { + private static final PathTemplate PROJECT_DATABASE_BACKUP_SCHEDULE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/databases/{database}/backupSchedules/{backup_schedule}"); + private volatile Map fieldValuesMap; + private final String project; + private final String database; + private final String backupSchedule; + + @Deprecated + protected BackupScheduleName() { + project = null; + database = null; + backupSchedule = null; + } + + private BackupScheduleName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + backupSchedule = Preconditions.checkNotNull(builder.getBackupSchedule()); + } + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getBackupSchedule() { + return backupSchedule; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static BackupScheduleName of(String project, String database, String backupSchedule) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setBackupSchedule(backupSchedule) + .build(); + } + + public static String format(String project, String database, String backupSchedule) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setBackupSchedule(backupSchedule) + .build() + .toString(); + } + + public static BackupScheduleName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_DATABASE_BACKUP_SCHEDULE.validatedMatch( + formattedString, "BackupScheduleName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database"), matchMap.get("backup_schedule")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (BackupScheduleName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_DATABASE_BACKUP_SCHEDULE.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (backupSchedule != null) { + fieldMapBuilder.put("backup_schedule", backupSchedule); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_DATABASE_BACKUP_SCHEDULE.instantiate( + "project", project, "database", database, "backup_schedule", backupSchedule); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + BackupScheduleName that = ((BackupScheduleName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.database, that.database) + && Objects.equals(this.backupSchedule, that.backupSchedule); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(database); + h *= 1000003; + h ^= Objects.hashCode(backupSchedule); + return h; + } + + /** Builder for projects/{project}/databases/{database}/backupSchedules/{backup_schedule}. */ + public static class Builder { + private String project; + private String database; + private String backupSchedule; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getBackupSchedule() { + return backupSchedule; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setBackupSchedule(String backupSchedule) { + this.backupSchedule = backupSchedule; + return this; + } + + private Builder(BackupScheduleName backupScheduleName) { + this.project = backupScheduleName.project; + this.database = backupScheduleName.database; + this.backupSchedule = backupScheduleName.backupSchedule; + } + + public BackupScheduleName build() { + return new BackupScheduleName(this); + } + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleOrBuilder.java new file mode 100644 index 000000000..d31b3c5c2 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleOrBuilder.java @@ -0,0 +1,264 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/schedule.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface BackupScheduleOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.BackupSchedule) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return Whether the retention field is set. + */ + boolean hasRetention(); + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return The retention. + */ + com.google.protobuf.Duration getRetention(); + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + */ + com.google.protobuf.DurationOrBuilder getRetentionOrBuilder(); + + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return Whether the dailyRecurrence field is set. + */ + boolean hasDailyRecurrence(); + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return The dailyRecurrence. + */ + com.google.firestore.admin.v1.DailyRecurrence getDailyRecurrence(); + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder getDailyRecurrenceOrBuilder(); + + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return Whether the weeklyRecurrence field is set. + */ + boolean hasWeeklyRecurrence(); + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return The weeklyRecurrence. + */ + com.google.firestore.admin.v1.WeeklyRecurrence getWeeklyRecurrence(); + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder getWeeklyRecurrenceOrBuilder(); + + com.google.firestore.admin.v1.BackupSchedule.RecurrenceCase getRecurrenceCase(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java index e47a9897e..2f22984f8 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequest.java new file mode 100644 index 000000000..63dbeb830 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequest.java @@ -0,0 +1,962 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.CreateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.CreateBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateBackupScheduleRequest} + */ +public final class CreateBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CreateBackupScheduleRequest) + CreateBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use CreateBackupScheduleRequest.newBuilder() to construct. + private CreateBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CreateBackupScheduleRequest() { + parent_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateBackupScheduleRequest.class, + com.google.firestore.admin.v1.CreateBackupScheduleRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The parent database.
+   *
+   *  Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The parent database.
+   *
+   *  Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_SCHEDULE_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + @java.lang.Override + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getBackupSchedule()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getBackupSchedule()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CreateBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CreateBackupScheduleRequest other = + (com.google.firestore.admin.v1.CreateBackupScheduleRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasBackupSchedule() != other.hasBackupSchedule()) return false; + if (hasBackupSchedule()) { + if (!getBackupSchedule().equals(other.getBackupSchedule())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasBackupSchedule()) { + hash = (37 * hash) + BACKUP_SCHEDULE_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedule().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.CreateBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.CreateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.CreateBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CreateBackupScheduleRequest) + com.google.firestore.admin.v1.CreateBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateBackupScheduleRequest.class, + com.google.firestore.admin.v1.CreateBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CreateBackupScheduleRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getBackupScheduleFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CreateBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest build() { + com.google.firestore.admin.v1.CreateBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.CreateBackupScheduleRequest result = + new com.google.firestore.admin.v1.CreateBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.CreateBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.backupSchedule_ = + backupScheduleBuilder_ == null ? backupSchedule_ : backupScheduleBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CreateBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.CreateBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CreateBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.CreateBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasBackupSchedule()) { + mergeBackupSchedule(other.getBackupSchedule()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getBackupScheduleFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The parent database.
+     *
+     *  Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     *  Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     *  Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     *  Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     *  Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + backupScheduleBuilder_; + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + if (backupScheduleBuilder_ == null) { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } else { + return backupScheduleBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupSchedule_ = value; + } else { + backupScheduleBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule( + com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupScheduleBuilder_ == null) { + backupSchedule_ = builderForValue.build(); + } else { + backupScheduleBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && backupSchedule_ != null + && backupSchedule_ + != com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()) { + getBackupScheduleBuilder().mergeFrom(value); + } else { + backupSchedule_ = value; + } + } else { + backupScheduleBuilder_.mergeFrom(value); + } + if (backupSchedule_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearBackupSchedule() { + bitField0_ = (bitField0_ & ~0x00000002); + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder getBackupScheduleBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getBackupScheduleFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + if (backupScheduleBuilder_ != null) { + return backupScheduleBuilder_.getMessageOrBuilder(); + } else { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + getBackupScheduleFieldBuilder() { + if (backupScheduleBuilder_ == null) { + backupScheduleBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder>( + getBackupSchedule(), getParentForChildren(), isClean()); + backupSchedule_ = null; + } + return backupScheduleBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CreateBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CreateBackupScheduleRequest) + private static final com.google.firestore.admin.v1.CreateBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CreateBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000..d5402d0e4 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequestOrBuilder.java @@ -0,0 +1,100 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface CreateBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CreateBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent database.
+   *
+   *  Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The parent database.
+   *
+   *  Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + boolean hasBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + com.google.firestore.admin.v1.BackupSchedule getBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrence.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrence.java new file mode 100644 index 000000000..8b21cbc67 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrence.java @@ -0,0 +1,435 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/schedule.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Represents a recurring schedule that runs at a specific time every day.
+ *
+ * The time zone is UTC.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DailyRecurrence} + */ +public final class DailyRecurrence extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DailyRecurrence) + DailyRecurrenceOrBuilder { + private static final long serialVersionUID = 0L; + // Use DailyRecurrence.newBuilder() to construct. + private DailyRecurrence(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DailyRecurrence() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DailyRecurrence(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DailyRecurrence.class, + com.google.firestore.admin.v1.DailyRecurrence.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DailyRecurrence)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DailyRecurrence other = + (com.google.firestore.admin.v1.DailyRecurrence) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DailyRecurrence prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Represents a recurring schedule that runs at a specific time every day.
+   *
+   * The time zone is UTC.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DailyRecurrence} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DailyRecurrence) + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DailyRecurrence.class, + com.google.firestore.admin.v1.DailyRecurrence.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DailyRecurrence.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence build() { + com.google.firestore.admin.v1.DailyRecurrence result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence buildPartial() { + com.google.firestore.admin.v1.DailyRecurrence result = + new com.google.firestore.admin.v1.DailyRecurrence(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DailyRecurrence) { + return mergeFrom((com.google.firestore.admin.v1.DailyRecurrence) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DailyRecurrence other) { + if (other == com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DailyRecurrence) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DailyRecurrence) + private static final com.google.firestore.admin.v1.DailyRecurrence DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DailyRecurrence(); + } + + public static com.google.firestore.admin.v1.DailyRecurrence getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DailyRecurrence parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrenceOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrenceOrBuilder.java new file mode 100644 index 000000000..750956a9b --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrenceOrBuilder.java @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/schedule.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface DailyRecurrenceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DailyRecurrence) + com.google.protobuf.MessageOrBuilder {} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java index abb5866cd..259990803 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java index d3f36bb80..7cd1e2643 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java @@ -45,50 +45,50 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "to\022\031google.firestore.admin.v1\032\037google/ap" + "i/field_behavior.proto\032\031google/api/resou" + "rce.proto\032\036google/protobuf/duration.prot" - + "o\032\037google/protobuf/timestamp.proto\"\277\013\n\010D" - + "atabase\022\014\n\004name\030\001 \001(\t\022\021\n\003uid\030\003 \001(\tB\004\342A\001\003" - + "\0225\n\013create_time\030\005 \001(\0132\032.google.protobuf." - + "TimestampB\004\342A\001\003\0225\n\013update_time\030\006 \001(\0132\032.g" - + "oogle.protobuf.TimestampB\004\342A\001\003\022\023\n\013locati" - + "on_id\030\t \001(\t\022>\n\004type\030\n \001(\01620.google.fires" - + "tore.admin.v1.Database.DatabaseType\022M\n\020c" - + "oncurrency_mode\030\017 \001(\01623.google.firestore" - + ".admin.v1.Database.ConcurrencyMode\022A\n\030ve" - + "rsion_retention_period\030\021 \001(\0132\031.google.pr" - + "otobuf.DurationB\004\342A\001\003\022?\n\025earliest_versio" - + "n_time\030\022 \001(\0132\032.google.protobuf.Timestamp" - + "B\004\342A\001\003\022l\n!point_in_time_recovery_enablem" - + "ent\030\025 \001(\0162A.google.firestore.admin.v1.Da" - + "tabase.PointInTimeRecoveryEnablement\022a\n\033" - + "app_engine_integration_mode\030\023 \001(\0162<.goog" - + "le.firestore.admin.v1.Database.AppEngine" - + "IntegrationMode\022\030\n\nkey_prefix\030\024 \001(\tB\004\342A\001" - + "\003\022Z\n\027delete_protection_state\030\026 \001(\01629.goo" - + "gle.firestore.admin.v1.Database.DeletePr" - + "otectionState\022\014\n\004etag\030c \001(\t\"W\n\014DatabaseT" - + "ype\022\035\n\031DATABASE_TYPE_UNSPECIFIED\020\000\022\024\n\020FI" - + "RESTORE_NATIVE\020\001\022\022\n\016DATASTORE_MODE\020\002\"w\n\017" - + "ConcurrencyMode\022 \n\034CONCURRENCY_MODE_UNSP" - + "ECIFIED\020\000\022\016\n\nOPTIMISTIC\020\001\022\017\n\013PESSIMISTIC" - + "\020\002\022!\n\035OPTIMISTIC_WITH_ENTITY_GROUPS\020\003\"\233\001" - + "\n\035PointInTimeRecoveryEnablement\0221\n-POINT" - + "_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED" - + "\020\000\022\"\n\036POINT_IN_TIME_RECOVERY_ENABLED\020\001\022#" - + "\n\037POINT_IN_TIME_RECOVERY_DISABLED\020\002\"b\n\030A" - + "ppEngineIntegrationMode\022+\n\'APP_ENGINE_IN" - + "TEGRATION_MODE_UNSPECIFIED\020\000\022\013\n\007ENABLED\020" - + "\001\022\014\n\010DISABLED\020\002\"\177\n\025DeleteProtectionState" - + "\022\'\n#DELETE_PROTECTION_STATE_UNSPECIFIED\020" - + "\000\022\036\n\032DELETE_PROTECTION_DISABLED\020\001\022\035\n\031DEL" - + "ETE_PROTECTION_ENABLED\020\002:R\352AO\n!firestore" - + ".googleapis.com/Database\022\'projects/{proj" - + "ect}/databases/{database}R\001\001B\334\001\n\035com.goo" - + "gle.firestore.admin.v1B\rDatabaseProtoP\001Z" - + "9cloud.google.com/go/firestore/apiv1/adm" - + "in/adminpb;adminpb\242\002\004GCFS\252\002\037Google.Cloud" - + ".Firestore.Admin.V1\312\002\037Google\\Cloud\\Fires" - + "tore\\Admin\\V1\352\002#Google::Cloud::Firestore" - + "::Admin::V1b\006proto3" + + "o\032\037google/protobuf/timestamp.proto\"\271\013\n\010D" + + "atabase\022\014\n\004name\030\001 \001(\t\022\020\n\003uid\030\003 \001(\tB\003\340A\003\022" + + "4\n\013create_time\030\005 \001(\0132\032.google.protobuf.T" + + "imestampB\003\340A\003\0224\n\013update_time\030\006 \001(\0132\032.goo" + + "gle.protobuf.TimestampB\003\340A\003\022\023\n\013location_" + + "id\030\t \001(\t\022>\n\004type\030\n \001(\01620.google.firestor" + + "e.admin.v1.Database.DatabaseType\022M\n\020conc" + + "urrency_mode\030\017 \001(\01623.google.firestore.ad" + + "min.v1.Database.ConcurrencyMode\022@\n\030versi" + + "on_retention_period\030\021 \001(\0132\031.google.proto" + + "buf.DurationB\003\340A\003\022>\n\025earliest_version_ti" + + "me\030\022 \001(\0132\032.google.protobuf.TimestampB\003\340A" + + "\003\022l\n!point_in_time_recovery_enablement\030\025" + + " \001(\0162A.google.firestore.admin.v1.Databas" + + "e.PointInTimeRecoveryEnablement\022a\n\033app_e" + + "ngine_integration_mode\030\023 \001(\0162<.google.fi" + + "restore.admin.v1.Database.AppEngineInteg" + + "rationMode\022\027\n\nkey_prefix\030\024 \001(\tB\003\340A\003\022Z\n\027d" + + "elete_protection_state\030\026 \001(\01629.google.fi" + + "restore.admin.v1.Database.DeleteProtecti" + + "onState\022\014\n\004etag\030c \001(\t\"W\n\014DatabaseType\022\035\n" + + "\031DATABASE_TYPE_UNSPECIFIED\020\000\022\024\n\020FIRESTOR" + + "E_NATIVE\020\001\022\022\n\016DATASTORE_MODE\020\002\"w\n\017Concur" + + "rencyMode\022 \n\034CONCURRENCY_MODE_UNSPECIFIE" + + "D\020\000\022\016\n\nOPTIMISTIC\020\001\022\017\n\013PESSIMISTIC\020\002\022!\n\035" + + "OPTIMISTIC_WITH_ENTITY_GROUPS\020\003\"\233\001\n\035Poin" + + "tInTimeRecoveryEnablement\0221\n-POINT_IN_TI" + + "ME_RECOVERY_ENABLEMENT_UNSPECIFIED\020\000\022\"\n\036" + + "POINT_IN_TIME_RECOVERY_ENABLED\020\001\022#\n\037POIN" + + "T_IN_TIME_RECOVERY_DISABLED\020\002\"b\n\030AppEngi" + + "neIntegrationMode\022+\n\'APP_ENGINE_INTEGRAT" + + "ION_MODE_UNSPECIFIED\020\000\022\013\n\007ENABLED\020\001\022\014\n\010D" + + "ISABLED\020\002\"\177\n\025DeleteProtectionState\022\'\n#DE" + + "LETE_PROTECTION_STATE_UNSPECIFIED\020\000\022\036\n\032D" + + "ELETE_PROTECTION_DISABLED\020\001\022\035\n\031DELETE_PR" + + "OTECTION_ENABLED\020\002:R\352AO\n!firestore.googl" + + "eapis.com/Database\022\'projects/{project}/d" + + "atabases/{database}R\001\001B\334\001\n\035com.google.fi" + + "restore.admin.v1B\rDatabaseProtoP\001Z9cloud" + + ".google.com/go/firestore/apiv1/admin/adm" + + "inpb;adminpb\242\002\004GCFS\252\002\037Google.Cloud.Fires" + + "tore.Admin.V1\312\002\037Google\\Cloud\\Firestore\\A" + + "dmin\\V1\352\002#Google::Cloud::Firestore::Admi" + + "n::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequest.java new file mode 100644 index 000000000..e4643bb90 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequest.java @@ -0,0 +1,655 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.DeleteBackup][google.firestore.admin.v1.FirestoreAdmin.DeleteBackup].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupRequest} + */ +public final class DeleteBackupRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteBackupRequest) + DeleteBackupRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use DeleteBackupRequest.newBuilder() to construct. + private DeleteBackupRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DeleteBackupRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DeleteBackupRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupRequest.class, + com.google.firestore.admin.v1.DeleteBackupRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteBackupRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteBackupRequest other = + (com.google.firestore.admin.v1.DeleteBackupRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DeleteBackupRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.DeleteBackup][google.firestore.admin.v1.FirestoreAdmin.DeleteBackup].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteBackupRequest) + com.google.firestore.admin.v1.DeleteBackupRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupRequest.class, + com.google.firestore.admin.v1.DeleteBackupRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteBackupRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteBackupRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest build() { + com.google.firestore.admin.v1.DeleteBackupRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest buildPartial() { + com.google.firestore.admin.v1.DeleteBackupRequest result = + new com.google.firestore.admin.v1.DeleteBackupRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DeleteBackupRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteBackupRequest) { + return mergeFrom((com.google.firestore.admin.v1.DeleteBackupRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteBackupRequest other) { + if (other == com.google.firestore.admin.v1.DeleteBackupRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteBackupRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteBackupRequest) + private static final com.google.firestore.admin.v1.DeleteBackupRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteBackupRequest(); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteBackupRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequestOrBuilder.java new file mode 100644 index 000000000..40dcbef62 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequestOrBuilder.java @@ -0,0 +1,59 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface DeleteBackupRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteBackupRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequest.java new file mode 100644 index 000000000..b17dc9415 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequest.java @@ -0,0 +1,661 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for [FirestoreAdmin.DeleteBackupSchedules][].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupScheduleRequest} + */ +public final class DeleteBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteBackupScheduleRequest) + DeleteBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use DeleteBackupScheduleRequest.newBuilder() to construct. + private DeleteBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DeleteBackupScheduleRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DeleteBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.class, + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteBackupScheduleRequest other = + (com.google.firestore.admin.v1.DeleteBackupScheduleRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for [FirestoreAdmin.DeleteBackupSchedules][].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteBackupScheduleRequest) + com.google.firestore.admin.v1.DeleteBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.class, + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteBackupScheduleRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest build() { + com.google.firestore.admin.v1.DeleteBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.DeleteBackupScheduleRequest result = + new com.google.firestore.admin.v1.DeleteBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DeleteBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.DeleteBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.DeleteBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteBackupScheduleRequest) + private static final com.google.firestore.admin.v1.DeleteBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000..3844da9fd --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequestOrBuilder.java @@ -0,0 +1,61 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface DeleteBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java index 88ac00009..d66a39319 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java index aacd40e4a..d3f999dbd 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java @@ -53,27 +53,27 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "\031google.firestore.admin.v1\032\037google/api/f" + "ield_behavior.proto\032\031google/api/resource" + ".proto\032%google/firestore/admin/v1/index." - + "proto\"\307\004\n\005Field\022\022\n\004name\030\001 \001(\tB\004\342A\001\002\022B\n\014i" - + "ndex_config\030\002 \001(\0132,.google.firestore.adm" - + "in.v1.Field.IndexConfig\022>\n\nttl_config\030\003 " - + "\001(\0132*.google.firestore.admin.v1.Field.Tt" - + "lConfig\032\211\001\n\013IndexConfig\0221\n\007indexes\030\001 \003(\013" - + "2 .google.firestore.admin.v1.Index\022\034\n\024us" - + "es_ancestor_config\030\002 \001(\010\022\026\n\016ancestor_fie" - + "ld\030\003 \001(\t\022\021\n\treverting\030\004 \001(\010\032\236\001\n\tTtlConfi" - + "g\022E\n\005state\030\001 \001(\01620.google.firestore.admi" - + "n.v1.Field.TtlConfig.StateB\004\342A\001\003\"J\n\005Stat" - + "e\022\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREATING\020\001\022\n" - + "\n\006ACTIVE\020\002\022\020\n\014NEEDS_REPAIR\020\003:y\352Av\n\036fires" - + "tore.googleapis.com/Field\022Tprojects/{pro" - + "ject}/databases/{database}/collectionGro" - + "ups/{collection}/fields/{field}B\331\001\n\035com." - + "google.firestore.admin.v1B\nFieldProtoP\001Z" - + "9cloud.google.com/go/firestore/apiv1/adm" - + "in/adminpb;adminpb\242\002\004GCFS\252\002\037Google.Cloud" - + ".Firestore.Admin.V1\312\002\037Google\\Cloud\\Fires" - + "tore\\Admin\\V1\352\002#Google::Cloud::Firestore" - + "::Admin::V1b\006proto3" + + "proto\"\305\004\n\005Field\022\021\n\004name\030\001 \001(\tB\003\340A\002\022B\n\014in" + + "dex_config\030\002 \001(\0132,.google.firestore.admi" + + "n.v1.Field.IndexConfig\022>\n\nttl_config\030\003 \001" + + "(\0132*.google.firestore.admin.v1.Field.Ttl" + + "Config\032\211\001\n\013IndexConfig\0221\n\007indexes\030\001 \003(\0132" + + " .google.firestore.admin.v1.Index\022\034\n\024use" + + "s_ancestor_config\030\002 \001(\010\022\026\n\016ancestor_fiel" + + "d\030\003 \001(\t\022\021\n\treverting\030\004 \001(\010\032\235\001\n\tTtlConfig" + + "\022D\n\005state\030\001 \001(\01620.google.firestore.admin" + + ".v1.Field.TtlConfig.StateB\003\340A\003\"J\n\005State\022" + + "\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREATING\020\001\022\n\n\006" + + "ACTIVE\020\002\022\020\n\014NEEDS_REPAIR\020\003:y\352Av\n\036firesto" + + "re.googleapis.com/Field\022Tprojects/{proje" + + "ct}/databases/{database}/collectionGroup" + + "s/{collection}/fields/{field}B\331\001\n\035com.go" + + "ogle.firestore.admin.v1B\nFieldProtoP\001Z9c" + + "loud.google.com/go/firestore/apiv1/admin" + + "/adminpb;adminpb\242\002\004GCFS\252\002\037Google.Cloud.F" + + "irestore.Admin.V1\312\002\037Google\\Cloud\\Firesto" + + "re\\Admin\\V1\352\002#Google::Cloud::Firestore::" + + "Admin::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java index 72ccb2c98..224144533 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java @@ -64,6 +64,30 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -108,6 +132,26 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_admin_v1_ImportDocumentsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -121,149 +165,224 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "min.proto\022\031google.firestore.admin.v1\032\034go" + "ogle/api/annotations.proto\032\027google/api/c" + "lient.proto\032\037google/api/field_behavior.p" - + "roto\032\031google/api/resource.proto\032(google/" + + "roto\032\031google/api/resource.proto\032&google/" + + "firestore/admin/v1/backup.proto\032(google/" + "firestore/admin/v1/database.proto\032%googl" + "e/firestore/admin/v1/field.proto\032%google" + "/firestore/admin/v1/index.proto\032)google/" - + "firestore/admin/v1/operation.proto\032#goog" - + "le/longrunning/operations.proto\032\033google/" - + "protobuf/empty.proto\032 google/protobuf/fi" - + "eld_mask.proto\032\037google/protobuf/timestam" - + "p.proto\"R\n\024ListDatabasesRequest\022:\n\006paren" - + "t\030\001 \001(\tB*\342A\001\002\372A#\022!firestore.googleapis.c" - + "om/Database\"\253\001\n\025CreateDatabaseRequest\022:\n" - + "\006parent\030\001 \001(\tB*\342A\001\002\372A#\022!firestore.google" - + "apis.com/Database\022;\n\010database\030\002 \001(\0132#.go" - + "ogle.firestore.admin.v1.DatabaseB\004\342A\001\002\022\031" - + "\n\013database_id\030\003 \001(\tB\004\342A\001\002\"\030\n\026CreateDatab" - + "aseMetadata\"d\n\025ListDatabasesResponse\0226\n\t" - + "databases\030\001 \003(\0132#.google.firestore.admin" - + ".v1.Database\022\023\n\013unreachable\030\003 \003(\t\"N\n\022Get" - + "DatabaseRequest\0228\n\004name\030\001 \001(\tB*\342A\001\002\372A#\n!" - + "firestore.googleapis.com/Database\"\205\001\n\025Up" - + "dateDatabaseRequest\022;\n\010database\030\001 \001(\0132#." - + "google.firestore.admin.v1.DatabaseB\004\342A\001\002" - + "\022/\n\013update_mask\030\002 \001(\0132\032.google.protobuf." - + "FieldMask\"\030\n\026UpdateDatabaseMetadata\"_\n\025D" - + "eleteDatabaseRequest\0228\n\004name\030\001 \001(\tB*\342A\001\002" - + "\372A#\n!firestore.googleapis.com/Database\022\014" - + "\n\004etag\030\003 \001(\t\"\030\n\026DeleteDatabaseMetadata\"\216" - + "\001\n\022CreateIndexRequest\022A\n\006parent\030\001 \001(\tB1\342" - + "A\001\002\372A*\n(firestore.googleapis.com/Collect" - + "ionGroup\0225\n\005index\030\002 \001(\0132 .google.firesto" - + "re.admin.v1.IndexB\004\342A\001\002\"\216\001\n\022ListIndexesR" - + "equest\022A\n\006parent\030\001 \001(\tB1\342A\001\002\372A*\n(firesto" - + "re.googleapis.com/CollectionGroup\022\016\n\006fil" - + "ter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage_tok" - + "en\030\004 \001(\t\"a\n\023ListIndexesResponse\0221\n\007index" - + "es\030\001 \003(\0132 .google.firestore.admin.v1.Ind" - + "ex\022\027\n\017next_page_token\030\002 \001(\t\"H\n\017GetIndexR" - + "equest\0225\n\004name\030\001 \001(\tB\'\342A\001\002\372A \n\036firestore" - + ".googleapis.com/Index\"K\n\022DeleteIndexRequ" - + "est\0225\n\004name\030\001 \001(\tB\'\342A\001\002\372A \n\036firestore.go" - + "ogleapis.com/Index\"|\n\022UpdateFieldRequest" - + "\0225\n\005field\030\001 \001(\0132 .google.firestore.admin" - + ".v1.FieldB\004\342A\001\002\022/\n\013update_mask\030\002 \001(\0132\032.g" - + "oogle.protobuf.FieldMask\"H\n\017GetFieldRequ" - + "est\0225\n\004name\030\001 \001(\tB\'\342A\001\002\372A \n\036firestore.go" - + "ogleapis.com/Field\"\215\001\n\021ListFieldsRequest" - + "\022A\n\006parent\030\001 \001(\tB1\342A\001\002\372A*\n(firestore.goo" - + "gleapis.com/CollectionGroup\022\016\n\006filter\030\002 " - + "\001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage_token\030\004 \001" - + "(\t\"_\n\022ListFieldsResponse\0220\n\006fields\030\001 \003(\013" - + "2 .google.firestore.admin.v1.Field\022\027\n\017ne" - + "xt_page_token\030\002 \001(\t\"\317\001\n\026ExportDocumentsR" - + "equest\0228\n\004name\030\001 \001(\tB*\342A\001\002\372A#\n!firestore" - + ".googleapis.com/Database\022\026\n\016collection_i" - + "ds\030\002 \003(\t\022\031\n\021output_uri_prefix\030\003 \001(\t\022\025\n\rn" - + "amespace_ids\030\004 \003(\t\0221\n\rsnapshot_time\030\005 \001(" - + "\0132\032.google.protobuf.Timestamp\"\233\001\n\026Import" - + "DocumentsRequest\0228\n\004name\030\001 \001(\tB*\342A\001\002\372A#\n" - + "!firestore.googleapis.com/Database\022\026\n\016co" - + "llection_ids\030\002 \003(\t\022\030\n\020input_uri_prefix\030\003" - + " \001(\t\022\025\n\rnamespace_ids\030\004 \003(\t2\251\026\n\016Firestor" - + "eAdmin\022\333\001\n\013CreateIndex\022-.google.firestor" - + "e.admin.v1.CreateIndexRequest\032\035.google.l" - + "ongrunning.Operation\"~\312A\037\n\005Index\022\026IndexO" - + "perationMetadata\332A\014parent,index\202\323\344\223\002G\">/" - + "v1/{parent=projects/*/databases/*/collec" - + "tionGroups/*}/indexes:\005index\022\275\001\n\013ListInd" - + "exes\022-.google.firestore.admin.v1.ListInd" - + "exesRequest\032..google.firestore.admin.v1." - + "ListIndexesResponse\"O\332A\006parent\202\323\344\223\002@\022>/v" - + "1/{parent=projects/*/databases/*/collect" - + "ionGroups/*}/indexes\022\247\001\n\010GetIndex\022*.goog" - + "le.firestore.admin.v1.GetIndexRequest\032 ." - + "google.firestore.admin.v1.Index\"M\332A\004name" - + "\202\323\344\223\002@\022>/v1/{name=projects/*/databases/*" - + "/collectionGroups/*/indexes/*}\022\243\001\n\013Delet" - + "eIndex\022-.google.firestore.admin.v1.Delet" - + "eIndexRequest\032\026.google.protobuf.Empty\"M\332" - + "A\004name\202\323\344\223\002@*>/v1/{name=projects/*/datab" - + "ases/*/collectionGroups/*/indexes/*}\022\246\001\n" - + "\010GetField\022*.google.firestore.admin.v1.Ge" - + "tFieldRequest\032 .google.firestore.admin.v" - + "1.Field\"L\332A\004name\202\323\344\223\002?\022=/v1/{name=projec" - + "ts/*/databases/*/collectionGroups/*/fiel" - + "ds/*}\022\331\001\n\013UpdateField\022-.google.firestore" - + ".admin.v1.UpdateFieldRequest\032\035.google.lo" - + "ngrunning.Operation\"|\312A\037\n\005Field\022\026FieldOp" - + "erationMetadata\332A\005field\202\323\344\223\002L2C/v1/{fiel" - + "d.name=projects/*/databases/*/collection" - + "Groups/*/fields/*}:\005field\022\271\001\n\nListFields" - + "\022,.google.firestore.admin.v1.ListFieldsR" - + "equest\032-.google.firestore.admin.v1.ListF" - + "ieldsResponse\"N\332A\006parent\202\323\344\223\002?\022=/v1/{par" - + "ent=projects/*/databases/*/collectionGro" - + "ups/*}/fields\022\335\001\n\017ExportDocuments\0221.goog" - + "le.firestore.admin.v1.ExportDocumentsReq" - + "uest\032\035.google.longrunning.Operation\"x\312A2" - + "\n\027ExportDocumentsResponse\022\027ExportDocumen" - + "tsMetadata\332A\004name\202\323\344\223\0026\"1/v1/{name=proje" - + "cts/*/databases/*}:exportDocuments:\001*\022\333\001" - + "\n\017ImportDocuments\0221.google.firestore.adm" - + "in.v1.ImportDocumentsRequest\032\035.google.lo" - + "ngrunning.Operation\"v\312A0\n\025google.protobu" - + "f.Empty\022\027ImportDocumentsMetadata\332A\004name\202" - + "\323\344\223\0026\"1/v1/{name=projects/*/databases/*}" - + ":importDocuments:\001*\022\331\001\n\016CreateDatabase\0220" - + ".google.firestore.admin.v1.CreateDatabas" - + "eRequest\032\035.google.longrunning.Operation\"" - + "v\312A\"\n\010Database\022\026CreateDatabaseMetadata\332A" - + "\033parent,database,database_id\202\323\344\223\002-\"!/v1/" - + "{parent=projects/*}/databases:\010database\022" - + "\223\001\n\013GetDatabase\022-.google.firestore.admin" - + ".v1.GetDatabaseRequest\032#.google.firestor" - + "e.admin.v1.Database\"0\332A\004name\202\323\344\223\002#\022!/v1/" - + "{name=projects/*/databases/*}\022\246\001\n\rListDa" - + "tabases\022/.google.firestore.admin.v1.List" - + "DatabasesRequest\0320.google.firestore.admi" - + "n.v1.ListDatabasesResponse\"2\332A\006parent\202\323\344" - + "\223\002#\022!/v1/{parent=projects/*}/databases\022\333" - + "\001\n\016UpdateDatabase\0220.google.firestore.adm" - + "in.v1.UpdateDatabaseRequest\032\035.google.lon" - + "grunning.Operation\"x\312A\"\n\010Database\022\026Updat" - + "eDatabaseMetadata\332A\024database,update_mask" - + "\202\323\344\223\00262*/v1/{database.name=projects/*/da" - + "tabases/*}:\010database\022\270\001\n\016DeleteDatabase\022" - + "0.google.firestore.admin.v1.DeleteDataba" - + "seRequest\032\035.google.longrunning.Operation" - + "\"U\312A\"\n\010Database\022\026DeleteDatabaseMetadata\332" - + "A\004name\202\323\344\223\002#*!/v1/{name=projects/*/datab" - + "ases/*}\032v\312A\030firestore.googleapis.com\322AXh" - + "ttps://www.googleapis.com/auth/cloud-pla" - + "tform,https://www.googleapis.com/auth/da" - + "tastoreB\245\003\n\035com.google.firestore.admin.v" - + "1B\023FirestoreAdminProtoP\001Z9cloud.google.c" - + "om/go/firestore/apiv1/admin/adminpb;admi" - + "npb\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Admi" - + "n.V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002" - + "#Google::Cloud::Firestore::Admin::V1\352AL\n" - + "!firestore.googleapis.com/Location\022\'proj" - + "ects/{project}/locations/{location}\352Aq\n(" - + "firestore.googleapis.com/CollectionGroup" - + "\022Eprojects/{project}/databases/{database" - + "}/collectionGroups/{collection}b\006proto3" + + "firestore/admin/v1/operation.proto\032(goog" + + "le/firestore/admin/v1/schedule.proto\032#go" + + "ogle/longrunning/operations.proto\032\033googl" + + "e/protobuf/empty.proto\032 google/protobuf/" + + "field_mask.proto\032\037google/protobuf/timest" + + "amp.proto\"Q\n\024ListDatabasesRequest\0229\n\006par" + + "ent\030\001 \001(\tB)\340A\002\372A#\022!firestore.googleapis." + + "com/Database\"\250\001\n\025CreateDatabaseRequest\0229" + + "\n\006parent\030\001 \001(\tB)\340A\002\372A#\022!firestore.google" + + "apis.com/Database\022:\n\010database\030\002 \001(\0132#.go" + + "ogle.firestore.admin.v1.DatabaseB\003\340A\002\022\030\n" + + "\013database_id\030\003 \001(\tB\003\340A\002\"\030\n\026CreateDatabas" + + "eMetadata\"d\n\025ListDatabasesResponse\0226\n\tda" + + "tabases\030\001 \003(\0132#.google.firestore.admin.v" + + "1.Database\022\023\n\013unreachable\030\003 \003(\t\"M\n\022GetDa" + + "tabaseRequest\0227\n\004name\030\001 \001(\tB)\340A\002\372A#\n!fir" + + "estore.googleapis.com/Database\"\204\001\n\025Updat" + + "eDatabaseRequest\022:\n\010database\030\001 \001(\0132#.goo" + + "gle.firestore.admin.v1.DatabaseB\003\340A\002\022/\n\013" + + "update_mask\030\002 \001(\0132\032.google.protobuf.Fiel" + + "dMask\"\030\n\026UpdateDatabaseMetadata\"^\n\025Delet" + + "eDatabaseRequest\0227\n\004name\030\001 \001(\tB)\340A\002\372A#\n!" + + "firestore.googleapis.com/Database\022\014\n\004eta" + + "g\030\003 \001(\t\"\030\n\026DeleteDatabaseMetadata\"\241\001\n\033Cr" + + "eateBackupScheduleRequest\0229\n\006parent\030\001 \001(" + + "\tB)\340A\002\372A#\n!firestore.googleapis.com/Data" + + "base\022G\n\017backup_schedule\030\002 \001(\0132).google.f" + + "irestore.admin.v1.BackupScheduleB\003\340A\002\"Y\n" + + "\030GetBackupScheduleRequest\022=\n\004name\030\001 \001(\tB" + + "/\340A\002\372A)\n\'firestore.googleapis.com/Backup" + + "Schedule\"\227\001\n\033UpdateBackupScheduleRequest" + + "\022G\n\017backup_schedule\030\001 \001(\0132).google.fires" + + "tore.admin.v1.BackupScheduleB\003\340A\002\022/\n\013upd" + + "ate_mask\030\002 \001(\0132\032.google.protobuf.FieldMa" + + "sk\"W\n\032ListBackupSchedulesRequest\0229\n\006pare" + + "nt\030\001 \001(\tB)\340A\002\372A#\n!firestore.googleapis.c" + + "om/Database\"b\n\033ListBackupSchedulesRespon" + + "se\022C\n\020backup_schedules\030\001 \003(\0132).google.fi" + + "restore.admin.v1.BackupSchedule\"\\\n\033Delet" + + "eBackupScheduleRequest\022=\n\004name\030\001 \001(\tB/\340A" + + "\002\372A)\n\'firestore.googleapis.com/BackupSch" + + "edule\"\214\001\n\022CreateIndexRequest\022@\n\006parent\030\001" + + " \001(\tB0\340A\002\372A*\n(firestore.googleapis.com/C" + + "ollectionGroup\0224\n\005index\030\002 \001(\0132 .google.f" + + "irestore.admin.v1.IndexB\003\340A\002\"\215\001\n\022ListInd" + + "exesRequest\022@\n\006parent\030\001 \001(\tB0\340A\002\372A*\n(fir" + + "estore.googleapis.com/CollectionGroup\022\016\n" + + "\006filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage" + + "_token\030\004 \001(\t\"a\n\023ListIndexesResponse\0221\n\007i" + + "ndexes\030\001 \003(\0132 .google.firestore.admin.v1" + + ".Index\022\027\n\017next_page_token\030\002 \001(\t\"G\n\017GetIn" + + "dexRequest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036firest" + + "ore.googleapis.com/Index\"J\n\022DeleteIndexR" + + "equest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036firestore." + + "googleapis.com/Index\"{\n\022UpdateFieldReque" + + "st\0224\n\005field\030\001 \001(\0132 .google.firestore.adm" + + "in.v1.FieldB\003\340A\002\022/\n\013update_mask\030\002 \001(\0132\032." + + "google.protobuf.FieldMask\"G\n\017GetFieldReq" + + "uest\0224\n\004name\030\001 \001(\tB&\340A\002\372A \n\036firestore.go" + + "ogleapis.com/Field\"\214\001\n\021ListFieldsRequest" + + "\022@\n\006parent\030\001 \001(\tB0\340A\002\372A*\n(firestore.goog" + + "leapis.com/CollectionGroup\022\016\n\006filter\030\002 \001" + + "(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage_token\030\004 \001(" + + "\t\"_\n\022ListFieldsResponse\0220\n\006fields\030\001 \003(\0132" + + " .google.firestore.admin.v1.Field\022\027\n\017nex" + + "t_page_token\030\002 \001(\t\"\316\001\n\026ExportDocumentsRe" + + "quest\0227\n\004name\030\001 \001(\tB)\340A\002\372A#\n!firestore.g" + + "oogleapis.com/Database\022\026\n\016collection_ids" + + "\030\002 \003(\t\022\031\n\021output_uri_prefix\030\003 \001(\t\022\025\n\rnam" + + "espace_ids\030\004 \003(\t\0221\n\rsnapshot_time\030\005 \001(\0132" + + "\032.google.protobuf.Timestamp\"\232\001\n\026ImportDo" + + "cumentsRequest\0227\n\004name\030\001 \001(\tB)\340A\002\372A#\n!fi" + + "restore.googleapis.com/Database\022\026\n\016colle" + + "ction_ids\030\002 \003(\t\022\030\n\020input_uri_prefix\030\003 \001(" + + "\t\022\025\n\rnamespace_ids\030\004 \003(\t\"I\n\020GetBackupReq" + + "uest\0225\n\004name\030\001 \001(\tB\'\340A\002\372A!\n\037firestore.go" + + "ogleapis.com/Backup\"O\n\022ListBackupsReques" + + "t\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!firestore.goo" + + "gleapis.com/Location\"^\n\023ListBackupsRespo" + + "nse\0222\n\007backups\030\001 \003(\0132!.google.firestore." + + "admin.v1.Backup\022\023\n\013unreachable\030\003 \003(\t\"L\n\023" + + "DeleteBackupRequest\0225\n\004name\030\001 \001(\tB\'\340A\002\372A" + + "!\n\037firestore.googleapis.com/Backup\"\246\001\n\026R" + + "estoreDatabaseRequest\0229\n\006parent\030\001 \001(\tB)\340" + + "A\002\372A#\022!firestore.googleapis.com/Database" + + "\022\030\n\013database_id\030\002 \001(\tB\003\340A\002\0227\n\006backup\030\003 \001" + + "(\tB\'\340A\002\372A!\n\037firestore.googleapis.com/Bac" + + "kup2\326#\n\016FirestoreAdmin\022\333\001\n\013CreateIndex\022-" + + ".google.firestore.admin.v1.CreateIndexRe" + + "quest\032\035.google.longrunning.Operation\"~\312A" + + "\037\n\005Index\022\026IndexOperationMetadata\332A\014paren" + + "t,index\202\323\344\223\002G\">/v1/{parent=projects/*/da" + + "tabases/*/collectionGroups/*}/indexes:\005i" + + "ndex\022\275\001\n\013ListIndexes\022-.google.firestore." + + "admin.v1.ListIndexesRequest\032..google.fir" + + "estore.admin.v1.ListIndexesResponse\"O\332A\006" + + "parent\202\323\344\223\002@\022>/v1/{parent=projects/*/dat" + + "abases/*/collectionGroups/*}/indexes\022\247\001\n" + + "\010GetIndex\022*.google.firestore.admin.v1.Ge" + + "tIndexRequest\032 .google.firestore.admin.v" + + "1.Index\"M\332A\004name\202\323\344\223\002@\022>/v1/{name=projec" + + "ts/*/databases/*/collectionGroups/*/inde" + + "xes/*}\022\243\001\n\013DeleteIndex\022-.google.firestor" + + "e.admin.v1.DeleteIndexRequest\032\026.google.p" + + "rotobuf.Empty\"M\332A\004name\202\323\344\223\002@*>/v1/{name=" + + "projects/*/databases/*/collectionGroups/" + + "*/indexes/*}\022\246\001\n\010GetField\022*.google.fires" + + "tore.admin.v1.GetFieldRequest\032 .google.f" + + "irestore.admin.v1.Field\"L\332A\004name\202\323\344\223\002?\022=" + + "/v1/{name=projects/*/databases/*/collect" + + "ionGroups/*/fields/*}\022\331\001\n\013UpdateField\022-." + + "google.firestore.admin.v1.UpdateFieldReq" + + "uest\032\035.google.longrunning.Operation\"|\312A\037" + + "\n\005Field\022\026FieldOperationMetadata\332A\005field\202" + + "\323\344\223\002L2C/v1/{field.name=projects/*/databa" + + "ses/*/collectionGroups/*/fields/*}:\005fiel" + + "d\022\271\001\n\nListFields\022,.google.firestore.admi" + + "n.v1.ListFieldsRequest\032-.google.firestor" + + "e.admin.v1.ListFieldsResponse\"N\332A\006parent" + + "\202\323\344\223\002?\022=/v1/{parent=projects/*/databases" + + "/*/collectionGroups/*}/fields\022\335\001\n\017Export" + + "Documents\0221.google.firestore.admin.v1.Ex" + + "portDocumentsRequest\032\035.google.longrunnin" + + "g.Operation\"x\312A2\n\027ExportDocumentsRespons" + + "e\022\027ExportDocumentsMetadata\332A\004name\202\323\344\223\0026\"" + + "1/v1/{name=projects/*/databases/*}:expor" + + "tDocuments:\001*\022\333\001\n\017ImportDocuments\0221.goog" + + "le.firestore.admin.v1.ImportDocumentsReq" + + "uest\032\035.google.longrunning.Operation\"v\312A0" + + "\n\025google.protobuf.Empty\022\027ImportDocuments" + + "Metadata\332A\004name\202\323\344\223\0026\"1/v1/{name=project" + + "s/*/databases/*}:importDocuments:\001*\022\331\001\n\016" + + "CreateDatabase\0220.google.firestore.admin." + + "v1.CreateDatabaseRequest\032\035.google.longru" + + "nning.Operation\"v\312A\"\n\010Database\022\026CreateDa" + + "tabaseMetadata\332A\033parent,database,databas" + + "e_id\202\323\344\223\002-\"!/v1/{parent=projects/*}/data" + + "bases:\010database\022\223\001\n\013GetDatabase\022-.google" + + ".firestore.admin.v1.GetDatabaseRequest\032#" + + ".google.firestore.admin.v1.Database\"0\332A\004" + + "name\202\323\344\223\002#\022!/v1/{name=projects/*/databas" + + "es/*}\022\246\001\n\rListDatabases\022/.google.firesto" + + "re.admin.v1.ListDatabasesRequest\0320.googl" + + "e.firestore.admin.v1.ListDatabasesRespon" + + "se\"2\332A\006parent\202\323\344\223\002#\022!/v1/{parent=project" + + "s/*}/databases\022\333\001\n\016UpdateDatabase\0220.goog" + + "le.firestore.admin.v1.UpdateDatabaseRequ" + + "est\032\035.google.longrunning.Operation\"x\312A\"\n" + + "\010Database\022\026UpdateDatabaseMetadata\332A\024data" + + "base,update_mask\202\323\344\223\00262*/v1/{database.na" + + "me=projects/*/databases/*}:\010database\022\270\001\n" + + "\016DeleteDatabase\0220.google.firestore.admin" + + ".v1.DeleteDatabaseRequest\032\035.google.longr" + + "unning.Operation\"U\312A\"\n\010Database\022\026DeleteD" + + "atabaseMetadata\332A\004name\202\323\344\223\002#*!/v1/{name=" + + "projects/*/databases/*}\022\227\001\n\tGetBackup\022+." + + "google.firestore.admin.v1.GetBackupReque" + + "st\032!.google.firestore.admin.v1.Backup\":\332" + + "A\004name\202\323\344\223\002-\022+/v1/{name=projects/*/locat" + + "ions/*/backups/*}\022\252\001\n\013ListBackups\022-.goog" + + "le.firestore.admin.v1.ListBackupsRequest" + + "\032..google.firestore.admin.v1.ListBackups" + + "Response\"<\332A\006parent\202\323\344\223\002-\022+/v1/{parent=p" + + "rojects/*/locations/*}/backups\022\222\001\n\014Delet" + + "eBackup\022..google.firestore.admin.v1.Dele" + + "teBackupRequest\032\026.google.protobuf.Empty\"" + + ":\332A\004name\202\323\344\223\002-*+/v1/{name=projects/*/loc" + + "ations/*/backups/*}\022\277\001\n\017RestoreDatabase\022" + + "1.google.firestore.admin.v1.RestoreDatab" + + "aseRequest\032\035.google.longrunning.Operatio" + + "n\"Z\312A#\n\010Database\022\027RestoreDatabaseMetadat" + + "a\202\323\344\223\002.\")/v1/{parent=projects/*}/databas" + + "es:restore:\001*\022\340\001\n\024CreateBackupSchedule\0226" + + ".google.firestore.admin.v1.CreateBackupS" + + "cheduleRequest\032).google.firestore.admin." + + "v1.BackupSchedule\"e\332A\026parent,backup_sche" + + "dule\202\323\344\223\002F\"3/v1/{parent=projects/*/datab" + + "ases/*}/backupSchedules:\017backup_schedule" + + "\022\267\001\n\021GetBackupSchedule\0223.google.firestor" + + "e.admin.v1.GetBackupScheduleRequest\032).go" + + "ogle.firestore.admin.v1.BackupSchedule\"B" + + "\332A\004name\202\323\344\223\0025\0223/v1/{name=projects/*/data" + + "bases/*/backupSchedules/*}\022\312\001\n\023ListBacku" + + "pSchedules\0225.google.firestore.admin.v1.L" + + "istBackupSchedulesRequest\0326.google.fires" + + "tore.admin.v1.ListBackupSchedulesRespons" + + "e\"D\332A\006parent\202\323\344\223\0025\0223/v1/{parent=projects" + + "/*/databases/*}/backupSchedules\022\365\001\n\024Upda" + + "teBackupSchedule\0226.google.firestore.admi" + + "n.v1.UpdateBackupScheduleRequest\032).googl" + + "e.firestore.admin.v1.BackupSchedule\"z\332A\033" + + "backup_schedule,update_mask\202\323\344\223\002V2C/v1/{" + + "backup_schedule.name=projects/*/database" + + "s/*/backupSchedules/*}:\017backup_schedule\022" + + "\252\001\n\024DeleteBackupSchedule\0226.google.firest" + + "ore.admin.v1.DeleteBackupScheduleRequest" + + "\032\026.google.protobuf.Empty\"B\332A\004name\202\323\344\223\0025*" + + "3/v1/{name=projects/*/databases/*/backup" + + "Schedules/*}\032v\312A\030firestore.googleapis.co" + + "m\322AXhttps://www.googleapis.com/auth/clou" + + "d-platform,https://www.googleapis.com/au" + + "th/datastoreB\245\003\n\035com.google.firestore.ad" + + "min.v1B\023FirestoreAdminProtoP\001Z9cloud.goo" + + "gle.com/go/firestore/apiv1/admin/adminpb" + + ";adminpb\242\002\004GCFS\252\002\037Google.Cloud.Firestore" + + ".Admin.V1\312\002\037Google\\Cloud\\Firestore\\Admin" + + "\\V1\352\002#Google::Cloud::Firestore::Admin::V" + + "1\352AL\n!firestore.googleapis.com/Location\022" + + "\'projects/{project}/locations/{location}" + + "\352Aq\n(firestore.googleapis.com/Collection" + + "Group\022Eprojects/{project}/databases/{dat" + + "abase}/collectionGroups/{collection}b\006pr" + + "oto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -273,10 +392,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.api.ClientProto.getDescriptor(), com.google.api.FieldBehaviorProto.getDescriptor(), com.google.api.ResourceProto.getDescriptor(), + com.google.firestore.admin.v1.BackupProto.getDescriptor(), com.google.firestore.admin.v1.DatabaseProto.getDescriptor(), com.google.firestore.admin.v1.FieldProto.getDescriptor(), com.google.firestore.admin.v1.IndexProto.getDescriptor(), com.google.firestore.admin.v1.OperationProto.getDescriptor(), + com.google.firestore.admin.v1.ScheduleProto.getDescriptor(), com.google.longrunning.OperationsProto.getDescriptor(), com.google.protobuf.EmptyProto.getDescriptor(), com.google.protobuf.FieldMaskProto.getDescriptor(), @@ -348,8 +469,56 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor, new java.lang.String[] {}); - internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor = + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor = getDescriptor().getMessageTypes().get(9); + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Parent", "BackupSchedule", + }); + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor, + new java.lang.String[] { + "BackupSchedule", "UpdateMask", + }); + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor, + new java.lang.String[] { + "Parent", + }); + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor, + new java.lang.String[] { + "BackupSchedules", + }); + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor = + getDescriptor().getMessageTypes().get(15); internal_static_google_firestore_admin_v1_CreateIndexRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor, @@ -357,7 +526,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Parent", "Index", }); internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor = - getDescriptor().getMessageTypes().get(10); + getDescriptor().getMessageTypes().get(16); internal_static_google_firestore_admin_v1_ListIndexesRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor, @@ -365,7 +534,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Parent", "Filter", "PageSize", "PageToken", }); internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor = - getDescriptor().getMessageTypes().get(11); + getDescriptor().getMessageTypes().get(17); internal_static_google_firestore_admin_v1_ListIndexesResponse_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor, @@ -373,7 +542,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Indexes", "NextPageToken", }); internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor = - getDescriptor().getMessageTypes().get(12); + getDescriptor().getMessageTypes().get(18); internal_static_google_firestore_admin_v1_GetIndexRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor, @@ -381,7 +550,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", }); internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor = - getDescriptor().getMessageTypes().get(13); + getDescriptor().getMessageTypes().get(19); internal_static_google_firestore_admin_v1_DeleteIndexRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor, @@ -389,7 +558,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", }); internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor = - getDescriptor().getMessageTypes().get(14); + getDescriptor().getMessageTypes().get(20); internal_static_google_firestore_admin_v1_UpdateFieldRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor, @@ -397,7 +566,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Field", "UpdateMask", }); internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor = - getDescriptor().getMessageTypes().get(15); + getDescriptor().getMessageTypes().get(21); internal_static_google_firestore_admin_v1_GetFieldRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor, @@ -405,7 +574,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", }); internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor = - getDescriptor().getMessageTypes().get(16); + getDescriptor().getMessageTypes().get(22); internal_static_google_firestore_admin_v1_ListFieldsRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor, @@ -413,7 +582,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Parent", "Filter", "PageSize", "PageToken", }); internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor = - getDescriptor().getMessageTypes().get(17); + getDescriptor().getMessageTypes().get(23); internal_static_google_firestore_admin_v1_ListFieldsResponse_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor, @@ -421,7 +590,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Fields", "NextPageToken", }); internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor = - getDescriptor().getMessageTypes().get(18); + getDescriptor().getMessageTypes().get(24); internal_static_google_firestore_admin_v1_ExportDocumentsRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor, @@ -429,13 +598,53 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", "CollectionIds", "OutputUriPrefix", "NamespaceIds", "SnapshotTime", }); internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor = - getDescriptor().getMessageTypes().get(19); + getDescriptor().getMessageTypes().get(25); internal_static_google_firestore_admin_v1_ImportDocumentsRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor, new java.lang.String[] { "Name", "CollectionIds", "InputUriPrefix", "NamespaceIds", }); + internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor = + getDescriptor().getMessageTypes().get(26); + internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor = + getDescriptor().getMessageTypes().get(27); + internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor, + new java.lang.String[] { + "Parent", + }); + internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor = + getDescriptor().getMessageTypes().get(28); + internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor, + new java.lang.String[] { + "Backups", "Unreachable", + }); + internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor = + getDescriptor().getMessageTypes().get(29); + internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor = + getDescriptor().getMessageTypes().get(30); + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor, + new java.lang.String[] { + "Parent", "DatabaseId", "Backup", + }); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); registry.add(com.google.api.ClientProto.defaultHost); @@ -452,10 +661,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.api.ClientProto.getDescriptor(); com.google.api.FieldBehaviorProto.getDescriptor(); com.google.api.ResourceProto.getDescriptor(); + com.google.firestore.admin.v1.BackupProto.getDescriptor(); com.google.firestore.admin.v1.DatabaseProto.getDescriptor(); com.google.firestore.admin.v1.FieldProto.getDescriptor(); com.google.firestore.admin.v1.IndexProto.getDescriptor(); com.google.firestore.admin.v1.OperationProto.getDescriptor(); + com.google.firestore.admin.v1.ScheduleProto.getDescriptor(); com.google.longrunning.OperationsProto.getDescriptor(); com.google.protobuf.EmptyProto.getDescriptor(); com.google.protobuf.FieldMaskProto.getDescriptor(); diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequest.java new file mode 100644 index 000000000..bc3a04431 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequest.java @@ -0,0 +1,654 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetBackup][google.firestore.admin.v1.FirestoreAdmin.GetBackup].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupRequest} + */ +public final class GetBackupRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetBackupRequest) + GetBackupRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use GetBackupRequest.newBuilder() to construct. + private GetBackupRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GetBackupRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetBackupRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupRequest.class, + com.google.firestore.admin.v1.GetBackupRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetBackupRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetBackupRequest other = + (com.google.firestore.admin.v1.GetBackupRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.GetBackupRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetBackup][google.firestore.admin.v1.FirestoreAdmin.GetBackup].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetBackupRequest) + com.google.firestore.admin.v1.GetBackupRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupRequest.class, + com.google.firestore.admin.v1.GetBackupRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetBackupRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetBackupRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest build() { + com.google.firestore.admin.v1.GetBackupRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest buildPartial() { + com.google.firestore.admin.v1.GetBackupRequest result = + new com.google.firestore.admin.v1.GetBackupRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetBackupRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetBackupRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetBackupRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetBackupRequest other) { + if (other == com.google.firestore.admin.v1.GetBackupRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetBackupRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetBackupRequest) + private static final com.google.firestore.admin.v1.GetBackupRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetBackupRequest(); + } + + public static com.google.firestore.admin.v1.GetBackupRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetBackupRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequestOrBuilder.java new file mode 100644 index 000000000..541b353aa --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequestOrBuilder.java @@ -0,0 +1,59 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface GetBackupRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetBackupRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequest.java new file mode 100644 index 000000000..466569f11 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequest.java @@ -0,0 +1,663 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.GetBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupScheduleRequest} + */ +public final class GetBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetBackupScheduleRequest) + GetBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use GetBackupScheduleRequest.newBuilder() to construct. + private GetBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GetBackupScheduleRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupScheduleRequest.class, + com.google.firestore.admin.v1.GetBackupScheduleRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetBackupScheduleRequest other = + (com.google.firestore.admin.v1.GetBackupScheduleRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.GetBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.GetBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetBackupScheduleRequest) + com.google.firestore.admin.v1.GetBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupScheduleRequest.class, + com.google.firestore.admin.v1.GetBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetBackupScheduleRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest build() { + com.google.firestore.admin.v1.GetBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.GetBackupScheduleRequest result = + new com.google.firestore.admin.v1.GetBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.GetBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetBackupScheduleRequest) + private static final com.google.firestore.admin.v1.GetBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000..d75c69e10 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequestOrBuilder.java @@ -0,0 +1,61 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface GetBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java index e977935be..ce0374de8 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java @@ -713,6 +713,44 @@ public interface IndexFieldOrBuilder */ com.google.firestore.admin.v1.Index.IndexField.ArrayConfig getArrayConfig(); + /** + * + * + *
+     * Indicates that this field supports nearest neighbors and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return Whether the vectorConfig field is set. + */ + boolean hasVectorConfig(); + /** + * + * + *
+     * Indicates that this field supports nearest neighbors and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return The vectorConfig. + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfig getVectorConfig(); + /** + * + * + *
+     * Indicates that this field supports nearest neighbors and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder getVectorConfigOrBuilder(); + com.google.firestore.admin.v1.Index.IndexField.ValueModeCase getValueModeCase(); } /** @@ -1003,54 +1041,1499 @@ public static ArrayConfig forNumber(int value) { default: return null; } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ArrayConfig findValueByNumber(int number) { + return ArrayConfig.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Index.IndexField.getDescriptor().getEnumTypes().get(1); + } + + private static final ArrayConfig[] VALUES = values(); + + public static ArrayConfig valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ArrayConfig(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.IndexField.ArrayConfig) + } + + public interface VectorConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Index.IndexField.VectorConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * Required. The vector dimension this configuration applies to.
+       *
+       * The resulting index will only include vectors of this dimension, and
+       * can be used for vector search with the same dimension.
+       * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The dimension. + */ + int getDimension(); + + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return Whether the flat field is set. + */ + boolean hasFlat(); + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return The flat. + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex getFlat(); + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder + getFlatOrBuilder(); + + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.TypeCase getTypeCase(); + } + /** + * + * + *
+     * The index configuration to support vector search operations
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig} + */ + public static final class VectorConfig extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig) + VectorConfigOrBuilder { + private static final long serialVersionUID = 0L; + // Use VectorConfig.newBuilder() to construct. + private VectorConfig(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private VectorConfig() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new VectorConfig(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder.class); + } + + public interface FlatIndexOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + com.google.protobuf.MessageOrBuilder {} + /** + * + * + *
+       * An index that stores vectors in a flat data structure, and supports
+       * exhaustive search.
+       * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex} + */ + public static final class FlatIndex extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + FlatIndexOrBuilder { + private static final long serialVersionUID = 0L; + // Use FlatIndex.newBuilder() to construct. + private FlatIndex(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private FlatIndex() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new FlatIndex(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + .class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex other = + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+         * An index that stores vectors in a flat data structure, and supports
+         * exhaustive search.
+         * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + .class); + } + + // Construct using + // com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex build() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + buildPartial() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex result = + new com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) { + return mergeFrom( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex other) { + if (other + == com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + private static final com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex(); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FlatIndex parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int typeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object type_; + + public enum TypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + FLAT(2), + TYPE_NOT_SET(0); + private final int value; + + private TypeCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TypeCase valueOf(int value) { + return forNumber(value); + } + + public static TypeCase forNumber(int value) { + switch (value) { + case 2: + return FLAT; + case 0: + return TYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public TypeCase getTypeCase() { + return TypeCase.forNumber(typeCase_); + } + + public static final int DIMENSION_FIELD_NUMBER = 1; + private int dimension_ = 0; + /** + * + * + *
+       * Required. The vector dimension this configuration applies to.
+       *
+       * The resulting index will only include vectors of this dimension, and
+       * can be used for vector search with the same dimension.
+       * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The dimension. + */ + @java.lang.Override + public int getDimension() { + return dimension_; + } + + public static final int FLAT_FIELD_NUMBER = 2; + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return Whether the flat field is set. + */ + @java.lang.Override + public boolean hasFlat() { + return typeCase_ == 2; + } + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return The flat. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex getFlat() { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder + getFlatOrBuilder() { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (dimension_ != 0) { + output.writeInt32(1, dimension_); + } + if (typeCase_ == 2) { + output.writeMessage( + 2, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (dimension_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, dimension_); + } + if (typeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Index.IndexField.VectorConfig other = + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) obj; + + if (getDimension() != other.getDimension()) return false; + if (!getTypeCase().equals(other.getTypeCase())) return false; + switch (typeCase_) { + case 2: + if (!getFlat().equals(other.getFlat())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DIMENSION_FIELD_NUMBER; + hash = (53 * hash) + getDimension(); + switch (typeCase_) { + case 2: + hash = (37 * hash) + FLAT_FIELD_NUMBER; + hash = (53 * hash) + getFlat().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+       * The index configuration to support vector search operations
+       * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig) + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Index.IndexField.VectorConfig.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + dimension_ = 0; + if (flatBuilder_ != null) { + flatBuilder_.clear(); + } + typeCase_ = 0; + type_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig build() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig buildPartial() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result = + new com.google.firestore.admin.v1.Index.IndexField.VectorConfig(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.dimension_ = dimension_; + } + } + + private void buildPartialOneofs( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result) { + result.typeCase_ = typeCase_; + result.type_ = this.type_; + if (typeCase_ == 2 && flatBuilder_ != null) { + result.type_ = flatBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig) { + return mergeFrom((com.google.firestore.admin.v1.Index.IndexField.VectorConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig other) { + if (other + == com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance()) + return this; + if (other.getDimension() != 0) { + setDimension(other.getDimension()); + } + switch (other.getTypeCase()) { + case FLAT: + { + mergeFlat(other.getFlat()); + break; + } + case TYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + dimension_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + input.readMessage(getFlatFieldBuilder().getBuilder(), extensionRegistry); + typeCase_ = 2; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public ArrayConfig findValueByNumber(int number) { - return ArrayConfig.forNumber(number); - } - }; + private int typeCase_ = 0; + private java.lang.Object type_; - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException( - "Can't get the descriptor of an unrecognized enum value."); + public TypeCase getTypeCase() { + return TypeCase.forNumber(typeCase_); } - return getDescriptor().getValues().get(ordinal()); - } - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } + public Builder clearType() { + typeCase_ = 0; + type_ = null; + onChanged(); + return this; + } - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return com.google.firestore.admin.v1.Index.IndexField.getDescriptor().getEnumTypes().get(1); - } + private int bitField0_; + + private int dimension_; + /** + * + * + *
+         * Required. The vector dimension this configuration applies to.
+         *
+         * The resulting index will only include vectors of this dimension, and
+         * can be used for vector search with the same dimension.
+         * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The dimension. + */ + @java.lang.Override + public int getDimension() { + return dimension_; + } + /** + * + * + *
+         * Required. The vector dimension this configuration applies to.
+         *
+         * The resulting index will only include vectors of this dimension, and
+         * can be used for vector search with the same dimension.
+         * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The dimension to set. + * @return This builder for chaining. + */ + public Builder setDimension(int value) { + + dimension_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+         * Required. The vector dimension this configuration applies to.
+         *
+         * The resulting index will only include vectors of this dimension, and
+         * can be used for vector search with the same dimension.
+         * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDimension() { + bitField0_ = (bitField0_ & ~0x00000001); + dimension_ = 0; + onChanged(); + return this; + } - private static final ArrayConfig[] VALUES = values(); + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder> + flatBuilder_; + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return Whether the flat field is set. + */ + @java.lang.Override + public boolean hasFlat() { + return typeCase_ == 2; + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return The flat. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex getFlat() { + if (flatBuilder_ == null) { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } else { + if (typeCase_ == 2) { + return flatBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder setFlat( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex value) { + if (flatBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + type_ = value; + onChanged(); + } else { + flatBuilder_.setMessage(value); + } + typeCase_ = 2; + return this; + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder setFlat( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + builderForValue) { + if (flatBuilder_ == null) { + type_ = builderForValue.build(); + onChanged(); + } else { + flatBuilder_.setMessage(builderForValue.build()); + } + typeCase_ = 2; + return this; + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder mergeFlat( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex value) { + if (flatBuilder_ == null) { + if (typeCase_ == 2 + && type_ + != com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance()) { + type_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.newBuilder( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + type_) + .mergeFrom(value) + .buildPartial(); + } else { + type_ = value; + } + onChanged(); + } else { + if (typeCase_ == 2) { + flatBuilder_.mergeFrom(value); + } else { + flatBuilder_.setMessage(value); + } + } + typeCase_ = 2; + return this; + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder clearFlat() { + if (flatBuilder_ == null) { + if (typeCase_ == 2) { + typeCase_ = 0; + type_ = null; + onChanged(); + } + } else { + if (typeCase_ == 2) { + typeCase_ = 0; + type_ = null; + } + flatBuilder_.clear(); + } + return this; + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + getFlatBuilder() { + return getFlatFieldBuilder().getBuilder(); + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder + getFlatOrBuilder() { + if ((typeCase_ == 2) && (flatBuilder_ != null)) { + return flatBuilder_.getMessageOrBuilder(); + } else { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + } + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder> + getFlatFieldBuilder() { + if (flatBuilder_ == null) { + if (!(typeCase_ == 2)) { + type_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + flatBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder>( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_, + getParentForChildren(), + isClean()); + type_ = null; + } + typeCase_ = 2; + onChanged(); + return flatBuilder_; + } - public static ArrayConfig valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); } - return VALUES[desc.getIndex()]; - } - private final int value; + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig) + private static final com.google.firestore.admin.v1.Index.IndexField.VectorConfig + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Index.IndexField.VectorConfig(); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public VectorConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; - private ArrayConfig(int value) { - this.value = value; + public static com.google.protobuf.Parser parser() { + return PARSER; } - // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.IndexField.ArrayConfig) + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } } private int valueModeCase_ = 0; @@ -1064,6 +2547,7 @@ public enum ValueModeCase com.google.protobuf.AbstractMessage.InternalOneOfEnum { ORDER(2), ARRAY_CONFIG(3), + VECTOR_CONFIG(4), VALUEMODE_NOT_SET(0); private final int value; @@ -1086,6 +2570,8 @@ public static ValueModeCase forNumber(int value) { return ORDER; case 3: return ARRAY_CONFIG; + case 4: + return VECTOR_CONFIG; case 0: return VALUEMODE_NOT_SET; default: @@ -1270,6 +2756,61 @@ public com.google.firestore.admin.v1.Index.IndexField.ArrayConfig getArrayConfig return com.google.firestore.admin.v1.Index.IndexField.ArrayConfig.ARRAY_CONFIG_UNSPECIFIED; } + public static final int VECTOR_CONFIG_FIELD_NUMBER = 4; + /** + * + * + *
+     * Indicates that this field supports nearest neighbors and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return Whether the vectorConfig field is set. + */ + @java.lang.Override + public boolean hasVectorConfig() { + return valueModeCase_ == 4; + } + /** + * + * + *
+     * Indicates that this field supports nearest neighbors and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return The vectorConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig getVectorConfig() { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + /** + * + * + *
+     * Indicates that this field supports nearest neighbors and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder + getVectorConfigOrBuilder() { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -1293,6 +2834,10 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (valueModeCase_ == 3) { output.writeEnum(3, ((java.lang.Integer) valueMode_)); } + if (valueModeCase_ == 4) { + output.writeMessage( + 4, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_); + } getUnknownFields().writeTo(output); } @@ -1315,6 +2860,11 @@ public int getSerializedSize() { com.google.protobuf.CodedOutputStream.computeEnumSize( 3, ((java.lang.Integer) valueMode_)); } + if (valueModeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -1340,6 +2890,9 @@ public boolean equals(final java.lang.Object obj) { case 3: if (getArrayConfigValue() != other.getArrayConfigValue()) return false; break; + case 4: + if (!getVectorConfig().equals(other.getVectorConfig())) return false; + break; case 0: default: } @@ -1365,6 +2918,10 @@ public int hashCode() { hash = (37 * hash) + ARRAY_CONFIG_FIELD_NUMBER; hash = (53 * hash) + getArrayConfigValue(); break; + case 4: + hash = (37 * hash) + VECTOR_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getVectorConfig().hashCode(); + break; case 0: default: } @@ -1512,6 +3069,9 @@ public Builder clear() { super.clear(); bitField0_ = 0; fieldPath_ = ""; + if (vectorConfigBuilder_ != null) { + vectorConfigBuilder_.clear(); + } valueModeCase_ = 0; valueMode_ = null; return this; @@ -1559,6 +3119,9 @@ private void buildPartial0(com.google.firestore.admin.v1.Index.IndexField result private void buildPartialOneofs(com.google.firestore.admin.v1.Index.IndexField result) { result.valueModeCase_ = valueModeCase_; result.valueMode_ = this.valueMode_; + if (valueModeCase_ == 4 && vectorConfigBuilder_ != null) { + result.valueMode_ = vectorConfigBuilder_.build(); + } } @java.lang.Override @@ -1625,6 +3188,11 @@ public Builder mergeFrom(com.google.firestore.admin.v1.Index.IndexField other) { setArrayConfigValue(other.getArrayConfigValue()); break; } + case VECTOR_CONFIG: + { + mergeVectorConfig(other.getVectorConfig()); + break; + } case VALUEMODE_NOT_SET: { break; @@ -1676,6 +3244,12 @@ public Builder mergeFrom( valueMode_ = rawValue; break; } // case 24 + case 34: + { + input.readMessage(getVectorConfigFieldBuilder().getBuilder(), extensionRegistry); + valueModeCase_ = 4; + break; + } // case 34 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -2062,6 +3636,231 @@ public Builder clearArrayConfig() { return this; } + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder> + vectorConfigBuilder_; + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return Whether the vectorConfig field is set. + */ + @java.lang.Override + public boolean hasVectorConfig() { + return valueModeCase_ == 4; + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return The vectorConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig getVectorConfig() { + if (vectorConfigBuilder_ == null) { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } else { + if (valueModeCase_ == 4) { + return vectorConfigBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder setVectorConfig( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig value) { + if (vectorConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueMode_ = value; + onChanged(); + } else { + vectorConfigBuilder_.setMessage(value); + } + valueModeCase_ = 4; + return this; + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder setVectorConfig( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder builderForValue) { + if (vectorConfigBuilder_ == null) { + valueMode_ = builderForValue.build(); + onChanged(); + } else { + vectorConfigBuilder_.setMessage(builderForValue.build()); + } + valueModeCase_ = 4; + return this; + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder mergeVectorConfig( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig value) { + if (vectorConfigBuilder_ == null) { + if (valueModeCase_ == 4 + && valueMode_ + != com.google.firestore.admin.v1.Index.IndexField.VectorConfig + .getDefaultInstance()) { + valueMode_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.newBuilder( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_) + .mergeFrom(value) + .buildPartial(); + } else { + valueMode_ = value; + } + onChanged(); + } else { + if (valueModeCase_ == 4) { + vectorConfigBuilder_.mergeFrom(value); + } else { + vectorConfigBuilder_.setMessage(value); + } + } + valueModeCase_ = 4; + return this; + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder clearVectorConfig() { + if (vectorConfigBuilder_ == null) { + if (valueModeCase_ == 4) { + valueModeCase_ = 0; + valueMode_ = null; + onChanged(); + } + } else { + if (valueModeCase_ == 4) { + valueModeCase_ = 0; + valueMode_ = null; + } + vectorConfigBuilder_.clear(); + } + return this; + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder + getVectorConfigBuilder() { + return getVectorConfigFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder + getVectorConfigOrBuilder() { + if ((valueModeCase_ == 4) && (vectorConfigBuilder_ != null)) { + return vectorConfigBuilder_.getMessageOrBuilder(); + } else { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + } + /** + * + * + *
+       * Indicates that this field supports nearest neighbors and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder> + getVectorConfigFieldBuilder() { + if (vectorConfigBuilder_ == null) { + if (!(valueModeCase_ == 4)) { + valueMode_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + vectorConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder>( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_, + getParentForChildren(), + isClean()); + valueMode_ = null; + } + valueModeCase_ = 4; + onChanged(); + return vectorConfigBuilder_; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java index 27bdd835d..efbbc0f38 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java index 3affdd640..ccc2c0808 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java @@ -36,6 +36,14 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_admin_v1_Index_IndexField_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_admin_v1_Index_IndexField_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -46,42 +54,50 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { static { java.lang.String[] descriptorData = { "\n%google/firestore/admin/v1/index.proto\022" - + "\031google.firestore.admin.v1\032\031google/api/r" - + "esource.proto\"\254\007\n\005Index\022\014\n\004name\030\001 \001(\t\022@\n" - + "\013query_scope\030\002 \001(\0162+.google.firestore.ad" - + "min.v1.Index.QueryScope\022<\n\tapi_scope\030\005 \001" - + "(\0162).google.firestore.admin.v1.Index.Api" - + "Scope\022;\n\006fields\030\003 \003(\0132+.google.firestore" - + ".admin.v1.Index.IndexField\0225\n\005state\030\004 \001(" - + "\0162&.google.firestore.admin.v1.Index.Stat" - + "e\032\275\002\n\nIndexField\022\022\n\nfield_path\030\001 \001(\t\022B\n\005" - + "order\030\002 \001(\01621.google.firestore.admin.v1." - + "Index.IndexField.OrderH\000\022O\n\014array_config" - + "\030\003 \001(\01627.google.firestore.admin.v1.Index" - + ".IndexField.ArrayConfigH\000\"=\n\005Order\022\025\n\021OR" - + "DER_UNSPECIFIED\020\000\022\r\n\tASCENDING\020\001\022\016\n\nDESC" - + "ENDING\020\002\"9\n\013ArrayConfig\022\034\n\030ARRAY_CONFIG_" - + "UNSPECIFIED\020\000\022\014\n\010CONTAINS\020\001B\014\n\nvalue_mod" - + "e\"i\n\nQueryScope\022\033\n\027QUERY_SCOPE_UNSPECIFI" - + "ED\020\000\022\016\n\nCOLLECTION\020\001\022\024\n\020COLLECTION_GROUP" - + "\020\002\022\030\n\024COLLECTION_RECURSIVE\020\003\"/\n\010ApiScope" - + "\022\013\n\007ANY_API\020\000\022\026\n\022DATASTORE_MODE_API\020\001\"I\n" - + "\005State\022\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREATIN" - + "G\020\001\022\t\n\005READY\020\002\022\020\n\014NEEDS_REPAIR\020\003:z\352Aw\n\036f" - + "irestore.googleapis.com/Index\022Uprojects/" - + "{project}/databases/{database}/collectio" - + "nGroups/{collection}/indexes/{index}B\331\001\n" - + "\035com.google.firestore.admin.v1B\nIndexPro" - + "toP\001Z9cloud.google.com/go/firestore/apiv" - + "1/admin/adminpb;adminpb\242\002\004GCFS\252\002\037Google." - + "Cloud.Firestore.Admin.V1\312\002\037Google\\Cloud\\" - + "Firestore\\Admin\\V1\352\002#Google::Cloud::Fire" - + "store::Admin::V1b\006proto3" + + "\031google.firestore.admin.v1\032\037google/api/f" + + "ield_behavior.proto\032\031google/api/resource" + + ".proto\"\221\t\n\005Index\022\014\n\004name\030\001 \001(\t\022@\n\013query_" + + "scope\030\002 \001(\0162+.google.firestore.admin.v1." + + "Index.QueryScope\022<\n\tapi_scope\030\005 \001(\0162).go" + + "ogle.firestore.admin.v1.Index.ApiScope\022;" + + "\n\006fields\030\003 \003(\0132+.google.firestore.admin." + + "v1.Index.IndexField\0225\n\005state\030\004 \001(\0162&.goo" + + "gle.firestore.admin.v1.Index.State\032\242\004\n\nI" + + "ndexField\022\022\n\nfield_path\030\001 \001(\t\022B\n\005order\030\002" + + " \001(\01621.google.firestore.admin.v1.Index.I" + + "ndexField.OrderH\000\022O\n\014array_config\030\003 \001(\0162" + + "7.google.firestore.admin.v1.Index.IndexF" + + "ield.ArrayConfigH\000\022Q\n\rvector_config\030\004 \001(" + + "\01328.google.firestore.admin.v1.Index.Inde" + + "xField.VectorConfigH\000\032\217\001\n\014VectorConfig\022\026" + + "\n\tdimension\030\001 \001(\005B\003\340A\002\022R\n\004flat\030\002 \001(\0132B.g" + + "oogle.firestore.admin.v1.Index.IndexFiel" + + "d.VectorConfig.FlatIndexH\000\032\013\n\tFlatIndexB" + + "\006\n\004type\"=\n\005Order\022\025\n\021ORDER_UNSPECIFIED\020\000\022" + + "\r\n\tASCENDING\020\001\022\016\n\nDESCENDING\020\002\"9\n\013ArrayC" + + "onfig\022\034\n\030ARRAY_CONFIG_UNSPECIFIED\020\000\022\014\n\010C" + + "ONTAINS\020\001B\014\n\nvalue_mode\"i\n\nQueryScope\022\033\n" + + "\027QUERY_SCOPE_UNSPECIFIED\020\000\022\016\n\nCOLLECTION" + + "\020\001\022\024\n\020COLLECTION_GROUP\020\002\022\030\n\024COLLECTION_R" + + "ECURSIVE\020\003\"/\n\010ApiScope\022\013\n\007ANY_API\020\000\022\026\n\022D" + + "ATASTORE_MODE_API\020\001\"I\n\005State\022\025\n\021STATE_UN" + + "SPECIFIED\020\000\022\014\n\010CREATING\020\001\022\t\n\005READY\020\002\022\020\n\014" + + "NEEDS_REPAIR\020\003:z\352Aw\n\036firestore.googleapi" + + "s.com/Index\022Uprojects/{project}/database" + + "s/{database}/collectionGroups/{collectio" + + "n}/indexes/{index}B\331\001\n\035com.google.firest" + + "ore.admin.v1B\nIndexProtoP\001Z9cloud.google" + + ".com/go/firestore/apiv1/admin/adminpb;ad" + + "minpb\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Ad" + + "min.V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1" + + "\352\002#Google::Cloud::Firestore::Admin::V1b\006" + + "proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), com.google.api.ResourceProto.getDescriptor(), }); internal_static_google_firestore_admin_v1_Index_descriptor = @@ -98,13 +114,33 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_Index_IndexField_descriptor, new java.lang.String[] { - "FieldPath", "Order", "ArrayConfig", "ValueMode", + "FieldPath", "Order", "ArrayConfig", "VectorConfig", "ValueMode", }); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor = + internal_static_google_firestore_admin_v1_Index_IndexField_descriptor + .getNestedTypes() + .get(0); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor, + new java.lang.String[] { + "Dimension", "Flat", "Type", + }); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor = + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor + .getNestedTypes() + .get(0); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor, + new java.lang.String[] {}); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); registry.add(com.google.api.ResourceProto.resource); com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( descriptor, registry); + com.google.api.FieldBehaviorProto.getDescriptor(); com.google.api.ResourceProto.getDescriptor(); } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequest.java new file mode 100644 index 000000000..c8f38c04c --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequest.java @@ -0,0 +1,656 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesRequest} + */ +public final class ListBackupSchedulesRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupSchedulesRequest) + ListBackupSchedulesRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListBackupSchedulesRequest.newBuilder() to construct. + private ListBackupSchedulesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListBackupSchedulesRequest() { + parent_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListBackupSchedulesRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesRequest.class, + com.google.firestore.admin.v1.ListBackupSchedulesRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupSchedulesRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupSchedulesRequest other = + (com.google.firestore.admin.v1.ListBackupSchedulesRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ListBackupSchedulesRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupSchedulesRequest) + com.google.firestore.admin.v1.ListBackupSchedulesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesRequest.class, + com.google.firestore.admin.v1.ListBackupSchedulesRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupSchedulesRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupSchedulesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest build() { + com.google.firestore.admin.v1.ListBackupSchedulesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest buildPartial() { + com.google.firestore.admin.v1.ListBackupSchedulesRequest result = + new com.google.firestore.admin.v1.ListBackupSchedulesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupSchedulesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupSchedulesRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupSchedulesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupSchedulesRequest other) { + if (other == com.google.firestore.admin.v1.ListBackupSchedulesRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupSchedulesRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupSchedulesRequest) + private static final com.google.firestore.admin.v1.ListBackupSchedulesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupSchedulesRequest(); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupSchedulesRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequestOrBuilder.java new file mode 100644 index 000000000..c2d083160 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequestOrBuilder.java @@ -0,0 +1,59 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface ListBackupSchedulesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupSchedulesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponse.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponse.java new file mode 100644 index 000000000..ea2ac8418 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponse.java @@ -0,0 +1,950 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesResponse} + */ +public final class ListBackupSchedulesResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupSchedulesResponse) + ListBackupSchedulesResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListBackupSchedulesResponse.newBuilder() to construct. + private ListBackupSchedulesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListBackupSchedulesResponse() { + backupSchedules_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListBackupSchedulesResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesResponse.class, + com.google.firestore.admin.v1.ListBackupSchedulesResponse.Builder.class); + } + + public static final int BACKUP_SCHEDULES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List backupSchedules_; + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public java.util.List getBackupSchedulesList() { + return backupSchedules_; + } + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public java.util.List + getBackupSchedulesOrBuilderList() { + return backupSchedules_; + } + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public int getBackupSchedulesCount() { + return backupSchedules_.size(); + } + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedules(int index) { + return backupSchedules_.get(index); + } + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder( + int index) { + return backupSchedules_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < backupSchedules_.size(); i++) { + output.writeMessage(1, backupSchedules_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < backupSchedules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, backupSchedules_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupSchedulesResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupSchedulesResponse other = + (com.google.firestore.admin.v1.ListBackupSchedulesResponse) obj; + + if (!getBackupSchedulesList().equals(other.getBackupSchedulesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getBackupSchedulesCount() > 0) { + hash = (37 * hash) + BACKUP_SCHEDULES_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedulesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ListBackupSchedulesResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupSchedulesResponse) + com.google.firestore.admin.v1.ListBackupSchedulesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesResponse.class, + com.google.firestore.admin.v1.ListBackupSchedulesResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupSchedulesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (backupSchedulesBuilder_ == null) { + backupSchedules_ = java.util.Collections.emptyList(); + } else { + backupSchedules_ = null; + backupSchedulesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupSchedulesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse build() { + com.google.firestore.admin.v1.ListBackupSchedulesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse buildPartial() { + com.google.firestore.admin.v1.ListBackupSchedulesResponse result = + new com.google.firestore.admin.v1.ListBackupSchedulesResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListBackupSchedulesResponse result) { + if (backupSchedulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + backupSchedules_ = java.util.Collections.unmodifiableList(backupSchedules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.backupSchedules_ = backupSchedules_; + } else { + result.backupSchedules_ = backupSchedulesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupSchedulesResponse result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupSchedulesResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupSchedulesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupSchedulesResponse other) { + if (other == com.google.firestore.admin.v1.ListBackupSchedulesResponse.getDefaultInstance()) + return this; + if (backupSchedulesBuilder_ == null) { + if (!other.backupSchedules_.isEmpty()) { + if (backupSchedules_.isEmpty()) { + backupSchedules_ = other.backupSchedules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBackupSchedulesIsMutable(); + backupSchedules_.addAll(other.backupSchedules_); + } + onChanged(); + } + } else { + if (!other.backupSchedules_.isEmpty()) { + if (backupSchedulesBuilder_.isEmpty()) { + backupSchedulesBuilder_.dispose(); + backupSchedulesBuilder_ = null; + backupSchedules_ = other.backupSchedules_; + bitField0_ = (bitField0_ & ~0x00000001); + backupSchedulesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getBackupSchedulesFieldBuilder() + : null; + } else { + backupSchedulesBuilder_.addAllMessages(other.backupSchedules_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.BackupSchedule m = + input.readMessage( + com.google.firestore.admin.v1.BackupSchedule.parser(), extensionRegistry); + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(m); + } else { + backupSchedulesBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List backupSchedules_ = + java.util.Collections.emptyList(); + + private void ensureBackupSchedulesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + backupSchedules_ = + new java.util.ArrayList(backupSchedules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + backupSchedulesBuilder_; + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List getBackupSchedulesList() { + if (backupSchedulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(backupSchedules_); + } else { + return backupSchedulesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public int getBackupSchedulesCount() { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.size(); + } else { + return backupSchedulesBuilder_.getCount(); + } + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedules(int index) { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.get(index); + } else { + return backupSchedulesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder setBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.set(index, value); + onChanged(); + } else { + backupSchedulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder setBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.set(index, builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(value); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(index, value); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(index, builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addAllBackupSchedules( + java.lang.Iterable values) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, backupSchedules_); + onChanged(); + } else { + backupSchedulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder clearBackupSchedules() { + if (backupSchedulesBuilder_ == null) { + backupSchedules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + backupSchedulesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder removeBackupSchedules(int index) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.remove(index); + onChanged(); + } else { + backupSchedulesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder getBackupSchedulesBuilder( + int index) { + return getBackupSchedulesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder( + int index) { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.get(index); + } else { + return backupSchedulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List + getBackupSchedulesOrBuilderList() { + if (backupSchedulesBuilder_ != null) { + return backupSchedulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(backupSchedules_); + } + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder addBackupSchedulesBuilder() { + return getBackupSchedulesFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()); + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder addBackupSchedulesBuilder( + int index) { + return getBackupSchedulesFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()); + } + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List + getBackupSchedulesBuilderList() { + return getBackupSchedulesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + getBackupSchedulesFieldBuilder() { + if (backupSchedulesBuilder_ == null) { + backupSchedulesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder>( + backupSchedules_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + backupSchedules_ = null; + } + return backupSchedulesBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupSchedulesResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupSchedulesResponse) + private static final com.google.firestore.admin.v1.ListBackupSchedulesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupSchedulesResponse(); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupSchedulesResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponseOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponseOrBuilder.java new file mode 100644 index 000000000..eea1e95de --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponseOrBuilder.java @@ -0,0 +1,78 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface ListBackupSchedulesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupSchedulesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + java.util.List getBackupSchedulesList(); + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + com.google.firestore.admin.v1.BackupSchedule getBackupSchedules(int index); + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + int getBackupSchedulesCount(); + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + java.util.List + getBackupSchedulesOrBuilderList(); + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder(int index); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequest.java new file mode 100644 index 000000000..63727c091 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequest.java @@ -0,0 +1,676 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsRequest} + */ +public final class ListBackupsRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupsRequest) + ListBackupsRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListBackupsRequest.newBuilder() to construct. + private ListBackupsRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListBackupsRequest() { + parent_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListBackupsRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsRequest.class, + com.google.firestore.admin.v1.ListBackupsRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupsRequest other = + (com.google.firestore.admin.v1.ListBackupsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListBackupsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupsRequest) + com.google.firestore.admin.v1.ListBackupsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsRequest.class, + com.google.firestore.admin.v1.ListBackupsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest build() { + com.google.firestore.admin.v1.ListBackupsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest buildPartial() { + com.google.firestore.admin.v1.ListBackupsRequest result = + new com.google.firestore.admin.v1.ListBackupsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupsRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupsRequest other) { + if (other == com.google.firestore.admin.v1.ListBackupsRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupsRequest) + private static final com.google.firestore.admin.v1.ListBackupsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupsRequest(); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequestOrBuilder.java new file mode 100644 index 000000000..2945d5c15 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequestOrBuilder.java @@ -0,0 +1,65 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface ListBackupsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponse.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponse.java new file mode 100644 index 000000000..728d020c9 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponse.java @@ -0,0 +1,1279 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsResponse} + */ +public final class ListBackupsResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupsResponse) + ListBackupsResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListBackupsResponse.newBuilder() to construct. + private ListBackupsResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListBackupsResponse() { + backups_ = java.util.Collections.emptyList(); + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListBackupsResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsResponse.class, + com.google.firestore.admin.v1.ListBackupsResponse.Builder.class); + } + + public static final int BACKUPS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List backups_; + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public java.util.List getBackupsList() { + return backups_; + } + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public java.util.List + getBackupsOrBuilderList() { + return backups_; + } + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public int getBackupsCount() { + return backups_.size(); + } + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup getBackups(int index) { + return backups_.get(index); + } + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupOrBuilder getBackupsOrBuilder(int index) { + return backups_.get(index); + } + + public static final int UNREACHABLE_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList unreachable_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + public com.google.protobuf.ProtocolStringList getUnreachableList() { + return unreachable_; + } + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + public int getUnreachableCount() { + return unreachable_.size(); + } + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + public java.lang.String getUnreachable(int index) { + return unreachable_.get(index); + } + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + public com.google.protobuf.ByteString getUnreachableBytes(int index) { + return unreachable_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < backups_.size(); i++) { + output.writeMessage(1, backups_.get(i)); + } + for (int i = 0; i < unreachable_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, unreachable_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < backups_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, backups_.get(i)); + } + { + int dataSize = 0; + for (int i = 0; i < unreachable_.size(); i++) { + dataSize += computeStringSizeNoTag(unreachable_.getRaw(i)); + } + size += dataSize; + size += 1 * getUnreachableList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupsResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupsResponse other = + (com.google.firestore.admin.v1.ListBackupsResponse) obj; + + if (!getBackupsList().equals(other.getBackupsList())) return false; + if (!getUnreachableList().equals(other.getUnreachableList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getBackupsCount() > 0) { + hash = (37 * hash) + BACKUPS_FIELD_NUMBER; + hash = (53 * hash) + getBackupsList().hashCode(); + } + if (getUnreachableCount() > 0) { + hash = (37 * hash) + UNREACHABLE_FIELD_NUMBER; + hash = (53 * hash) + getUnreachableList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListBackupsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupsResponse) + com.google.firestore.admin.v1.ListBackupsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsResponse.class, + com.google.firestore.admin.v1.ListBackupsResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (backupsBuilder_ == null) { + backups_ = java.util.Collections.emptyList(); + } else { + backups_ = null; + backupsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse build() { + com.google.firestore.admin.v1.ListBackupsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse buildPartial() { + com.google.firestore.admin.v1.ListBackupsResponse result = + new com.google.firestore.admin.v1.ListBackupsResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListBackupsResponse result) { + if (backupsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + backups_ = java.util.Collections.unmodifiableList(backups_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.backups_ = backups_; + } else { + result.backups_ = backupsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupsResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + unreachable_.makeImmutable(); + result.unreachable_ = unreachable_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupsResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupsResponse other) { + if (other == com.google.firestore.admin.v1.ListBackupsResponse.getDefaultInstance()) + return this; + if (backupsBuilder_ == null) { + if (!other.backups_.isEmpty()) { + if (backups_.isEmpty()) { + backups_ = other.backups_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBackupsIsMutable(); + backups_.addAll(other.backups_); + } + onChanged(); + } + } else { + if (!other.backups_.isEmpty()) { + if (backupsBuilder_.isEmpty()) { + backupsBuilder_.dispose(); + backupsBuilder_ = null; + backups_ = other.backups_; + bitField0_ = (bitField0_ & ~0x00000001); + backupsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getBackupsFieldBuilder() + : null; + } else { + backupsBuilder_.addAllMessages(other.backups_); + } + } + } + if (!other.unreachable_.isEmpty()) { + if (unreachable_.isEmpty()) { + unreachable_ = other.unreachable_; + bitField0_ |= 0x00000002; + } else { + ensureUnreachableIsMutable(); + unreachable_.addAll(other.unreachable_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.Backup m = + input.readMessage( + com.google.firestore.admin.v1.Backup.parser(), extensionRegistry); + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.add(m); + } else { + backupsBuilder_.addMessage(m); + } + break; + } // case 10 + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureUnreachableIsMutable(); + unreachable_.add(s); + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List backups_ = + java.util.Collections.emptyList(); + + private void ensureBackupsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + backups_ = new java.util.ArrayList(backups_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.admin.v1.Backup, + com.google.firestore.admin.v1.Backup.Builder, + com.google.firestore.admin.v1.BackupOrBuilder> + backupsBuilder_; + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public java.util.List getBackupsList() { + if (backupsBuilder_ == null) { + return java.util.Collections.unmodifiableList(backups_); + } else { + return backupsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public int getBackupsCount() { + if (backupsBuilder_ == null) { + return backups_.size(); + } else { + return backupsBuilder_.getCount(); + } + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup getBackups(int index) { + if (backupsBuilder_ == null) { + return backups_.get(index); + } else { + return backupsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder setBackups(int index, com.google.firestore.admin.v1.Backup value) { + if (backupsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupsIsMutable(); + backups_.set(index, value); + onChanged(); + } else { + backupsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder setBackups( + int index, com.google.firestore.admin.v1.Backup.Builder builderForValue) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.set(index, builderForValue.build()); + onChanged(); + } else { + backupsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups(com.google.firestore.admin.v1.Backup value) { + if (backupsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupsIsMutable(); + backups_.add(value); + onChanged(); + } else { + backupsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups(int index, com.google.firestore.admin.v1.Backup value) { + if (backupsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupsIsMutable(); + backups_.add(index, value); + onChanged(); + } else { + backupsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups(com.google.firestore.admin.v1.Backup.Builder builderForValue) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.add(builderForValue.build()); + onChanged(); + } else { + backupsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups( + int index, com.google.firestore.admin.v1.Backup.Builder builderForValue) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.add(index, builderForValue.build()); + onChanged(); + } else { + backupsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addAllBackups( + java.lang.Iterable values) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, backups_); + onChanged(); + } else { + backupsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder clearBackups() { + if (backupsBuilder_ == null) { + backups_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + backupsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder removeBackups(int index) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.remove(index); + onChanged(); + } else { + backupsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup.Builder getBackupsBuilder(int index) { + return getBackupsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.BackupOrBuilder getBackupsOrBuilder(int index) { + if (backupsBuilder_ == null) { + return backups_.get(index); + } else { + return backupsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public java.util.List + getBackupsOrBuilderList() { + if (backupsBuilder_ != null) { + return backupsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(backups_); + } + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup.Builder addBackupsBuilder() { + return getBackupsFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.Backup.getDefaultInstance()); + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup.Builder addBackupsBuilder(int index) { + return getBackupsFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.Backup.getDefaultInstance()); + } + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public java.util.List getBackupsBuilderList() { + return getBackupsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.admin.v1.Backup, + com.google.firestore.admin.v1.Backup.Builder, + com.google.firestore.admin.v1.BackupOrBuilder> + getBackupsFieldBuilder() { + if (backupsBuilder_ == null) { + backupsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.admin.v1.Backup, + com.google.firestore.admin.v1.Backup.Builder, + com.google.firestore.admin.v1.BackupOrBuilder>( + backups_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + backups_ = null; + } + return backupsBuilder_; + } + + private com.google.protobuf.LazyStringArrayList unreachable_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureUnreachableIsMutable() { + if (!unreachable_.isModifiable()) { + unreachable_ = new com.google.protobuf.LazyStringArrayList(unreachable_); + } + bitField0_ |= 0x00000002; + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + public com.google.protobuf.ProtocolStringList getUnreachableList() { + unreachable_.makeImmutable(); + return unreachable_; + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + public int getUnreachableCount() { + return unreachable_.size(); + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + public java.lang.String getUnreachable(int index) { + return unreachable_.get(index); + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + public com.google.protobuf.ByteString getUnreachableBytes(int index) { + return unreachable_.getByteString(index); + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index to set the value at. + * @param value The unreachable to set. + * @return This builder for chaining. + */ + public Builder setUnreachable(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureUnreachableIsMutable(); + unreachable_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param value The unreachable to add. + * @return This builder for chaining. + */ + public Builder addUnreachable(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureUnreachableIsMutable(); + unreachable_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param values The unreachable to add. + * @return This builder for chaining. + */ + public Builder addAllUnreachable(java.lang.Iterable values) { + ensureUnreachableIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, unreachable_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return This builder for chaining. + */ + public Builder clearUnreachable() { + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param value The bytes of the unreachable to add. + * @return This builder for chaining. + */ + public Builder addUnreachableBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureUnreachableIsMutable(); + unreachable_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupsResponse) + private static final com.google.firestore.admin.v1.ListBackupsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupsResponse(); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponseOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponseOrBuilder.java new file mode 100644 index 000000000..9cbfc18a4 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponseOrBuilder.java @@ -0,0 +1,148 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface ListBackupsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + java.util.List getBackupsList(); + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + com.google.firestore.admin.v1.Backup getBackups(int index); + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + int getBackupsCount(); + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + java.util.List getBackupsOrBuilderList(); + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + com.google.firestore.admin.v1.BackupOrBuilder getBackupsOrBuilder(int index); + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + java.util.List getUnreachableList(); + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + int getUnreachableCount(); + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + java.lang.String getUnreachable(int index); + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + com.google.protobuf.ByteString getUnreachableBytes(int index); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationName.java new file mode 100644 index 000000000..3e4c27491 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationName.java @@ -0,0 +1,192 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class LocationName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION = + PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + + @Deprecated + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LocationName of(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build(); + } + + public static String format(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build().toString(); + } + + public static LocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION.validatedMatch( + formattedString, "LocationName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LocationName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION.instantiate("project", project, "location", location); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { + private String project; + private String location; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(LocationName locationName) { + this.project = locationName.project; + this.location = locationName.location; + } + + public LocationName build() { + return new LocationName(this); + } + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java index 28676b40c..fd5e57b65 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java @@ -56,6 +56,10 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_admin_v1_ExportDocumentsResponse_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_admin_v1_ExportDocumentsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_firestore_admin_v1_Progress_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -126,18 +130,27 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "1.Progress\022\026\n\016collection_ids\030\006 \003(\t\022\030\n\020in" + "put_uri_prefix\030\007 \001(\t\022\025\n\rnamespace_ids\030\010 " + "\003(\t\"4\n\027ExportDocumentsResponse\022\031\n\021output" - + "_uri_prefix\030\001 \001(\t\":\n\010Progress\022\026\n\016estimat" - + "ed_work\030\001 \001(\003\022\026\n\016completed_work\030\002 \001(\003*\236\001" - + "\n\016OperationState\022\037\n\033OPERATION_STATE_UNSP" - + "ECIFIED\020\000\022\020\n\014INITIALIZING\020\001\022\016\n\nPROCESSIN" - + "G\020\002\022\016\n\nCANCELLING\020\003\022\016\n\nFINALIZING\020\004\022\016\n\nS" - + "UCCESSFUL\020\005\022\n\n\006FAILED\020\006\022\r\n\tCANCELLED\020\007B\335" - + "\001\n\035com.google.firestore.admin.v1B\016Operat" - + "ionProtoP\001Z9cloud.google.com/go/firestor" - + "e/apiv1/admin/adminpb;adminpb\242\002\004GCFS\252\002\037G" - + "oogle.Cloud.Firestore.Admin.V1\312\002\037Google\\" - + "Cloud\\Firestore\\Admin\\V1\352\002#Google::Cloud" - + "::Firestore::Admin::V1b\006proto3" + + "_uri_prefix\030\001 \001(\t\"\355\002\n\027RestoreDatabaseMet" + + "adata\022.\n\nstart_time\030\001 \001(\0132\032.google.proto" + + "buf.Timestamp\022,\n\010end_time\030\002 \001(\0132\032.google" + + ".protobuf.Timestamp\022B\n\017operation_state\030\003" + + " \001(\0162).google.firestore.admin.v1.Operati" + + "onState\0228\n\010database\030\004 \001(\tB&\372A#\n!firestor" + + "e.googleapis.com/Database\0224\n\006backup\030\005 \001(" + + "\tB$\372A!\n\037firestore.googleapis.com/Backup\022" + + "@\n\023progress_percentage\030\010 \001(\0132#.google.fi" + + "restore.admin.v1.Progress\":\n\010Progress\022\026\n" + + "\016estimated_work\030\001 \001(\003\022\026\n\016completed_work\030" + + "\002 \001(\003*\236\001\n\016OperationState\022\037\n\033OPERATION_ST" + + "ATE_UNSPECIFIED\020\000\022\020\n\014INITIALIZING\020\001\022\016\n\nP" + + "ROCESSING\020\002\022\016\n\nCANCELLING\020\003\022\016\n\nFINALIZIN" + + "G\020\004\022\016\n\nSUCCESSFUL\020\005\022\n\n\006FAILED\020\006\022\r\n\tCANCE" + + "LLED\020\007B\335\001\n\035com.google.firestore.admin.v1" + + "B\016OperationProtoP\001Z9cloud.google.com/go/" + + "firestore/apiv1/admin/adminpb;adminpb\242\002\004" + + "GCFS\252\002\037Google.Cloud.Firestore.Admin.V1\312\002" + + "\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#Googl" + + "e::Cloud::Firestore::Admin::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -229,14 +242,27 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "OutputUriPrefix", }); - internal_static_google_firestore_admin_v1_Progress_descriptor = + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor = getDescriptor().getMessageTypes().get(5); + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor, + new java.lang.String[] { + "StartTime", "EndTime", "OperationState", "Database", "Backup", "ProgressPercentage", + }); + internal_static_google_firestore_admin_v1_Progress_descriptor = + getDescriptor().getMessageTypes().get(6); internal_static_google_firestore_admin_v1_Progress_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_admin_v1_Progress_descriptor, new java.lang.String[] { "EstimatedWork", "CompletedWork", }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); com.google.api.ResourceProto.getDescriptor(); com.google.firestore.admin.v1.IndexProto.getDescriptor(); com.google.protobuf.TimestampProto.getDescriptor(); diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProjectName.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProjectName.java index 2a446269a..3d6a8c946 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProjectName.java +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProjectName.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadata.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadata.java new file mode 100644 index 000000000..00716f960 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadata.java @@ -0,0 +1,1764 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/operation.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for the [long-running operation][google.longrunning.Operation] from
+ * the [RestoreDatabase][google.firestore.admin.v1.RestoreDatabase] request.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseMetadata} + */ +public final class RestoreDatabaseMetadata extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.RestoreDatabaseMetadata) + RestoreDatabaseMetadataOrBuilder { + private static final long serialVersionUID = 0L; + // Use RestoreDatabaseMetadata.newBuilder() to construct. + private RestoreDatabaseMetadata(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RestoreDatabaseMetadata() { + operationState_ = 0; + database_ = ""; + backup_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RestoreDatabaseMetadata(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseMetadata.class, + com.google.firestore.admin.v1.RestoreDatabaseMetadata.Builder.class); + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int OPERATION_STATE_FIELD_NUMBER = 3; + private int operationState_ = 0; + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int DATABASE_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object backup_ = ""; + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + @java.lang.Override + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } + } + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROGRESS_PERCENTAGE_FIELD_NUMBER = 8; + private com.google.firestore.admin.v1.Progress progressPercentage_; + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return Whether the progressPercentage field is set. + */ + @java.lang.Override + public boolean hasProgressPercentage() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return The progressPercentage. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressPercentage() { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder() { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(3, operationState_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, database_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backup_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, backup_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(8, getProgressPercentage()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, operationState_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, database_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backup_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, backup_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getProgressPercentage()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.RestoreDatabaseMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.RestoreDatabaseMetadata other = + (com.google.firestore.admin.v1.RestoreDatabaseMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (operationState_ != other.operationState_) return false; + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getBackup().equals(other.getBackup())) return false; + if (hasProgressPercentage() != other.hasProgressPercentage()) return false; + if (hasProgressPercentage()) { + if (!getProgressPercentage().equals(other.getProgressPercentage())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + OPERATION_STATE_FIELD_NUMBER; + hash = (53 * hash) + operationState_; + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + hash = (37 * hash) + BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getBackup().hashCode(); + if (hasProgressPercentage()) { + hash = (37 * hash) + PROGRESS_PERCENTAGE_FIELD_NUMBER; + hash = (53 * hash) + getProgressPercentage().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.RestoreDatabaseMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Metadata for the [long-running operation][google.longrunning.Operation] from
+   * the [RestoreDatabase][google.firestore.admin.v1.RestoreDatabase] request.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.RestoreDatabaseMetadata) + com.google.firestore.admin.v1.RestoreDatabaseMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseMetadata.class, + com.google.firestore.admin.v1.RestoreDatabaseMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.RestoreDatabaseMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getStartTimeFieldBuilder(); + getEndTimeFieldBuilder(); + getProgressPercentageFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + operationState_ = 0; + database_ = ""; + backup_ = ""; + progressPercentage_ = null; + if (progressPercentageBuilder_ != null) { + progressPercentageBuilder_.dispose(); + progressPercentageBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.RestoreDatabaseMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata build() { + com.google.firestore.admin.v1.RestoreDatabaseMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata buildPartial() { + com.google.firestore.admin.v1.RestoreDatabaseMetadata result = + new com.google.firestore.admin.v1.RestoreDatabaseMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.RestoreDatabaseMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.operationState_ = operationState_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.backup_ = backup_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.progressPercentage_ = + progressPercentageBuilder_ == null + ? progressPercentage_ + : progressPercentageBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.RestoreDatabaseMetadata) { + return mergeFrom((com.google.firestore.admin.v1.RestoreDatabaseMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.RestoreDatabaseMetadata other) { + if (other == com.google.firestore.admin.v1.RestoreDatabaseMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (other.operationState_ != 0) { + setOperationStateValue(other.getOperationStateValue()); + } + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000008; + onChanged(); + } + if (!other.getBackup().isEmpty()) { + backup_ = other.backup_; + bitField0_ |= 0x00000010; + onChanged(); + } + if (other.hasProgressPercentage()) { + mergeProgressPercentage(other.getProgressPercentage()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(getStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + operationState_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + backup_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 66: + { + input.readMessage( + getProgressPercentageFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 66 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getStartTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getEndTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private int operationState_ = 0; + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The enum numeric value on the wire for operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationStateValue(int value) { + operationState_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + operationState_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return This builder for chaining. + */ + public Builder clearOperationState() { + bitField0_ = (bitField0_ & ~0x00000004); + operationState_ = 0; + onChanged(); + return this; + } + + private java.lang.Object database_ = ""; + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private java.lang.Object backup_ = ""; + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @param value The backup to set. + * @return This builder for chaining. + */ + public Builder setBackup(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + backup_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearBackup() { + backup_ = getDefaultInstance().getBackup(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for backup to set. + * @return This builder for chaining. + */ + public Builder setBackupBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + backup_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Progress progressPercentage_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressPercentageBuilder_; + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return Whether the progressPercentage field is set. + */ + public boolean hasProgressPercentage() { + return ((bitField0_ & 0x00000020) != 0); + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return The progressPercentage. + */ + public com.google.firestore.admin.v1.Progress getProgressPercentage() { + if (progressPercentageBuilder_ == null) { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } else { + return progressPercentageBuilder_.getMessage(); + } + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder setProgressPercentage(com.google.firestore.admin.v1.Progress value) { + if (progressPercentageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressPercentage_ = value; + } else { + progressPercentageBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder setProgressPercentage( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressPercentageBuilder_ == null) { + progressPercentage_ = builderForValue.build(); + } else { + progressPercentageBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder mergeProgressPercentage(com.google.firestore.admin.v1.Progress value) { + if (progressPercentageBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && progressPercentage_ != null + && progressPercentage_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressPercentageBuilder().mergeFrom(value); + } else { + progressPercentage_ = value; + } + } else { + progressPercentageBuilder_.mergeFrom(value); + } + if (progressPercentage_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder clearProgressPercentage() { + bitField0_ = (bitField0_ & ~0x00000020); + progressPercentage_ = null; + if (progressPercentageBuilder_ != null) { + progressPercentageBuilder_.dispose(); + progressPercentageBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressPercentageBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return getProgressPercentageFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder() { + if (progressPercentageBuilder_ != null) { + return progressPercentageBuilder_.getMessageOrBuilder(); + } else { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + } + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + getProgressPercentageFieldBuilder() { + if (progressPercentageBuilder_ == null) { + progressPercentageBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressPercentage(), getParentForChildren(), isClean()); + progressPercentage_ = null; + } + return progressPercentageBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.RestoreDatabaseMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.RestoreDatabaseMetadata) + private static final com.google.firestore.admin.v1.RestoreDatabaseMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.RestoreDatabaseMetadata(); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RestoreDatabaseMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadataOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadataOrBuilder.java new file mode 100644 index 000000000..10131af08 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadataOrBuilder.java @@ -0,0 +1,206 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/operation.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface RestoreDatabaseMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.RestoreDatabaseMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + int getOperationStateValue(); + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + com.google.firestore.admin.v1.OperationState getOperationState(); + + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + java.lang.String getDatabase(); + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + java.lang.String getBackup(); + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + com.google.protobuf.ByteString getBackupBytes(); + + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return Whether the progressPercentage field is set. + */ + boolean hasProgressPercentage(); + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return The progressPercentage. + */ + com.google.firestore.admin.v1.Progress getProgressPercentage(); + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequest.java new file mode 100644 index 000000000..1f88b08d7 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequest.java @@ -0,0 +1,1103 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request message for
+ * [FirestoreAdmin.RestoreDatabase][google.firestore.admin.v1.RestoreDatabase].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseRequest} + */ +public final class RestoreDatabaseRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.RestoreDatabaseRequest) + RestoreDatabaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use RestoreDatabaseRequest.newBuilder() to construct. + private RestoreDatabaseRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RestoreDatabaseRequest() { + parent_ = ""; + databaseId_ = ""; + backup_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RestoreDatabaseRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseRequest.class, + com.google.firestore.admin.v1.RestoreDatabaseRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database id must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database id is also valid.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + @java.lang.Override + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database id must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database id is also valid.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object backup_ = ""; + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The backup. + */ + @java.lang.Override + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for backup. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, databaseId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backup_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, backup_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, databaseId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backup_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, backup_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.RestoreDatabaseRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.RestoreDatabaseRequest other = + (com.google.firestore.admin.v1.RestoreDatabaseRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (!getBackup().equals(other.getBackup())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + hash = (37 * hash) + BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getBackup().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.RestoreDatabaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request message for
+   * [FirestoreAdmin.RestoreDatabase][google.firestore.admin.v1.RestoreDatabase].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.RestoreDatabaseRequest) + com.google.firestore.admin.v1.RestoreDatabaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseRequest.class, + com.google.firestore.admin.v1.RestoreDatabaseRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.RestoreDatabaseRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + databaseId_ = ""; + backup_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.RestoreDatabaseRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest build() { + com.google.firestore.admin.v1.RestoreDatabaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest buildPartial() { + com.google.firestore.admin.v1.RestoreDatabaseRequest result = + new com.google.firestore.admin.v1.RestoreDatabaseRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.RestoreDatabaseRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.backup_ = backup_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.RestoreDatabaseRequest) { + return mergeFrom((com.google.firestore.admin.v1.RestoreDatabaseRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.RestoreDatabaseRequest other) { + if (other == com.google.firestore.admin.v1.RestoreDatabaseRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getBackup().isEmpty()) { + backup_ = other.backup_; + bitField0_ |= 0x00000004; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + backup_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database id must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database id is also valid.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database id must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database id is also valid.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database id must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database id is also valid.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + databaseId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database id must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database id is also valid.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database id must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database id is also valid.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + databaseId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object backup_ = ""; + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The backup. + */ + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for backup. + */ + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The backup to set. + * @return This builder for chaining. + */ + public Builder setBackup(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + backup_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearBackup() { + backup_ = getDefaultInstance().getBackup(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for backup to set. + * @return This builder for chaining. + */ + public Builder setBackupBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + backup_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.RestoreDatabaseRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.RestoreDatabaseRequest) + private static final com.google.firestore.admin.v1.RestoreDatabaseRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.RestoreDatabaseRequest(); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RestoreDatabaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequestOrBuilder.java new file mode 100644 index 000000000..33d7b0110 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequestOrBuilder.java @@ -0,0 +1,133 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface RestoreDatabaseRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.RestoreDatabaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database id must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database id is also valid.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database id must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database id is also valid.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The backup. + */ + java.lang.String getBackup(); + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for backup. + */ + com.google.protobuf.ByteString getBackupBytes(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ScheduleProto.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ScheduleProto.java new file mode 100644 index 000000000..ddec765b9 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ScheduleProto.java @@ -0,0 +1,131 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/schedule.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public final class ScheduleProto { + private ScheduleProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n(google/firestore/admin/v1/schedule.pro" + + "to\022\031google.firestore.admin.v1\032\037google/ap" + + "i/field_behavior.proto\032\031google/api/resou" + + "rce.proto\032\036google/protobuf/duration.prot" + + "o\032\037google/protobuf/timestamp.proto\032\033goog" + + "le/type/dayofweek.proto\"\326\003\n\016BackupSchedu" + + "le\022\021\n\004name\030\001 \001(\tB\003\340A\003\0224\n\013create_time\030\003 \001" + + "(\0132\032.google.protobuf.TimestampB\003\340A\003\0224\n\013u" + + "pdate_time\030\n \001(\0132\032.google.protobuf.Times" + + "tampB\003\340A\003\022,\n\tretention\030\006 \001(\0132\031.google.pr" + + "otobuf.Duration\022F\n\020daily_recurrence\030\007 \001(" + + "\0132*.google.firestore.admin.v1.DailyRecur" + + "renceH\000\022H\n\021weekly_recurrence\030\010 \001(\0132+.goo" + + "gle.firestore.admin.v1.WeeklyRecurrenceH" + + "\000:w\352At\n\'firestore.googleapis.com/BackupS" + + "chedule\022Iprojects/{project}/databases/{d" + + "atabase}/backupSchedules/{backup_schedul" + + "e}B\014\n\nrecurrence\"\021\n\017DailyRecurrence\"7\n\020W" + + "eeklyRecurrence\022#\n\003day\030\002 \001(\0162\026.google.ty" + + "pe.DayOfWeekB\334\001\n\035com.google.firestore.ad" + + "min.v1B\rScheduleProtoP\001Z9cloud.google.co" + + "m/go/firestore/apiv1/admin/adminpb;admin" + + "pb\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Admin" + + ".V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#" + + "Google::Cloud::Firestore::Admin::V1b\006pro" + + "to3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.DurationProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.type.DayOfWeekProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_BackupSchedule_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_BackupSchedule_descriptor, + new java.lang.String[] { + "Name", + "CreateTime", + "UpdateTime", + "Retention", + "DailyRecurrence", + "WeeklyRecurrence", + "Recurrence", + }); + internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor, + new java.lang.String[] { + "Day", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.DurationProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.type.DayOfWeekProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequest.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequest.java new file mode 100644 index 000000000..e0ef6097a --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequest.java @@ -0,0 +1,1015 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.UpdateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.UpdateBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateBackupScheduleRequest} + */ +public final class UpdateBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.UpdateBackupScheduleRequest) + UpdateBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use UpdateBackupScheduleRequest.newBuilder() to construct. + private UpdateBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private UpdateBackupScheduleRequest() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new UpdateBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.class, + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.Builder.class); + } + + private int bitField0_; + public static final int BACKUP_SCHEDULE_FIELD_NUMBER = 1; + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + @java.lang.Override + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + public static final int UPDATE_MASK_FIELD_NUMBER = 2; + private com.google.protobuf.FieldMask updateMask_; + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + @java.lang.Override + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + @java.lang.Override + public com.google.protobuf.FieldMask getUpdateMask() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + @java.lang.Override + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getBackupSchedule()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getUpdateMask()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getBackupSchedule()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.UpdateBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.UpdateBackupScheduleRequest other = + (com.google.firestore.admin.v1.UpdateBackupScheduleRequest) obj; + + if (hasBackupSchedule() != other.hasBackupSchedule()) return false; + if (hasBackupSchedule()) { + if (!getBackupSchedule().equals(other.getBackupSchedule())) return false; + } + if (hasUpdateMask() != other.hasUpdateMask()) return false; + if (hasUpdateMask()) { + if (!getUpdateMask().equals(other.getUpdateMask())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBackupSchedule()) { + hash = (37 * hash) + BACKUP_SCHEDULE_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedule().hashCode(); + } + if (hasUpdateMask()) { + hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; + hash = (53 * hash) + getUpdateMask().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.UpdateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.UpdateBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.UpdateBackupScheduleRequest) + com.google.firestore.admin.v1.UpdateBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.class, + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.UpdateBackupScheduleRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getBackupScheduleFieldBuilder(); + getUpdateMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.UpdateBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest build() { + com.google.firestore.admin.v1.UpdateBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.UpdateBackupScheduleRequest result = + new com.google.firestore.admin.v1.UpdateBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.UpdateBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.backupSchedule_ = + backupScheduleBuilder_ == null ? backupSchedule_ : backupScheduleBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.UpdateBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.UpdateBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.UpdateBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.UpdateBackupScheduleRequest.getDefaultInstance()) + return this; + if (other.hasBackupSchedule()) { + mergeBackupSchedule(other.getBackupSchedule()); + } + if (other.hasUpdateMask()) { + mergeUpdateMask(other.getUpdateMask()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(getBackupScheduleFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + backupScheduleBuilder_; + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + if (backupScheduleBuilder_ == null) { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } else { + return backupScheduleBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupSchedule_ = value; + } else { + backupScheduleBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule( + com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupScheduleBuilder_ == null) { + backupSchedule_ = builderForValue.build(); + } else { + backupScheduleBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && backupSchedule_ != null + && backupSchedule_ + != com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()) { + getBackupScheduleBuilder().mergeFrom(value); + } else { + backupSchedule_ = value; + } + } else { + backupScheduleBuilder_.mergeFrom(value); + } + if (backupSchedule_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearBackupSchedule() { + bitField0_ = (bitField0_ & ~0x00000001); + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder getBackupScheduleBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getBackupScheduleFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + if (backupScheduleBuilder_ != null) { + return backupScheduleBuilder_.getMessageOrBuilder(); + } else { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + } + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + getBackupScheduleFieldBuilder() { + if (backupScheduleBuilder_ == null) { + backupScheduleBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder>( + getBackupSchedule(), getParentForChildren(), isClean()); + backupSchedule_ = null; + } + return backupScheduleBuilder_; + } + + private com.google.protobuf.FieldMask updateMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + updateMaskBuilder_; + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + public com.google.protobuf.FieldMask getUpdateMask() { + if (updateMaskBuilder_ == null) { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } else { + return updateMaskBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateMask_ = value; + } else { + updateMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) { + if (updateMaskBuilder_ == null) { + updateMask_ = builderForValue.build(); + } else { + updateMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && updateMask_ != null + && updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) { + getUpdateMaskBuilder().mergeFrom(value); + } else { + updateMask_ = value; + } + } else { + updateMaskBuilder_.mergeFrom(value); + } + if (updateMask_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder clearUpdateMask() { + bitField0_ = (bitField0_ & ~0x00000002); + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getUpdateMaskFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + if (updateMaskBuilder_ != null) { + return updateMaskBuilder_.getMessageOrBuilder(); + } else { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } + } + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + getUpdateMaskFieldBuilder() { + if (updateMaskBuilder_ == null) { + updateMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder>( + getUpdateMask(), getParentForChildren(), isClean()); + updateMask_ = null; + } + return updateMaskBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.UpdateBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.UpdateBackupScheduleRequest) + private static final com.google.firestore.admin.v1.UpdateBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.UpdateBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdateBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequestOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000..07e4d0cb7 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequestOrBuilder.java @@ -0,0 +1,102 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/firestore_admin.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface UpdateBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.UpdateBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + boolean hasBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + com.google.firestore.admin.v1.BackupSchedule getBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder(); + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + boolean hasUpdateMask(); + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + com.google.protobuf.FieldMask getUpdateMask(); + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrence.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrence.java new file mode 100644 index 000000000..58dcabbaf --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrence.java @@ -0,0 +1,606 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/schedule.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Represents a recurring schedule that runs on a specified day of the week.
+ *
+ * The time zone is UTC.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.WeeklyRecurrence} + */ +public final class WeeklyRecurrence extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.WeeklyRecurrence) + WeeklyRecurrenceOrBuilder { + private static final long serialVersionUID = 0L; + // Use WeeklyRecurrence.newBuilder() to construct. + private WeeklyRecurrence(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private WeeklyRecurrence() { + day_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new WeeklyRecurrence(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.WeeklyRecurrence.class, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder.class); + } + + public static final int DAY_FIELD_NUMBER = 2; + private int day_ = 0; + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The enum numeric value on the wire for day. + */ + @java.lang.Override + public int getDayValue() { + return day_; + } + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The day. + */ + @java.lang.Override + public com.google.type.DayOfWeek getDay() { + com.google.type.DayOfWeek result = com.google.type.DayOfWeek.forNumber(day_); + return result == null ? com.google.type.DayOfWeek.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (day_ != com.google.type.DayOfWeek.DAY_OF_WEEK_UNSPECIFIED.getNumber()) { + output.writeEnum(2, day_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (day_ != com.google.type.DayOfWeek.DAY_OF_WEEK_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, day_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.WeeklyRecurrence)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.WeeklyRecurrence other = + (com.google.firestore.admin.v1.WeeklyRecurrence) obj; + + if (day_ != other.day_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DAY_FIELD_NUMBER; + hash = (53 * hash) + day_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.WeeklyRecurrence prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Represents a recurring schedule that runs on a specified day of the week.
+   *
+   * The time zone is UTC.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.WeeklyRecurrence} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.WeeklyRecurrence) + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.WeeklyRecurrence.class, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.WeeklyRecurrence.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + day_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getDefaultInstanceForType() { + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence build() { + com.google.firestore.admin.v1.WeeklyRecurrence result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence buildPartial() { + com.google.firestore.admin.v1.WeeklyRecurrence result = + new com.google.firestore.admin.v1.WeeklyRecurrence(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.WeeklyRecurrence result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.day_ = day_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.WeeklyRecurrence) { + return mergeFrom((com.google.firestore.admin.v1.WeeklyRecurrence) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.WeeklyRecurrence other) { + if (other == com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance()) return this; + if (other.day_ != 0) { + setDayValue(other.getDayValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 16: + { + day_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int day_ = 0; + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The enum numeric value on the wire for day. + */ + @java.lang.Override + public int getDayValue() { + return day_; + } + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @param value The enum numeric value on the wire for day to set. + * @return This builder for chaining. + */ + public Builder setDayValue(int value) { + day_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The day. + */ + @java.lang.Override + public com.google.type.DayOfWeek getDay() { + com.google.type.DayOfWeek result = com.google.type.DayOfWeek.forNumber(day_); + return result == null ? com.google.type.DayOfWeek.UNRECOGNIZED : result; + } + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @param value The day to set. + * @return This builder for chaining. + */ + public Builder setDay(com.google.type.DayOfWeek value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + day_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return This builder for chaining. + */ + public Builder clearDay() { + bitField0_ = (bitField0_ & ~0x00000001); + day_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.WeeklyRecurrence) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.WeeklyRecurrence) + private static final com.google.firestore.admin.v1.WeeklyRecurrence DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.WeeklyRecurrence(); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public WeeklyRecurrence parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrenceOrBuilder.java b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrenceOrBuilder.java new file mode 100644 index 000000000..668210ab6 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrenceOrBuilder.java @@ -0,0 +1,55 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/admin/v1/schedule.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.admin.v1; + +public interface WeeklyRecurrenceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.WeeklyRecurrence) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The enum numeric value on the wire for day. + */ + int getDayValue(); + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The day. + */ + com.google.type.DayOfWeek getDay(); +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/backup.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/backup.proto new file mode 100644 index 000000000..e01f81ff8 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/backup.proto @@ -0,0 +1,107 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "BackupProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// A Backup of a Cloud Firestore Database. +// +// The backup contains all documents and index configurations for the given +// database at a specific point in time. +message Backup { + option (google.api.resource) = { + type: "firestore.googleapis.com/Backup" + pattern: "projects/{project}/locations/{location}/backups/{backup}" + }; + + // Backup specific statistics. + message Stats { + // Output only. Summation of the size of all documents and index entries in + // the backup, measured in bytes. + int64 size_bytes = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The total number of documents contained in the backup. + int64 document_count = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The total number of index entries contained in the backup. + int64 index_count = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Indicate the current state of the backup. + enum State { + // The state is unspecified. + STATE_UNSPECIFIED = 0; + + // The pending backup is still being created. Operations on the + // backup will be rejected in this state. + CREATING = 1; + + // The backup is complete and ready to use. + READY = 2; + + // The backup is not available at this moment. + NOT_AVAILABLE = 3; + } + + // Output only. The unique resource name of the Backup. + // + // Format is `projects/{project}/locations/{location}/backups/{backup}`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the Firestore database that the backup is from. + // + // Format is `projects/{project}/databases/{database}`. + string database = 2 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Output only. The system-generated UUID4 for the Firestore database that the + // backup is from. + string database_uid = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The backup contains an externally consistent copy of the + // database at this time. + google.protobuf.Timestamp snapshot_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this backup expires. + google.protobuf.Timestamp expire_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Statistics about the backup. + // + // This data only becomes available after the backup is fully materialized to + // secondary storage. This field will be empty till then. + Stats stats = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current state of the backup. + State state = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto index 07cc764b5..a9bfa6ec9 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto @@ -20,10 +20,12 @@ import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; +import "google/firestore/admin/v1/backup.proto"; import "google/firestore/admin/v1/database.proto"; import "google/firestore/admin/v1/field.proto"; import "google/firestore/admin/v1/index.proto"; import "google/firestore/admin/v1/operation.proto"; +import "google/firestore/admin/v1/schedule.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; @@ -271,6 +273,107 @@ service FirestoreAdmin { metadata_type: "DeleteDatabaseMetadata" }; } + + // Gets information about a backup. + rpc GetBackup(GetBackupRequest) returns (Backup) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the backups. + rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/backups" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes a backup. + rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new database by restoring from an existing backup. + // + // The new database must be in the same cloud region or multi-region location + // as the existing backup. This behaves similar to + // [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.CreateDatabase] + // except instead of creating a new empty database, a new database is created + // with the database type, index configuration, and documents from an existing + // backup. + // + // The [long-running operation][google.longrunning.Operation] can be used to + // track the progress of the restore, with the Operation's + // [metadata][google.longrunning.Operation.metadata] field type being the + // [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + // The [response][google.longrunning.Operation.response] type is the + // [Database][google.firestore.admin.v1.Database] if the restore was + // successful. The new database is not readable or writeable until the LRO has + // completed. + rpc RestoreDatabase(RestoreDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/databases:restore" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "RestoreDatabaseMetadata" + }; + } + + // Creates a backup schedule on a database. + // At most two backup schedules can be configured on a database, one daily + // backup schedule and one weekly backup schedule. + rpc CreateBackupSchedule(CreateBackupScheduleRequest) + returns (BackupSchedule) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*}/backupSchedules" + body: "backup_schedule" + }; + option (google.api.method_signature) = "parent,backup_schedule"; + } + + // Gets information about a backup schedule. + rpc GetBackupSchedule(GetBackupScheduleRequest) returns (BackupSchedule) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/backupSchedules/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List backup schedules. + rpc ListBackupSchedules(ListBackupSchedulesRequest) + returns (ListBackupSchedulesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*}/backupSchedules" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a backup schedule. + rpc UpdateBackupSchedule(UpdateBackupScheduleRequest) + returns (BackupSchedule) { + option (google.api.http) = { + patch: "/v1/{backup_schedule.name=projects/*/databases/*/backupSchedules/*}" + body: "backup_schedule" + }; + option (google.api.method_signature) = "backup_schedule,update_mask"; + } + + // Deletes a backup schedule. + rpc DeleteBackupSchedule(DeleteBackupScheduleRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*/backupSchedules/*}" + }; + option (google.api.method_signature) = "name"; + } } // A request to list the Firestore Databases in all locations for a project. @@ -378,6 +481,83 @@ message DeleteDatabaseRequest { // Metadata related to the delete database operation. message DeleteDatabaseMetadata {} +// The request for +// [FirestoreAdmin.CreateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.CreateBackupSchedule]. +message CreateBackupScheduleRequest { + // Required. The parent database. + // + // Format `projects/{project}/databases/{database}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Required. The backup schedule to create. + BackupSchedule backup_schedule = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [FirestoreAdmin.GetBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.GetBackupSchedule]. +message GetBackupScheduleRequest { + // Required. The name of the backup schedule. + // + // Format + // `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/BackupSchedule" + } + ]; +} + +// The request for +// [FirestoreAdmin.UpdateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.UpdateBackupSchedule]. +message UpdateBackupScheduleRequest { + // Required. The backup schedule to update. + BackupSchedule backup_schedule = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// The request for +// [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules]. +message ListBackupSchedulesRequest { + // Required. The parent database. + // + // Format is `projects/{project}/databases/{database}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; +} + +// The response for +// [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules]. +message ListBackupSchedulesResponse { + // List of all backup schedules. + repeated BackupSchedule backup_schedules = 1; +} + +// The request for [FirestoreAdmin.DeleteBackupSchedules][]. +message DeleteBackupScheduleRequest { + // Required. The name of the backup schedule. + // + // Format + // `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/BackupSchedule" + } + ]; +} + // The request for // [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. message CreateIndexRequest { @@ -587,3 +767,98 @@ message ImportDocumentsRequest { // to include them. Each namespace in this list must be unique. repeated string namespace_ids = 4; } + +// The request for +// [FirestoreAdmin.GetBackup][google.firestore.admin.v1.FirestoreAdmin.GetBackup]. +message GetBackupRequest { + // Required. Name of the backup to fetch. + // + // Format is `projects/{project}/locations/{location}/backups/{backup}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + } + ]; +} + +// The request for +// [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups]. +message ListBackupsRequest { + // Required. The location to list backups from. + // + // Format is `projects/{project}/locations/{location}`. + // Use `{location} = '-'` to list backups from all locations for the given + // project. This allows listing backups from a single location or from all + // locations. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Location" + } + ]; +} + +// The response for +// [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups]. +message ListBackupsResponse { + // List of all backups for the project. + repeated Backup backups = 1; + + // List of locations that existing backups were not able to be fetched from. + // + // Instead of failing the entire requests when a single location is + // unreachable, this response returns a partial result set and list of + // locations unable to be reached here. The request can be retried against a + // single location to get a concrete error. + repeated string unreachable = 3; +} + +// The request for +// [FirestoreAdmin.DeleteBackup][google.firestore.admin.v1.FirestoreAdmin.DeleteBackup]. +message DeleteBackupRequest { + // Required. Name of the backup to delete. + // + // format is `projects/{project}/locations/{location}/backups/{backup}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + } + ]; +} + +// The request message for +// [FirestoreAdmin.RestoreDatabase][google.firestore.admin.v1.RestoreDatabase]. +message RestoreDatabaseRequest { + // Required. The project to restore the database in. Format is + // `projects/{project_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/Database" + } + ]; + + // Required. The ID to use for the database, which will become the final + // component of the database's resource name. This database id must not be + // associated with an existing database. + // + // This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ + // with first character a letter and the last a letter or a number. Must not + // be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + // + // "(default)" database id is also valid. + string database_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Backup to restore from. Must be from the same project as the + // parent. + // + // Format is: `projects/{project_id}/locations/{location}/backups/{backup}` + string backup = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + } + ]; +} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto index 2567da650..add5c3f3f 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto @@ -16,6 +16,7 @@ syntax = "proto3"; package google.firestore.admin.v1; +import "google/api/field_behavior.proto"; import "google/api/resource.proto"; option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; @@ -92,6 +93,25 @@ message Index { CONTAINS = 1; } + // The index configuration to support vector search operations + message VectorConfig { + // An index that stores vectors in a flat data structure, and supports + // exhaustive search. + message FlatIndex {} + + // Required. The vector dimension this configuration applies to. + // + // The resulting index will only include vectors of this dimension, and + // can be used for vector search with the same dimension. + int32 dimension = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of index used. + oneof type { + // Indicates the vector index is a flat index. + FlatIndex flat = 2; + } + } + // Can be __name__. // For single field indexes, this must match the name of the field or may // be omitted. @@ -105,6 +125,10 @@ message Index { // Indicates that this field supports operations on `array_value`s. ArrayConfig array_config = 3; + + // Indicates that this field supports nearest neighbors and distance + // operations on vector. + VectorConfig vector_config = 4; } } diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto index 31f63af37..d3d3e43e4 100644 --- a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto @@ -200,6 +200,43 @@ message ExportDocumentsResponse { string output_uri_prefix = 1; } +// Metadata for the [long-running operation][google.longrunning.Operation] from +// the [RestoreDatabase][google.firestore.admin.v1.RestoreDatabase] request. +message RestoreDatabaseMetadata { + // The time the restore was started. + google.protobuf.Timestamp start_time = 1; + + // The time the restore finished, unset for ongoing restores. + google.protobuf.Timestamp end_time = 2; + + // The operation state of the restore. + OperationState operation_state = 3; + + // The name of the database being restored to. + string database = 4 [(google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + }]; + + // The name of the backup restoring from. + string backup = 5 [(google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + }]; + + // How far along the restore is as an estimated percentage of remaining time. + Progress progress_percentage = 8; +} + +// Describes the progress of the operation. +// Unit of work is generic and must be interpreted based on where +// [Progress][google.firestore.admin.v1.Progress] is used. +message Progress { + // The amount of work estimated. + int64 estimated_work = 1; + + // The amount of work completed. + int64 completed_work = 2; +} + // Describes the state of the operation. enum OperationState { // Unspecified. @@ -228,14 +265,3 @@ enum OperationState { // google.longrunning.Operations.CancelOperation. CANCELLED = 7; } - -// Describes the progress of the operation. -// Unit of work is generic and must be interpreted based on where -// [Progress][google.firestore.admin.v1.Progress] is used. -message Progress { - // The amount of work estimated. - int64 estimated_work = 1; - - // The amount of work completed. - int64 completed_work = 2; -} diff --git a/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/schedule.proto b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/schedule.proto new file mode 100644 index 000000000..7a45238f0 --- /dev/null +++ b/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/schedule.proto @@ -0,0 +1,93 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/dayofweek.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "ScheduleProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// A backup schedule for a Cloud Firestore Database. +// +// This resource is owned by the database it is backing up, and is deleted along +// with the database. The actual backups are not though. +message BackupSchedule { + option (google.api.resource) = { + type: "firestore.googleapis.com/BackupSchedule" + pattern: "projects/{project}/databases/{database}/backupSchedules/{backup_schedule}" + }; + + // Output only. The unique backup schedule identifier across all locations and + // databases for the given project. + // + // This will be auto-assigned. + // + // Format is + // `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this backup schedule was created and + // effective since. + // + // No backups will be created for this schedule before this time. + google.protobuf.Timestamp create_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this backup schedule was most recently + // updated. When a backup schedule is first created, this is the same as + // create_time. + google.protobuf.Timestamp update_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // At what relative time in the future, compared to its creation time, + // the backup should be deleted, e.g. keep backups for 7 days. + google.protobuf.Duration retention = 6; + + // A oneof field to represent when backups will be taken. + oneof recurrence { + // For a schedule that runs daily. + DailyRecurrence daily_recurrence = 7; + + // For a schedule that runs weekly on a specific day. + WeeklyRecurrence weekly_recurrence = 8; + } +} + +// Represents a recurring schedule that runs at a specific time every day. +// +// The time zone is UTC. +message DailyRecurrence {} + +// Represents a recurring schedule that runs on a specified day of the week. +// +// The time zone is UTC. +message WeeklyRecurrence { + // The day of week to run. + // + // DAY_OF_WEEK_UNSPECIFIED is not allowed. + google.type.DayOfWeek day = 2; +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentProto.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentProto.java index d797d200b..5261404ec 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentProto.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentProto.java @@ -52,6 +52,26 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_v1_MapValue_FieldsEntry_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_v1_MapValue_FieldsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Function_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_Function_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Function_OptionsEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_Function_OptionsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Pipeline_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_Pipeline_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -71,7 +91,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "p\022/\n\013update_time\030\004 \001(\0132\032.google.protobuf" + ".Timestamp\032I\n\013FieldsEntry\022\013\n\003key\030\001 \001(\t\022)" + "\n\005value\030\002 \001(\0132\032.google.firestore.v1.Valu" - + "e:\0028\001\"\256\003\n\005Value\0220\n\nnull_value\030\013 \001(\0162\032.go" + + "e:\0028\001\"\301\004\n\005Value\0220\n\nnull_value\030\013 \001(\0162\032.go" + "ogle.protobuf.NullValueH\000\022\027\n\rboolean_val" + "ue\030\001 \001(\010H\000\022\027\n\rinteger_value\030\002 \001(\003H\000\022\026\n\014d" + "ouble_value\030\003 \001(\001H\000\0225\n\017timestamp_value\030\n" @@ -81,18 +101,33 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "t_value\030\010 \001(\0132\023.google.type.LatLngH\000\0226\n\013" + "array_value\030\t \001(\0132\037.google.firestore.v1." + "ArrayValueH\000\0222\n\tmap_value\030\006 \001(\0132\035.google" - + ".firestore.v1.MapValueH\000B\014\n\nvalue_type\"8" - + "\n\nArrayValue\022*\n\006values\030\001 \003(\0132\032.google.fi" - + "restore.v1.Value\"\220\001\n\010MapValue\0229\n\006fields\030" - + "\001 \003(\0132).google.firestore.v1.MapValue.Fie" - + "ldsEntry\032I\n\013FieldsEntry\022\013\n\003key\030\001 \001(\t\022)\n\005" - + "value\030\002 \001(\0132\032.google.firestore.v1.Value:" - + "\0028\001B\305\001\n\027com.google.firestore.v1B\rDocumen" - + "tProtoP\001Z;cloud.google.com/go/firestore/" - + "apiv1/firestorepb;firestorepb\242\002\004GCFS\252\002\031G" - + "oogle.Cloud.Firestore.V1\312\002\031Google\\Cloud\\" - + "Firestore\\V1\352\002\034Google::Cloud::Firestore:" - + ":V1b\006proto3" + + ".firestore.v1.MapValueH\000\022\037\n\025field_refere" + + "nce_value\030\023 \001(\tH\000\0227\n\016function_value\030\024 \001(" + + "\0132\035.google.firestore.v1.FunctionH\000\0227\n\016pi" + + "peline_value\030\025 \001(\0132\035.google.firestore.v1" + + ".PipelineH\000B\014\n\nvalue_type\"8\n\nArrayValue\022" + + "*\n\006values\030\001 \003(\0132\032.google.firestore.v1.Va" + + "lue\"\220\001\n\010MapValue\0229\n\006fields\030\001 \003(\0132).googl" + + "e.firestore.v1.MapValue.FieldsEntry\032I\n\013F" + + "ieldsEntry\022\013\n\003key\030\001 \001(\t\022)\n\005value\030\002 \001(\0132\032" + + ".google.firestore.v1.Value:\0028\001\"\313\001\n\010Funct" + + "ion\022\014\n\004name\030\001 \001(\t\022(\n\004args\030\002 \003(\0132\032.google" + + ".firestore.v1.Value\022;\n\007options\030\003 \003(\0132*.g" + + "oogle.firestore.v1.Function.OptionsEntry" + + "\032J\n\014OptionsEntry\022\013\n\003key\030\001 \001(\t\022)\n\005value\030\002" + + " \001(\0132\032.google.firestore.v1.Value:\0028\001\"\220\002\n" + + "\010Pipeline\0223\n\006stages\030\001 \003(\0132#.google.fires" + + "tore.v1.Pipeline.Stage\032\316\001\n\005Stage\022\014\n\004name" + + "\030\001 \001(\t\022(\n\004args\030\002 \003(\0132\032.google.firestore." + + "v1.Value\022A\n\007options\030\003 \003(\01320.google.fires" + + "tore.v1.Pipeline.Stage.OptionsEntry\032J\n\014O" + + "ptionsEntry\022\013\n\003key\030\001 \001(\t\022)\n\005value\030\002 \001(\0132" + + "\032.google.firestore.v1.Value:\0028\001B\305\001\n\027com." + + "google.firestore.v1B\rDocumentProtoP\001Z;cl" + + "oud.google.com/go/firestore/apiv1/firest" + + "orepb;firestorepb\242\002\004GCFS\252\002\031Google.Cloud." + + "Firestore.V1\312\002\031Google\\Cloud\\Firestore\\V1" + + "\352\002\034Google::Cloud::Firestore::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -134,6 +169,9 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "GeoPointValue", "ArrayValue", "MapValue", + "FieldReferenceValue", + "FunctionValue", + "PipelineValue", "ValueType", }); internal_static_google_firestore_v1_ArrayValue_descriptor = @@ -160,6 +198,46 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Key", "Value", }); + internal_static_google_firestore_v1_Function_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_firestore_v1_Function_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_Function_descriptor, + new java.lang.String[] { + "Name", "Args", "Options", + }); + internal_static_google_firestore_v1_Function_OptionsEntry_descriptor = + internal_static_google_firestore_v1_Function_descriptor.getNestedTypes().get(0); + internal_static_google_firestore_v1_Function_OptionsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_Function_OptionsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_firestore_v1_Pipeline_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_firestore_v1_Pipeline_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_Pipeline_descriptor, + new java.lang.String[] { + "Stages", + }); + internal_static_google_firestore_v1_Pipeline_Stage_descriptor = + internal_static_google_firestore_v1_Pipeline_descriptor.getNestedTypes().get(0); + internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_Pipeline_Stage_descriptor, + new java.lang.String[] { + "Name", "Args", "Options", + }); + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor = + internal_static_google_firestore_v1_Pipeline_Stage_descriptor.getNestedTypes().get(0); + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); com.google.protobuf.StructProto.getDescriptor(); com.google.protobuf.TimestampProto.getDescriptor(); com.google.type.LatLngProto.getDescriptor(); diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequest.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequest.java new file mode 100644 index 000000000..544c520ff --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequest.java @@ -0,0 +1,1898 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/firestore.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for [Firestore.ExecutePipeline][].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineRequest} + */ +public final class ExecutePipelineRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExecutePipelineRequest) + ExecutePipelineRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExecutePipelineRequest.newBuilder() to construct. + private ExecutePipelineRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExecutePipelineRequest() { + database_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExecutePipelineRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineRequest.class, + com.google.firestore.v1.ExecutePipelineRequest.Builder.class); + } + + private int pipelineTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object pipelineType_; + + public enum PipelineTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_PIPELINE(2), + PIPELINETYPE_NOT_SET(0); + private final int value; + + private PipelineTypeCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static PipelineTypeCase valueOf(int value) { + return forNumber(value); + } + + public static PipelineTypeCase forNumber(int value) { + switch (value) { + case 2: + return STRUCTURED_PIPELINE; + case 0: + return PIPELINETYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public PipelineTypeCase getPipelineTypeCase() { + return PipelineTypeCase.forNumber(pipelineTypeCase_); + } + + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(5), + NEW_TRANSACTION(6), + READ_TIME(7), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 5: + return TRANSACTION; + case 6: + return NEW_TRANSACTION; + case 7: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + /** + * + * + *
+   * Database identifier, in the form `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + /** + * + * + *
+   * Database identifier, in the form `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STRUCTURED_PIPELINE_FIELD_NUMBER = 2; + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return Whether the structuredPipeline field is set. + */ + @java.lang.Override + public boolean hasStructuredPipeline() { + return pipelineTypeCase_ == 2; + } + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return The structuredPipeline. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getStructuredPipeline() { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipelineOrBuilder getStructuredPipelineOrBuilder() { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int NEW_TRANSACTION_FIELD_NUMBER = 6; + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 6; + } + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + public static final int READ_TIME_FIELD_NUMBER = 7; + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, database_); + } + if (pipelineTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredPipeline) pipelineType_); + } + if (consistencySelectorCase_ == 5) { + output.writeBytes(5, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + output.writeMessage(6, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + output.writeMessage(7, (com.google.protobuf.Timestamp) consistencySelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, database_); + } + if (pipelineTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredPipeline) pipelineType_); + } + if (consistencySelectorCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 5, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.protobuf.Timestamp) consistencySelector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExecutePipelineRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.ExecutePipelineRequest other = + (com.google.firestore.v1.ExecutePipelineRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getPipelineTypeCase().equals(other.getPipelineTypeCase())) return false; + switch (pipelineTypeCase_) { + case 2: + if (!getStructuredPipeline().equals(other.getStructuredPipeline())) return false; + break; + case 0: + default: + } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 5: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 6: + if (!getNewTransaction().equals(other.getNewTransaction())) return false; + break; + case 7: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + switch (pipelineTypeCase_) { + case 2: + hash = (37 * hash) + STRUCTURED_PIPELINE_FIELD_NUMBER; + hash = (53 * hash) + getStructuredPipeline().hashCode(); + break; + case 0: + default: + } + switch (consistencySelectorCase_) { + case 5: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 6: + hash = (37 * hash) + NEW_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getNewTransaction().hashCode(); + break; + case 7: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExecutePipelineRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for [Firestore.ExecutePipeline][].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExecutePipelineRequest) + com.google.firestore.v1.ExecutePipelineRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineRequest.class, + com.google.firestore.v1.ExecutePipelineRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.ExecutePipelineRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + if (structuredPipelineBuilder_ != null) { + structuredPipelineBuilder_.clear(); + } + if (newTransactionBuilder_ != null) { + newTransactionBuilder_.clear(); + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + pipelineTypeCase_ = 0; + pipelineType_ = null; + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest getDefaultInstanceForType() { + return com.google.firestore.v1.ExecutePipelineRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest build() { + com.google.firestore.v1.ExecutePipelineRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest buildPartial() { + com.google.firestore.v1.ExecutePipelineRequest result = + new com.google.firestore.v1.ExecutePipelineRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExecutePipelineRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + } + + private void buildPartialOneofs(com.google.firestore.v1.ExecutePipelineRequest result) { + result.pipelineTypeCase_ = pipelineTypeCase_; + result.pipelineType_ = this.pipelineType_; + if (pipelineTypeCase_ == 2 && structuredPipelineBuilder_ != null) { + result.pipelineType_ = structuredPipelineBuilder_.build(); + } + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 6 && newTransactionBuilder_ != null) { + result.consistencySelector_ = newTransactionBuilder_.build(); + } + if (consistencySelectorCase_ == 7 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExecutePipelineRequest) { + return mergeFrom((com.google.firestore.v1.ExecutePipelineRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExecutePipelineRequest other) { + if (other == com.google.firestore.v1.ExecutePipelineRequest.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + switch (other.getPipelineTypeCase()) { + case STRUCTURED_PIPELINE: + { + mergeStructuredPipeline(other.getStructuredPipeline()); + break; + } + case PIPELINETYPE_NOT_SET: + { + break; + } + } + switch (other.getConsistencySelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case NEW_TRANSACTION: + { + mergeNewTransaction(other.getNewTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + getStructuredPipelineFieldBuilder().getBuilder(), extensionRegistry); + pipelineTypeCase_ = 2; + break; + } // case 18 + case 42: + { + consistencySelector_ = input.readBytes(); + consistencySelectorCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage(getNewTransactionFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 6; + break; + } // case 50 + case 58: + { + input.readMessage(getReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 7; + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int pipelineTypeCase_ = 0; + private java.lang.Object pipelineType_; + + public PipelineTypeCase getPipelineTypeCase() { + return PipelineTypeCase.forNumber(pipelineTypeCase_); + } + + public Builder clearPipelineType() { + pipelineTypeCase_ = 0; + pipelineType_ = null; + onChanged(); + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + /** + * + * + *
+     * Database identifier, in the form `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Database identifier, in the form `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Database identifier, in the form `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Database identifier, in the form `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Database identifier, in the form `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredPipeline, + com.google.firestore.v1.StructuredPipeline.Builder, + com.google.firestore.v1.StructuredPipelineOrBuilder> + structuredPipelineBuilder_; + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return Whether the structuredPipeline field is set. + */ + @java.lang.Override + public boolean hasStructuredPipeline() { + return pipelineTypeCase_ == 2; + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return The structuredPipeline. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getStructuredPipeline() { + if (structuredPipelineBuilder_ == null) { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } else { + if (pipelineTypeCase_ == 2) { + return structuredPipelineBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder setStructuredPipeline(com.google.firestore.v1.StructuredPipeline value) { + if (structuredPipelineBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pipelineType_ = value; + onChanged(); + } else { + structuredPipelineBuilder_.setMessage(value); + } + pipelineTypeCase_ = 2; + return this; + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder setStructuredPipeline( + com.google.firestore.v1.StructuredPipeline.Builder builderForValue) { + if (structuredPipelineBuilder_ == null) { + pipelineType_ = builderForValue.build(); + onChanged(); + } else { + structuredPipelineBuilder_.setMessage(builderForValue.build()); + } + pipelineTypeCase_ = 2; + return this; + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder mergeStructuredPipeline(com.google.firestore.v1.StructuredPipeline value) { + if (structuredPipelineBuilder_ == null) { + if (pipelineTypeCase_ == 2 + && pipelineType_ != com.google.firestore.v1.StructuredPipeline.getDefaultInstance()) { + pipelineType_ = + com.google.firestore.v1.StructuredPipeline.newBuilder( + (com.google.firestore.v1.StructuredPipeline) pipelineType_) + .mergeFrom(value) + .buildPartial(); + } else { + pipelineType_ = value; + } + onChanged(); + } else { + if (pipelineTypeCase_ == 2) { + structuredPipelineBuilder_.mergeFrom(value); + } else { + structuredPipelineBuilder_.setMessage(value); + } + } + pipelineTypeCase_ = 2; + return this; + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder clearStructuredPipeline() { + if (structuredPipelineBuilder_ == null) { + if (pipelineTypeCase_ == 2) { + pipelineTypeCase_ = 0; + pipelineType_ = null; + onChanged(); + } + } else { + if (pipelineTypeCase_ == 2) { + pipelineTypeCase_ = 0; + pipelineType_ = null; + } + structuredPipelineBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public com.google.firestore.v1.StructuredPipeline.Builder getStructuredPipelineBuilder() { + return getStructuredPipelineFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipelineOrBuilder getStructuredPipelineOrBuilder() { + if ((pipelineTypeCase_ == 2) && (structuredPipelineBuilder_ != null)) { + return structuredPipelineBuilder_.getMessageOrBuilder(); + } else { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + } + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredPipeline, + com.google.firestore.v1.StructuredPipeline.Builder, + com.google.firestore.v1.StructuredPipelineOrBuilder> + getStructuredPipelineFieldBuilder() { + if (structuredPipelineBuilder_ == null) { + if (!(pipelineTypeCase_ == 2)) { + pipelineType_ = com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + structuredPipelineBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredPipeline, + com.google.firestore.v1.StructuredPipeline.Builder, + com.google.firestore.v1.StructuredPipelineOrBuilder>( + (com.google.firestore.v1.StructuredPipeline) pipelineType_, + getParentForChildren(), + isClean()); + pipelineType_ = null; + } + pipelineTypeCase_ = 2; + onChanged(); + return structuredPipelineBuilder_; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelectorCase_ = 5; + consistencySelector_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + newTransactionBuilder_; + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 6; + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 6) { + return newTransactionBuilder_.getMessage(); + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder setNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + newTransactionBuilder_.setMessage(value); + } + consistencySelectorCase_ = 6; + return this; + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder setNewTransaction( + com.google.firestore.v1.TransactionOptions.Builder builderForValue) { + if (newTransactionBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + newTransactionBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 6; + return this; + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder mergeNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6 + && consistencySelector_ + != com.google.firestore.v1.TransactionOptions.getDefaultInstance()) { + consistencySelector_ = + com.google.firestore.v1.TransactionOptions.newBuilder( + (com.google.firestore.v1.TransactionOptions) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 6) { + newTransactionBuilder_.mergeFrom(value); + } else { + newTransactionBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 6; + return this; + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder clearNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + newTransactionBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public com.google.firestore.v1.TransactionOptions.Builder getNewTransactionBuilder() { + return getNewTransactionFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if ((consistencySelectorCase_ == 6) && (newTransactionBuilder_ != null)) { + return newTransactionBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + getNewTransactionFieldBuilder() { + if (newTransactionBuilder_ == null) { + if (!(consistencySelectorCase_ == 6)) { + consistencySelector_ = com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + newTransactionBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder>( + (com.google.firestore.v1.TransactionOptions) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 6; + onChanged(); + return newTransactionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 7) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 7; + return this; + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 7; + return this; + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 7) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 7; + return this; + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return getReadTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 7) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 7)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 7; + onChanged(); + return readTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExecutePipelineRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExecutePipelineRequest) + private static final com.google.firestore.v1.ExecutePipelineRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExecutePipelineRequest(); + } + + public static com.google.firestore.v1.ExecutePipelineRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExecutePipelineRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequestOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequestOrBuilder.java new file mode 100644 index 000000000..95a65826b --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequestOrBuilder.java @@ -0,0 +1,211 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/firestore.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface ExecutePipelineRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExecutePipelineRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Database identifier, in the form `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + /** + * + * + *
+   * Database identifier, in the form `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return Whether the structuredPipeline field is set. + */ + boolean hasStructuredPipeline(); + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return The structuredPipeline. + */ + com.google.firestore.v1.StructuredPipeline getStructuredPipeline(); + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + com.google.firestore.v1.StructuredPipelineOrBuilder getStructuredPipelineOrBuilder(); + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + boolean hasNewTransaction(); + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + com.google.firestore.v1.TransactionOptions getNewTransaction(); + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder(); + + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.ExecutePipelineRequest.PipelineTypeCase getPipelineTypeCase(); + + com.google.firestore.v1.ExecutePipelineRequest.ConsistencySelectorCase + getConsistencySelectorCase(); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponse.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponse.java new file mode 100644 index 000000000..a8408e14e --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponse.java @@ -0,0 +1,1647 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/firestore.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for [Firestore.Execute][].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineResponse} + */ +public final class ExecutePipelineResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExecutePipelineResponse) + ExecutePipelineResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExecutePipelineResponse.newBuilder() to construct. + private ExecutePipelineResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExecutePipelineResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + results_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExecutePipelineResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineResponse.class, + com.google.firestore.v1.ExecutePipelineResponse.Builder.class); + } + + private int bitField0_; + public static final int TRANSACTION_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+   * Newly created transaction identifier.
+   *
+   * This field is only specified on the first response from the server when
+   * the request specified [ExecuteRequest.new_transaction][].
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int RESULTS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List results_; + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public java.util.List getResultsList() { + return results_; + } + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public java.util.List + getResultsOrBuilderList() { + return results_; + } + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public int getResultsCount() { + return results_.size(); + } + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Document getResults(int index) { + return results_.get(index); + } + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getResultsOrBuilder(int index) { + return results_.get(index); + } + + public static final int EXECUTION_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp executionTime_; + /** + * + * + *
+   * The time at which the document(s) were read.
+   *
+   * This may be monotonically increasing; in this case, the previous documents
+   * in the result stream are guaranteed not to have changed between their
+   * `execution_time` and this one.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return Whether the executionTime field is set. + */ + @java.lang.Override + public boolean hasExecutionTime() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * The time at which the document(s) were read.
+   *
+   * This may be monotonically increasing; in this case, the previous documents
+   * in the result stream are guaranteed not to have changed between their
+   * `execution_time` and this one.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return The executionTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getExecutionTime() { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } + /** + * + * + *
+   * The time at which the document(s) were read.
+   *
+   * This may be monotonically increasing; in this case, the previous documents
+   * in the result stream are guaranteed not to have changed between their
+   * `execution_time` and this one.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getExecutionTimeOrBuilder() { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!transaction_.isEmpty()) { + output.writeBytes(1, transaction_); + } + for (int i = 0; i < results_.size(); i++) { + output.writeMessage(2, results_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getExecutionTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, transaction_); + } + for (int i = 0; i < results_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, results_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getExecutionTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExecutePipelineResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.ExecutePipelineResponse other = + (com.google.firestore.v1.ExecutePipelineResponse) obj; + + if (!getTransaction().equals(other.getTransaction())) return false; + if (!getResultsList().equals(other.getResultsList())) return false; + if (hasExecutionTime() != other.hasExecutionTime()) return false; + if (hasExecutionTime()) { + if (!getExecutionTime().equals(other.getExecutionTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + if (getResultsCount() > 0) { + hash = (37 * hash) + RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getResultsList().hashCode(); + } + if (hasExecutionTime()) { + hash = (37 * hash) + EXECUTION_TIME_FIELD_NUMBER; + hash = (53 * hash) + getExecutionTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExecutePipelineResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The response for [Firestore.Execute][].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExecutePipelineResponse) + com.google.firestore.v1.ExecutePipelineResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineResponse.class, + com.google.firestore.v1.ExecutePipelineResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.ExecutePipelineResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getResultsFieldBuilder(); + getExecutionTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + transaction_ = com.google.protobuf.ByteString.EMPTY; + if (resultsBuilder_ == null) { + results_ = java.util.Collections.emptyList(); + } else { + results_ = null; + resultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + executionTime_ = null; + if (executionTimeBuilder_ != null) { + executionTimeBuilder_.dispose(); + executionTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse getDefaultInstanceForType() { + return com.google.firestore.v1.ExecutePipelineResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse build() { + com.google.firestore.v1.ExecutePipelineResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse buildPartial() { + com.google.firestore.v1.ExecutePipelineResponse result = + new com.google.firestore.v1.ExecutePipelineResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.v1.ExecutePipelineResponse result) { + if (resultsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + results_ = java.util.Collections.unmodifiableList(results_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.results_ = results_; + } else { + result.results_ = resultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.ExecutePipelineResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.transaction_ = transaction_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.executionTime_ = + executionTimeBuilder_ == null ? executionTime_ : executionTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExecutePipelineResponse) { + return mergeFrom((com.google.firestore.v1.ExecutePipelineResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExecutePipelineResponse other) { + if (other == com.google.firestore.v1.ExecutePipelineResponse.getDefaultInstance()) + return this; + if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { + setTransaction(other.getTransaction()); + } + if (resultsBuilder_ == null) { + if (!other.results_.isEmpty()) { + if (results_.isEmpty()) { + results_ = other.results_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureResultsIsMutable(); + results_.addAll(other.results_); + } + onChanged(); + } + } else { + if (!other.results_.isEmpty()) { + if (resultsBuilder_.isEmpty()) { + resultsBuilder_.dispose(); + resultsBuilder_ = null; + results_ = other.results_; + bitField0_ = (bitField0_ & ~0x00000002); + resultsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getResultsFieldBuilder() + : null; + } else { + resultsBuilder_.addAllMessages(other.results_); + } + } + } + if (other.hasExecutionTime()) { + mergeExecutionTime(other.getExecutionTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Document m = + input.readMessage(com.google.firestore.v1.Document.parser(), extensionRegistry); + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(m); + } else { + resultsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + input.readMessage(getExecutionTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + /** + * + * + *
+     * Newly created transaction identifier.
+     *
+     * This field is only specified on the first response from the server when
+     * the request specified [ExecuteRequest.new_transaction][].
+     * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + /** + * + * + *
+     * Newly created transaction identifier.
+     *
+     * This field is only specified on the first response from the server when
+     * the request specified [ExecuteRequest.new_transaction][].
+     * 
+ * + * bytes transaction = 1; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Newly created transaction identifier.
+     *
+     * This field is only specified on the first response from the server when
+     * the request specified [ExecuteRequest.new_transaction][].
+     * 
+ * + * bytes transaction = 1; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000001); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private java.util.List results_ = + java.util.Collections.emptyList(); + + private void ensureResultsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + results_ = new java.util.ArrayList(results_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + resultsBuilder_; + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public java.util.List getResultsList() { + if (resultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(results_); + } else { + return resultsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public int getResultsCount() { + if (resultsBuilder_ == null) { + return results_.size(); + } else { + return resultsBuilder_.getCount(); + } + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document getResults(int index) { + if (resultsBuilder_ == null) { + return results_.get(index); + } else { + return resultsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder setResults(int index, com.google.firestore.v1.Document value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.set(index, value); + onChanged(); + } else { + resultsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder setResults(int index, com.google.firestore.v1.Document.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.set(index, builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(com.google.firestore.v1.Document value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.add(value); + onChanged(); + } else { + resultsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(int index, com.google.firestore.v1.Document value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.add(index, value); + onChanged(); + } else { + resultsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(com.google.firestore.v1.Document.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(int index, com.google.firestore.v1.Document.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(index, builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addAllResults( + java.lang.Iterable values) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, results_); + onChanged(); + } else { + resultsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder clearResults() { + if (resultsBuilder_ == null) { + results_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + resultsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder removeResults(int index) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.remove(index); + onChanged(); + } else { + resultsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document.Builder getResultsBuilder(int index) { + return getResultsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.DocumentOrBuilder getResultsOrBuilder(int index) { + if (resultsBuilder_ == null) { + return results_.get(index); + } else { + return resultsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public java.util.List + getResultsOrBuilderList() { + if (resultsBuilder_ != null) { + return resultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(results_); + } + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document.Builder addResultsBuilder() { + return getResultsFieldBuilder() + .addBuilder(com.google.firestore.v1.Document.getDefaultInstance()); + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document.Builder addResultsBuilder(int index) { + return getResultsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Document.getDefaultInstance()); + } + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this include those like
+     * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+     * This is explicitly a divergence from `Firestore.RunQuery` /
+     * `Firestore.GetDocument` RPCs which always return such fields even when they
+     * are not specified in the [`mask`][DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public java.util.List getResultsBuilderList() { + return getResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + getResultsFieldBuilder() { + if (resultsBuilder_ == null) { + resultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + results_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + results_ = null; + } + return resultsBuilder_; + } + + private com.google.protobuf.Timestamp executionTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + executionTimeBuilder_; + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return Whether the executionTime field is set. + */ + public boolean hasExecutionTime() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return The executionTime. + */ + public com.google.protobuf.Timestamp getExecutionTime() { + if (executionTimeBuilder_ == null) { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } else { + return executionTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder setExecutionTime(com.google.protobuf.Timestamp value) { + if (executionTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + executionTime_ = value; + } else { + executionTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder setExecutionTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (executionTimeBuilder_ == null) { + executionTime_ = builderForValue.build(); + } else { + executionTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder mergeExecutionTime(com.google.protobuf.Timestamp value) { + if (executionTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && executionTime_ != null + && executionTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getExecutionTimeBuilder().mergeFrom(value); + } else { + executionTime_ = value; + } + } else { + executionTimeBuilder_.mergeFrom(value); + } + if (executionTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder clearExecutionTime() { + bitField0_ = (bitField0_ & ~0x00000004); + executionTime_ = null; + if (executionTimeBuilder_ != null) { + executionTimeBuilder_.dispose(); + executionTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public com.google.protobuf.Timestamp.Builder getExecutionTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getExecutionTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public com.google.protobuf.TimestampOrBuilder getExecutionTimeOrBuilder() { + if (executionTimeBuilder_ != null) { + return executionTimeBuilder_.getMessageOrBuilder(); + } else { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } + } + /** + * + * + *
+     * The time at which the document(s) were read.
+     *
+     * This may be monotonically increasing; in this case, the previous documents
+     * in the result stream are guaranteed not to have changed between their
+     * `execution_time` and this one.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getExecutionTimeFieldBuilder() { + if (executionTimeBuilder_ == null) { + executionTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getExecutionTime(), getParentForChildren(), isClean()); + executionTime_ = null; + } + return executionTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExecutePipelineResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExecutePipelineResponse) + private static final com.google.firestore.v1.ExecutePipelineResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExecutePipelineResponse(); + } + + public static com.google.firestore.v1.ExecutePipelineResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExecutePipelineResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponseOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponseOrBuilder.java new file mode 100644 index 000000000..9aec28083 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponseOrBuilder.java @@ -0,0 +1,202 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/firestore.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface ExecutePipelineResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExecutePipelineResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Newly created transaction identifier.
+   *
+   * This field is only specified on the first response from the server when
+   * the request specified [ExecuteRequest.new_transaction][].
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + java.util.List getResultsList(); + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + com.google.firestore.v1.Document getResults(int index); + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + int getResultsCount(); + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + java.util.List getResultsOrBuilderList(); + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this include those like
+   * [`__name__`][Document.name] & [`__update_time__`][Document.update_time].
+   * This is explicitly a divergence from `Firestore.RunQuery` /
+   * `Firestore.GetDocument` RPCs which always return such fields even when they
+   * are not specified in the [`mask`][DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + com.google.firestore.v1.DocumentOrBuilder getResultsOrBuilder(int index); + + /** + * + * + *
+   * The time at which the document(s) were read.
+   *
+   * This may be monotonically increasing; in this case, the previous documents
+   * in the result stream are guaranteed not to have changed between their
+   * `execution_time` and this one.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return Whether the executionTime field is set. + */ + boolean hasExecutionTime(); + /** + * + * + *
+   * The time at which the document(s) were read.
+   *
+   * This may be monotonically increasing; in this case, the previous documents
+   * in the result stream are guaranteed not to have changed between their
+   * `execution_time` and this one.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return The executionTime. + */ + com.google.protobuf.Timestamp getExecutionTime(); + /** + * + * + *
+   * The time at which the document(s) were read.
+   *
+   * This may be monotonically increasing; in this case, the previous documents
+   * in the result stream are guaranteed not to have changed between their
+   * `execution_time` and this one.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + com.google.protobuf.TimestampOrBuilder getExecutionTimeOrBuilder(); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStats.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStats.java new file mode 100644 index 000000000..3c3fd0a97 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStats.java @@ -0,0 +1,1305 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * Execution statistics for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutionStats} + */ +public final class ExecutionStats extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExecutionStats) + ExecutionStatsOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExecutionStats.newBuilder() to construct. + private ExecutionStats(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExecutionStats() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExecutionStats(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutionStats.class, + com.google.firestore.v1.ExecutionStats.Builder.class); + } + + private int bitField0_; + public static final int RESULTS_RETURNED_FIELD_NUMBER = 1; + private long resultsReturned_ = 0L; + /** + * + * + *
+   * Total number of results returned, including documents, projections,
+   * aggregation results, keys.
+   * 
+ * + * int64 results_returned = 1; + * + * @return The resultsReturned. + */ + @java.lang.Override + public long getResultsReturned() { + return resultsReturned_; + } + + public static final int EXECUTION_DURATION_FIELD_NUMBER = 3; + private com.google.protobuf.Duration executionDuration_; + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return Whether the executionDuration field is set. + */ + @java.lang.Override + public boolean hasExecutionDuration() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return The executionDuration. + */ + @java.lang.Override + public com.google.protobuf.Duration getExecutionDuration() { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getExecutionDurationOrBuilder() { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } + + public static final int READ_OPERATIONS_FIELD_NUMBER = 4; + private long readOperations_ = 0L; + /** + * + * + *
+   * Total billable read operations.
+   * 
+ * + * int64 read_operations = 4; + * + * @return The readOperations. + */ + @java.lang.Override + public long getReadOperations() { + return readOperations_; + } + + public static final int DEBUG_STATS_FIELD_NUMBER = 5; + private com.google.protobuf.Struct debugStats_; + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   *  {
+   *    "indexes_entries_scanned": "1000",
+   *    "documents_scanned": "20",
+   *    "billing_details" : {
+   *       "documents_billable": "20",
+   *       "index_entries_billable": "1000",
+   *       "min_query_cost": "0"
+   *    }
+   *  }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return Whether the debugStats field is set. + */ + @java.lang.Override + public boolean hasDebugStats() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   *  {
+   *    "indexes_entries_scanned": "1000",
+   *    "documents_scanned": "20",
+   *    "billing_details" : {
+   *       "documents_billable": "20",
+   *       "index_entries_billable": "1000",
+   *       "min_query_cost": "0"
+   *    }
+   *  }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return The debugStats. + */ + @java.lang.Override + public com.google.protobuf.Struct getDebugStats() { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   *  {
+   *    "indexes_entries_scanned": "1000",
+   *    "documents_scanned": "20",
+   *    "billing_details" : {
+   *       "documents_billable": "20",
+   *       "index_entries_billable": "1000",
+   *       "min_query_cost": "0"
+   *    }
+   *  }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + @java.lang.Override + public com.google.protobuf.StructOrBuilder getDebugStatsOrBuilder() { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (resultsReturned_ != 0L) { + output.writeInt64(1, resultsReturned_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getExecutionDuration()); + } + if (readOperations_ != 0L) { + output.writeInt64(4, readOperations_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(5, getDebugStats()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (resultsReturned_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, resultsReturned_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getExecutionDuration()); + } + if (readOperations_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, readOperations_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getDebugStats()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExecutionStats)) { + return super.equals(obj); + } + com.google.firestore.v1.ExecutionStats other = (com.google.firestore.v1.ExecutionStats) obj; + + if (getResultsReturned() != other.getResultsReturned()) return false; + if (hasExecutionDuration() != other.hasExecutionDuration()) return false; + if (hasExecutionDuration()) { + if (!getExecutionDuration().equals(other.getExecutionDuration())) return false; + } + if (getReadOperations() != other.getReadOperations()) return false; + if (hasDebugStats() != other.hasDebugStats()) return false; + if (hasDebugStats()) { + if (!getDebugStats().equals(other.getDebugStats())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESULTS_RETURNED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getResultsReturned()); + if (hasExecutionDuration()) { + hash = (37 * hash) + EXECUTION_DURATION_FIELD_NUMBER; + hash = (53 * hash) + getExecutionDuration().hashCode(); + } + hash = (37 * hash) + READ_OPERATIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getReadOperations()); + if (hasDebugStats()) { + hash = (37 * hash) + DEBUG_STATS_FIELD_NUMBER; + hash = (53 * hash) + getDebugStats().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExecutionStats parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutionStats parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExecutionStats prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Execution statistics for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutionStats} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExecutionStats) + com.google.firestore.v1.ExecutionStatsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutionStats.class, + com.google.firestore.v1.ExecutionStats.Builder.class); + } + + // Construct using com.google.firestore.v1.ExecutionStats.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getExecutionDurationFieldBuilder(); + getDebugStatsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + resultsReturned_ = 0L; + executionDuration_ = null; + if (executionDurationBuilder_ != null) { + executionDurationBuilder_.dispose(); + executionDurationBuilder_ = null; + } + readOperations_ = 0L; + debugStats_ = null; + if (debugStatsBuilder_ != null) { + debugStatsBuilder_.dispose(); + debugStatsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats getDefaultInstanceForType() { + return com.google.firestore.v1.ExecutionStats.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats build() { + com.google.firestore.v1.ExecutionStats result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats buildPartial() { + com.google.firestore.v1.ExecutionStats result = + new com.google.firestore.v1.ExecutionStats(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExecutionStats result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.resultsReturned_ = resultsReturned_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.executionDuration_ = + executionDurationBuilder_ == null + ? executionDuration_ + : executionDurationBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readOperations_ = readOperations_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.debugStats_ = debugStatsBuilder_ == null ? debugStats_ : debugStatsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExecutionStats) { + return mergeFrom((com.google.firestore.v1.ExecutionStats) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExecutionStats other) { + if (other == com.google.firestore.v1.ExecutionStats.getDefaultInstance()) return this; + if (other.getResultsReturned() != 0L) { + setResultsReturned(other.getResultsReturned()); + } + if (other.hasExecutionDuration()) { + mergeExecutionDuration(other.getExecutionDuration()); + } + if (other.getReadOperations() != 0L) { + setReadOperations(other.getReadOperations()); + } + if (other.hasDebugStats()) { + mergeDebugStats(other.getDebugStats()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + resultsReturned_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 26: + { + input.readMessage( + getExecutionDurationFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 32: + { + readOperations_ = input.readInt64(); + bitField0_ |= 0x00000004; + break; + } // case 32 + case 42: + { + input.readMessage(getDebugStatsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 42 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private long resultsReturned_; + /** + * + * + *
+     * Total number of results returned, including documents, projections,
+     * aggregation results, keys.
+     * 
+ * + * int64 results_returned = 1; + * + * @return The resultsReturned. + */ + @java.lang.Override + public long getResultsReturned() { + return resultsReturned_; + } + /** + * + * + *
+     * Total number of results returned, including documents, projections,
+     * aggregation results, keys.
+     * 
+ * + * int64 results_returned = 1; + * + * @param value The resultsReturned to set. + * @return This builder for chaining. + */ + public Builder setResultsReturned(long value) { + + resultsReturned_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Total number of results returned, including documents, projections,
+     * aggregation results, keys.
+     * 
+ * + * int64 results_returned = 1; + * + * @return This builder for chaining. + */ + public Builder clearResultsReturned() { + bitField0_ = (bitField0_ & ~0x00000001); + resultsReturned_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.Duration executionDuration_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + executionDurationBuilder_; + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return Whether the executionDuration field is set. + */ + public boolean hasExecutionDuration() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return The executionDuration. + */ + public com.google.protobuf.Duration getExecutionDuration() { + if (executionDurationBuilder_ == null) { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } else { + return executionDurationBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder setExecutionDuration(com.google.protobuf.Duration value) { + if (executionDurationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + executionDuration_ = value; + } else { + executionDurationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder setExecutionDuration(com.google.protobuf.Duration.Builder builderForValue) { + if (executionDurationBuilder_ == null) { + executionDuration_ = builderForValue.build(); + } else { + executionDurationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder mergeExecutionDuration(com.google.protobuf.Duration value) { + if (executionDurationBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && executionDuration_ != null + && executionDuration_ != com.google.protobuf.Duration.getDefaultInstance()) { + getExecutionDurationBuilder().mergeFrom(value); + } else { + executionDuration_ = value; + } + } else { + executionDurationBuilder_.mergeFrom(value); + } + if (executionDuration_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder clearExecutionDuration() { + bitField0_ = (bitField0_ & ~0x00000002); + executionDuration_ = null; + if (executionDurationBuilder_ != null) { + executionDurationBuilder_.dispose(); + executionDurationBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public com.google.protobuf.Duration.Builder getExecutionDurationBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getExecutionDurationFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public com.google.protobuf.DurationOrBuilder getExecutionDurationOrBuilder() { + if (executionDurationBuilder_ != null) { + return executionDurationBuilder_.getMessageOrBuilder(); + } else { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } + } + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + getExecutionDurationFieldBuilder() { + if (executionDurationBuilder_ == null) { + executionDurationBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getExecutionDuration(), getParentForChildren(), isClean()); + executionDuration_ = null; + } + return executionDurationBuilder_; + } + + private long readOperations_; + /** + * + * + *
+     * Total billable read operations.
+     * 
+ * + * int64 read_operations = 4; + * + * @return The readOperations. + */ + @java.lang.Override + public long getReadOperations() { + return readOperations_; + } + /** + * + * + *
+     * Total billable read operations.
+     * 
+ * + * int64 read_operations = 4; + * + * @param value The readOperations to set. + * @return This builder for chaining. + */ + public Builder setReadOperations(long value) { + + readOperations_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Total billable read operations.
+     * 
+ * + * int64 read_operations = 4; + * + * @return This builder for chaining. + */ + public Builder clearReadOperations() { + bitField0_ = (bitField0_ & ~0x00000004); + readOperations_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.Struct debugStats_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + debugStatsBuilder_; + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return Whether the debugStats field is set. + */ + public boolean hasDebugStats() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return The debugStats. + */ + public com.google.protobuf.Struct getDebugStats() { + if (debugStatsBuilder_ == null) { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } else { + return debugStatsBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder setDebugStats(com.google.protobuf.Struct value) { + if (debugStatsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + debugStats_ = value; + } else { + debugStatsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder setDebugStats(com.google.protobuf.Struct.Builder builderForValue) { + if (debugStatsBuilder_ == null) { + debugStats_ = builderForValue.build(); + } else { + debugStatsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder mergeDebugStats(com.google.protobuf.Struct value) { + if (debugStatsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && debugStats_ != null + && debugStats_ != com.google.protobuf.Struct.getDefaultInstance()) { + getDebugStatsBuilder().mergeFrom(value); + } else { + debugStats_ = value; + } + } else { + debugStatsBuilder_.mergeFrom(value); + } + if (debugStats_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder clearDebugStats() { + bitField0_ = (bitField0_ & ~0x00000008); + debugStats_ = null; + if (debugStatsBuilder_ != null) { + debugStatsBuilder_.dispose(); + debugStatsBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public com.google.protobuf.Struct.Builder getDebugStatsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getDebugStatsFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public com.google.protobuf.StructOrBuilder getDebugStatsOrBuilder() { + if (debugStatsBuilder_ != null) { + return debugStatsBuilder_.getMessageOrBuilder(); + } else { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } + } + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     *  {
+     *    "indexes_entries_scanned": "1000",
+     *    "documents_scanned": "20",
+     *    "billing_details" : {
+     *       "documents_billable": "20",
+     *       "index_entries_billable": "1000",
+     *       "min_query_cost": "0"
+     *    }
+     *  }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + getDebugStatsFieldBuilder() { + if (debugStatsBuilder_ == null) { + debugStatsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder>( + getDebugStats(), getParentForChildren(), isClean()); + debugStats_ = null; + } + return debugStatsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExecutionStats) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExecutionStats) + private static final com.google.firestore.v1.ExecutionStats DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExecutionStats(); + } + + public static com.google.firestore.v1.ExecutionStats getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExecutionStats parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStatsOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStatsOrBuilder.java new file mode 100644 index 000000000..1694bea5f --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStatsOrBuilder.java @@ -0,0 +1,156 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface ExecutionStatsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExecutionStats) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Total number of results returned, including documents, projections,
+   * aggregation results, keys.
+   * 
+ * + * int64 results_returned = 1; + * + * @return The resultsReturned. + */ + long getResultsReturned(); + + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return Whether the executionDuration field is set. + */ + boolean hasExecutionDuration(); + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return The executionDuration. + */ + com.google.protobuf.Duration getExecutionDuration(); + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + com.google.protobuf.DurationOrBuilder getExecutionDurationOrBuilder(); + + /** + * + * + *
+   * Total billable read operations.
+   * 
+ * + * int64 read_operations = 4; + * + * @return The readOperations. + */ + long getReadOperations(); + + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   *  {
+   *    "indexes_entries_scanned": "1000",
+   *    "documents_scanned": "20",
+   *    "billing_details" : {
+   *       "documents_billable": "20",
+   *       "index_entries_billable": "1000",
+   *       "min_query_cost": "0"
+   *    }
+   *  }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return Whether the debugStats field is set. + */ + boolean hasDebugStats(); + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   *  {
+   *    "indexes_entries_scanned": "1000",
+   *    "documents_scanned": "20",
+   *    "billing_details" : {
+   *       "documents_billable": "20",
+   *       "index_entries_billable": "1000",
+   *       "min_query_cost": "0"
+   *    }
+   *  }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return The debugStats. + */ + com.google.protobuf.Struct getDebugStats(); + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   *  {
+   *    "indexes_entries_scanned": "1000",
+   *    "documents_scanned": "20",
+   *    "billing_details" : {
+   *       "documents_billable": "20",
+   *       "index_entries_billable": "1000",
+   *       "min_query_cost": "0"
+   *    }
+   *  }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + com.google.protobuf.StructOrBuilder getDebugStatsOrBuilder(); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetrics.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetrics.java new file mode 100644 index 000000000..9f862e933 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetrics.java @@ -0,0 +1,1014 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * Explain metrics for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainMetrics} + */ +public final class ExplainMetrics extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExplainMetrics) + ExplainMetricsOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExplainMetrics.newBuilder() to construct. + private ExplainMetrics(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExplainMetrics() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExplainMetrics(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainMetrics.class, + com.google.firestore.v1.ExplainMetrics.Builder.class); + } + + private int bitField0_; + public static final int PLAN_SUMMARY_FIELD_NUMBER = 1; + private com.google.firestore.v1.PlanSummary planSummary_; + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return Whether the planSummary field is set. + */ + @java.lang.Override + public boolean hasPlanSummary() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + @java.lang.Override + public com.google.firestore.v1.PlanSummary getPlanSummary() { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + @java.lang.Override + public com.google.firestore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder() { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + + public static final int EXECUTION_STATS_FIELD_NUMBER = 2; + private com.google.firestore.v1.ExecutionStats executionStats_; + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return Whether the executionStats field is set. + */ + @java.lang.Override + public boolean hasExecutionStats() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + @java.lang.Override + public com.google.firestore.v1.ExecutionStats getExecutionStats() { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + @java.lang.Override + public com.google.firestore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder() { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getPlanSummary()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getExecutionStats()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getPlanSummary()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getExecutionStats()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExplainMetrics)) { + return super.equals(obj); + } + com.google.firestore.v1.ExplainMetrics other = (com.google.firestore.v1.ExplainMetrics) obj; + + if (hasPlanSummary() != other.hasPlanSummary()) return false; + if (hasPlanSummary()) { + if (!getPlanSummary().equals(other.getPlanSummary())) return false; + } + if (hasExecutionStats() != other.hasExecutionStats()) return false; + if (hasExecutionStats()) { + if (!getExecutionStats().equals(other.getExecutionStats())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasPlanSummary()) { + hash = (37 * hash) + PLAN_SUMMARY_FIELD_NUMBER; + hash = (53 * hash) + getPlanSummary().hashCode(); + } + if (hasExecutionStats()) { + hash = (37 * hash) + EXECUTION_STATS_FIELD_NUMBER; + hash = (53 * hash) + getExecutionStats().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainMetrics parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExplainMetrics prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Explain metrics for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainMetrics} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExplainMetrics) + com.google.firestore.v1.ExplainMetricsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainMetrics.class, + com.google.firestore.v1.ExplainMetrics.Builder.class); + } + + // Construct using com.google.firestore.v1.ExplainMetrics.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPlanSummaryFieldBuilder(); + getExecutionStatsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + planSummary_ = null; + if (planSummaryBuilder_ != null) { + planSummaryBuilder_.dispose(); + planSummaryBuilder_ = null; + } + executionStats_ = null; + if (executionStatsBuilder_ != null) { + executionStatsBuilder_.dispose(); + executionStatsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics getDefaultInstanceForType() { + return com.google.firestore.v1.ExplainMetrics.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics build() { + com.google.firestore.v1.ExplainMetrics result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics buildPartial() { + com.google.firestore.v1.ExplainMetrics result = + new com.google.firestore.v1.ExplainMetrics(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExplainMetrics result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.planSummary_ = + planSummaryBuilder_ == null ? planSummary_ : planSummaryBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.executionStats_ = + executionStatsBuilder_ == null ? executionStats_ : executionStatsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExplainMetrics) { + return mergeFrom((com.google.firestore.v1.ExplainMetrics) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExplainMetrics other) { + if (other == com.google.firestore.v1.ExplainMetrics.getDefaultInstance()) return this; + if (other.hasPlanSummary()) { + mergePlanSummary(other.getPlanSummary()); + } + if (other.hasExecutionStats()) { + mergeExecutionStats(other.getExecutionStats()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(getPlanSummaryFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getExecutionStatsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.PlanSummary planSummary_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.PlanSummary, + com.google.firestore.v1.PlanSummary.Builder, + com.google.firestore.v1.PlanSummaryOrBuilder> + planSummaryBuilder_; + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return Whether the planSummary field is set. + */ + public boolean hasPlanSummary() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + public com.google.firestore.v1.PlanSummary getPlanSummary() { + if (planSummaryBuilder_ == null) { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } else { + return planSummaryBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder setPlanSummary(com.google.firestore.v1.PlanSummary value) { + if (planSummaryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + planSummary_ = value; + } else { + planSummaryBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder setPlanSummary(com.google.firestore.v1.PlanSummary.Builder builderForValue) { + if (planSummaryBuilder_ == null) { + planSummary_ = builderForValue.build(); + } else { + planSummaryBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder mergePlanSummary(com.google.firestore.v1.PlanSummary value) { + if (planSummaryBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && planSummary_ != null + && planSummary_ != com.google.firestore.v1.PlanSummary.getDefaultInstance()) { + getPlanSummaryBuilder().mergeFrom(value); + } else { + planSummary_ = value; + } + } else { + planSummaryBuilder_.mergeFrom(value); + } + if (planSummary_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder clearPlanSummary() { + bitField0_ = (bitField0_ & ~0x00000001); + planSummary_ = null; + if (planSummaryBuilder_ != null) { + planSummaryBuilder_.dispose(); + planSummaryBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public com.google.firestore.v1.PlanSummary.Builder getPlanSummaryBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPlanSummaryFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public com.google.firestore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder() { + if (planSummaryBuilder_ != null) { + return planSummaryBuilder_.getMessageOrBuilder(); + } else { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + } + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.PlanSummary, + com.google.firestore.v1.PlanSummary.Builder, + com.google.firestore.v1.PlanSummaryOrBuilder> + getPlanSummaryFieldBuilder() { + if (planSummaryBuilder_ == null) { + planSummaryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.PlanSummary, + com.google.firestore.v1.PlanSummary.Builder, + com.google.firestore.v1.PlanSummaryOrBuilder>( + getPlanSummary(), getParentForChildren(), isClean()); + planSummary_ = null; + } + return planSummaryBuilder_; + } + + private com.google.firestore.v1.ExecutionStats executionStats_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.ExecutionStats, + com.google.firestore.v1.ExecutionStats.Builder, + com.google.firestore.v1.ExecutionStatsOrBuilder> + executionStatsBuilder_; + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return Whether the executionStats field is set. + */ + public boolean hasExecutionStats() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + public com.google.firestore.v1.ExecutionStats getExecutionStats() { + if (executionStatsBuilder_ == null) { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } else { + return executionStatsBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder setExecutionStats(com.google.firestore.v1.ExecutionStats value) { + if (executionStatsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + executionStats_ = value; + } else { + executionStatsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder setExecutionStats( + com.google.firestore.v1.ExecutionStats.Builder builderForValue) { + if (executionStatsBuilder_ == null) { + executionStats_ = builderForValue.build(); + } else { + executionStatsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder mergeExecutionStats(com.google.firestore.v1.ExecutionStats value) { + if (executionStatsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && executionStats_ != null + && executionStats_ != com.google.firestore.v1.ExecutionStats.getDefaultInstance()) { + getExecutionStatsBuilder().mergeFrom(value); + } else { + executionStats_ = value; + } + } else { + executionStatsBuilder_.mergeFrom(value); + } + if (executionStats_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder clearExecutionStats() { + bitField0_ = (bitField0_ & ~0x00000002); + executionStats_ = null; + if (executionStatsBuilder_ != null) { + executionStatsBuilder_.dispose(); + executionStatsBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public com.google.firestore.v1.ExecutionStats.Builder getExecutionStatsBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getExecutionStatsFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public com.google.firestore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder() { + if (executionStatsBuilder_ != null) { + return executionStatsBuilder_.getMessageOrBuilder(); + } else { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + } + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.ExecutionStats, + com.google.firestore.v1.ExecutionStats.Builder, + com.google.firestore.v1.ExecutionStatsOrBuilder> + getExecutionStatsFieldBuilder() { + if (executionStatsBuilder_ == null) { + executionStatsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.ExecutionStats, + com.google.firestore.v1.ExecutionStats.Builder, + com.google.firestore.v1.ExecutionStatsOrBuilder>( + getExecutionStats(), getParentForChildren(), isClean()); + executionStats_ = null; + } + return executionStatsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExplainMetrics) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExplainMetrics) + private static final com.google.firestore.v1.ExplainMetrics DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExplainMetrics(); + } + + public static com.google.firestore.v1.ExplainMetrics getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExplainMetrics parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetricsOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetricsOrBuilder.java new file mode 100644 index 000000000..ba5a87f0f --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetricsOrBuilder.java @@ -0,0 +1,102 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface ExplainMetricsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExplainMetrics) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return Whether the planSummary field is set. + */ + boolean hasPlanSummary(); + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + com.google.firestore.v1.PlanSummary getPlanSummary(); + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + com.google.firestore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder(); + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return Whether the executionStats field is set. + */ + boolean hasExecutionStats(); + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + com.google.firestore.v1.ExecutionStats getExecutionStats(); + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + com.google.firestore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder(); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptions.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptions.java new file mode 100644 index 000000000..82c242b89 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptions.java @@ -0,0 +1,557 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * Explain options for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainOptions} + */ +public final class ExplainOptions extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExplainOptions) + ExplainOptionsOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExplainOptions.newBuilder() to construct. + private ExplainOptions(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExplainOptions() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExplainOptions(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainOptions.class, + com.google.firestore.v1.ExplainOptions.Builder.class); + } + + public static final int ANALYZE_FIELD_NUMBER = 1; + private boolean analyze_ = false; + /** + * + * + *
+   * Optional. Whether to execute this query.
+   *
+   * When false (the default), the query will be planned, returning only
+   * metrics from the planning stages.
+   *
+   * When true, the query will be planned and executed, returning the full
+   * query results along with both planning and execution stage metrics.
+   * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The analyze. + */ + @java.lang.Override + public boolean getAnalyze() { + return analyze_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (analyze_ != false) { + output.writeBool(1, analyze_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (analyze_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(1, analyze_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExplainOptions)) { + return super.equals(obj); + } + com.google.firestore.v1.ExplainOptions other = (com.google.firestore.v1.ExplainOptions) obj; + + if (getAnalyze() != other.getAnalyze()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ANALYZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getAnalyze()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExplainOptions parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainOptions parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExplainOptions prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Explain options for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainOptions} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExplainOptions) + com.google.firestore.v1.ExplainOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainOptions.class, + com.google.firestore.v1.ExplainOptions.Builder.class); + } + + // Construct using com.google.firestore.v1.ExplainOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + analyze_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions getDefaultInstanceForType() { + return com.google.firestore.v1.ExplainOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions build() { + com.google.firestore.v1.ExplainOptions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions buildPartial() { + com.google.firestore.v1.ExplainOptions result = + new com.google.firestore.v1.ExplainOptions(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExplainOptions result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.analyze_ = analyze_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExplainOptions) { + return mergeFrom((com.google.firestore.v1.ExplainOptions) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExplainOptions other) { + if (other == com.google.firestore.v1.ExplainOptions.getDefaultInstance()) return this; + if (other.getAnalyze() != false) { + setAnalyze(other.getAnalyze()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + analyze_ = input.readBool(); + bitField0_ |= 0x00000001; + break; + } // case 8 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private boolean analyze_; + /** + * + * + *
+     * Optional. Whether to execute this query.
+     *
+     * When false (the default), the query will be planned, returning only
+     * metrics from the planning stages.
+     *
+     * When true, the query will be planned and executed, returning the full
+     * query results along with both planning and execution stage metrics.
+     * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The analyze. + */ + @java.lang.Override + public boolean getAnalyze() { + return analyze_; + } + /** + * + * + *
+     * Optional. Whether to execute this query.
+     *
+     * When false (the default), the query will be planned, returning only
+     * metrics from the planning stages.
+     *
+     * When true, the query will be planned and executed, returning the full
+     * query results along with both planning and execution stage metrics.
+     * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The analyze to set. + * @return This builder for chaining. + */ + public Builder setAnalyze(boolean value) { + + analyze_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Whether to execute this query.
+     *
+     * When false (the default), the query will be planned, returning only
+     * metrics from the planning stages.
+     *
+     * When true, the query will be planned and executed, returning the full
+     * query results along with both planning and execution stage metrics.
+     * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearAnalyze() { + bitField0_ = (bitField0_ & ~0x00000001); + analyze_ = false; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExplainOptions) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExplainOptions) + private static final com.google.firestore.v1.ExplainOptions DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExplainOptions(); + } + + public static com.google.firestore.v1.ExplainOptions getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExplainOptions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptionsOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptionsOrBuilder.java new file mode 100644 index 000000000..2acb95c56 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptionsOrBuilder.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface ExplainOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExplainOptions) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Optional. Whether to execute this query.
+   *
+   * When false (the default), the query will be planned, returning only
+   * metrics from the planning stages.
+   *
+   * When true, the query will be planned and executed, returning the full
+   * query results along with both planning and execution stage metrics.
+   * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The analyze. + */ + boolean getAnalyze(); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java index 0b500b3c3..cb7375ccc 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java @@ -88,6 +88,14 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_v1_RunQueryResponse_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_v1_RunQueryResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_ExecutePipelineRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_ExecutePipelineResponse_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_firestore_v1_RunAggregationQueryRequest_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -179,243 +187,259 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "e/api/field_behavior.proto\032,google/fires" + "tore/v1/aggregation_result.proto\032 google" + "/firestore/v1/common.proto\032\"google/fires" - + "tore/v1/document.proto\032\037google/firestore" - + "/v1/query.proto\032\037google/firestore/v1/wri" - + "te.proto\032\033google/protobuf/empty.proto\032\037g" - + "oogle/protobuf/timestamp.proto\032\036google/p" - + "rotobuf/wrappers.proto\032\027google/rpc/statu" - + "s.proto\"\271\001\n\022GetDocumentRequest\022\022\n\004name\030\001" - + " \001(\tB\004\342A\001\002\022/\n\004mask\030\002 \001(\0132!.google.firest" - + "ore.v1.DocumentMask\022\025\n\013transaction\030\003 \001(\014" - + "H\000\022/\n\tread_time\030\005 \001(\0132\032.google.protobuf." - + "TimestampH\000B\026\n\024consistency_selector\"\301\002\n\024" - + "ListDocumentsRequest\022\024\n\006parent\030\001 \001(\tB\004\342A" - + "\001\002\022\033\n\rcollection_id\030\002 \001(\tB\004\342A\001\001\022\027\n\tpage_" - + "size\030\003 \001(\005B\004\342A\001\001\022\030\n\npage_token\030\004 \001(\tB\004\342A" - + "\001\001\022\026\n\010order_by\030\006 \001(\tB\004\342A\001\001\0225\n\004mask\030\007 \001(\013" - + "2!.google.firestore.v1.DocumentMaskB\004\342A\001" - + "\001\022\025\n\013transaction\030\010 \001(\014H\000\022/\n\tread_time\030\n " - + "\001(\0132\032.google.protobuf.TimestampH\000\022\024\n\014sho" - + "w_missing\030\014 \001(\010B\026\n\024consistency_selector\"" - + "b\n\025ListDocumentsResponse\0220\n\tdocuments\030\001 " - + "\003(\0132\035.google.firestore.v1.Document\022\027\n\017ne" - + "xt_page_token\030\002 \001(\t\"\307\001\n\025CreateDocumentRe" - + "quest\022\024\n\006parent\030\001 \001(\tB\004\342A\001\002\022\033\n\rcollectio" - + "n_id\030\002 \001(\tB\004\342A\001\002\022\023\n\013document_id\030\003 \001(\t\0225\n" - + "\010document\030\004 \001(\0132\035.google.firestore.v1.Do" - + "cumentB\004\342A\001\002\022/\n\004mask\030\005 \001(\0132!.google.fire" - + "store.v1.DocumentMask\"\364\001\n\025UpdateDocument" - + "Request\0225\n\010document\030\001 \001(\0132\035.google.fires" - + "tore.v1.DocumentB\004\342A\001\002\0226\n\013update_mask\030\002 " - + "\001(\0132!.google.firestore.v1.DocumentMask\022/" - + "\n\004mask\030\003 \001(\0132!.google.firestore.v1.Docum" - + "entMask\022;\n\020current_document\030\004 \001(\0132!.goog" - + "le.firestore.v1.Precondition\"h\n\025DeleteDo" - + "cumentRequest\022\022\n\004name\030\001 \001(\tB\004\342A\001\002\022;\n\020cur" - + "rent_document\030\002 \001(\0132!.google.firestore.v" - + "1.Precondition\"\232\002\n\030BatchGetDocumentsRequ" - + "est\022\026\n\010database\030\001 \001(\tB\004\342A\001\002\022\021\n\tdocuments" - + "\030\002 \003(\t\022/\n\004mask\030\003 \001(\0132!.google.firestore." - + "v1.DocumentMask\022\025\n\013transaction\030\004 \001(\014H\000\022B" - + "\n\017new_transaction\030\005 \001(\0132\'.google.firesto" - + "re.v1.TransactionOptionsH\000\022/\n\tread_time\030" - + "\007 \001(\0132\032.google.protobuf.TimestampH\000B\026\n\024c" - + "onsistency_selector\"\254\001\n\031BatchGetDocument" - + "sResponse\022.\n\005found\030\001 \001(\0132\035.google.firest" - + "ore.v1.DocumentH\000\022\021\n\007missing\030\002 \001(\tH\000\022\023\n\013" - + "transaction\030\003 \001(\014\022-\n\tread_time\030\004 \001(\0132\032.g" - + "oogle.protobuf.TimestampB\010\n\006result\"k\n\027Be" - + "ginTransactionRequest\022\026\n\010database\030\001 \001(\tB" - + "\004\342A\001\002\0228\n\007options\030\002 \001(\0132\'.google.firestor" - + "e.v1.TransactionOptions\"/\n\030BeginTransact" - + "ionResponse\022\023\n\013transaction\030\001 \001(\014\"h\n\rComm" - + "itRequest\022\026\n\010database\030\001 \001(\tB\004\342A\001\002\022*\n\006wri" - + "tes\030\002 \003(\0132\032.google.firestore.v1.Write\022\023\n" - + "\013transaction\030\003 \001(\014\"z\n\016CommitResponse\0227\n\r" - + "write_results\030\001 \003(\0132 .google.firestore.v" - + "1.WriteResult\022/\n\013commit_time\030\002 \001(\0132\032.goo" - + "gle.protobuf.Timestamp\"D\n\017RollbackReques" - + "t\022\026\n\010database\030\001 \001(\tB\004\342A\001\002\022\031\n\013transaction" - + "\030\002 \001(\014B\004\342A\001\002\"\233\002\n\017RunQueryRequest\022\024\n\006pare" - + "nt\030\001 \001(\tB\004\342A\001\002\022@\n\020structured_query\030\002 \001(\013" + + "tore/v1/document.proto\032\"google/firestore" + + "/v1/pipeline.proto\032\037google/firestore/v1/" + + "query.proto\032\037google/firestore/v1/write.p" + + "roto\032\033google/protobuf/empty.proto\032\037googl" + + "e/protobuf/timestamp.proto\032\036google/proto" + + "buf/wrappers.proto\032\027google/rpc/status.pr" + + "oto\"\270\001\n\022GetDocumentRequest\022\021\n\004name\030\001 \001(\t" + + "B\003\340A\002\022/\n\004mask\030\002 \001(\0132!.google.firestore.v" + + "1.DocumentMask\022\025\n\013transaction\030\003 \001(\014H\000\022/\n" + + "\tread_time\030\005 \001(\0132\032.google.protobuf.Times" + + "tampH\000B\026\n\024consistency_selector\"\273\002\n\024ListD" + + "ocumentsRequest\022\023\n\006parent\030\001 \001(\tB\003\340A\002\022\032\n\r" + + "collection_id\030\002 \001(\tB\003\340A\001\022\026\n\tpage_size\030\003 " + + "\001(\005B\003\340A\001\022\027\n\npage_token\030\004 \001(\tB\003\340A\001\022\025\n\010ord" + + "er_by\030\006 \001(\tB\003\340A\001\0224\n\004mask\030\007 \001(\0132!.google." + + "firestore.v1.DocumentMaskB\003\340A\001\022\025\n\013transa" + + "ction\030\010 \001(\014H\000\022/\n\tread_time\030\n \001(\0132\032.googl" + + "e.protobuf.TimestampH\000\022\024\n\014show_missing\030\014" + + " \001(\010B\026\n\024consistency_selector\"b\n\025ListDocu" + + "mentsResponse\0220\n\tdocuments\030\001 \003(\0132\035.googl" + + "e.firestore.v1.Document\022\027\n\017next_page_tok" + + "en\030\002 \001(\t\"\304\001\n\025CreateDocumentRequest\022\023\n\006pa" + + "rent\030\001 \001(\tB\003\340A\002\022\032\n\rcollection_id\030\002 \001(\tB\003" + + "\340A\002\022\023\n\013document_id\030\003 \001(\t\0224\n\010document\030\004 \001" + + "(\0132\035.google.firestore.v1.DocumentB\003\340A\002\022/" + + "\n\004mask\030\005 \001(\0132!.google.firestore.v1.Docum" + + "entMask\"\363\001\n\025UpdateDocumentRequest\0224\n\010doc" + + "ument\030\001 \001(\0132\035.google.firestore.v1.Docume" + + "ntB\003\340A\002\0226\n\013update_mask\030\002 \001(\0132!.google.fi" + + "restore.v1.DocumentMask\022/\n\004mask\030\003 \001(\0132!." + + "google.firestore.v1.DocumentMask\022;\n\020curr" + + "ent_document\030\004 \001(\0132!.google.firestore.v1" + + ".Precondition\"g\n\025DeleteDocumentRequest\022\021" + + "\n\004name\030\001 \001(\tB\003\340A\002\022;\n\020current_document\030\002 " + + "\001(\0132!.google.firestore.v1.Precondition\"\231" + + "\002\n\030BatchGetDocumentsRequest\022\025\n\010database\030" + + "\001 \001(\tB\003\340A\002\022\021\n\tdocuments\030\002 \003(\t\022/\n\004mask\030\003 " + + "\001(\0132!.google.firestore.v1.DocumentMask\022\025" + + "\n\013transaction\030\004 \001(\014H\000\022B\n\017new_transaction" + + "\030\005 \001(\0132\'.google.firestore.v1.Transaction" + + "OptionsH\000\022/\n\tread_time\030\007 \001(\0132\032.google.pr" + + "otobuf.TimestampH\000B\026\n\024consistency_select" + + "or\"\254\001\n\031BatchGetDocumentsResponse\022.\n\005foun" + + "d\030\001 \001(\0132\035.google.firestore.v1.DocumentH\000" + + "\022\021\n\007missing\030\002 \001(\tH\000\022\023\n\013transaction\030\003 \001(\014" + + "\022-\n\tread_time\030\004 \001(\0132\032.google.protobuf.Ti" + + "mestampB\010\n\006result\"j\n\027BeginTransactionReq" + + "uest\022\025\n\010database\030\001 \001(\tB\003\340A\002\0228\n\007options\030\002" + + " \001(\0132\'.google.firestore.v1.TransactionOp" + + "tions\"/\n\030BeginTransactionResponse\022\023\n\013tra" + + "nsaction\030\001 \001(\014\"g\n\rCommitRequest\022\025\n\010datab" + + "ase\030\001 \001(\tB\003\340A\002\022*\n\006writes\030\002 \003(\0132\032.google." + + "firestore.v1.Write\022\023\n\013transaction\030\003 \001(\014\"" + + "z\n\016CommitResponse\0227\n\rwrite_results\030\001 \003(\013" + + "2 .google.firestore.v1.WriteResult\022/\n\013co" + + "mmit_time\030\002 \001(\0132\032.google.protobuf.Timest" + + "amp\"B\n\017RollbackRequest\022\025\n\010database\030\001 \001(\t" + + "B\003\340A\002\022\030\n\013transaction\030\002 \001(\014B\003\340A\002\"\232\002\n\017RunQ" + + "ueryRequest\022\023\n\006parent\030\001 \001(\tB\003\340A\002\022@\n\020stru" + + "ctured_query\030\002 \001(\0132$.google.firestore.v1" + + ".StructuredQueryH\000\022\025\n\013transaction\030\005 \001(\014H" + + "\001\022B\n\017new_transaction\030\006 \001(\0132\'.google.fire" + + "store.v1.TransactionOptionsH\001\022/\n\tread_ti" + + "me\030\007 \001(\0132\032.google.protobuf.TimestampH\001B\014" + + "\n\nquery_typeB\026\n\024consistency_selector\"\311\001\n" + + "\020RunQueryResponse\022\023\n\013transaction\030\002 \001(\014\022/" + + "\n\010document\030\001 \001(\0132\035.google.firestore.v1.D" + + "ocument\022-\n\tread_time\030\003 \001(\0132\032.google.prot" + + "obuf.Timestamp\022\027\n\017skipped_results\030\004 \001(\005\022" + + "\016\n\004done\030\006 \001(\010H\000B\027\n\025continuation_selector" + + "\"\254\002\n\026ExecutePipelineRequest\022\025\n\010database\030" + + "\001 \001(\tB\003\340A\002\022F\n\023structured_pipeline\030\002 \001(\0132" + + "\'.google.firestore.v1.StructuredPipeline" + + "H\000\022\025\n\013transaction\030\005 \001(\014H\001\022B\n\017new_transac" + + "tion\030\006 \001(\0132\'.google.firestore.v1.Transac" + + "tionOptionsH\001\022/\n\tread_time\030\007 \001(\0132\032.googl" + + "e.protobuf.TimestampH\001B\017\n\rpipeline_typeB" + + "\026\n\024consistency_selector\"\222\001\n\027ExecutePipel" + + "ineResponse\022\023\n\013transaction\030\001 \001(\014\022.\n\007resu" + + "lts\030\002 \003(\0132\035.google.firestore.v1.Document" + + "\0222\n\016execution_time\030\003 \001(\0132\032.google.protob" + + "uf.Timestamp\"\274\002\n\032RunAggregationQueryRequ" + + "est\022\023\n\006parent\030\001 \001(\tB\003\340A\002\022W\n\034structured_a" + + "ggregation_query\030\002 \001(\0132/.google.firestor" + + "e.v1.StructuredAggregationQueryH\000\022\025\n\013tra" + + "nsaction\030\004 \001(\014H\001\022B\n\017new_transaction\030\005 \001(" + + "\0132\'.google.firestore.v1.TransactionOptio" + + "nsH\001\022/\n\tread_time\030\006 \001(\0132\032.google.protobu" + + "f.TimestampH\001B\014\n\nquery_typeB\026\n\024consisten" + + "cy_selector\"\231\001\n\033RunAggregationQueryRespo" + + "nse\0226\n\006result\030\001 \001(\0132&.google.firestore.v" + + "1.AggregationResult\022\023\n\013transaction\030\002 \001(\014" + + "\022-\n\tread_time\030\003 \001(\0132\032.google.protobuf.Ti" + + "mestamp\"\205\002\n\025PartitionQueryRequest\022\023\n\006par" + + "ent\030\001 \001(\tB\003\340A\002\022@\n\020structured_query\030\002 \001(\013" + "2$.google.firestore.v1.StructuredQueryH\000" - + "\022\025\n\013transaction\030\005 \001(\014H\001\022B\n\017new_transacti" - + "on\030\006 \001(\0132\'.google.firestore.v1.Transacti" - + "onOptionsH\001\022/\n\tread_time\030\007 \001(\0132\032.google." - + "protobuf.TimestampH\001B\014\n\nquery_typeB\026\n\024co" - + "nsistency_selector\"\311\001\n\020RunQueryResponse\022" - + "\023\n\013transaction\030\002 \001(\014\022/\n\010document\030\001 \001(\0132\035" - + ".google.firestore.v1.Document\022-\n\tread_ti" - + "me\030\003 \001(\0132\032.google.protobuf.Timestamp\022\027\n\017" - + "skipped_results\030\004 \001(\005\022\016\n\004done\030\006 \001(\010H\000B\027\n" - + "\025continuation_selector\"\275\002\n\032RunAggregatio" - + "nQueryRequest\022\024\n\006parent\030\001 \001(\tB\004\342A\001\002\022W\n\034s" - + "tructured_aggregation_query\030\002 \001(\0132/.goog" - + "le.firestore.v1.StructuredAggregationQue" - + "ryH\000\022\025\n\013transaction\030\004 \001(\014H\001\022B\n\017new_trans" - + "action\030\005 \001(\0132\'.google.firestore.v1.Trans" - + "actionOptionsH\001\022/\n\tread_time\030\006 \001(\0132\032.goo" - + "gle.protobuf.TimestampH\001B\014\n\nquery_typeB\026" - + "\n\024consistency_selector\"\231\001\n\033RunAggregatio" - + "nQueryResponse\0226\n\006result\030\001 \001(\0132&.google." - + "firestore.v1.AggregationResult\022\023\n\013transa" - + "ction\030\002 \001(\014\022-\n\tread_time\030\003 \001(\0132\032.google." - + "protobuf.Timestamp\"\206\002\n\025PartitionQueryReq" - + "uest\022\024\n\006parent\030\001 \001(\tB\004\342A\001\002\022@\n\020structured" - + "_query\030\002 \001(\0132$.google.firestore.v1.Struc" - + "turedQueryH\000\022\027\n\017partition_count\030\003 \001(\003\022\022\n" - + "\npage_token\030\004 \001(\t\022\021\n\tpage_size\030\005 \001(\005\022/\n\t" - + "read_time\030\006 \001(\0132\032.google.protobuf.Timest" - + "ampH\001B\014\n\nquery_typeB\026\n\024consistency_selec" - + "tor\"b\n\026PartitionQueryResponse\022/\n\npartiti" - + "ons\030\001 \003(\0132\033.google.firestore.v1.Cursor\022\027" - + "\n\017next_page_token\030\002 \001(\t\"\351\001\n\014WriteRequest" - + "\022\026\n\010database\030\001 \001(\tB\004\342A\001\002\022\021\n\tstream_id\030\002 " - + "\001(\t\022*\n\006writes\030\003 \003(\0132\032.google.firestore.v" - + "1.Write\022\024\n\014stream_token\030\004 \001(\014\022=\n\006labels\030" - + "\005 \003(\0132-.google.firestore.v1.WriteRequest" - + ".LabelsEntry\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t" - + "\022\r\n\005value\030\002 \001(\t:\0028\001\"\242\001\n\rWriteResponse\022\021\n" - + "\tstream_id\030\001 \001(\t\022\024\n\014stream_token\030\002 \001(\014\0227" - + "\n\rwrite_results\030\003 \003(\0132 .google.firestore" - + ".v1.WriteResult\022/\n\013commit_time\030\004 \001(\0132\032.g" - + "oogle.protobuf.Timestamp\"\363\001\n\rListenReque" - + "st\022\026\n\010database\030\001 \001(\tB\004\342A\001\002\0221\n\nadd_target" - + "\030\002 \001(\0132\033.google.firestore.v1.TargetH\000\022\027\n" - + "\rremove_target\030\003 \001(\005H\000\022>\n\006labels\030\004 \003(\0132." - + ".google.firestore.v1.ListenRequest.Label" - + "sEntry\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005va" - + "lue\030\002 \001(\t:\0028\001B\017\n\rtarget_change\"\325\002\n\016Liste" - + "nResponse\022:\n\rtarget_change\030\002 \001(\0132!.googl" - + "e.firestore.v1.TargetChangeH\000\022>\n\017documen" - + "t_change\030\003 \001(\0132#.google.firestore.v1.Doc" - + "umentChangeH\000\022>\n\017document_delete\030\004 \001(\0132#" - + ".google.firestore.v1.DocumentDeleteH\000\022>\n" - + "\017document_remove\030\006 \001(\0132#.google.firestor" - + "e.v1.DocumentRemoveH\000\0226\n\006filter\030\005 \001(\0132$." - + "google.firestore.v1.ExistenceFilterH\000B\017\n" - + "\rresponse_type\"\326\003\n\006Target\0228\n\005query\030\002 \001(\013" - + "2\'.google.firestore.v1.Target.QueryTarge" - + "tH\000\022@\n\tdocuments\030\003 \001(\0132+.google.firestor" - + "e.v1.Target.DocumentsTargetH\000\022\026\n\014resume_" - + "token\030\004 \001(\014H\001\022/\n\tread_time\030\013 \001(\0132\032.googl" - + "e.protobuf.TimestampH\001\022\021\n\ttarget_id\030\005 \001(" - + "\005\022\014\n\004once\030\006 \001(\010\0223\n\016expected_count\030\014 \001(\0132" - + "\033.google.protobuf.Int32Value\032$\n\017Document" - + "sTarget\022\021\n\tdocuments\030\002 \003(\t\032m\n\013QueryTarge" - + "t\022\016\n\006parent\030\001 \001(\t\022@\n\020structured_query\030\002 " - + "\001(\0132$.google.firestore.v1.StructuredQuer" - + "yH\000B\014\n\nquery_typeB\r\n\013target_typeB\r\n\013resu" - + "me_type\"\252\002\n\014TargetChange\022N\n\022target_chang" - + "e_type\030\001 \001(\01622.google.firestore.v1.Targe" - + "tChange.TargetChangeType\022\022\n\ntarget_ids\030\002" - + " \003(\005\022!\n\005cause\030\003 \001(\0132\022.google.rpc.Status\022" - + "\024\n\014resume_token\030\004 \001(\014\022-\n\tread_time\030\006 \001(\013" - + "2\032.google.protobuf.Timestamp\"N\n\020TargetCh" - + "angeType\022\r\n\tNO_CHANGE\020\000\022\007\n\003ADD\020\001\022\n\n\006REMO" - + "VE\020\002\022\013\n\007CURRENT\020\003\022\t\n\005RESET\020\004\"\240\001\n\030ListCol" - + "lectionIdsRequest\022\024\n\006parent\030\001 \001(\tB\004\342A\001\002\022" - + "\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\022/" - + "\n\tread_time\030\004 \001(\0132\032.google.protobuf.Time" - + "stampH\000B\026\n\024consistency_selector\"L\n\031ListC" - + "ollectionIdsResponse\022\026\n\016collection_ids\030\001" - + " \003(\t\022\027\n\017next_page_token\030\002 \001(\t\"\312\001\n\021BatchW" - + "riteRequest\022\026\n\010database\030\001 \001(\tB\004\342A\001\002\022*\n\006w" - + "rites\030\002 \003(\0132\032.google.firestore.v1.Write\022" - + "B\n\006labels\030\003 \003(\01322.google.firestore.v1.Ba" - + "tchWriteRequest.LabelsEntry\032-\n\013LabelsEnt" - + "ry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"q\n\022Ba" - + "tchWriteResponse\0227\n\rwrite_results\030\001 \003(\0132" - + " .google.firestore.v1.WriteResult\022\"\n\006sta" - + "tus\030\002 \003(\0132\022.google.rpc.Status2\332\031\n\tFirest" - + "ore\022\217\001\n\013GetDocument\022\'.google.firestore.v" - + "1.GetDocumentRequest\032\035.google.firestore." - + "v1.Document\"8\202\323\344\223\0022\0220/v1/{name=projects/" - + "*/databases/*/documents/*/**}\022\365\001\n\rListDo" - + "cuments\022).google.firestore.v1.ListDocume" - + "ntsRequest\032*.google.firestore.v1.ListDoc" - + "umentsResponse\"\214\001\202\323\344\223\002\205\001\022B/v1/{parent=pr" - + "ojects/*/databases/*/documents/*/**}/{co" - + "llection_id}Z?\022=/v1/{parent=projects/*/d" - + "atabases/*/documents}/{collection_id}\022\277\001" - + "\n\016UpdateDocument\022*.google.firestore.v1.U" - + "pdateDocumentRequest\032\035.google.firestore." - + "v1.Document\"b\332A\024document,update_mask\202\323\344\223" - + "\002E29/v1/{document.name=projects/*/databa" - + "ses/*/documents/*/**}:\010document\022\225\001\n\016Dele" - + "teDocument\022*.google.firestore.v1.DeleteD" - + "ocumentRequest\032\026.google.protobuf.Empty\"?" - + "\332A\004name\202\323\344\223\0022*0/v1/{name=projects/*/data" - + "bases/*/documents/*/**}\022\271\001\n\021BatchGetDocu" - + "ments\022-.google.firestore.v1.BatchGetDocu" - + "mentsRequest\032..google.firestore.v1.Batch" - + "GetDocumentsResponse\"C\202\323\344\223\002=\"8/v1/{datab" - + "ase=projects/*/databases/*}/documents:ba" - + "tchGet:\001*0\001\022\307\001\n\020BeginTransaction\022,.googl" - + "e.firestore.v1.BeginTransactionRequest\032-" - + ".google.firestore.v1.BeginTransactionRes" - + "ponse\"V\332A\010database\202\323\344\223\002E\"@/v1/{database=" - + "projects/*/databases/*}/documents:beginT" - + "ransaction:\001*\022\246\001\n\006Commit\022\".google.firest" - + "ore.v1.CommitRequest\032#.google.firestore." - + "v1.CommitResponse\"S\332A\017database,writes\202\323\344" + + "\022\027\n\017partition_count\030\003 \001(\003\022\022\n\npage_token\030" + + "\004 \001(\t\022\021\n\tpage_size\030\005 \001(\005\022/\n\tread_time\030\006 " + + "\001(\0132\032.google.protobuf.TimestampH\001B\014\n\nque" + + "ry_typeB\026\n\024consistency_selector\"b\n\026Parti" + + "tionQueryResponse\022/\n\npartitions\030\001 \003(\0132\033." + + "google.firestore.v1.Cursor\022\027\n\017next_page_" + + "token\030\002 \001(\t\"\350\001\n\014WriteRequest\022\025\n\010database" + + "\030\001 \001(\tB\003\340A\002\022\021\n\tstream_id\030\002 \001(\t\022*\n\006writes" + + "\030\003 \003(\0132\032.google.firestore.v1.Write\022\024\n\014st" + + "ream_token\030\004 \001(\014\022=\n\006labels\030\005 \003(\0132-.googl" + + "e.firestore.v1.WriteRequest.LabelsEntry\032" + + "-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001" + + "(\t:\0028\001\"\242\001\n\rWriteResponse\022\021\n\tstream_id\030\001 " + + "\001(\t\022\024\n\014stream_token\030\002 \001(\014\0227\n\rwrite_resul" + + "ts\030\003 \003(\0132 .google.firestore.v1.WriteResu" + + "lt\022/\n\013commit_time\030\004 \001(\0132\032.google.protobu" + + "f.Timestamp\"\362\001\n\rListenRequest\022\025\n\010databas" + + "e\030\001 \001(\tB\003\340A\002\0221\n\nadd_target\030\002 \001(\0132\033.googl" + + "e.firestore.v1.TargetH\000\022\027\n\rremove_target" + + "\030\003 \001(\005H\000\022>\n\006labels\030\004 \003(\0132..google.firest" + + "ore.v1.ListenRequest.LabelsEntry\032-\n\013Labe" + + "lsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001B" + + "\017\n\rtarget_change\"\325\002\n\016ListenResponse\022:\n\rt" + + "arget_change\030\002 \001(\0132!.google.firestore.v1" + + ".TargetChangeH\000\022>\n\017document_change\030\003 \001(\013" + + "2#.google.firestore.v1.DocumentChangeH\000\022" + + ">\n\017document_delete\030\004 \001(\0132#.google.firest" + + "ore.v1.DocumentDeleteH\000\022>\n\017document_remo" + + "ve\030\006 \001(\0132#.google.firestore.v1.DocumentR" + + "emoveH\000\0226\n\006filter\030\005 \001(\0132$.google.firesto" + + "re.v1.ExistenceFilterH\000B\017\n\rresponse_type" + + "\"\326\003\n\006Target\0228\n\005query\030\002 \001(\0132\'.google.fire" + + "store.v1.Target.QueryTargetH\000\022@\n\tdocumen" + + "ts\030\003 \001(\0132+.google.firestore.v1.Target.Do" + + "cumentsTargetH\000\022\026\n\014resume_token\030\004 \001(\014H\001\022" + + "/\n\tread_time\030\013 \001(\0132\032.google.protobuf.Tim" + + "estampH\001\022\021\n\ttarget_id\030\005 \001(\005\022\014\n\004once\030\006 \001(" + + "\010\0223\n\016expected_count\030\014 \001(\0132\033.google.proto" + + "buf.Int32Value\032$\n\017DocumentsTarget\022\021\n\tdoc" + + "uments\030\002 \003(\t\032m\n\013QueryTarget\022\016\n\006parent\030\001 " + + "\001(\t\022@\n\020structured_query\030\002 \001(\0132$.google.f" + + "irestore.v1.StructuredQueryH\000B\014\n\nquery_t" + + "ypeB\r\n\013target_typeB\r\n\013resume_type\"\252\002\n\014Ta" + + "rgetChange\022N\n\022target_change_type\030\001 \001(\01622" + + ".google.firestore.v1.TargetChange.Target" + + "ChangeType\022\022\n\ntarget_ids\030\002 \003(\005\022!\n\005cause\030" + + "\003 \001(\0132\022.google.rpc.Status\022\024\n\014resume_toke" + + "n\030\004 \001(\014\022-\n\tread_time\030\006 \001(\0132\032.google.prot" + + "obuf.Timestamp\"N\n\020TargetChangeType\022\r\n\tNO" + + "_CHANGE\020\000\022\007\n\003ADD\020\001\022\n\n\006REMOVE\020\002\022\013\n\007CURREN" + + "T\020\003\022\t\n\005RESET\020\004\"\237\001\n\030ListCollectionIdsRequ" + + "est\022\023\n\006parent\030\001 \001(\tB\003\340A\002\022\021\n\tpage_size\030\002 " + + "\001(\005\022\022\n\npage_token\030\003 \001(\t\022/\n\tread_time\030\004 \001" + + "(\0132\032.google.protobuf.TimestampH\000B\026\n\024cons" + + "istency_selector\"L\n\031ListCollectionIdsRes" + + "ponse\022\026\n\016collection_ids\030\001 \003(\t\022\027\n\017next_pa" + + "ge_token\030\002 \001(\t\"\311\001\n\021BatchWriteRequest\022\025\n\010" + + "database\030\001 \001(\tB\003\340A\002\022*\n\006writes\030\002 \003(\0132\032.go" + + "ogle.firestore.v1.Write\022B\n\006labels\030\003 \003(\0132" + + "2.google.firestore.v1.BatchWriteRequest." + + "LabelsEntry\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022" + + "\r\n\005value\030\002 \001(\t:\0028\001\"q\n\022BatchWriteResponse" + + "\0227\n\rwrite_results\030\001 \003(\0132 .google.firesto" + + "re.v1.WriteResult\022\"\n\006status\030\002 \003(\0132\022.goog" + + "le.rpc.Status2\222\033\n\tFirestore\022\217\001\n\013GetDocum" + + "ent\022\'.google.firestore.v1.GetDocumentReq" + + "uest\032\035.google.firestore.v1.Document\"8\202\323\344" + + "\223\0022\0220/v1/{name=projects/*/databases/*/do" + + "cuments/*/**}\022\365\001\n\rListDocuments\022).google" + + ".firestore.v1.ListDocumentsRequest\032*.goo" + + "gle.firestore.v1.ListDocumentsResponse\"\214" + + "\001\202\323\344\223\002\205\001\022B/v1/{parent=projects/*/databas" + + "es/*/documents/*/**}/{collection_id}Z?\022=" + + "/v1/{parent=projects/*/databases/*/docum" + + "ents}/{collection_id}\022\277\001\n\016UpdateDocument" + + "\022*.google.firestore.v1.UpdateDocumentReq" + + "uest\032\035.google.firestore.v1.Document\"b\332A\024" + + "document,update_mask\202\323\344\223\002E29/v1/{documen" + + "t.name=projects/*/databases/*/documents/" + + "*/**}:\010document\022\225\001\n\016DeleteDocument\022*.goo" + + "gle.firestore.v1.DeleteDocumentRequest\032\026" + + ".google.protobuf.Empty\"?\332A\004name\202\323\344\223\0022*0/" + + "v1/{name=projects/*/databases/*/document" + + "s/*/**}\022\271\001\n\021BatchGetDocuments\022-.google.f" + + "irestore.v1.BatchGetDocumentsRequest\032..g" + + "oogle.firestore.v1.BatchGetDocumentsResp" + + "onse\"C\202\323\344\223\002=\"8/v1/{database=projects/*/d" + + "atabases/*}/documents:batchGet:\001*0\001\022\307\001\n\020" + + "BeginTransaction\022,.google.firestore.v1.B" + + "eginTransactionRequest\032-.google.firestor" + + "e.v1.BeginTransactionResponse\"V\332A\010databa" + + "se\202\323\344\223\002E\"@/v1/{database=projects/*/datab" + + "ases/*}/documents:beginTransaction:\001*\022\246\001" + + "\n\006Commit\022\".google.firestore.v1.CommitReq" + + "uest\032#.google.firestore.v1.CommitRespons" + + "e\"S\332A\017database,writes\202\323\344\223\002;\"6/v1/{databa" + + "se=projects/*/databases/*}/documents:com" + + "mit:\001*\022\244\001\n\010Rollback\022$.google.firestore.v" + + "1.RollbackRequest\032\026.google.protobuf.Empt" + + "y\"Z\332A\024database,transaction\202\323\344\223\002=\"8/v1/{d" + + "atabase=projects/*/databases/*}/document" + + "s:rollback:\001*\022\337\001\n\010RunQuery\022$.google.fire" + + "store.v1.RunQueryRequest\032%.google.firest" + + "ore.v1.RunQueryResponse\"\203\001\202\323\344\223\002}\"6/v1/{p" + + "arent=projects/*/databases/*/documents}:" + + "runQuery:\001*Z@\";/v1/{parent=projects/*/da" + + "tabases/*/documents/*/**}:runQuery:\001*0\001\022" + + "\265\001\n\017ExecutePipeline\022+.google.firestore.v" + + "1.ExecutePipelineRequest\032,.google.firest" + + "ore.v1.ExecutePipelineResponse\"E\202\323\344\223\002?\":" + + "/v1beta1/{database=projects/*/databases/" + + "*}:executePipeline:\001*0\001\022\227\002\n\023RunAggregati" + + "onQuery\022/.google.firestore.v1.RunAggrega" + + "tionQueryRequest\0320.google.firestore.v1.R" + + "unAggregationQueryResponse\"\232\001\202\323\344\223\002\223\001\"A/v" + + "1/{parent=projects/*/databases/*/documen" + + "ts}:runAggregationQuery:\001*ZK\"F/v1/{paren" + + "t=projects/*/databases/*/documents/*/**}" + + ":runAggregationQuery:\001*0\001\022\374\001\n\016PartitionQ" + + "uery\022*.google.firestore.v1.PartitionQuer" + + "yRequest\032+.google.firestore.v1.Partition" + + "QueryResponse\"\220\001\202\323\344\223\002\211\001\" + * Represents an unevaluated scalar expression. + * + * For example, the expression `like(user_name, "%alice%")` is represented as: + * + * ``` + * name: "like" + * args { field_reference: "user_name" } + * args { string_value: "%alice%" } + * ``` + * + * (-- api-linter: core::0123::resource-annotation=disabled + * aip.dev/not-precedent: this is not a One Platform API resource. --) + * + * + * Protobuf type {@code google.firestore.v1.Function} + */ +public final class Function extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Function) + FunctionOrBuilder { + private static final long serialVersionUID = 0L; + // Use Function.newBuilder() to construct. + private Function(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Function() { + name_ = ""; + args_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Function(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Function.class, com.google.firestore.v1.Function.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ARGS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List args_; + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public java.util.List getArgsList() { + return args_; + } + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public java.util.List getArgsOrBuilderList() { + return args_; + } + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public int getArgsCount() { + return args_.size(); + } + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getArgs(int index) { + return args_.get(index); + } + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + return args_.get(index); + } + + public static final int OPTIONS_FIELD_NUMBER = 3; + + private static final class OptionsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_OptionsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField options_; + + private com.google.protobuf.MapField + internalGetOptions() { + if (options_ == null) { + return com.google.protobuf.MapField.emptyMapField(OptionsDefaultEntryHolder.defaultEntry); + } + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().getMap().size(); + } + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().getMap().containsKey(key); + } + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getMap(); + } + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + for (int i = 0; i < args_.size(); i++) { + output.writeMessage(2, args_.get(i)); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetOptions(), OptionsDefaultEntryHolder.defaultEntry, 3); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + for (int i = 0; i < args_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, args_.get(i)); + } + for (java.util.Map.Entry entry : + internalGetOptions().getMap().entrySet()) { + com.google.protobuf.MapEntry options__ = + OptionsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, options__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Function)) { + return super.equals(obj); + } + com.google.firestore.v1.Function other = (com.google.firestore.v1.Function) obj; + + if (!getName().equals(other.getName())) return false; + if (!getArgsList().equals(other.getArgsList())) return false; + if (!internalGetOptions().equals(other.internalGetOptions())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getArgsCount() > 0) { + hash = (37 * hash) + ARGS_FIELD_NUMBER; + hash = (53 * hash) + getArgsList().hashCode(); + } + if (!internalGetOptions().getMap().isEmpty()) { + hash = (37 * hash) + OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + internalGetOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Function parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Function parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Function parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Function parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Function parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Function parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Function parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Function prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Represents an unevaluated scalar expression.
+   *
+   * For example, the expression `like(user_name, "%alice%")` is represented as:
+   *
+   * ```
+   * name: "like"
+   * args { field_reference: "user_name" }
+   * args { string_value: "%alice%" }
+   * ```
+   *
+   * (-- api-linter: core::0123::resource-annotation=disabled
+   *     aip.dev/not-precedent: this is not a One Platform API resource. --)
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Function} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Function) + com.google.firestore.v1.FunctionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetMutableOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Function.class, + com.google.firestore.v1.Function.Builder.class); + } + + // Construct using com.google.firestore.v1.Function.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + } else { + args_ = null; + argsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableOptions().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Function getDefaultInstanceForType() { + return com.google.firestore.v1.Function.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Function build() { + com.google.firestore.v1.Function result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Function buildPartial() { + com.google.firestore.v1.Function result = new com.google.firestore.v1.Function(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Function result) { + if (argsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + args_ = java.util.Collections.unmodifiableList(args_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.args_ = args_; + } else { + result.args_ = argsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Function result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.options_ = internalGetOptions().build(OptionsDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Function) { + return mergeFrom((com.google.firestore.v1.Function) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Function other) { + if (other == com.google.firestore.v1.Function.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (argsBuilder_ == null) { + if (!other.args_.isEmpty()) { + if (args_.isEmpty()) { + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureArgsIsMutable(); + args_.addAll(other.args_); + } + onChanged(); + } + } else { + if (!other.args_.isEmpty()) { + if (argsBuilder_.isEmpty()) { + argsBuilder_.dispose(); + argsBuilder_ = null; + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + argsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getArgsFieldBuilder() + : null; + } else { + argsBuilder_.addAllMessages(other.args_); + } + } + } + internalGetMutableOptions().mergeFrom(other.internalGetOptions()); + bitField0_ |= 0x00000004; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Value m = + input.readMessage(com.google.firestore.v1.Value.parser(), extensionRegistry); + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(m); + } else { + argsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + com.google.protobuf.MapEntry + options__ = + input.readMessage( + OptionsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableOptions() + .ensureBuilderMap() + .put(options__.getKey(), options__.getValue()); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List args_ = java.util.Collections.emptyList(); + + private void ensureArgsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + args_ = new java.util.ArrayList(args_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + argsBuilder_; + + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public java.util.List getArgsList() { + if (argsBuilder_ == null) { + return java.util.Collections.unmodifiableList(args_); + } else { + return argsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public int getArgsCount() { + if (argsBuilder_ == null) { + return args_.size(); + } else { + return argsBuilder_.getCount(); + } + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value getArgs(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder setArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.set(index, value); + onChanged(); + } else { + argsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder setArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.set(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(value); + onChanged(); + } else { + argsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(index, value); + onChanged(); + } else { + argsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addAllArgs(java.lang.Iterable values) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, args_); + onChanged(); + } else { + argsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder clearArgs() { + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + argsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder removeArgs(int index) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.remove(index); + onChanged(); + } else { + argsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value.Builder getArgsBuilder(int index) { + return getArgsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public java.util.List getArgsOrBuilderList() { + if (argsBuilder_ != null) { + return argsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(args_); + } + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder() { + return getArgsFieldBuilder().addBuilder(com.google.firestore.v1.Value.getDefaultInstance()); + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder(int index) { + return getArgsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Value.getDefaultInstance()); + } + /** + * + * + *
+     * Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public java.util.List getArgsBuilderList() { + return getArgsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + getArgsFieldBuilder() { + if (argsBuilder_ == null) { + argsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + args_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + args_ = null; + } + return argsBuilder_; + } + + private static final class OptionsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return OptionsDefaultEntryHolder.defaultEntry; + } + }; + + private static final OptionsConverter optionsConverter = new OptionsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + options_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetOptions() { + if (options_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + return options_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableOptions() { + if (options_ == null) { + options_ = new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + bitField0_ |= 0x00000004; + onChanged(); + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().ensureBuilderMap().size(); + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().ensureBuilderMap().containsKey(key); + } + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getImmutableMap(); + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + return map.containsKey(key) ? optionsConverter.build(map.get(key)) : defaultValue; + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return optionsConverter.build(map.get(key)); + } + + public Builder clearOptions() { + bitField0_ = (bitField0_ & ~0x00000004); + internalGetMutableOptions().clear(); + return this; + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public Builder removeOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableOptions().ensureBuilderMap().remove(key); + return this; + } + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableOptions() { + bitField0_ |= 0x00000004; + return internalGetMutableOptions().ensureMessageMap(); + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public Builder putOptions(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableOptions().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000004; + return this; + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public Builder putAllOptions( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableOptions().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000004; + return this; + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public com.google.firestore.v1.Value.Builder putOptionsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableOptions().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Function) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Function) + private static final com.google.firestore.v1.Function DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Function(); + } + + public static com.google.firestore.v1.Function getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Function parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Function getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FunctionOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FunctionOrBuilder.java new file mode 100644 index 000000000..e1ca51940 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FunctionOrBuilder.java @@ -0,0 +1,168 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/document.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface FunctionOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Function) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + java.util.List getArgsList(); + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + com.google.firestore.v1.Value getArgs(int index); + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + int getArgsCount(); + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + java.util.List getArgsOrBuilderList(); + /** + * + * + *
+   * Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index); + + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + int getOptionsCount(); + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + boolean containsOptions(java.lang.String key); + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getOptions(); + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + java.util.Map getOptionsMap(); + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + /* nullable */ + com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + /** + * + * + *
+   * Optional named arguments that certain functions may support.
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Pipeline.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Pipeline.java new file mode 100644 index 000000000..5be2143a0 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Pipeline.java @@ -0,0 +1,2640 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/document.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * A Firestore query represented as an ordered list of operations / stages.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline} + */ +public final class Pipeline extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Pipeline) + PipelineOrBuilder { + private static final long serialVersionUID = 0L; + // Use Pipeline.newBuilder() to construct. + private Pipeline(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Pipeline() { + stages_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Pipeline(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.class, com.google.firestore.v1.Pipeline.Builder.class); + } + + public interface StageOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Pipeline.Stage) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+     * The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + java.util.List getArgsList(); + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + com.google.firestore.v1.Value getArgs(int index); + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + int getArgsCount(); + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + java.util.List getArgsOrBuilderList(); + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index); + + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + int getOptionsCount(); + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + boolean containsOptions(java.lang.String key); + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getOptions(); + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + java.util.Map getOptionsMap(); + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + /* nullable */ + com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key); + } + /** + * + * + *
+   * A single operation within a pipeline.
+   *
+   * A stage is made up of a unique name, and a list of arguments. The exact
+   * number of arguments & types is dependent on the stage type.
+   *
+   * To give an example, the stage `filter(state = "MD")` would be encoded as:
+   *
+   * ```
+   * name: "filter"
+   * args {
+   *   function_value {
+   *     name: "eq"
+   *     args { field_reference_value: "state" }
+   *     args { string_value: "MD" }
+   *   }
+   * }
+   * ```
+   *
+   * See public documentation for the full list.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline.Stage} + */ + public static final class Stage extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Pipeline.Stage) + StageOrBuilder { + private static final long serialVersionUID = 0L; + // Use Stage.newBuilder() to construct. + private Stage(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Stage() { + name_ = ""; + args_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Stage(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.Stage.class, + com.google.firestore.v1.Pipeline.Stage.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+     * The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+     * The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ARGS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List args_; + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public java.util.List getArgsList() { + return args_; + } + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public java.util.List getArgsOrBuilderList() { + return args_; + } + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public int getArgsCount() { + return args_.size(); + } + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getArgs(int index) { + return args_.get(index); + } + /** + * + * + *
+     * Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + return args_.get(index); + } + + public static final int OPTIONS_FIELD_NUMBER = 3; + + private static final class OptionsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField options_; + + private com.google.protobuf.MapField + internalGetOptions() { + if (options_ == null) { + return com.google.protobuf.MapField.emptyMapField(OptionsDefaultEntryHolder.defaultEntry); + } + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().getMap().size(); + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().getMap().containsKey(key); + } + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getMap(); + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+     * Optional named arguments that certain functions may support.
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + for (int i = 0; i < args_.size(); i++) { + output.writeMessage(2, args_.get(i)); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetOptions(), OptionsDefaultEntryHolder.defaultEntry, 3); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + for (int i = 0; i < args_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, args_.get(i)); + } + for (java.util.Map.Entry entry : + internalGetOptions().getMap().entrySet()) { + com.google.protobuf.MapEntry options__ = + OptionsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, options__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Pipeline.Stage)) { + return super.equals(obj); + } + com.google.firestore.v1.Pipeline.Stage other = (com.google.firestore.v1.Pipeline.Stage) obj; + + if (!getName().equals(other.getName())) return false; + if (!getArgsList().equals(other.getArgsList())) return false; + if (!internalGetOptions().equals(other.internalGetOptions())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getArgsCount() > 0) { + hash = (37 * hash) + ARGS_FIELD_NUMBER; + hash = (53 * hash) + getArgsList().hashCode(); + } + if (!internalGetOptions().getMap().isEmpty()) { + hash = (37 * hash) + OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + internalGetOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline.Stage parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Pipeline.Stage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+     * A single operation within a pipeline.
+     *
+     * A stage is made up of a unique name, and a list of arguments. The exact
+     * number of arguments & types is dependent on the stage type.
+     *
+     * To give an example, the stage `filter(state = "MD")` would be encoded as:
+     *
+     * ```
+     * name: "filter"
+     * args {
+     *   function_value {
+     *     name: "eq"
+     *     args { field_reference_value: "state" }
+     *     args { string_value: "MD" }
+     *   }
+     * }
+     * ```
+     *
+     * See public documentation for the full list.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline.Stage} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Pipeline.Stage) + com.google.firestore.v1.Pipeline.StageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetMutableOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.Stage.class, + com.google.firestore.v1.Pipeline.Stage.Builder.class); + } + + // Construct using com.google.firestore.v1.Pipeline.Stage.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + } else { + args_ = null; + argsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableOptions().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage getDefaultInstanceForType() { + return com.google.firestore.v1.Pipeline.Stage.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage build() { + com.google.firestore.v1.Pipeline.Stage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage buildPartial() { + com.google.firestore.v1.Pipeline.Stage result = + new com.google.firestore.v1.Pipeline.Stage(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Pipeline.Stage result) { + if (argsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + args_ = java.util.Collections.unmodifiableList(args_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.args_ = args_; + } else { + result.args_ = argsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Pipeline.Stage result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.options_ = internalGetOptions().build(OptionsDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Pipeline.Stage) { + return mergeFrom((com.google.firestore.v1.Pipeline.Stage) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Pipeline.Stage other) { + if (other == com.google.firestore.v1.Pipeline.Stage.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (argsBuilder_ == null) { + if (!other.args_.isEmpty()) { + if (args_.isEmpty()) { + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureArgsIsMutable(); + args_.addAll(other.args_); + } + onChanged(); + } + } else { + if (!other.args_.isEmpty()) { + if (argsBuilder_.isEmpty()) { + argsBuilder_.dispose(); + argsBuilder_ = null; + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + argsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getArgsFieldBuilder() + : null; + } else { + argsBuilder_.addAllMessages(other.args_); + } + } + } + internalGetMutableOptions().mergeFrom(other.internalGetOptions()); + bitField0_ |= 0x00000004; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Value m = + input.readMessage(com.google.firestore.v1.Value.parser(), extensionRegistry); + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(m); + } else { + argsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + com.google.protobuf.MapEntry + options__ = + input.readMessage( + OptionsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableOptions() + .ensureBuilderMap() + .put(options__.getKey(), options__.getValue()); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+       * The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+       * The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+       * The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+       * The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+       * The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List args_ = + java.util.Collections.emptyList(); + + private void ensureArgsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + args_ = new java.util.ArrayList(args_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + argsBuilder_; + + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public java.util.List getArgsList() { + if (argsBuilder_ == null) { + return java.util.Collections.unmodifiableList(args_); + } else { + return argsBuilder_.getMessageList(); + } + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public int getArgsCount() { + if (argsBuilder_ == null) { + return args_.size(); + } else { + return argsBuilder_.getCount(); + } + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value getArgs(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessage(index); + } + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder setArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.set(index, value); + onChanged(); + } else { + argsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder setArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.set(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(value); + onChanged(); + } else { + argsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(index, value); + onChanged(); + } else { + argsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder addAllArgs( + java.lang.Iterable values) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, args_); + onChanged(); + } else { + argsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder clearArgs() { + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + argsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public Builder removeArgs(int index) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.remove(index); + onChanged(); + } else { + argsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value.Builder getArgsBuilder(int index) { + return getArgsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public java.util.List + getArgsOrBuilderList() { + if (argsBuilder_ != null) { + return argsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(args_); + } + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder() { + return getArgsFieldBuilder().addBuilder(com.google.firestore.v1.Value.getDefaultInstance()); + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder(int index) { + return getArgsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Value.getDefaultInstance()); + } + /** + * + * + *
+       * Ordered list of arguments the given stage expects.
+       * 
+ * + * repeated .google.firestore.v1.Value args = 2; + */ + public java.util.List getArgsBuilderList() { + return getArgsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + getArgsFieldBuilder() { + if (argsBuilder_ == null) { + argsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + args_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + args_ = null; + } + return argsBuilder_; + } + + private static final class OptionsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return OptionsDefaultEntryHolder.defaultEntry; + } + }; + + private static final OptionsConverter optionsConverter = new OptionsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + options_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetOptions() { + if (options_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + return options_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableOptions() { + if (options_ == null) { + options_ = new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + bitField0_ |= 0x00000004; + onChanged(); + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().ensureBuilderMap().size(); + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().ensureBuilderMap().containsKey(key); + } + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getImmutableMap(); + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + return map.containsKey(key) ? optionsConverter.build(map.get(key)) : defaultValue; + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return optionsConverter.build(map.get(key)); + } + + public Builder clearOptions() { + bitField0_ = (bitField0_ & ~0x00000004); + internalGetMutableOptions().clear(); + return this; + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public Builder removeOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableOptions().ensureBuilderMap().remove(key); + return this; + } + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableOptions() { + bitField0_ |= 0x00000004; + return internalGetMutableOptions().ensureMessageMap(); + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public Builder putOptions(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableOptions().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000004; + return this; + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public Builder putAllOptions( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableOptions().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000004; + return this; + } + /** + * + * + *
+       * Optional named arguments that certain functions may support.
+       * 
+ * + * map<string, .google.firestore.v1.Value> options = 3; + */ + public com.google.firestore.v1.Value.Builder putOptionsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableOptions().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Pipeline.Stage) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Pipeline.Stage) + private static final com.google.firestore.v1.Pipeline.Stage DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Pipeline.Stage(); + } + + public static com.google.firestore.v1.Pipeline.Stage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Stage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int STAGES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List stages_; + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + @java.lang.Override + public java.util.List getStagesList() { + return stages_; + } + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + @java.lang.Override + public java.util.List + getStagesOrBuilderList() { + return stages_; + } + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + @java.lang.Override + public int getStagesCount() { + return stages_.size(); + } + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage getStages(int index) { + return stages_.get(index); + } + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline.StageOrBuilder getStagesOrBuilder(int index) { + return stages_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < stages_.size(); i++) { + output.writeMessage(1, stages_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < stages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, stages_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Pipeline)) { + return super.equals(obj); + } + com.google.firestore.v1.Pipeline other = (com.google.firestore.v1.Pipeline) obj; + + if (!getStagesList().equals(other.getStagesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getStagesCount() > 0) { + hash = (37 * hash) + STAGES_FIELD_NUMBER; + hash = (53 * hash) + getStagesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Pipeline parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Pipeline prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A Firestore query represented as an ordered list of operations / stages.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Pipeline) + com.google.firestore.v1.PipelineOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.class, + com.google.firestore.v1.Pipeline.Builder.class); + } + + // Construct using com.google.firestore.v1.Pipeline.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (stagesBuilder_ == null) { + stages_ = java.util.Collections.emptyList(); + } else { + stages_ = null; + stagesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline getDefaultInstanceForType() { + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline build() { + com.google.firestore.v1.Pipeline result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline buildPartial() { + com.google.firestore.v1.Pipeline result = new com.google.firestore.v1.Pipeline(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Pipeline result) { + if (stagesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + stages_ = java.util.Collections.unmodifiableList(stages_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.stages_ = stages_; + } else { + result.stages_ = stagesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Pipeline result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Pipeline) { + return mergeFrom((com.google.firestore.v1.Pipeline) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Pipeline other) { + if (other == com.google.firestore.v1.Pipeline.getDefaultInstance()) return this; + if (stagesBuilder_ == null) { + if (!other.stages_.isEmpty()) { + if (stages_.isEmpty()) { + stages_ = other.stages_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureStagesIsMutable(); + stages_.addAll(other.stages_); + } + onChanged(); + } + } else { + if (!other.stages_.isEmpty()) { + if (stagesBuilder_.isEmpty()) { + stagesBuilder_.dispose(); + stagesBuilder_ = null; + stages_ = other.stages_; + bitField0_ = (bitField0_ & ~0x00000001); + stagesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getStagesFieldBuilder() + : null; + } else { + stagesBuilder_.addAllMessages(other.stages_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.Pipeline.Stage m = + input.readMessage( + com.google.firestore.v1.Pipeline.Stage.parser(), extensionRegistry); + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.add(m); + } else { + stagesBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List stages_ = + java.util.Collections.emptyList(); + + private void ensureStagesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + stages_ = new java.util.ArrayList(stages_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Pipeline.Stage, + com.google.firestore.v1.Pipeline.Stage.Builder, + com.google.firestore.v1.Pipeline.StageOrBuilder> + stagesBuilder_; + + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public java.util.List getStagesList() { + if (stagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(stages_); + } else { + return stagesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public int getStagesCount() { + if (stagesBuilder_ == null) { + return stages_.size(); + } else { + return stagesBuilder_.getCount(); + } + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public com.google.firestore.v1.Pipeline.Stage getStages(int index) { + if (stagesBuilder_ == null) { + return stages_.get(index); + } else { + return stagesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder setStages(int index, com.google.firestore.v1.Pipeline.Stage value) { + if (stagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStagesIsMutable(); + stages_.set(index, value); + onChanged(); + } else { + stagesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder setStages( + int index, com.google.firestore.v1.Pipeline.Stage.Builder builderForValue) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.set(index, builderForValue.build()); + onChanged(); + } else { + stagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder addStages(com.google.firestore.v1.Pipeline.Stage value) { + if (stagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStagesIsMutable(); + stages_.add(value); + onChanged(); + } else { + stagesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder addStages(int index, com.google.firestore.v1.Pipeline.Stage value) { + if (stagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStagesIsMutable(); + stages_.add(index, value); + onChanged(); + } else { + stagesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder addStages(com.google.firestore.v1.Pipeline.Stage.Builder builderForValue) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.add(builderForValue.build()); + onChanged(); + } else { + stagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder addStages( + int index, com.google.firestore.v1.Pipeline.Stage.Builder builderForValue) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.add(index, builderForValue.build()); + onChanged(); + } else { + stagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder addAllStages( + java.lang.Iterable values) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, stages_); + onChanged(); + } else { + stagesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder clearStages() { + if (stagesBuilder_ == null) { + stages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + stagesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public Builder removeStages(int index) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.remove(index); + onChanged(); + } else { + stagesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public com.google.firestore.v1.Pipeline.Stage.Builder getStagesBuilder(int index) { + return getStagesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public com.google.firestore.v1.Pipeline.StageOrBuilder getStagesOrBuilder(int index) { + if (stagesBuilder_ == null) { + return stages_.get(index); + } else { + return stagesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public java.util.List + getStagesOrBuilderList() { + if (stagesBuilder_ != null) { + return stagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(stages_); + } + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public com.google.firestore.v1.Pipeline.Stage.Builder addStagesBuilder() { + return getStagesFieldBuilder() + .addBuilder(com.google.firestore.v1.Pipeline.Stage.getDefaultInstance()); + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public com.google.firestore.v1.Pipeline.Stage.Builder addStagesBuilder(int index) { + return getStagesFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Pipeline.Stage.getDefaultInstance()); + } + /** + * + * + *
+     * Ordered list of stages to evaluate.
+     * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + public java.util.List getStagesBuilderList() { + return getStagesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Pipeline.Stage, + com.google.firestore.v1.Pipeline.Stage.Builder, + com.google.firestore.v1.Pipeline.StageOrBuilder> + getStagesFieldBuilder() { + if (stagesBuilder_ == null) { + stagesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.firestore.v1.Pipeline.Stage, + com.google.firestore.v1.Pipeline.Stage.Builder, + com.google.firestore.v1.Pipeline.StageOrBuilder>( + stages_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + stages_ = null; + } + return stagesBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Pipeline) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Pipeline) + private static final com.google.firestore.v1.Pipeline DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Pipeline(); + } + + public static com.google.firestore.v1.Pipeline getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Pipeline parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineOrBuilder.java new file mode 100644 index 000000000..3373b5e73 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineOrBuilder.java @@ -0,0 +1,78 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/document.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface PipelineOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Pipeline) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + java.util.List getStagesList(); + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + com.google.firestore.v1.Pipeline.Stage getStages(int index); + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + int getStagesCount(); + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + java.util.List + getStagesOrBuilderList(); + /** + * + * + *
+   * Ordered list of stages to evaluate.
+   * 
+ * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1; + */ + com.google.firestore.v1.Pipeline.StageOrBuilder getStagesOrBuilder(int index); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineProto.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineProto.java new file mode 100644 index 000000000..816d3fe3f --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineProto.java @@ -0,0 +1,87 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/pipeline.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public final class PipelineProto { + private PipelineProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredPipeline_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\"google/firestore/v1/pipeline.proto\022\023go" + + "ogle.firestore.v1\032\"google/firestore/v1/d" + + "ocument.proto\"\330\001\n\022StructuredPipeline\022/\n\010" + + "pipeline\030\001 \001(\0132\035.google.firestore.v1.Pip" + + "eline\022E\n\007options\030\002 \003(\01324.google.firestor" + + "e.v1.StructuredPipeline.OptionsEntry\032J\n\014" + + "OptionsEntry\022\013\n\003key\030\001 \001(\t\022)\n\005value\030\002 \001(\013" + + "2\032.google.firestore.v1.Value:\0028\001B\210\001\n\027com" + + ".google.firestore.v1B\rPipelineProtoP\001\242\002\004" + + "GCFS\252\002\031Google.Cloud.Firestore.V1\312\002\031Googl" + + "e\\Cloud\\Firestore\\V1\352\002\034Google::Cloud::Fi" + + "restore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.firestore.v1.DocumentProto.getDescriptor(), + }); + internal_static_google_firestore_v1_StructuredPipeline_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredPipeline_descriptor, + new java.lang.String[] { + "Pipeline", "Options", + }); + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor = + internal_static_google_firestore_v1_StructuredPipeline_descriptor.getNestedTypes().get(0); + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + com.google.firestore.v1.DocumentProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummary.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummary.java new file mode 100644 index 000000000..43bafcd6f --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummary.java @@ -0,0 +1,1019 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * Planning phase information for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.PlanSummary} + */ +public final class PlanSummary extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.PlanSummary) + PlanSummaryOrBuilder { + private static final long serialVersionUID = 0L; + // Use PlanSummary.newBuilder() to construct. + private PlanSummary(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PlanSummary() { + indexesUsed_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PlanSummary(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PlanSummary.class, + com.google.firestore.v1.PlanSummary.Builder.class); + } + + public static final int INDEXES_USED_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List indexesUsed_; + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public java.util.List getIndexesUsedList() { + return indexesUsed_; + } + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public java.util.List + getIndexesUsedOrBuilderList() { + return indexesUsed_; + } + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public int getIndexesUsedCount() { + return indexesUsed_.size(); + } + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public com.google.protobuf.Struct getIndexesUsed(int index) { + return indexesUsed_.get(index); + } + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public com.google.protobuf.StructOrBuilder getIndexesUsedOrBuilder(int index) { + return indexesUsed_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < indexesUsed_.size(); i++) { + output.writeMessage(1, indexesUsed_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < indexesUsed_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, indexesUsed_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.PlanSummary)) { + return super.equals(obj); + } + com.google.firestore.v1.PlanSummary other = (com.google.firestore.v1.PlanSummary) obj; + + if (!getIndexesUsedList().equals(other.getIndexesUsedList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getIndexesUsedCount() > 0) { + hash = (37 * hash) + INDEXES_USED_FIELD_NUMBER; + hash = (53 * hash) + getIndexesUsedList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.PlanSummary parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PlanSummary parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.PlanSummary prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.PlanSummary} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.PlanSummary) + com.google.firestore.v1.PlanSummaryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PlanSummary.class, + com.google.firestore.v1.PlanSummary.Builder.class); + } + + // Construct using com.google.firestore.v1.PlanSummary.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (indexesUsedBuilder_ == null) { + indexesUsed_ = java.util.Collections.emptyList(); + } else { + indexesUsed_ = null; + indexesUsedBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary getDefaultInstanceForType() { + return com.google.firestore.v1.PlanSummary.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary build() { + com.google.firestore.v1.PlanSummary result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary buildPartial() { + com.google.firestore.v1.PlanSummary result = new com.google.firestore.v1.PlanSummary(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.PlanSummary result) { + if (indexesUsedBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + indexesUsed_ = java.util.Collections.unmodifiableList(indexesUsed_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.indexesUsed_ = indexesUsed_; + } else { + result.indexesUsed_ = indexesUsedBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.PlanSummary result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.PlanSummary) { + return mergeFrom((com.google.firestore.v1.PlanSummary) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.PlanSummary other) { + if (other == com.google.firestore.v1.PlanSummary.getDefaultInstance()) return this; + if (indexesUsedBuilder_ == null) { + if (!other.indexesUsed_.isEmpty()) { + if (indexesUsed_.isEmpty()) { + indexesUsed_ = other.indexesUsed_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIndexesUsedIsMutable(); + indexesUsed_.addAll(other.indexesUsed_); + } + onChanged(); + } + } else { + if (!other.indexesUsed_.isEmpty()) { + if (indexesUsedBuilder_.isEmpty()) { + indexesUsedBuilder_.dispose(); + indexesUsedBuilder_ = null; + indexesUsed_ = other.indexesUsed_; + bitField0_ = (bitField0_ & ~0x00000001); + indexesUsedBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getIndexesUsedFieldBuilder() + : null; + } else { + indexesUsedBuilder_.addAllMessages(other.indexesUsed_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.protobuf.Struct m = + input.readMessage(com.google.protobuf.Struct.parser(), extensionRegistry); + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.add(m); + } else { + indexesUsedBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List indexesUsed_ = + java.util.Collections.emptyList(); + + private void ensureIndexesUsedIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + indexesUsed_ = new java.util.ArrayList(indexesUsed_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + indexesUsedBuilder_; + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public java.util.List getIndexesUsedList() { + if (indexesUsedBuilder_ == null) { + return java.util.Collections.unmodifiableList(indexesUsed_); + } else { + return indexesUsedBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public int getIndexesUsedCount() { + if (indexesUsedBuilder_ == null) { + return indexesUsed_.size(); + } else { + return indexesUsedBuilder_.getCount(); + } + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct getIndexesUsed(int index) { + if (indexesUsedBuilder_ == null) { + return indexesUsed_.get(index); + } else { + return indexesUsedBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder setIndexesUsed(int index, com.google.protobuf.Struct value) { + if (indexesUsedBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesUsedIsMutable(); + indexesUsed_.set(index, value); + onChanged(); + } else { + indexesUsedBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder setIndexesUsed(int index, com.google.protobuf.Struct.Builder builderForValue) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.set(index, builderForValue.build()); + onChanged(); + } else { + indexesUsedBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(com.google.protobuf.Struct value) { + if (indexesUsedBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesUsedIsMutable(); + indexesUsed_.add(value); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(int index, com.google.protobuf.Struct value) { + if (indexesUsedBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesUsedIsMutable(); + indexesUsed_.add(index, value); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(com.google.protobuf.Struct.Builder builderForValue) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.add(builderForValue.build()); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(int index, com.google.protobuf.Struct.Builder builderForValue) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.add(index, builderForValue.build()); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addAllIndexesUsed( + java.lang.Iterable values) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, indexesUsed_); + onChanged(); + } else { + indexesUsedBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder clearIndexesUsed() { + if (indexesUsedBuilder_ == null) { + indexesUsed_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + indexesUsedBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder removeIndexesUsed(int index) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.remove(index); + onChanged(); + } else { + indexesUsedBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct.Builder getIndexesUsedBuilder(int index) { + return getIndexesUsedFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.StructOrBuilder getIndexesUsedOrBuilder(int index) { + if (indexesUsedBuilder_ == null) { + return indexesUsed_.get(index); + } else { + return indexesUsedBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public java.util.List + getIndexesUsedOrBuilderList() { + if (indexesUsedBuilder_ != null) { + return indexesUsedBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(indexesUsed_); + } + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct.Builder addIndexesUsedBuilder() { + return getIndexesUsedFieldBuilder() + .addBuilder(com.google.protobuf.Struct.getDefaultInstance()); + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct.Builder addIndexesUsedBuilder(int index) { + return getIndexesUsedFieldBuilder() + .addBuilder(index, com.google.protobuf.Struct.getDefaultInstance()); + } + /** + * + * + *
+     * The indexes selected for the query. For example:
+     *  [
+     *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     *  ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public java.util.List getIndexesUsedBuilderList() { + return getIndexesUsedFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + getIndexesUsedFieldBuilder() { + if (indexesUsedBuilder_ == null) { + indexesUsedBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder>( + indexesUsed_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + indexesUsed_ = null; + } + return indexesUsedBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.PlanSummary) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.PlanSummary) + private static final com.google.firestore.v1.PlanSummary DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.PlanSummary(); + } + + public static com.google.firestore.v1.PlanSummary getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PlanSummary parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummaryOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummaryOrBuilder.java new file mode 100644 index 000000000..4f3c0d8f3 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummaryOrBuilder.java @@ -0,0 +1,97 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface PlanSummaryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.PlanSummary) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + java.util.List getIndexesUsedList(); + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + com.google.protobuf.Struct getIndexesUsed(int index); + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + int getIndexesUsedCount(); + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + java.util.List getIndexesUsedOrBuilderList(); + /** + * + * + *
+   * The indexes selected for the query. For example:
+   *  [
+   *    {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   *    {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   *  ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + com.google.protobuf.StructOrBuilder getIndexesUsedOrBuilder(int index); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProfileProto.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProfileProto.java new file mode 100644 index 000000000..e1195e5d7 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProfileProto.java @@ -0,0 +1,128 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public final class QueryProfileProto { + private QueryProfileProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExplainOptions_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExplainMetrics_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_PlanSummary_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExecutionStats_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\'google/firestore/v1/query_profile.prot" + + "o\022\023google.firestore.v1\032\037google/api/field" + + "_behavior.proto\032\036google/protobuf/duratio" + + "n.proto\032\034google/protobuf/struct.proto\"&\n" + + "\016ExplainOptions\022\024\n\007analyze\030\001 \001(\010B\003\340A\001\"\206\001" + + "\n\016ExplainMetrics\0226\n\014plan_summary\030\001 \001(\0132 " + + ".google.firestore.v1.PlanSummary\022<\n\017exec" + + "ution_stats\030\002 \001(\0132#.google.firestore.v1." + + "ExecutionStats\"<\n\013PlanSummary\022-\n\014indexes" + + "_used\030\001 \003(\0132\027.google.protobuf.Struct\"\250\001\n" + + "\016ExecutionStats\022\030\n\020results_returned\030\001 \001(" + + "\003\0225\n\022execution_duration\030\003 \001(\0132\031.google.p" + + "rotobuf.Duration\022\027\n\017read_operations\030\004 \001(" + + "\003\022,\n\013debug_stats\030\005 \001(\0132\027.google.protobuf" + + ".StructB\311\001\n\027com.google.firestore.v1B\021Que" + + "ryProfileProtoP\001Z;cloud.google.com/go/fi" + + "restore/apiv1/firestorepb;firestorepb\242\002\004" + + "GCFS\252\002\031Google.Cloud.Firestore.V1\312\002\031Googl" + + "e\\Cloud\\Firestore\\V1\352\002\034Google::Cloud::Fi" + + "restore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.protobuf.DurationProto.getDescriptor(), + com.google.protobuf.StructProto.getDescriptor(), + }); + internal_static_google_firestore_v1_ExplainOptions_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_ExplainOptions_descriptor, + new java.lang.String[] { + "Analyze", + }); + internal_static_google_firestore_v1_ExplainMetrics_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_ExplainMetrics_descriptor, + new java.lang.String[] { + "PlanSummary", "ExecutionStats", + }); + internal_static_google_firestore_v1_PlanSummary_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_PlanSummary_descriptor, + new java.lang.String[] { + "IndexesUsed", + }); + internal_static_google_firestore_v1_ExecutionStats_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_ExecutionStats_descriptor, + new java.lang.String[] { + "ResultsReturned", "ExecutionDuration", "ReadOperations", "DebugStats", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.protobuf.DurationProto.getDescriptor(); + com.google.protobuf.StructProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProto.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProto.java index a54bc4ef4..b87474e84 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProto.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProto.java @@ -64,6 +64,10 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_firestore_v1_StructuredQuery_Projection_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_firestore_v1_StructuredQuery_Projection_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable @@ -100,7 +104,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "\n\037google/firestore/v1/query.proto\022\023googl" + "e.firestore.v1\032\037google/api/field_behavio" + "r.proto\032\"google/firestore/v1/document.pr" - + "oto\032\036google/protobuf/wrappers.proto\"\276\017\n\017" + + "oto\032\036google/protobuf/wrappers.proto\"\225\023\n\017" + "StructuredQuery\022?\n\006select\030\001 \001(\0132/.google" + ".firestore.v1.StructuredQuery.Projection" + "\022E\n\004from\030\002 \003(\01327.google.firestore.v1.Str" @@ -111,70 +115,82 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "rt_at\030\007 \001(\0132\033.google.firestore.v1.Cursor" + "\022+\n\006end_at\030\010 \001(\0132\033.google.firestore.v1.C" + "ursor\022\016\n\006offset\030\006 \001(\005\022*\n\005limit\030\005 \001(\0132\033.g" - + "oogle.protobuf.Int32Value\032D\n\022CollectionS" - + "elector\022\025\n\rcollection_id\030\002 \001(\t\022\027\n\017all_de" - + "scendants\030\003 \001(\010\032\375\001\n\006Filter\022P\n\020composite_" - + "filter\030\001 \001(\01324.google.firestore.v1.Struc" - + "turedQuery.CompositeFilterH\000\022H\n\014field_fi" - + "lter\030\002 \001(\01320.google.firestore.v1.Structu" - + "redQuery.FieldFilterH\000\022H\n\014unary_filter\030\003" - + " \001(\01320.google.firestore.v1.StructuredQue" - + "ry.UnaryFilterH\000B\r\n\013filter_type\032\321\001\n\017Comp" - + "ositeFilter\022I\n\002op\030\001 \001(\0162=.google.firesto" - + "re.v1.StructuredQuery.CompositeFilter.Op" - + "erator\022<\n\007filters\030\002 \003(\0132+.google.firesto" - + "re.v1.StructuredQuery.Filter\"5\n\010Operator" - + "\022\030\n\024OPERATOR_UNSPECIFIED\020\000\022\007\n\003AND\020\001\022\006\n\002O" - + "R\020\002\032\230\003\n\013FieldFilter\022B\n\005field\030\001 \001(\01323.goo" - + "gle.firestore.v1.StructuredQuery.FieldRe" - + "ference\022E\n\002op\030\002 \001(\01629.google.firestore.v" - + "1.StructuredQuery.FieldFilter.Operator\022)" - + "\n\005value\030\003 \001(\0132\032.google.firestore.v1.Valu" - + "e\"\322\001\n\010Operator\022\030\n\024OPERATOR_UNSPECIFIED\020\000" - + "\022\r\n\tLESS_THAN\020\001\022\026\n\022LESS_THAN_OR_EQUAL\020\002\022" - + "\020\n\014GREATER_THAN\020\003\022\031\n\025GREATER_THAN_OR_EQU" - + "AL\020\004\022\t\n\005EQUAL\020\005\022\r\n\tNOT_EQUAL\020\006\022\022\n\016ARRAY_" - + "CONTAINS\020\007\022\006\n\002IN\020\010\022\026\n\022ARRAY_CONTAINS_ANY" - + "\020\t\022\n\n\006NOT_IN\020\n\032\212\002\n\013UnaryFilter\022E\n\002op\030\001 \001" - + "(\01629.google.firestore.v1.StructuredQuery" - + ".UnaryFilter.Operator\022D\n\005field\030\002 \001(\01323.g" + + "oogle.protobuf.Int32Value\022K\n\014find_neares" + + "t\030\t \001(\01320.google.firestore.v1.Structured" + + "Query.FindNearestB\003\340A\001\032D\n\022CollectionSele" + + "ctor\022\025\n\rcollection_id\030\002 \001(\t\022\027\n\017all_desce" + + "ndants\030\003 \001(\010\032\375\001\n\006Filter\022P\n\020composite_fil" + + "ter\030\001 \001(\01324.google.firestore.v1.Structur" + + "edQuery.CompositeFilterH\000\022H\n\014field_filte" + + "r\030\002 \001(\01320.google.firestore.v1.Structured" + + "Query.FieldFilterH\000\022H\n\014unary_filter\030\003 \001(" + + "\01320.google.firestore.v1.StructuredQuery." + + "UnaryFilterH\000B\r\n\013filter_type\032\321\001\n\017Composi" + + "teFilter\022I\n\002op\030\001 \001(\0162=.google.firestore." + + "v1.StructuredQuery.CompositeFilter.Opera" + + "tor\022<\n\007filters\030\002 \003(\0132+.google.firestore." + + "v1.StructuredQuery.Filter\"5\n\010Operator\022\030\n" + + "\024OPERATOR_UNSPECIFIED\020\000\022\007\n\003AND\020\001\022\006\n\002OR\020\002" + + "\032\230\003\n\013FieldFilter\022B\n\005field\030\001 \001(\01323.google" + + ".firestore.v1.StructuredQuery.FieldRefer" + + "ence\022E\n\002op\030\002 \001(\01629.google.firestore.v1.S" + + "tructuredQuery.FieldFilter.Operator\022)\n\005v" + + "alue\030\003 \001(\0132\032.google.firestore.v1.Value\"\322" + + "\001\n\010Operator\022\030\n\024OPERATOR_UNSPECIFIED\020\000\022\r\n" + + "\tLESS_THAN\020\001\022\026\n\022LESS_THAN_OR_EQUAL\020\002\022\020\n\014" + + "GREATER_THAN\020\003\022\031\n\025GREATER_THAN_OR_EQUAL\020" + + "\004\022\t\n\005EQUAL\020\005\022\r\n\tNOT_EQUAL\020\006\022\022\n\016ARRAY_CON" + + "TAINS\020\007\022\006\n\002IN\020\010\022\026\n\022ARRAY_CONTAINS_ANY\020\t\022" + + "\n\n\006NOT_IN\020\n\032\212\002\n\013UnaryFilter\022E\n\002op\030\001 \001(\0162" + + "9.google.firestore.v1.StructuredQuery.Un" + + "aryFilter.Operator\022D\n\005field\030\002 \001(\01323.goog" + + "le.firestore.v1.StructuredQuery.FieldRef" + + "erenceH\000\"^\n\010Operator\022\030\n\024OPERATOR_UNSPECI" + + "FIED\020\000\022\n\n\006IS_NAN\020\002\022\013\n\007IS_NULL\020\003\022\016\n\nIS_NO" + + "T_NAN\020\004\022\017\n\013IS_NOT_NULL\020\005B\016\n\014operand_type" + + "\032\216\001\n\005Order\022B\n\005field\030\001 \001(\01323.google.fires" + + "tore.v1.StructuredQuery.FieldReference\022A" + + "\n\tdirection\030\002 \001(\0162..google.firestore.v1." + + "StructuredQuery.Direction\032$\n\016FieldRefere" + + "nce\022\022\n\nfield_path\030\002 \001(\t\032Q\n\nProjection\022C\n" + + "\006fields\030\002 \003(\01323.google.firestore.v1.Stru" + + "cturedQuery.FieldReference\032\207\003\n\013FindNeare" + + "st\022N\n\014vector_field\030\001 \001(\01323.google.firest" + + "ore.v1.StructuredQuery.FieldReferenceB\003\340" + + "A\002\0225\n\014query_vector\030\002 \001(\0132\032.google.firest" + + "ore.v1.ValueB\003\340A\002\022_\n\020distance_measure\030\003 " + + "\001(\0162@.google.firestore.v1.StructuredQuer" + + "y.FindNearest.DistanceMeasureB\003\340A\002\022/\n\005li" + + "mit\030\004 \001(\0132\033.google.protobuf.Int32ValueB\003" + + "\340A\002\"_\n\017DistanceMeasure\022 \n\034DISTANCE_MEASU" + + "RE_UNSPECIFIED\020\000\022\r\n\tEUCLIDEAN\020\001\022\n\n\006COSIN" + + "E\020\002\022\017\n\013DOT_PRODUCT\020\003\"E\n\tDirection\022\031\n\025DIR" + + "ECTION_UNSPECIFIED\020\000\022\r\n\tASCENDING\020\001\022\016\n\nD" + + "ESCENDING\020\002\"\270\005\n\032StructuredAggregationQue" + + "ry\022@\n\020structured_query\030\001 \001(\0132$.google.fi" + + "restore.v1.StructuredQueryH\000\022V\n\014aggregat" + + "ions\030\003 \003(\0132;.google.firestore.v1.Structu" + + "redAggregationQuery.AggregationB\003\340A\001\032\361\003\n" + + "\013Aggregation\022R\n\005count\030\001 \001(\0132A.google.fir" + + "estore.v1.StructuredAggregationQuery.Agg" + + "regation.CountH\000\022N\n\003sum\030\002 \001(\0132?.google.f" + + "irestore.v1.StructuredAggregationQuery.A" + + "ggregation.SumH\000\022N\n\003avg\030\003 \001(\0132?.google.f" + + "irestore.v1.StructuredAggregationQuery.A" + + "ggregation.AvgH\000\022\022\n\005alias\030\007 \001(\tB\003\340A\001\0328\n\005" + + "Count\022/\n\005up_to\030\001 \001(\0132\033.google.protobuf.I" + + "nt64ValueB\003\340A\001\032I\n\003Sum\022B\n\005field\030\001 \001(\01323.g" + "oogle.firestore.v1.StructuredQuery.Field" - + "ReferenceH\000\"^\n\010Operator\022\030\n\024OPERATOR_UNSP" - + "ECIFIED\020\000\022\n\n\006IS_NAN\020\002\022\013\n\007IS_NULL\020\003\022\016\n\nIS" - + "_NOT_NAN\020\004\022\017\n\013IS_NOT_NULL\020\005B\016\n\014operand_t" - + "ype\032\216\001\n\005Order\022B\n\005field\030\001 \001(\01323.google.fi" - + "restore.v1.StructuredQuery.FieldReferenc" - + "e\022A\n\tdirection\030\002 \001(\0162..google.firestore." - + "v1.StructuredQuery.Direction\032$\n\016FieldRef" - + "erence\022\022\n\nfield_path\030\002 \001(\t\032Q\n\nProjection" - + "\022C\n\006fields\030\002 \003(\01323.google.firestore.v1.S" - + "tructuredQuery.FieldReference\"E\n\tDirecti" - + "on\022\031\n\025DIRECTION_UNSPECIFIED\020\000\022\r\n\tASCENDI" - + "NG\020\001\022\016\n\nDESCENDING\020\002\"\273\005\n\032StructuredAggre" - + "gationQuery\022@\n\020structured_query\030\001 \001(\0132$." - + "google.firestore.v1.StructuredQueryH\000\022W\n" - + "\014aggregations\030\003 \003(\0132;.google.firestore.v" - + "1.StructuredAggregationQuery.Aggregation" - + "B\004\342A\001\001\032\363\003\n\013Aggregation\022R\n\005count\030\001 \001(\0132A." - + "google.firestore.v1.StructuredAggregatio" - + "nQuery.Aggregation.CountH\000\022N\n\003sum\030\002 \001(\0132" - + "?.google.firestore.v1.StructuredAggregat" - + "ionQuery.Aggregation.SumH\000\022N\n\003avg\030\003 \001(\0132" - + "?.google.firestore.v1.StructuredAggregat" - + "ionQuery.Aggregation.AvgH\000\022\023\n\005alias\030\007 \001(" - + "\tB\004\342A\001\001\0329\n\005Count\0220\n\005up_to\030\001 \001(\0132\033.google" - + ".protobuf.Int64ValueB\004\342A\001\001\032I\n\003Sum\022B\n\005fie" - + "ld\030\001 \001(\01323.google.firestore.v1.Structure" - + "dQuery.FieldReference\032I\n\003Avg\022B\n\005field\030\001 " - + "\001(\01323.google.firestore.v1.StructuredQuer" - + "y.FieldReferenceB\n\n\010operatorB\014\n\nquery_ty" - + "pe\"D\n\006Cursor\022*\n\006values\030\001 \003(\0132\032.google.fi" - + "restore.v1.Value\022\016\n\006before\030\002 \001(\010B\302\001\n\027com" - + ".google.firestore.v1B\nQueryProtoP\001Z;clou" - + "d.google.com/go/firestore/apiv1/firestor" - + "epb;firestorepb\242\002\004GCFS\252\002\031Google.Cloud.Fi" - + "restore.V1\312\002\031Google\\Cloud\\Firestore\\V1\352\002" - + "\034Google::Cloud::Firestore::V1b\006proto3" + + "Reference\032I\n\003Avg\022B\n\005field\030\001 \001(\01323.google" + + ".firestore.v1.StructuredQuery.FieldRefer" + + "enceB\n\n\010operatorB\014\n\nquery_type\"D\n\006Cursor" + + "\022*\n\006values\030\001 \003(\0132\032.google.firestore.v1.V" + + "alue\022\016\n\006before\030\002 \001(\010B\302\001\n\027com.google.fire" + + "store.v1B\nQueryProtoP\001Z;cloud.google.com" + + "/go/firestore/apiv1/firestorepb;firestor" + + "epb\242\002\004GCFS\252\002\031Google.Cloud.Firestore.V1\312\002" + + "\031Google\\Cloud\\Firestore\\V1\352\002\034Google::Clo" + + "ud::Firestore::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -190,7 +206,15 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_firestore_v1_StructuredQuery_descriptor, new java.lang.String[] { - "Select", "From", "Where", "OrderBy", "StartAt", "EndAt", "Offset", "Limit", + "Select", + "From", + "Where", + "OrderBy", + "StartAt", + "EndAt", + "Offset", + "Limit", + "FindNearest", }); internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_descriptor = internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedTypes().get(0); @@ -256,6 +280,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "Fields", }); + internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedTypes().get(8); + internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor, + new java.lang.String[] { + "VectorField", "QueryVector", "DistanceMeasure", "Limit", + }); internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_google_firestore_v1_StructuredAggregationQuery_fieldAccessorTable = diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipeline.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipeline.java new file mode 100644 index 000000000..860bd4e1c --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipeline.java @@ -0,0 +1,1177 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/pipeline.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +/** + * + * + *
+ * A Firestore query represented as an ordered list of operations / stages.
+ *
+ * This is considered the top-level function which plans & executes a query.
+ * It is logically equivalent to `query(stages, options)`, but prevents the
+ * client from having to build a function wrapper.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredPipeline} + */ +public final class StructuredPipeline extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredPipeline) + StructuredPipelineOrBuilder { + private static final long serialVersionUID = 0L; + // Use StructuredPipeline.newBuilder() to construct. + private StructuredPipeline(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private StructuredPipeline() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new StructuredPipeline(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredPipeline.class, + com.google.firestore.v1.StructuredPipeline.Builder.class); + } + + private int bitField0_; + public static final int PIPELINE_FIELD_NUMBER = 1; + private com.google.firestore.v1.Pipeline pipeline_; + /** + * + * + *
+   * The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + * + * @return Whether the pipeline field is set. + */ + @java.lang.Override + public boolean hasPipeline() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + * + * @return The pipeline. + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline getPipeline() { + return pipeline_ == null ? com.google.firestore.v1.Pipeline.getDefaultInstance() : pipeline_; + } + /** + * + * + *
+   * The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + @java.lang.Override + public com.google.firestore.v1.PipelineOrBuilder getPipelineOrBuilder() { + return pipeline_ == null ? com.google.firestore.v1.Pipeline.getDefaultInstance() : pipeline_; + } + + public static final int OPTIONS_FIELD_NUMBER = 2; + + private static final class OptionsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField options_; + + private com.google.protobuf.MapField + internalGetOptions() { + if (options_ == null) { + return com.google.protobuf.MapField.emptyMapField(OptionsDefaultEntryHolder.defaultEntry); + } + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().getMap().size(); + } + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().getMap().containsKey(key); + } + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getMap(); + } + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getPipeline()); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetOptions(), OptionsDefaultEntryHolder.defaultEntry, 2); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getPipeline()); + } + for (java.util.Map.Entry entry : + internalGetOptions().getMap().entrySet()) { + com.google.protobuf.MapEntry options__ = + OptionsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, options__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredPipeline)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredPipeline other = + (com.google.firestore.v1.StructuredPipeline) obj; + + if (hasPipeline() != other.hasPipeline()) return false; + if (hasPipeline()) { + if (!getPipeline().equals(other.getPipeline())) return false; + } + if (!internalGetOptions().equals(other.internalGetOptions())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasPipeline()) { + hash = (37 * hash) + PIPELINE_FIELD_NUMBER; + hash = (53 * hash) + getPipeline().hashCode(); + } + if (!internalGetOptions().getMap().isEmpty()) { + hash = (37 * hash) + OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + internalGetOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredPipeline parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.StructuredPipeline prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A Firestore query represented as an ordered list of operations / stages.
+   *
+   * This is considered the top-level function which plans & executes a query.
+   * It is logically equivalent to `query(stages, options)`, but prevents the
+   * client from having to build a function wrapper.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredPipeline} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredPipeline) + com.google.firestore.v1.StructuredPipelineOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetMutableOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredPipeline.class, + com.google.firestore.v1.StructuredPipeline.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredPipeline.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPipelineFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + pipeline_ = null; + if (pipelineBuilder_ != null) { + pipelineBuilder_.dispose(); + pipelineBuilder_ = null; + } + internalGetMutableOptions().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline build() { + com.google.firestore.v1.StructuredPipeline result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline buildPartial() { + com.google.firestore.v1.StructuredPipeline result = + new com.google.firestore.v1.StructuredPipeline(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredPipeline result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.pipeline_ = pipelineBuilder_ == null ? pipeline_ : pipelineBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.options_ = internalGetOptions().build(OptionsDefaultEntryHolder.defaultEntry); + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredPipeline) { + return mergeFrom((com.google.firestore.v1.StructuredPipeline) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredPipeline other) { + if (other == com.google.firestore.v1.StructuredPipeline.getDefaultInstance()) return this; + if (other.hasPipeline()) { + mergePipeline(other.getPipeline()); + } + internalGetMutableOptions().mergeFrom(other.internalGetOptions()); + bitField0_ |= 0x00000002; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(getPipelineFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.protobuf.MapEntry + options__ = + input.readMessage( + OptionsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableOptions() + .ensureBuilderMap() + .put(options__.getKey(), options__.getValue()); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.Pipeline pipeline_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + pipelineBuilder_; + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + * + * @return Whether the pipeline field is set. + */ + public boolean hasPipeline() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + * + * @return The pipeline. + */ + public com.google.firestore.v1.Pipeline getPipeline() { + if (pipelineBuilder_ == null) { + return pipeline_ == null + ? com.google.firestore.v1.Pipeline.getDefaultInstance() + : pipeline_; + } else { + return pipelineBuilder_.getMessage(); + } + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + public Builder setPipeline(com.google.firestore.v1.Pipeline value) { + if (pipelineBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pipeline_ = value; + } else { + pipelineBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + public Builder setPipeline(com.google.firestore.v1.Pipeline.Builder builderForValue) { + if (pipelineBuilder_ == null) { + pipeline_ = builderForValue.build(); + } else { + pipelineBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + public Builder mergePipeline(com.google.firestore.v1.Pipeline value) { + if (pipelineBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && pipeline_ != null + && pipeline_ != com.google.firestore.v1.Pipeline.getDefaultInstance()) { + getPipelineBuilder().mergeFrom(value); + } else { + pipeline_ = value; + } + } else { + pipelineBuilder_.mergeFrom(value); + } + if (pipeline_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + public Builder clearPipeline() { + bitField0_ = (bitField0_ & ~0x00000001); + pipeline_ = null; + if (pipelineBuilder_ != null) { + pipelineBuilder_.dispose(); + pipelineBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + public com.google.firestore.v1.Pipeline.Builder getPipelineBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPipelineFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + public com.google.firestore.v1.PipelineOrBuilder getPipelineOrBuilder() { + if (pipelineBuilder_ != null) { + return pipelineBuilder_.getMessageOrBuilder(); + } else { + return pipeline_ == null + ? com.google.firestore.v1.Pipeline.getDefaultInstance() + : pipeline_; + } + } + /** + * + * + *
+     * The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + getPipelineFieldBuilder() { + if (pipelineBuilder_ == null) { + pipelineBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder>( + getPipeline(), getParentForChildren(), isClean()); + pipeline_ = null; + } + return pipelineBuilder_; + } + + private static final class OptionsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return OptionsDefaultEntryHolder.defaultEntry; + } + }; + + private static final OptionsConverter optionsConverter = new OptionsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + options_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetOptions() { + if (options_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + return options_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableOptions() { + if (options_ == null) { + options_ = new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + bitField0_ |= 0x00000002; + onChanged(); + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().ensureBuilderMap().size(); + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().ensureBuilderMap().containsKey(key); + } + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getImmutableMap(); + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + return map.containsKey(key) ? optionsConverter.build(map.get(key)) : defaultValue; + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return optionsConverter.build(map.get(key)); + } + + public Builder clearOptions() { + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableOptions().clear(); + return this; + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + public Builder removeOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableOptions().ensureBuilderMap().remove(key); + return this; + } + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableOptions() { + bitField0_ |= 0x00000002; + return internalGetMutableOptions().ensureMessageMap(); + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + public Builder putOptions(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableOptions().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000002; + return this; + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + public Builder putAllOptions( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableOptions().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + /** + * + * + *
+     * Optional query-level arguments.
+     *
+     * (-- Think query statement hints. --)
+     *
+     * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+     * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + public com.google.firestore.v1.Value.Builder putOptionsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableOptions().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredPipeline) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredPipeline) + private static final com.google.firestore.v1.StructuredPipeline DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredPipeline(); + } + + public static com.google.firestore.v1.StructuredPipeline getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StructuredPipeline parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipelineOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipelineOrBuilder.java new file mode 100644 index 000000000..b6e1c59c1 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipelineOrBuilder.java @@ -0,0 +1,139 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/firestore/v1/pipeline.proto + +// Protobuf Java Version: 3.25.2 +package com.google.firestore.v1; + +public interface StructuredPipelineOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredPipeline) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + * + * @return Whether the pipeline field is set. + */ + boolean hasPipeline(); + /** + * + * + *
+   * The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + * + * @return The pipeline. + */ + com.google.firestore.v1.Pipeline getPipeline(); + /** + * + * + *
+   * The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1; + */ + com.google.firestore.v1.PipelineOrBuilder getPipelineOrBuilder(); + + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + int getOptionsCount(); + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + boolean containsOptions(java.lang.String key); + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getOptions(); + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + java.util.Map getOptionsMap(); + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + /* nullable */ + com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + /** + * + * + *
+   * Optional query-level arguments.
+   *
+   * (-- Think query statement hints. --)
+   *
+   * (-- TODO(batchik): define the api contract of using an unsupported hint --)
+   * 
+ * + * map<string, .google.firestore.v1.Value> options = 2; + */ + com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key); +} diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQuery.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQuery.java index 2ebba9c23..0d3f509e8 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQuery.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQuery.java @@ -9559,6 +9559,1892 @@ public com.google.firestore.v1.StructuredQuery.Projection getDefaultInstanceForT } } + public interface FindNearestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.FindNearest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorField field is set. + */ + boolean hasVectorField(); + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorField. + */ + com.google.firestore.v1.StructuredQuery.FieldReference getVectorField(); + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getVectorFieldOrBuilder(); + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + boolean hasQueryVector(); + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + com.google.firestore.v1.Value getQueryVector(); + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.ValueOrBuilder getQueryVectorOrBuilder(); + + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + int getDistanceMeasureValue(); + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure getDistanceMeasure(); + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the limit field is set. + */ + boolean hasLimit(); + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The limit. + */ + com.google.protobuf.Int32Value getLimit(); + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder(); + } + /** + * + * + *
+   * Nearest Neighbors search config.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FindNearest} + */ + public static final class FindNearest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.FindNearest) + FindNearestOrBuilder { + private static final long serialVersionUID = 0L; + // Use FindNearest.newBuilder() to construct. + private FindNearest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private FindNearest() { + distanceMeasure_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new FindNearest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FindNearest.class, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder.class); + } + + /** + * + * + *
+     * The distance measure to use when comparing vectors.
+     * 
+ * + * Protobuf enum {@code google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure} + */ + public enum DistanceMeasure implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * Should not be set.
+       * 
+ * + * DISTANCE_MEASURE_UNSPECIFIED = 0; + */ + DISTANCE_MEASURE_UNSPECIFIED(0), + /** + * + * + *
+       * Measures the EUCLIDEAN distance between the vectors. See
+       * [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
+       * more
+       * 
+ * + * EUCLIDEAN = 1; + */ + EUCLIDEAN(1), + /** + * + * + *
+       * Compares vectors based on the angle between them, which allows you to
+       * measure similarity that isn't based on the vectors magnitude.
+       * We recommend using DOT_PRODUCT with unit normalized vectors instead of
+       * COSINE distance, which is mathematically equivalent with better
+       * performance. See [Cosine
+       * Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
+       * more.
+       * 
+ * + * COSINE = 2; + */ + COSINE(2), + /** + * + * + *
+       * Similar to cosine but is affected by the magnitude of the vectors. See
+       * [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
+       * 
+ * + * DOT_PRODUCT = 3; + */ + DOT_PRODUCT(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+       * Should not be set.
+       * 
+ * + * DISTANCE_MEASURE_UNSPECIFIED = 0; + */ + public static final int DISTANCE_MEASURE_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+       * Measures the EUCLIDEAN distance between the vectors. See
+       * [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
+       * more
+       * 
+ * + * EUCLIDEAN = 1; + */ + public static final int EUCLIDEAN_VALUE = 1; + /** + * + * + *
+       * Compares vectors based on the angle between them, which allows you to
+       * measure similarity that isn't based on the vectors magnitude.
+       * We recommend using DOT_PRODUCT with unit normalized vectors instead of
+       * COSINE distance, which is mathematically equivalent with better
+       * performance. See [Cosine
+       * Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
+       * more.
+       * 
+ * + * COSINE = 2; + */ + public static final int COSINE_VALUE = 2; + /** + * + * + *
+       * Similar to cosine but is affected by the magnitude of the vectors. See
+       * [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
+       * 
+ * + * DOT_PRODUCT = 3; + */ + public static final int DOT_PRODUCT_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DistanceMeasure valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static DistanceMeasure forNumber(int value) { + switch (value) { + case 0: + return DISTANCE_MEASURE_UNSPECIFIED; + case 1: + return EUCLIDEAN; + case 2: + return COSINE; + case 3: + return DOT_PRODUCT; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DistanceMeasure findValueByNumber(int number) { + return DistanceMeasure.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.StructuredQuery.FindNearest.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final DistanceMeasure[] VALUES = values(); + + public static DistanceMeasure valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DistanceMeasure(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure) + } + + private int bitField0_; + public static final int VECTOR_FIELD_FIELD_NUMBER = 1; + private com.google.firestore.v1.StructuredQuery.FieldReference vectorField_; + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorField field is set. + */ + @java.lang.Override + public boolean hasVectorField() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorField. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getVectorField() { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder + getVectorFieldOrBuilder() { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } + + public static final int QUERY_VECTOR_FIELD_NUMBER = 2; + private com.google.firestore.v1.Value queryVector_; + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + @java.lang.Override + public boolean hasQueryVector() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + @java.lang.Override + public com.google.firestore.v1.Value getQueryVector() { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } + + public static final int DISTANCE_MEASURE_FIELD_NUMBER = 3; + private int distanceMeasure_ = 0; + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + @java.lang.Override + public int getDistanceMeasureValue() { + return distanceMeasure_; + } + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + getDistanceMeasure() { + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure result = + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.forNumber( + distanceMeasure_); + return result == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.UNRECOGNIZED + : result; + } + + public static final int LIMIT_FIELD_NUMBER = 4; + private com.google.protobuf.Int32Value limit_; + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the limit field is set. + */ + @java.lang.Override + public boolean hasLimit() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The limit. + */ + @java.lang.Override + public com.google.protobuf.Int32Value getLimit() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + @java.lang.Override + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getVectorField()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + .DISTANCE_MEASURE_UNSPECIFIED + .getNumber()) { + output.writeEnum(3, distanceMeasure_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getLimit()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getVectorField()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + .DISTANCE_MEASURE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, distanceMeasure_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getLimit()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.FindNearest)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.FindNearest other = + (com.google.firestore.v1.StructuredQuery.FindNearest) obj; + + if (hasVectorField() != other.hasVectorField()) return false; + if (hasVectorField()) { + if (!getVectorField().equals(other.getVectorField())) return false; + } + if (hasQueryVector() != other.hasQueryVector()) return false; + if (hasQueryVector()) { + if (!getQueryVector().equals(other.getQueryVector())) return false; + } + if (distanceMeasure_ != other.distanceMeasure_) return false; + if (hasLimit() != other.hasLimit()) return false; + if (hasLimit()) { + if (!getLimit().equals(other.getLimit())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasVectorField()) { + hash = (37 * hash) + VECTOR_FIELD_FIELD_NUMBER; + hash = (53 * hash) + getVectorField().hashCode(); + } + if (hasQueryVector()) { + hash = (37 * hash) + QUERY_VECTOR_FIELD_NUMBER; + hash = (53 * hash) + getQueryVector().hashCode(); + } + hash = (37 * hash) + DISTANCE_MEASURE_FIELD_NUMBER; + hash = (53 * hash) + distanceMeasure_; + if (hasLimit()) { + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + getLimit().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredQuery.FindNearest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+     * Nearest Neighbors search config.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FindNearest} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.FindNearest) + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FindNearest.class, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.FindNearest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getVectorFieldFieldBuilder(); + getQueryVectorFieldBuilder(); + getLimitFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + vectorField_ = null; + if (vectorFieldBuilder_ != null) { + vectorFieldBuilder_.dispose(); + vectorFieldBuilder_ = null; + } + queryVector_ = null; + if (queryVectorBuilder_ != null) { + queryVectorBuilder_.dispose(); + queryVectorBuilder_ = null; + } + distanceMeasure_ = 0; + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest build() { + com.google.firestore.v1.StructuredQuery.FindNearest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest buildPartial() { + com.google.firestore.v1.StructuredQuery.FindNearest result = + new com.google.firestore.v1.StructuredQuery.FindNearest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.FindNearest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.vectorField_ = + vectorFieldBuilder_ == null ? vectorField_ : vectorFieldBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.queryVector_ = + queryVectorBuilder_ == null ? queryVector_ : queryVectorBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.distanceMeasure_ = distanceMeasure_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.limit_ = limitBuilder_ == null ? limit_ : limitBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.FindNearest) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.FindNearest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.FindNearest other) { + if (other == com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance()) + return this; + if (other.hasVectorField()) { + mergeVectorField(other.getVectorField()); + } + if (other.hasQueryVector()) { + mergeQueryVector(other.getQueryVector()); + } + if (other.distanceMeasure_ != 0) { + setDistanceMeasureValue(other.getDistanceMeasureValue()); + } + if (other.hasLimit()) { + mergeLimit(other.getLimit()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(getVectorFieldFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getQueryVectorFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + distanceMeasure_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + input.readMessage(getLimitFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.StructuredQuery.FieldReference vectorField_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + vectorFieldBuilder_; + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorField field is set. + */ + public boolean hasVectorField() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorField. + */ + public com.google.firestore.v1.StructuredQuery.FieldReference getVectorField() { + if (vectorFieldBuilder_ == null) { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } else { + return vectorFieldBuilder_.getMessage(); + } + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (vectorFieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + vectorField_ = value; + } else { + vectorFieldBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorField( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (vectorFieldBuilder_ == null) { + vectorField_ = builderForValue.build(); + } else { + vectorFieldBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeVectorField( + com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (vectorFieldBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && vectorField_ != null + && vectorField_ + != com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()) { + getVectorFieldBuilder().mergeFrom(value); + } else { + vectorField_ = value; + } + } else { + vectorFieldBuilder_.mergeFrom(value); + } + if (vectorField_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearVectorField() { + bitField0_ = (bitField0_ & ~0x00000001); + vectorField_ = null; + if (vectorFieldBuilder_ != null) { + vectorFieldBuilder_.dispose(); + vectorFieldBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder + getVectorFieldBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getVectorFieldFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder + getVectorFieldOrBuilder() { + if (vectorFieldBuilder_ != null) { + return vectorFieldBuilder_.getMessageOrBuilder(); + } else { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } + } + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + getVectorFieldFieldBuilder() { + if (vectorFieldBuilder_ == null) { + vectorFieldBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + getVectorField(), getParentForChildren(), isClean()); + vectorField_ = null; + } + return vectorFieldBuilder_; + } + + private com.google.firestore.v1.Value queryVector_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + queryVectorBuilder_; + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + public boolean hasQueryVector() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + public com.google.firestore.v1.Value getQueryVector() { + if (queryVectorBuilder_ == null) { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } else { + return queryVectorBuilder_.getMessage(); + } + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.firestore.v1.Value value) { + if (queryVectorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryVector_ = value; + } else { + queryVectorBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.firestore.v1.Value.Builder builderForValue) { + if (queryVectorBuilder_ == null) { + queryVector_ = builderForValue.build(); + } else { + queryVectorBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeQueryVector(com.google.firestore.v1.Value value) { + if (queryVectorBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && queryVector_ != null + && queryVector_ != com.google.firestore.v1.Value.getDefaultInstance()) { + getQueryVectorBuilder().mergeFrom(value); + } else { + queryVector_ = value; + } + } else { + queryVectorBuilder_.mergeFrom(value); + } + if (queryVector_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearQueryVector() { + bitField0_ = (bitField0_ & ~0x00000002); + queryVector_ = null; + if (queryVectorBuilder_ != null) { + queryVectorBuilder_.dispose(); + queryVectorBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Value.Builder getQueryVectorBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getQueryVectorFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + if (queryVectorBuilder_ != null) { + return queryVectorBuilder_.getMessageOrBuilder(); + } else { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } + } + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + getQueryVectorFieldBuilder() { + if (queryVectorBuilder_ == null) { + queryVectorBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + getQueryVector(), getParentForChildren(), isClean()); + queryVector_ = null; + } + return queryVectorBuilder_; + } + + private int distanceMeasure_ = 0; + /** + * + * + *
+       * Required. The Distance Measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + @java.lang.Override + public int getDistanceMeasureValue() { + return distanceMeasure_; + } + /** + * + * + *
+       * Required. The Distance Measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The enum numeric value on the wire for distanceMeasure to set. + * @return This builder for chaining. + */ + public Builder setDistanceMeasureValue(int value) { + distanceMeasure_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The Distance Measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + getDistanceMeasure() { + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure result = + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.forNumber( + distanceMeasure_); + return result == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.UNRECOGNIZED + : result; + } + /** + * + * + *
+       * Required. The Distance Measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The distanceMeasure to set. + * @return This builder for chaining. + */ + public Builder setDistanceMeasure( + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + distanceMeasure_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The Distance Measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return This builder for chaining. + */ + public Builder clearDistanceMeasure() { + bitField0_ = (bitField0_ & ~0x00000004); + distanceMeasure_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Int32Value limit_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + limitBuilder_; + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the limit field is set. + */ + public boolean hasLimit() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The limit. + */ + public com.google.protobuf.Int32Value getLimit() { + if (limitBuilder_ == null) { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } else { + return limitBuilder_.getMessage(); + } + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + limit_ = value; + } else { + limitBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setLimit(com.google.protobuf.Int32Value.Builder builderForValue) { + if (limitBuilder_ == null) { + limit_ = builderForValue.build(); + } else { + limitBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && limit_ != null + && limit_ != com.google.protobuf.Int32Value.getDefaultInstance()) { + getLimitBuilder().mergeFrom(value); + } else { + limit_ = value; + } + } else { + limitBuilder_.mergeFrom(value); + } + if (limit_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearLimit() { + bitField0_ = (bitField0_ & ~0x00000008); + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.Int32Value.Builder getLimitBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getLimitFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + if (limitBuilder_ != null) { + return limitBuilder_.getMessageOrBuilder(); + } else { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + } + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + getLimitFieldBuilder() { + if (limitBuilder_ == null) { + limitBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder>( + getLimit(), getParentForChildren(), isClean()); + limit_ = null; + } + return limitBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.FindNearest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.FindNearest) + private static final com.google.firestore.v1.StructuredQuery.FindNearest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.FindNearest(); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FindNearest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + private int bitField0_; public static final int SELECT_FIELD_NUMBER = 1; private com.google.firestore.v1.StructuredQuery.Projection select_; @@ -10206,6 +12092,74 @@ public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; } + public static final int FIND_NEAREST_FIELD_NUMBER = 9; + private com.google.firestore.v1.StructuredQuery.FindNearest findNearest_; + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + @java.lang.Override + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000020) != 0); + } + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest getFindNearest() { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder getFindNearestOrBuilder() { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -10244,6 +12198,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (((bitField0_ & 0x00000008) != 0)) { output.writeMessage(8, getEndAt()); } + if (((bitField0_ & 0x00000020) != 0)) { + output.writeMessage(9, getFindNearest()); + } getUnknownFields().writeTo(output); } @@ -10277,6 +12234,9 @@ public int getSerializedSize() { if (((bitField0_ & 0x00000008) != 0)) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getEndAt()); } + if (((bitField0_ & 0x00000020) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getFindNearest()); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -10315,6 +12275,10 @@ public boolean equals(final java.lang.Object obj) { if (hasLimit()) { if (!getLimit().equals(other.getLimit())) return false; } + if (hasFindNearest() != other.hasFindNearest()) return false; + if (hasFindNearest()) { + if (!getFindNearest().equals(other.getFindNearest())) return false; + } if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -10356,6 +12320,10 @@ public int hashCode() { hash = (37 * hash) + LIMIT_FIELD_NUMBER; hash = (53 * hash) + getLimit().hashCode(); } + if (hasFindNearest()) { + hash = (37 * hash) + FIND_NEAREST_FIELD_NUMBER; + hash = (53 * hash) + getFindNearest().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -10511,6 +12479,7 @@ private void maybeForceBuilderInitialization() { getStartAtFieldBuilder(); getEndAtFieldBuilder(); getLimitFieldBuilder(); + getFindNearestFieldBuilder(); } } @@ -10558,6 +12527,11 @@ public Builder clear() { limitBuilder_.dispose(); limitBuilder_ = null; } + findNearest_ = null; + if (findNearestBuilder_ != null) { + findNearestBuilder_.dispose(); + findNearestBuilder_ = null; + } return this; } @@ -10640,6 +12614,11 @@ private void buildPartial0(com.google.firestore.v1.StructuredQuery result) { result.limit_ = limitBuilder_ == null ? limit_ : limitBuilder_.build(); to_bitField0_ |= 0x00000010; } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.findNearest_ = + findNearestBuilder_ == null ? findNearest_ : findNearestBuilder_.build(); + to_bitField0_ |= 0x00000020; + } result.bitField0_ |= to_bitField0_; } @@ -10760,6 +12739,9 @@ public Builder mergeFrom(com.google.firestore.v1.StructuredQuery other) { if (other.hasLimit()) { mergeLimit(other.getLimit()); } + if (other.hasFindNearest()) { + mergeFindNearest(other.getFindNearest()); + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -10849,6 +12831,12 @@ public Builder mergeFrom( bitField0_ |= 0x00000020; break; } // case 66 + case 74: + { + input.readMessage(getFindNearestFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000100; + break; + } // case 74 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -13346,6 +15334,247 @@ public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { return limitBuilder_; } + private com.google.firestore.v1.StructuredQuery.FindNearest findNearest_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredQuery.FindNearest, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder, + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder> + findNearestBuilder_; + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000100) != 0); + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + public com.google.firestore.v1.StructuredQuery.FindNearest getFindNearest() { + if (findNearestBuilder_ == null) { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } else { + return findNearestBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest(com.google.firestore.v1.StructuredQuery.FindNearest value) { + if (findNearestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + findNearest_ = value; + } else { + findNearestBuilder_.setMessage(value); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest( + com.google.firestore.v1.StructuredQuery.FindNearest.Builder builderForValue) { + if (findNearestBuilder_ == null) { + findNearest_ = builderForValue.build(); + } else { + findNearestBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeFindNearest(com.google.firestore.v1.StructuredQuery.FindNearest value) { + if (findNearestBuilder_ == null) { + if (((bitField0_ & 0x00000100) != 0) + && findNearest_ != null + && findNearest_ + != com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance()) { + getFindNearestBuilder().mergeFrom(value); + } else { + findNearest_ = value; + } + } else { + findNearestBuilder_.mergeFrom(value); + } + if (findNearest_ != null) { + bitField0_ |= 0x00000100; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearFindNearest() { + bitField0_ = (bitField0_ & ~0x00000100); + findNearest_ = null; + if (findNearestBuilder_ != null) { + findNearestBuilder_.dispose(); + findNearestBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredQuery.FindNearest.Builder getFindNearestBuilder() { + bitField0_ |= 0x00000100; + onChanged(); + return getFindNearestFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder getFindNearestOrBuilder() { + if (findNearestBuilder_ != null) { + return findNearestBuilder_.getMessageOrBuilder(); + } else { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } + } + /** + * + * + *
+     * Optional. A potential Nearest Neighbors Search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredQuery.FindNearest, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder, + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder> + getFindNearestFieldBuilder() { + if (findNearestBuilder_ == null) { + findNearestBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.StructuredQuery.FindNearest, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder, + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder>( + getFindNearest(), getParentForChildren(), isClean()); + findNearest_ = null; + } + return findNearestBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQueryOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQueryOrBuilder.java index b22f484b5..1fa612379 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQueryOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQueryOrBuilder.java @@ -561,4 +561,57 @@ public interface StructuredQueryOrBuilder * .google.protobuf.Int32Value limit = 5; */ com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder(); + + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + boolean hasFindNearest(); + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + com.google.firestore.v1.StructuredQuery.FindNearest getFindNearest(); + /** + * + * + *
+   * Optional. A potential Nearest Neighbors Search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder getFindNearestOrBuilder(); } diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java index 5613257ec..7a1fa4b97 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java @@ -80,6 +80,9 @@ public enum ValueTypeCase GEO_POINT_VALUE(8), ARRAY_VALUE(9), MAP_VALUE(6), + FIELD_REFERENCE_VALUE(19), + FUNCTION_VALUE(20), + PIPELINE_VALUE(21), VALUETYPE_NOT_SET(0); private final int value; @@ -120,6 +123,12 @@ public static ValueTypeCase forNumber(int value) { return ARRAY_VALUE; case 6: return MAP_VALUE; + case 19: + return FIELD_REFERENCE_VALUE; + case 20: + return FUNCTION_VALUE; + case 21: + return PIPELINE_VALUE; case 0: return VALUETYPE_NOT_SET; default: @@ -711,6 +720,280 @@ public com.google.firestore.v1.MapValueOrBuilder getMapValueOrBuilder() { return com.google.firestore.v1.MapValue.getDefaultInstance(); } + public static final int FIELD_REFERENCE_VALUE_FIELD_NUMBER = 19; + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): long term, there is no reason this type should not be
+   *     allowed to be used on the write path. --)
+   * 
+ * + * string field_reference_value = 19; + * + * @return Whether the fieldReferenceValue field is set. + */ + public boolean hasFieldReferenceValue() { + return valueTypeCase_ == 19; + } + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): long term, there is no reason this type should not be
+   *     allowed to be used on the write path. --)
+   * 
+ * + * string field_reference_value = 19; + * + * @return The fieldReferenceValue. + */ + public java.lang.String getFieldReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 19) { + valueType_ = s; + } + return s; + } + } + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): long term, there is no reason this type should not be
+   *     allowed to be used on the write path. --)
+   * 
+ * + * string field_reference_value = 19; + * + * @return The bytes for fieldReferenceValue. + */ + public com.google.protobuf.ByteString getFieldReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 19) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FUNCTION_VALUE_FIELD_NUMBER = 20; + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return Whether the functionValue field is set. + */ + @java.lang.Override + public boolean hasFunctionValue() { + return valueTypeCase_ == 20; + } + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return The functionValue. + */ + @java.lang.Override + public com.google.firestore.v1.Function getFunctionValue() { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + @java.lang.Override + public com.google.firestore.v1.FunctionOrBuilder getFunctionValueOrBuilder() { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + + public static final int PIPELINE_VALUE_FIELD_NUMBER = 21; + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return Whether the pipelineValue field is set. + */ + @java.lang.Override + public boolean hasPipelineValue() { + return valueTypeCase_ == 21; + } + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return The pipelineValue. + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline getPipelineValue() { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + @java.lang.Override + public com.google.firestore.v1.PipelineOrBuilder getPipelineValueOrBuilder() { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -758,6 +1041,15 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (valueTypeCase_ == 18) { output.writeBytes(18, (com.google.protobuf.ByteString) valueType_); } + if (valueTypeCase_ == 19) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 19, valueType_); + } + if (valueTypeCase_ == 20) { + output.writeMessage(20, (com.google.firestore.v1.Function) valueType_); + } + if (valueTypeCase_ == 21) { + output.writeMessage(21, (com.google.firestore.v1.Pipeline) valueType_); + } getUnknownFields().writeTo(output); } @@ -818,6 +1110,19 @@ public int getSerializedSize() { com.google.protobuf.CodedOutputStream.computeBytesSize( 18, (com.google.protobuf.ByteString) valueType_); } + if (valueTypeCase_ == 19) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(19, valueType_); + } + if (valueTypeCase_ == 20) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 20, (com.google.firestore.v1.Function) valueType_); + } + if (valueTypeCase_ == 21) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 21, (com.google.firestore.v1.Pipeline) valueType_); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -869,6 +1174,15 @@ public boolean equals(final java.lang.Object obj) { case 6: if (!getMapValue().equals(other.getMapValue())) return false; break; + case 19: + if (!getFieldReferenceValue().equals(other.getFieldReferenceValue())) return false; + break; + case 20: + if (!getFunctionValue().equals(other.getFunctionValue())) return false; + break; + case 21: + if (!getPipelineValue().equals(other.getPipelineValue())) return false; + break; case 0: default: } @@ -931,6 +1245,18 @@ public int hashCode() { hash = (37 * hash) + MAP_VALUE_FIELD_NUMBER; hash = (53 * hash) + getMapValue().hashCode(); break; + case 19: + hash = (37 * hash) + FIELD_REFERENCE_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getFieldReferenceValue().hashCode(); + break; + case 20: + hash = (37 * hash) + FUNCTION_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getFunctionValue().hashCode(); + break; + case 21: + hash = (37 * hash) + PIPELINE_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getPipelineValue().hashCode(); + break; case 0: default: } @@ -1083,6 +1409,12 @@ public Builder clear() { if (mapValueBuilder_ != null) { mapValueBuilder_.clear(); } + if (functionValueBuilder_ != null) { + functionValueBuilder_.clear(); + } + if (pipelineValueBuilder_ != null) { + pipelineValueBuilder_.clear(); + } valueTypeCase_ = 0; valueType_ = null; return this; @@ -1138,6 +1470,12 @@ private void buildPartialOneofs(com.google.firestore.v1.Value result) { if (valueTypeCase_ == 6 && mapValueBuilder_ != null) { result.valueType_ = mapValueBuilder_.build(); } + if (valueTypeCase_ == 20 && functionValueBuilder_ != null) { + result.valueType_ = functionValueBuilder_.build(); + } + if (valueTypeCase_ == 21 && pipelineValueBuilder_ != null) { + result.valueType_ = pipelineValueBuilder_.build(); + } } @java.lang.Override @@ -1245,6 +1583,23 @@ public Builder mergeFrom(com.google.firestore.v1.Value other) { mergeMapValue(other.getMapValue()); break; } + case FIELD_REFERENCE_VALUE: + { + valueTypeCase_ = 19; + valueType_ = other.valueType_; + onChanged(); + break; + } + case FUNCTION_VALUE: + { + mergeFunctionValue(other.getFunctionValue()); + break; + } + case PIPELINE_VALUE: + { + mergePipelineValue(other.getPipelineValue()); + break; + } case VALUETYPE_NOT_SET: { break; @@ -1345,6 +1700,25 @@ public Builder mergeFrom( valueTypeCase_ = 18; break; } // case 146 + case 154: + { + java.lang.String s = input.readStringRequireUtf8(); + valueTypeCase_ = 19; + valueType_ = s; + break; + } // case 154 + case 162: + { + input.readMessage(getFunctionValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 20; + break; + } // case 162 + case 170: + { + input.readMessage(getPipelineValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 21; + break; + } // case 170 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -2953,6 +3327,822 @@ public com.google.firestore.v1.MapValueOrBuilder getMapValueOrBuilder() { return mapValueBuilder_; } + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): long term, there is no reason this type should not be
+     *     allowed to be used on the write path. --)
+     * 
+ * + * string field_reference_value = 19; + * + * @return Whether the fieldReferenceValue field is set. + */ + @java.lang.Override + public boolean hasFieldReferenceValue() { + return valueTypeCase_ == 19; + } + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): long term, there is no reason this type should not be
+     *     allowed to be used on the write path. --)
+     * 
+ * + * string field_reference_value = 19; + * + * @return The fieldReferenceValue. + */ + @java.lang.Override + public java.lang.String getFieldReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 19) { + valueType_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): long term, there is no reason this type should not be
+     *     allowed to be used on the write path. --)
+     * 
+ * + * string field_reference_value = 19; + * + * @return The bytes for fieldReferenceValue. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFieldReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 19) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): long term, there is no reason this type should not be
+     *     allowed to be used on the write path. --)
+     * 
+ * + * string field_reference_value = 19; + * + * @param value The fieldReferenceValue to set. + * @return This builder for chaining. + */ + public Builder setFieldReferenceValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 19; + valueType_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): long term, there is no reason this type should not be
+     *     allowed to be used on the write path. --)
+     * 
+ * + * string field_reference_value = 19; + * + * @return This builder for chaining. + */ + public Builder clearFieldReferenceValue() { + if (valueTypeCase_ == 19) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): long term, there is no reason this type should not be
+     *     allowed to be used on the write path. --)
+     * 
+ * + * string field_reference_value = 19; + * + * @param value The bytes for fieldReferenceValue to set. + * @return This builder for chaining. + */ + public Builder setFieldReferenceValueBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + valueTypeCase_ = 19; + valueType_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Function, + com.google.firestore.v1.Function.Builder, + com.google.firestore.v1.FunctionOrBuilder> + functionValueBuilder_; + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return Whether the functionValue field is set. + */ + @java.lang.Override + public boolean hasFunctionValue() { + return valueTypeCase_ == 20; + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return The functionValue. + */ + @java.lang.Override + public com.google.firestore.v1.Function getFunctionValue() { + if (functionValueBuilder_ == null) { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } else { + if (valueTypeCase_ == 20) { + return functionValueBuilder_.getMessage(); + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder setFunctionValue(com.google.firestore.v1.Function value) { + if (functionValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + functionValueBuilder_.setMessage(value); + } + valueTypeCase_ = 20; + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder setFunctionValue(com.google.firestore.v1.Function.Builder builderForValue) { + if (functionValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + functionValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 20; + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder mergeFunctionValue(com.google.firestore.v1.Function value) { + if (functionValueBuilder_ == null) { + if (valueTypeCase_ == 20 + && valueType_ != com.google.firestore.v1.Function.getDefaultInstance()) { + valueType_ = + com.google.firestore.v1.Function.newBuilder( + (com.google.firestore.v1.Function) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 20) { + functionValueBuilder_.mergeFrom(value); + } else { + functionValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 20; + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder clearFunctionValue() { + if (functionValueBuilder_ == null) { + if (valueTypeCase_ == 20) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 20) { + valueTypeCase_ = 0; + valueType_ = null; + } + functionValueBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public com.google.firestore.v1.Function.Builder getFunctionValueBuilder() { + return getFunctionValueFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + @java.lang.Override + public com.google.firestore.v1.FunctionOrBuilder getFunctionValueOrBuilder() { + if ((valueTypeCase_ == 20) && (functionValueBuilder_ != null)) { + return functionValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + } + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Function, + com.google.firestore.v1.Function.Builder, + com.google.firestore.v1.FunctionOrBuilder> + getFunctionValueFieldBuilder() { + if (functionValueBuilder_ == null) { + if (!(valueTypeCase_ == 20)) { + valueType_ = com.google.firestore.v1.Function.getDefaultInstance(); + } + functionValueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Function, + com.google.firestore.v1.Function.Builder, + com.google.firestore.v1.FunctionOrBuilder>( + (com.google.firestore.v1.Function) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 20; + onChanged(); + return functionValueBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + pipelineValueBuilder_; + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return Whether the pipelineValue field is set. + */ + @java.lang.Override + public boolean hasPipelineValue() { + return valueTypeCase_ == 21; + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return The pipelineValue. + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline getPipelineValue() { + if (pipelineValueBuilder_ == null) { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } else { + if (valueTypeCase_ == 21) { + return pipelineValueBuilder_.getMessage(); + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder setPipelineValue(com.google.firestore.v1.Pipeline value) { + if (pipelineValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + pipelineValueBuilder_.setMessage(value); + } + valueTypeCase_ = 21; + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder setPipelineValue(com.google.firestore.v1.Pipeline.Builder builderForValue) { + if (pipelineValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + pipelineValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 21; + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder mergePipelineValue(com.google.firestore.v1.Pipeline value) { + if (pipelineValueBuilder_ == null) { + if (valueTypeCase_ == 21 + && valueType_ != com.google.firestore.v1.Pipeline.getDefaultInstance()) { + valueType_ = + com.google.firestore.v1.Pipeline.newBuilder( + (com.google.firestore.v1.Pipeline) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 21) { + pipelineValueBuilder_.mergeFrom(value); + } else { + pipelineValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 21; + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder clearPipelineValue() { + if (pipelineValueBuilder_ == null) { + if (valueTypeCase_ == 21) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 21) { + valueTypeCase_ = 0; + valueType_ = null; + } + pipelineValueBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public com.google.firestore.v1.Pipeline.Builder getPipelineValueBuilder() { + return getPipelineValueFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + @java.lang.Override + public com.google.firestore.v1.PipelineOrBuilder getPipelineValueOrBuilder() { + if ((valueTypeCase_ == 21) && (pipelineValueBuilder_ != null)) { + return pipelineValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + } + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     *
+     * (-- NOTE(batchik): similar to above, there is no reason to not allow
+     *     storing expressions into the database, just no plan to support in
+     *     the near term.
+     *
+     *     This would actually be an interesting way to represent user-defined
+     *     functions or more expressive rules-based systems. --)
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + getPipelineValueFieldBuilder() { + if (pipelineValueBuilder_ == null) { + if (!(valueTypeCase_ == 21)) { + valueType_ = com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + pipelineValueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder>( + (com.google.firestore.v1.Pipeline) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 21; + onChanged(); + return pipelineValueBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java index 047f6c988..9b553bcd3 100644 --- a/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java +++ b/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java @@ -414,5 +414,214 @@ public interface ValueOrBuilder */ com.google.firestore.v1.MapValueOrBuilder getMapValueOrBuilder(); + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): long term, there is no reason this type should not be
+   *     allowed to be used on the write path. --)
+   * 
+ * + * string field_reference_value = 19; + * + * @return Whether the fieldReferenceValue field is set. + */ + boolean hasFieldReferenceValue(); + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): long term, there is no reason this type should not be
+   *     allowed to be used on the write path. --)
+   * 
+ * + * string field_reference_value = 19; + * + * @return The fieldReferenceValue. + */ + java.lang.String getFieldReferenceValue(); + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): long term, there is no reason this type should not be
+   *     allowed to be used on the write path. --)
+   * 
+ * + * string field_reference_value = 19; + * + * @return The bytes for fieldReferenceValue. + */ + com.google.protobuf.ByteString getFieldReferenceValueBytes(); + + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return Whether the functionValue field is set. + */ + boolean hasFunctionValue(); + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return The functionValue. + */ + com.google.firestore.v1.Function getFunctionValue(); + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + com.google.firestore.v1.FunctionOrBuilder getFunctionValueOrBuilder(); + + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return Whether the pipelineValue field is set. + */ + boolean hasPipelineValue(); + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return The pipelineValue. + */ + com.google.firestore.v1.Pipeline getPipelineValue(); + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   *
+   * (-- NOTE(batchik): similar to above, there is no reason to not allow
+   *     storing expressions into the database, just no plan to support in
+   *     the near term.
+   *
+   *     This would actually be an interesting way to represent user-defined
+   *     functions or more expressive rules-based systems. --)
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + com.google.firestore.v1.PipelineOrBuilder getPipelineValueOrBuilder(); + com.google.firestore.v1.Value.ValueTypeCase getValueTypeCase(); } diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto index 1ccc93a10..d2f1f262e 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto @@ -260,3 +260,4 @@ message Pipeline { // Ordered list of stages to evaluate. repeated Stage stages = 1; } + diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto index 20f0c17be..0a198cd6e 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto @@ -24,3 +24,4 @@ message StructuredPipeline { // (-- TODO(batchik): define the api contract of using an unsupported hint --) map options = 2; } + diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto index 09eefa241..68d9d5458 100644 --- a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto @@ -263,6 +263,51 @@ message StructuredQuery { repeated FieldReference fields = 2; } + // Nearest Neighbors search config. + message FindNearest { + // The distance measure to use when comparing vectors. + enum DistanceMeasure { + // Should not be set. + DISTANCE_MEASURE_UNSPECIFIED = 0; + + // Measures the EUCLIDEAN distance between the vectors. See + // [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn + // more + EUCLIDEAN = 1; + + // Compares vectors based on the angle between them, which allows you to + // measure similarity that isn't based on the vectors magnitude. + // We recommend using DOT_PRODUCT with unit normalized vectors instead of + // COSINE distance, which is mathematically equivalent with better + // performance. See [Cosine + // Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn + // more. + COSINE = 2; + + // Similar to cosine but is affected by the magnitude of the vectors. See + // [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more. + DOT_PRODUCT = 3; + } + + // Required. An indexed vector field to search upon. Only documents which + // contain vectors whose dimensionality match the query_vector can be + // returned. + FieldReference vector_field = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The query vector that we are searching on. Must be a vector of + // no more than 2048 dimensions. + Value query_vector = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Distance Measure to use, required. + DistanceMeasure distance_measure = 3 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The number of nearest neighbors to return. Must be a positive + // integer of no more than 1000. + google.protobuf.Int32Value limit = 4 + [(google.api.field_behavior) = REQUIRED]; + } + // Optional sub-set of the fields to return. // // This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the @@ -360,6 +405,13 @@ message StructuredQuery { // // * The value must be greater than or equal to zero if specified. google.protobuf.Int32Value limit = 5; + + // Optional. A potential Nearest Neighbors Search. + // + // Applies after all other filters and ordering. + // + // Finds the closest vector embeddings to the given query vector. + FindNearest find_nearest = 9 [(google.api.field_behavior) = OPTIONAL]; } // Firestore query for running an aggregation over a diff --git a/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query_profile.proto b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query_profile.proto new file mode 100644 index 000000000..931e083b0 --- /dev/null +++ b/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query_profile.proto @@ -0,0 +1,92 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProfileProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// Specification of the Firestore Query Profile fields. + +// Explain options for the query. +message ExplainOptions { + // Optional. Whether to execute this query. + // + // When false (the default), the query will be planned, returning only + // metrics from the planning stages. + // + // When true, the query will be planned and executed, returning the full + // query results along with both planning and execution stage metrics. + bool analyze = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// Explain metrics for the query. +message ExplainMetrics { + // Planning phase information for the query. + PlanSummary plan_summary = 1; + + // Aggregated stats from the execution of the query. Only present when + // [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set + // to true. + ExecutionStats execution_stats = 2; +} + +// Planning phase information for the query. +message PlanSummary { + // The indexes selected for the query. For example: + // [ + // {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, + // {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} + // ] + repeated google.protobuf.Struct indexes_used = 1; +} + +// Execution statistics for the query. +message ExecutionStats { + // Total number of results returned, including documents, projections, + // aggregation results, keys. + int64 results_returned = 1; + + // Total time to execute the query in the backend. + google.protobuf.Duration execution_duration = 3; + + // Total billable read operations. + int64 read_operations = 4; + + // Debugging statistics from the execution of the query. Note that the + // debugging stats are subject to change as Firestore evolves. It could + // include: + // { + // "indexes_entries_scanned": "1000", + // "documents_scanned": "20", + // "billing_details" : { + // "documents_billable": "20", + // "index_entries_billable": "1000", + // "min_query_cost": "0" + // } + // } + google.protobuf.Struct debug_stats = 5; +} From 336947300aeff4a1e331427465b3c738c7dddef0 Mon Sep 17 00:00:00 2001 From: wu-hui Date: Fri, 12 Apr 2024 18:47:15 +0000 Subject: [PATCH 31/45] pull in proto change and regenerate --- .../com/google/cloud/firestore/Pipeline.kt | 74 ++++++++++----- .../cloud/firestore/UserDataConverter.java | 3 + .../cloud/firestore/pipeline/Expressions.kt | 95 ++++++++++++------- .../google/cloud/firestore/pipeline/Stages.kt | 90 ++++++++++-------- 4 files changed, 168 insertions(+), 94 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 7c5a39cf7..26886ba2c 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -3,25 +3,29 @@ package com.google.cloud.firestore import com.google.api.core.ApiFuture import com.google.api.core.ApiFutures import com.google.api.gax.rpc.ApiStreamObserver +import com.google.cloud.firestore.UserDataConverter.EncodingOptions import com.google.cloud.firestore.pipeline.AggregatorTarget import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup +import com.google.cloud.firestore.pipeline.Expr +import com.google.cloud.firestore.pipeline.ExprAsAlias import com.google.cloud.firestore.pipeline.Field +import com.google.cloud.firestore.pipeline.Fields import com.google.cloud.firestore.pipeline.Filter import com.google.cloud.firestore.pipeline.FindNearest import com.google.cloud.firestore.pipeline.Function -import com.google.cloud.firestore.pipeline.GenericStage -import com.google.cloud.firestore.pipeline.Limit -import com.google.cloud.firestore.pipeline.Offset -import com.google.cloud.firestore.pipeline.Ordering +import com.google.cloud.firestore.pipeline.Project import com.google.cloud.firestore.pipeline.Projectable import com.google.cloud.firestore.pipeline.Sort +import com.google.cloud.firestore.pipeline.Sort.Ordering import com.google.cloud.firestore.pipeline.Stage +import com.google.cloud.firestore.pipeline.ToProto +import com.google.firestore.v1.Value class PaginatingPipeline internal constructor( val p: Pipeline, pageSize: Int, - orders: Array + orders: Array ) { fun firstPage(): Pipeline { return this.p @@ -78,19 +82,12 @@ class PaginatingPipeline internal constructor( * .aggregate(count(Field.of("orderId")).asAlias("orderCount")); * ``` */ -class Pipeline { - private val stages: MutableList = mutableListOf() - private var name: String +class Pipeline private constructor(private val stages: List, private val name: String): + ToProto { - private constructor(collection: Collection) { - stages.add(collection) - name = collection.path - } + private constructor(collection: Collection) : this(listOf(collection), collection.path) - private constructor(group: CollectionGroup) { - stages.add(group) - name = group.path - } + private constructor(group: CollectionGroup): this(listOf(group), group.path) companion object { @JvmStatic @@ -115,21 +112,27 @@ class Pipeline { } fun project(vararg projections: Projectable): Pipeline { - return this + val projMap = mutableMapOf() + for(proj in projections) { + when (proj){ + is Field -> projMap[proj.field] = proj + is AggregatorTarget -> projMap[proj.target] = proj.current + is ExprAsAlias -> projMap[proj.alias] = proj.current + is Fields -> proj.fs?.forEach { projMap[it.field] = it} + } + } + return Pipeline(stages.plus(Project(projMap)), name) } fun filter(condition: Function.FilterCondition): Pipeline { - stages.add(Filter(condition)) - return this + return Pipeline(stages.plus(Filter(condition)), name) } fun offset(offset: Int): Pipeline { - stages.add(Offset(offset)) return this } fun limit(limit: Int): Pipeline { - stages.add(Limit(limit)) return this } @@ -144,16 +147,14 @@ class Pipeline { vector: DoubleArray, options: FindNearest.FindNearestOptions ): Pipeline { - stages.add(FindNearest(property, vector, options)) return this } fun sort( - orders: List, + orders: List, density: Sort.Density = Sort.Density.UNSPECIFIED, truncation: Sort.Truncation = Sort.Truncation.UNSPECIFIED ): Pipeline { - stages.add(Sort(orders, density, truncation)) return this } @@ -167,7 +168,6 @@ class Pipeline { } fun genericOperation(name: String, params: Map? = null): Pipeline { - stages.add(GenericStage(name, params)) return this } @@ -177,5 +177,29 @@ class Pipeline { fun execute(db: Firestore, observer: ApiStreamObserver): Unit { } + + override fun toProto(): Value { + return Value.newBuilder() + .setPipelineValue(com.google.firestore.v1.Pipeline.newBuilder() + .addAllStages(stages.map { toStageProto(it) }) + ) + .build() + } +} + +internal fun toStageProto(stage: Stage): com.google.firestore.v1.Pipeline.Stage { + return when (stage) { + is Project -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName("project") + .addArgs(UserDataConverter.encodeValue(FieldPath.empty(), stage.projections, UserDataConverter.ARGUMENT)) + .build() + is Collection -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName("collection") + .addArgs(UserDataConverter.encodeValue(FieldPath.empty(),stage.path, UserDataConverter.ARGUMENT)) + .build() + else -> { + TODO() + } + } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java index 50222fefd..6506b9f2b 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java @@ -17,6 +17,7 @@ package com.google.cloud.firestore; import com.google.cloud.Timestamp; +import com.google.cloud.firestore.pipeline.ToProto; import com.google.common.base.Preconditions; import com.google.firestore.v1.ArrayValue; import com.google.firestore.v1.MapValue; @@ -154,6 +155,8 @@ static Value encodeValue( return Value.newBuilder().setBytesValue(blob.toByteString()).build(); } else if (sanitizedObject instanceof Value) { return (Value) sanitizedObject; + } else if (sanitizedObject instanceof ToProto) { + return ((ToProto) sanitizedObject).toProto(); } else if (sanitizedObject instanceof DocumentReference) { DocumentReference docRef = (DocumentReference) sanitizedObject; return Value.newBuilder().setReferenceValue(docRef.getName()).build(); diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 56fc06462..286e86895 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -22,9 +22,25 @@ import com.google.cloud.firestore.pipeline.Function.NotIn import com.google.cloud.firestore.pipeline.Function.Sum import com.google.firestore.v1.Value +internal interface ToProto { + fun toProto(): Value +} + +internal fun exprToValue(expr: Expr): Value{ + return when(expr) { + is Constant -> expr.toProto() + is Field -> expr.toProto() + is Function -> expr.toProto() + // is ExprAsAlias -> + else -> { + TODO() + } + } +} + sealed interface Projectable -sealed interface Expr { +interface Expr { // Infix functions returning Function subclasses infix fun equal(other: Expr) = Equal(this, other) infix fun equal(other: Number) = Equal(this, Constant.of(other)) @@ -85,7 +101,7 @@ sealed interface Expr { internal data class ListOfExprs(val conditions: List) : Expr internal data class ListOfConditions(val conditions: List) : Expr, Function.FilterCondition -data class Constant internal constructor(val value: Any) : Expr { +data class Constant internal constructor(val value: Any) : Expr, ToProto { companion object { @JvmStatic fun of(value: String): Constant { @@ -117,10 +133,15 @@ data class Constant internal constructor(val value: Any) : Expr { return Constant(value) } } + + override fun toProto(): Value { + return Value.newBuilder().build() + } } data class Field internal constructor(val field: String, var pipeline: Pipeline? = null) : Expr, - Projectable { + Projectable, + ToProto { companion object { const val DOCUMENT_ID: String = "__path__" @@ -131,6 +152,10 @@ data class Field internal constructor(val field: String, var pipeline: Pipeline? } fun exists() = Function.Exists(this) + + override fun toProto(): Value { + return Value.newBuilder().setFieldReferenceValue(field).build() + } } data class Fields internal constructor(val fs: List? = null) : Expr, Projectable { @@ -156,10 +181,10 @@ data class AggregatorTarget internal constructor( Projectable, Function.Accumulator -sealed class Function(val name: String, val params: Map?) : Expr { +sealed class Function(val name: String, val params: List): Expr, ToProto { interface FilterCondition - interface Accumulator { + interface Accumulator: Expr { var distinct: Boolean fun distinct(on: Boolean): Accumulator { @@ -170,82 +195,88 @@ sealed class Function(val name: String, val params: Map?) : Expr { fun toField(target: String) = AggregatorTarget(this, target, this.distinct) } + override fun toProto(): Value { + return Value.newBuilder().setFunctionValue(com.google.firestore.v1.Function.newBuilder() + .setName(name) + .addAllArgs(params.map { exprToValue(it) })).build() + } + data class Equal internal constructor(val left: Expr, val right: Expr) : - Function("equal", mapOf("left" to left, "right" to right)), FilterCondition + Function("equal", listOf(left, right)), FilterCondition data class NotEqual(val left: Expr, val right: Expr) : - Function("not_equal", mapOf("left" to left, "right" to right)), FilterCondition + Function("not_equal", listOf(left, right)), FilterCondition data class GreaterThan(val left: Expr, val right: Expr) : - Function("greater_than", mapOf("left" to left, "right" to right)), FilterCondition + Function("greater_than", listOf(left, right)), FilterCondition data class GreaterThanOrEqual(val left: Expr, val right: Expr) : - Function("greater_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + Function("greater_than_equal", listOf(left, right)), FilterCondition data class In(val left: Expr, val others: List) : - Function("in", mapOf("left" to left, "others" to ListOfExprs(others))), + Function("in", listOf(left, ListOfExprs(others))), FilterCondition // For 'in' data class LessThan(val left: Expr, val right: Expr) : - Function("less_than", mapOf("left" to left, "right" to right)), FilterCondition + Function("less_than", listOf(left, right)), FilterCondition data class LessThanOrEqual(val left: Expr, val right: Expr) : - Function("less_than_equal", mapOf("left" to left, "right" to right)), FilterCondition + Function("less_than_equal", listOf(left, right)), FilterCondition data class NotIn(val left: Expr, val others: List) : - Function("not_in", mapOf("left" to left, "others" to ListOfExprs(others))), + Function("not_in", listOf(left, ListOfExprs(others))), FilterCondition // For 'not in' data class And(val conditions: List) : - Function("and", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + Function("and", listOf(ListOfConditions(conditions))), FilterCondition data class Or(val conditions: List) : - Function("or", mapOf("conditions" to ListOfConditions(conditions))), FilterCondition + Function("or", listOf(ListOfConditions(conditions))), FilterCondition - data class Not(val condition: Expr) : Function("not", mapOf("condition" to condition)), + data class Not(val condition: Expr) : Function("not", listOf(condition)), FilterCondition - data class Exists(val current: Field) : Function("exists", mapOf("current" to current)), + data class Exists(val current: Field) : Function("exists", listOf(current)), FilterCondition data class MapGet(val map: Expr, val key: String) : Function( "map_get", - mapOf( - "map" to map, - "key" to Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()) + listOf( + map, + Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()) ) ) data class ArrayContains(val array: Expr, val element: Expr) : - Function("array_contains", mapOf("array" to array, "element" to element)), FilterCondition + Function("array_contains", listOf(array, element)), FilterCondition data class ArrayContainsAny(val array: Expr, val elements: List) : - Function("array_contains_any", mapOf("array" to array, "elements" to ListOfExprs(elements))), + Function("array_contains_any", listOf(array, ListOfExprs(elements))), FilterCondition - data class IsNaN(val value: Expr) : Function("is_nan", mapOf("value" to value)), FilterCondition - data class IsNull(val value: Expr) : Function("is_null", mapOf("value" to value)), + data class IsNaN(val value: Expr) : Function("is_nan", listOf(value)), FilterCondition + data class IsNull(val value: Expr) : Function("is_null", listOf(value)), FilterCondition data class Sum(val value: Expr, override var distinct: Boolean) : - Function("sum", mapOf("value" to value)), Accumulator + Function("sum", listOf(value)), Accumulator data class Avg(val value: Expr, override var distinct: Boolean) : - Function("avg", mapOf("value" to value)), Accumulator + Function("avg", listOf(value)), Accumulator data class Count(val value: Expr, override var distinct: Boolean) : - Function("count", mapOf("value" to value)), Accumulator + Function("count", listOf(value)), Accumulator data class CosineDistance(val vector1: Expr, val vector2: Expr) : - Function("cosine_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + Function("cosine_distance", listOf(vector1, vector2)) data class DotProductDistance(val vector1: Expr, val vector2: Expr) : - Function("dot_product_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + Function("dot_product_distance", listOf(vector1, vector2)) data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : - Function("euclidean_distance", mapOf("vector1" to vector1, "vector2" to vector2)) + Function("euclidean_distance", listOf(vector1, vector2)) - data class Generic(val n: String, val ps: Map?) : Function(n, ps) + data class Generic(val n: String, val ps: List) : Function(n, ps) companion object { @@ -411,7 +442,7 @@ sealed class Function(val name: String, val params: Map?) : Expr { fun asAlias(expr: Expr, alias: String): Projectable = ExprAsAlias(expr, alias) @JvmStatic - fun function(name: String, params: Map?) = Generic(name, params) + fun function(name: String, params: List) = Generic(name, params) } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index 9044f192a..06e445d01 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -1,14 +1,29 @@ package com.google.cloud.firestore.pipeline -interface Stage +import com.google.firestore.v1.Pipeline +import com.google.firestore.v1.Value -internal data class Collection(val path: String) : Stage -internal data class CollectionGroup(val path: String) : Stage +internal interface Stage -internal data class Project(val projections: Map) : Stage -internal data class Filter(val condition: Function.FilterCondition) : Stage -internal data class Offset(val offset: Int) : Stage -internal data class Limit(val limit: Int) : Stage +internal data class Collection(val path: String) : Stage { + +} + +internal data class CollectionGroup(val path: String) : Stage { + +} + +internal data class Project(val projections: Map) : Stage { +} + +data class Filter(val condition: Function.FilterCondition) : Stage { +} + +data class Offset(val offset: Int) : Stage { +} + +data class Limit(val limit: Int) : Stage { +} data class FindNearest internal constructor( val property: Field, @@ -42,35 +57,7 @@ data class FindNearest internal constructor( val limit: Long, val output: Field? = null ) -} - -data class Ordering internal constructor(val expr: Expr, val dir: Direction = Direction.ASC) { - enum class Direction { - ASC, - DESC - } - - companion object { - @JvmStatic - fun of(expr: Expr, dir: Direction = Direction.ASC): Ordering { - return Ordering(expr, dir) - } - - @JvmStatic - fun of(expr: Expr): Ordering { - return Ordering(expr, Direction.ASC) - } - @JvmStatic - fun ascending(expr: Expr): Ordering { - return Ordering(expr, Direction.ASC) - } - - @JvmStatic - fun descending(expr: Expr): Ordering { - return Ordering(expr, Direction.DESC) - } - } } data class Sort internal constructor( @@ -87,7 +74,36 @@ data class Sort internal constructor( UNSPECIFIED, DISABLED } -} -data class GenericStage(val name: String, val params: Map?) : Stage + data class Ordering internal constructor(val expr: Expr, val dir: Direction = Direction.ASC) { + enum class Direction { + ASC, + DESC + } + companion object { + @JvmStatic + fun of(expr: Expr, dir: Direction = Direction.ASC): Ordering { + return Ordering(expr, dir) + } + + @JvmStatic + fun of(expr: Expr): Ordering { + return Ordering(expr, Direction.ASC) + } + + @JvmStatic + fun ascending(expr: Expr): Ordering { + return Ordering(expr, Direction.ASC) + } + + @JvmStatic + fun descending(expr: Expr): Ordering { + return Ordering(expr, Direction.DESC) + } + } + } +} + +data class GenericStage(val name: String, val params: Map?) : Stage { +} From 948602782e48ce88c317c72b76f44350f9bb1771 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Wed, 17 Apr 2024 14:52:33 -0400 Subject: [PATCH 32/45] Basic serialization --- .../com/google/cloud/firestore/Pipeline.kt | 263 ++++++++++++++--- .../google/cloud/firestore/PipelineResult.kt | 25 +- .../cloud/firestore/UserDataConverter.java | 8 +- .../cloud/firestore/pipeline/Expressions.kt | 279 +++++++++--------- .../google/cloud/firestore/pipeline/Stages.kt | 243 +++++++++++++-- .../cloud/firestore/spi/v1/FirestoreRpc.java | 6 + .../firestore/spi/v1/GrpcFirestoreRpc.java | 8 + .../cloud/firestore/it/ITPipelineTest.java | 74 +++-- 8 files changed, 655 insertions(+), 251 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 26886ba2c..422a15816 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -1,26 +1,43 @@ package com.google.cloud.firestore import com.google.api.core.ApiFuture -import com.google.api.core.ApiFutures +import com.google.api.core.SettableApiFuture import com.google.api.gax.rpc.ApiStreamObserver -import com.google.cloud.firestore.UserDataConverter.EncodingOptions +import com.google.api.gax.rpc.ResponseObserver +import com.google.api.gax.rpc.StreamController +import com.google.cloud.Timestamp +import com.google.cloud.firestore.pipeline.AddFields +import com.google.cloud.firestore.pipeline.Aggregate import com.google.cloud.firestore.pipeline.AggregatorTarget import com.google.cloud.firestore.pipeline.Collection import com.google.cloud.firestore.pipeline.CollectionGroup +import com.google.cloud.firestore.pipeline.Database +import com.google.cloud.firestore.pipeline.Documents import com.google.cloud.firestore.pipeline.Expr -import com.google.cloud.firestore.pipeline.ExprAsAlias import com.google.cloud.firestore.pipeline.Field import com.google.cloud.firestore.pipeline.Fields import com.google.cloud.firestore.pipeline.Filter import com.google.cloud.firestore.pipeline.FindNearest import com.google.cloud.firestore.pipeline.Function +import com.google.cloud.firestore.pipeline.Limit +import com.google.cloud.firestore.pipeline.Offset import com.google.cloud.firestore.pipeline.Project import com.google.cloud.firestore.pipeline.Projectable import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.Sort.Ordering import com.google.cloud.firestore.pipeline.Stage -import com.google.cloud.firestore.pipeline.ToProto +import com.google.cloud.firestore.pipeline.toStageProto +import com.google.common.base.Preconditions +import com.google.common.collect.ImmutableMap +import com.google.firestore.v1.Document +import com.google.firestore.v1.ExecutePipelineRequest +import com.google.firestore.v1.ExecutePipelineResponse +import com.google.firestore.v1.StructuredPipeline import com.google.firestore.v1.Value +import io.opencensus.trace.AttributeValue +import io.opencensus.trace.Tracing +import java.util.logging.Level +import java.util.logging.Logger class PaginatingPipeline internal constructor( val p: Pipeline, @@ -82,12 +99,15 @@ class PaginatingPipeline internal constructor( * .aggregate(count(Field.of("orderId")).asAlias("orderCount")); * ``` */ -class Pipeline private constructor(private val stages: List, private val name: String): - ToProto { +class Pipeline private constructor(private val stages: List, private val name: String) { - private constructor(collection: Collection) : this(listOf(collection), collection.path) + private constructor(collection: Collection) : this(listOf(collection), collection.relativePath) - private constructor(group: CollectionGroup): this(listOf(group), group.path) + private constructor(group: CollectionGroup) : this(listOf(group), group.collectionId) + + private constructor(db: Database) : this(listOf(db), db.name) + + private constructor(docs: Documents) : this(listOf(docs), docs.name) companion object { @JvmStatic @@ -106,40 +126,60 @@ class Pipeline private constructor(private val stages: List, private val } @JvmStatic - fun fromCollectionGroup(group: String): Pipeline { - return Pipeline(CollectionGroup(group)) + fun fromCollectionGroup(collectionId: String): Pipeline { + Preconditions.checkArgument( + !collectionId.contains("/"), + "Invalid collectionId '%s'. Collection IDs must not contain '/'.", + collectionId + ) + return Pipeline(CollectionGroup(collectionId)) + } + + @JvmStatic + fun fromDatabase(): Pipeline { + return Pipeline(Database()) + } + + @JvmStatic + fun fromDocuments(vararg docs: DocumentReference): Pipeline { + return Pipeline(Documents.of(*docs)) } } - fun project(vararg projections: Projectable): Pipeline { + private fun projectablesToMap(vararg projectables: Projectable): Map { val projMap = mutableMapOf() - for(proj in projections) { - when (proj){ + for (proj in projectables) { + when (proj) { is Field -> projMap[proj.field] = proj - is AggregatorTarget -> projMap[proj.target] = proj.current - is ExprAsAlias -> projMap[proj.alias] = proj.current - is Fields -> proj.fs?.forEach { projMap[it.field] = it} + is AggregatorTarget -> projMap[proj.fieldName] = proj.accumulator + is Fields -> proj.fs?.forEach { projMap[it.field] = it } } } - return Pipeline(stages.plus(Project(projMap)), name) + return projMap + } + + fun addFields(vararg fields: Projectable): Pipeline { + return Pipeline(stages.plus(AddFields(projectablesToMap(*fields))), name) + } + + fun project(vararg projections: Projectable): Pipeline { + return Pipeline(stages.plus(Project(projectablesToMap(*projections))), name) } - fun filter(condition: Function.FilterCondition): Pipeline { + fun filter(condition: T): Pipeline where T : Expr, T:Function.FilterCondition{ return Pipeline(stages.plus(Filter(condition)), name) } fun offset(offset: Int): Pipeline { - return this + return Pipeline(stages.plus(Offset(offset)), name) } fun limit(limit: Int): Pipeline { - return this + return Pipeline(stages.plus(Limit(limit)), name) } - fun aggregate(vararg aggregator: AggregatorTarget): Pipeline { - // operations.add(Group()) - // operations.add(aggregator) - return this + fun aggregate(vararg aggregators: AggregatorTarget): Pipeline { + return Pipeline(stages.plus(Aggregate(*aggregators)), name) } fun findNearest( @@ -171,35 +211,174 @@ class Pipeline private constructor(private val stages: List, private val return this } - fun execute(db: Firestore): ApiFuture> { - return ApiFutures.immediateFuture(listOf(PipelineResult()).iterator()) + fun execute(db: Firestore): ApiFuture> { + when (db) { + is FirestoreImpl -> { + val pipelineValue = toProto() + val request = ExecutePipelineRequest.newBuilder() + .setStructuredPipeline( + StructuredPipeline.newBuilder() + .setPipeline(pipelineValue.pipelineValue).build() + ).build() + + val futureResult = SettableApiFuture.create>() + pipelineInternalStream(db, request, object : PipelineResultObserver() { + val results = mutableListOf() + override fun onCompleted() { + futureResult.set(results) + } + + override fun onNext(result: PipelineResult?) { + results.add(result!!) + } + + override fun onError(t: Throwable?) { + futureResult.setException(t) + } + }) + + return futureResult + } + + else -> { + TODO() + } + } } fun execute(db: Firestore, observer: ApiStreamObserver): Unit { + when (db) { + is FirestoreImpl -> { + val pipelineValue = toProto() + val request = ExecutePipelineRequest.newBuilder() + .setDatabase(db.resourcePath.databaseName.toString()) + .setStructuredPipeline( + StructuredPipeline.newBuilder() + .setPipeline(pipelineValue.pipelineValue).build() + ).build() + + pipelineInternalStream(db, request, object : PipelineResultObserver() { + override fun onCompleted() { + observer.onCompleted() + } + + override fun onNext(result: PipelineResult?) { + observer.onNext(result) + } + + override fun onError(t: Throwable?) { + observer.onError(t) + } + }) + } + + else -> { + TODO() + } + } } - override fun toProto(): Value { + fun toProto(): Value { return Value.newBuilder() - .setPipelineValue(com.google.firestore.v1.Pipeline.newBuilder() - .addAllStages(stages.map { toStageProto(it) }) + .setPipelineValue( + com.google.firestore.v1.Pipeline.newBuilder() + .addAllStages(stages.map { toStageProto(it) }) ) .build() } } -internal fun toStageProto(stage: Stage): com.google.firestore.v1.Pipeline.Stage { - return when (stage) { - is Project -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName("project") - .addArgs(UserDataConverter.encodeValue(FieldPath.empty(), stage.projections, UserDataConverter.ARGUMENT)) - .build() - is Collection -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName("collection") - .addArgs(UserDataConverter.encodeValue(FieldPath.empty(),stage.path, UserDataConverter.ARGUMENT)) - .build() - else -> { - TODO() - } +internal fun encodeValue(value: Any?): Value? { + return UserDataConverter.encodeValue( + FieldPath.empty(), + value, + UserDataConverter.ARGUMENT + ) +} + +private abstract class PipelineResultObserver + + : ApiStreamObserver { + var executionTime: Timestamp? = null + private set + + fun onCompleted(executionTime: Timestamp?) { + this.executionTime = executionTime + this.onCompleted() } } +private fun pipelineInternalStream( + rpcContext: FirestoreImpl, + request: ExecutePipelineRequest, + resultObserver: PipelineResultObserver +) { + val observer: ResponseObserver = + object : ResponseObserver { + var executionTime: Timestamp? = null + var firstResponse: Boolean = false + var numDocuments: Int = 0 + + // The stream's `onComplete()` could be called more than once, + // this flag makes sure only the first one is actually processed. + var hasCompleted: Boolean = false + + override fun onStart(streamController: StreamController) { + } + + override fun onResponse(response: ExecutePipelineResponse) { + if (!firstResponse) { + firstResponse = true + Tracing.getTracer().currentSpan.addAnnotation("Firestore.Query: First response") + } + if (response.resultsCount > 0) { + numDocuments += response.resultsCount + if (numDocuments % 100 == 0) { + Tracing.getTracer() + .currentSpan + .addAnnotation("Firestore.Query: Received 100 documents") + } + response.resultsList.forEach { doc: Document -> + resultObserver.onNext( + PipelineResult.fromDocument( + rpcContext, + response.executionTime, + doc + ) + ) + } + } + + if (executionTime == null) { + executionTime = Timestamp.fromProto(response.executionTime) + } + } + + override fun onError(throwable: Throwable) { + Tracing.getTracer().currentSpan.addAnnotation("Firestore.Query: Error") + resultObserver.onError(throwable) + } + + override fun onComplete() { + if (hasCompleted) { + return + } + hasCompleted = true + + Tracing.getTracer() + .currentSpan + .addAnnotation( + "Firestore.Query: Completed", + ImmutableMap.of( + "numDocuments", AttributeValue.longAttributeValue(numDocuments.toLong()) + ) + ) + resultObserver.onCompleted(executionTime) + } + } + + Logger.getLogger("Pipeline") + .log(Level.WARNING, "Sending request: $request") + + rpcContext.streamRequest(request, observer, rpcContext.client.executePipelineCallable()) +} diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt index 9bf617c74..ab184c2c9 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -1,6 +1,7 @@ package com.google.cloud.firestore import com.google.cloud.Timestamp +import com.google.firestore.v1.Document import com.google.firestore.v1.Value import java.util.Date import javax.annotation.Nonnull @@ -8,13 +9,11 @@ import javax.annotation.Nonnull data class PipelineResult internal constructor( private val rpcContext: FirestoreRpcContext<*>?, val reference: DocumentReference?, - val protoFields: Map?, - val readTime: Timestamp?, + val protoFields: Map, + val readTime: Timestamp, val updateTime: Timestamp?, val createTime: Timestamp? ) { - constructor() : this(null, null, null, null, null, null) - val id: String? get() = reference?.id @@ -154,5 +153,21 @@ data class PipelineResult internal constructor( } val isEmpty: Boolean - get() = protoFields == null || protoFields.isEmpty() + get() = protoFields.isEmpty() + + companion object { + @JvmStatic + internal fun fromDocument( + rpcContext: FirestoreRpcContext<*>?, readTime: com.google.protobuf.Timestamp, document: Document + ): PipelineResult { + return PipelineResult( + rpcContext, + document.name?.let { DocumentReference(rpcContext, ResourcePath.create(it)) }, + document.fieldsMap, + Timestamp.fromProto(readTime), + document.updateTime?.let {Timestamp.fromProto(it)}, + document.createTime?.let {Timestamp.fromProto(it)}, + ) + } + } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java index 6506b9f2b..8f824de71 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java @@ -16,8 +16,10 @@ package com.google.cloud.firestore; +import static com.google.cloud.firestore.pipeline.ExpressionsKt.exprToValue; + import com.google.cloud.Timestamp; -import com.google.cloud.firestore.pipeline.ToProto; +import com.google.cloud.firestore.pipeline.Expr; import com.google.common.base.Preconditions; import com.google.firestore.v1.ArrayValue; import com.google.firestore.v1.MapValue; @@ -153,10 +155,10 @@ static Value encodeValue( } else if (sanitizedObject instanceof Blob) { Blob blob = (Blob) sanitizedObject; return Value.newBuilder().setBytesValue(blob.toByteString()).build(); + } else if (sanitizedObject instanceof Expr) { + return exprToValue((Expr) sanitizedObject); } else if (sanitizedObject instanceof Value) { return (Value) sanitizedObject; - } else if (sanitizedObject instanceof ToProto) { - return ((ToProto) sanitizedObject).toProto(); } else if (sanitizedObject instanceof DocumentReference) { DocumentReference docRef = (DocumentReference) sanitizedObject; return Value.newBuilder().setReferenceValue(docRef.getName()).build(); diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 286e86895..3abecfa5f 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -1,6 +1,7 @@ package com.google.cloud.firestore.pipeline import com.google.cloud.firestore.Pipeline +import com.google.cloud.firestore.encodeValue import com.google.cloud.firestore.pipeline.Function.ArrayContains import com.google.cloud.firestore.pipeline.Function.ArrayContainsAny import com.google.cloud.firestore.pipeline.Function.Avg @@ -16,22 +17,26 @@ import com.google.cloud.firestore.pipeline.Function.IsNaN import com.google.cloud.firestore.pipeline.Function.IsNull import com.google.cloud.firestore.pipeline.Function.LessThan import com.google.cloud.firestore.pipeline.Function.LessThanOrEqual -import com.google.cloud.firestore.pipeline.Function.MapGet import com.google.cloud.firestore.pipeline.Function.NotEqual -import com.google.cloud.firestore.pipeline.Function.NotIn import com.google.cloud.firestore.pipeline.Function.Sum import com.google.firestore.v1.Value - -internal interface ToProto { - fun toProto(): Value -} +import com.google.cloud.Timestamp +import com.google.cloud.firestore.Blob +import com.google.cloud.firestore.DocumentReference +import com.google.cloud.firestore.GeoPoint +import com.google.cloud.firestore.pipeline.Sort.Ordering +import com.google.cloud.firestore.pipeline.Sort.Ordering.Direction +import com.google.firestore.v1.ArrayValue +import java.util.Date internal fun exprToValue(expr: Expr): Value{ return when(expr) { is Constant -> expr.toProto() is Field -> expr.toProto() is Function -> expr.toProto() - // is ExprAsAlias -> + is ListOfExprs -> { + Value.newBuilder().setArrayValue(ArrayValue.newBuilder().addAllValues(expr.conditions.map { exprToValue(it) })).build() + } else -> { TODO() } @@ -43,44 +48,35 @@ sealed interface Projectable interface Expr { // Infix functions returning Function subclasses infix fun equal(other: Expr) = Equal(this, other) - infix fun equal(other: Number) = Equal(this, Constant.of(other)) - infix fun equal(other: String) = Equal(this, Constant.of(other)) infix fun equal(other: Any) = Equal(this, Constant.of(other)) infix fun notEqual(other: Expr) = NotEqual(this, other) - infix fun notEqual(other: Number) = NotEqual(this, Constant.of(other)) - infix fun notEqual(other: String) = NotEqual(this, Constant.of(other)) infix fun notEqual(other: Any) = NotEqual(this, Constant.of(other)) infix fun greaterThan(other: Expr) = GreaterThan(this, other) - infix fun greaterThan(other: Number) = GreaterThan(this, Constant.of(other)) - infix fun greaterThan(other: String) = GreaterThan(this, Constant.of(other)) infix fun greaterThan(other: Any) = GreaterThan(this, Constant.of(other)) infix fun greaterThanOrEqual(other: Expr) = GreaterThanOrEqual(this, other) - infix fun greaterThanOrEqual(other: Number) = GreaterThanOrEqual(this, Constant.of(other)) - infix fun greaterThanOrEqual(other: String) = GreaterThanOrEqual(this, Constant.of(other)) infix fun greaterThanOrEqual(other: Any) = GreaterThanOrEqual(this, Constant.of(other)) infix fun lessThan(other: Expr) = LessThan(this, other) - infix fun lessThan(other: Number) = LessThan(this, Constant.of(other)) - infix fun lessThan(other: String) = LessThan(this, Constant.of(other)) infix fun lessThan(other: Any) = LessThan(this, Constant.of(other)) infix fun lessThanOrEqual(other: Expr) = LessThanOrEqual(this, other) - infix fun lessThanOrEqual(other: Number) = LessThanOrEqual(this, Constant.of(other)) - infix fun lessThanOrEqual(other: String) = LessThanOrEqual(this, Constant.of(other)) infix fun lessThanOrEqual(other: Any) = LessThanOrEqual(this, Constant.of(other)) - fun inAny(vararg other: Expr) = In(this, other.toList()) - fun notInAny(vararg other: Expr) = NotIn(this, other.toList()) - - infix fun mapGet(key: String) = MapGet(this, key) + fun inAny(vararg other: Any) = In(this, other.toList().map { when(it) { + is Expr -> it + else -> Constant.of(it) }}) + fun notInAny(vararg other: Any) = Function.Not(In(this, other.toList().map { when(it) { + is Expr -> it + else -> Constant.of(it) }})) infix fun arrayContains(element: Expr) = ArrayContains(this, element) - infix fun arrayContains(element: Number) = ArrayContains(this, Constant.of(element)) - infix fun arrayContains(element: String) = ArrayContains(this, Constant.of(element)) infix fun arrayContains(element: Any) = ArrayContains(this, Constant.of(element)) fun arrayContainsAny(vararg elements: Expr) = ArrayContainsAny(this, elements.toList()) + fun arrayContainsAny(vararg elements: Any) = ArrayContainsAny(this, elements.toList().map { Constant.of(it) }) fun isNaN() = IsNaN(this) fun isNull() = IsNull(this) fun sum() = Sum(this, false) fun avg() = Avg(this, false) fun count() = Count(this, false) + fun min() = Count(this, false) + fun max() = Count(this, false) infix fun cosineDistance(other: Expr) = CosineDistance(this, other) infix fun cosineDistance(other: DoubleArray) = @@ -94,54 +90,108 @@ interface Expr { infix fun dotProductDistance(other: DoubleArray) = DotProductDistance(this, Constant.ofVector(other)) - fun asAlias(alias: String): Projectable = ExprAsAlias(this, alias) + fun ascending(): Ordering { + return Ordering(this, Direction.ASCENDING) + } + + fun descending(): Ordering { + return Ordering(this, Direction.DESCENDING) + } } // Convenient class for internal usage internal data class ListOfExprs(val conditions: List) : Expr -internal data class ListOfConditions(val conditions: List) : Expr, - Function.FilterCondition -data class Constant internal constructor(val value: Any) : Expr, ToProto { + +data class Constant internal constructor(val value: Any?) : Expr { companion object { @JvmStatic - fun of(value: String): Constant { + fun of(value: String?): Constant { return Constant(value) } @JvmStatic - fun of(value: Number): Constant { + fun of(value: Number?): Constant { return Constant(value) } @JvmStatic - fun of(value: Any): Constant { + fun of(value: Date?): Constant { return Constant(value) } @JvmStatic - fun ofArray(value: Iterable): Constant { + fun of(value: Timestamp?): Constant { return Constant(value) } @JvmStatic - fun ofMap(value: Map): Constant { + fun of(value: Boolean?): Constant { return Constant(value) } @JvmStatic - fun ofVector(value: DoubleArray): Constant { + fun of(value: GeoPoint?): Constant { + return Constant(value) + } + + @JvmStatic + fun of(value: Blob?): Constant { + return Constant(value) + } + + @JvmStatic + fun of(value: DocumentReference?): Constant { + return Constant(value) + } + + @JvmStatic + internal fun of(value: Any?): Constant { + if (value == null) { + return Constant(null) + } + + return when (value) { + is String -> of(value) + is Number -> of(value) + is Date -> of(value) + is Timestamp -> of(value) + is Boolean -> of(value) + is GeoPoint -> of(value) + is Blob -> of(value) + is DocumentReference -> of(value) + else -> TODO("Unknown type: $value") + } + } + + @JvmStatic + fun ofArray(value: Iterable): Constant { + return Constant(value) + } + + @JvmStatic + fun ofArray(value: Array): Constant { + return Constant(value) + } + + @JvmStatic + fun ofMap(value: Map): Constant { return Constant(value) } + + @JvmStatic + fun ofVector(value: DoubleArray): Constant { + // TODO: Vector is really a map, not a list + return Constant(value.asList()) + } } - override fun toProto(): Value { - return Value.newBuilder().build() + fun toProto(): Value { + return encodeValue(value)!! } } data class Field internal constructor(val field: String, var pipeline: Pipeline? = null) : Expr, - Projectable, - ToProto { + Projectable{ companion object { const val DOCUMENT_ID: String = "__path__" @@ -151,9 +201,7 @@ data class Field internal constructor(val field: String, var pipeline: Pipeline? } } - fun exists() = Function.Exists(this) - - override fun toProto(): Value { + fun toProto(): Value { return Value.newBuilder().setFieldReferenceValue(field).build() } } @@ -164,24 +212,16 @@ data class Fields internal constructor(val fs: List? = null) : Expr, Proj fun of(f1: String, vararg f: String): Fields { return Fields(listOf(Field.of(f1)) + f.map(Field.Companion::of)) } - - @JvmStatic - fun ofAll(): Fields { - return Fields(null) - } } } -internal data class ExprAsAlias(val current: Expr, val alias: String) : Expr, Projectable - data class AggregatorTarget internal constructor( - val current: Function.Accumulator, val target: String, + val accumulator: Function.Accumulator, val fieldName: String, override var distinct: Boolean -) : Expr, - Projectable, +) : Projectable, Function.Accumulator -sealed class Function(val name: String, val params: List): Expr, ToProto { +sealed class Function(val name: String, val params: List): Expr { interface FilterCondition interface Accumulator: Expr { @@ -195,58 +235,43 @@ sealed class Function(val name: String, val params: List): Expr, ToProto { fun toField(target: String) = AggregatorTarget(this, target, this.distinct) } - override fun toProto(): Value { + fun toProto(): Value { return Value.newBuilder().setFunctionValue(com.google.firestore.v1.Function.newBuilder() .setName(name) .addAllArgs(params.map { exprToValue(it) })).build() } data class Equal internal constructor(val left: Expr, val right: Expr) : - Function("equal", listOf(left, right)), FilterCondition + Function("eq", listOf(left, right)), FilterCondition data class NotEqual(val left: Expr, val right: Expr) : - Function("not_equal", listOf(left, right)), FilterCondition + Function("neq", listOf(left, right)), FilterCondition data class GreaterThan(val left: Expr, val right: Expr) : - Function("greater_than", listOf(left, right)), FilterCondition + Function("gt", listOf(left, right)), FilterCondition data class GreaterThanOrEqual(val left: Expr, val right: Expr) : - Function("greater_than_equal", listOf(left, right)), FilterCondition - - data class In(val left: Expr, val others: List) : - Function("in", listOf(left, ListOfExprs(others))), - FilterCondition // For 'in' + Function("gte", listOf(left, right)), FilterCondition data class LessThan(val left: Expr, val right: Expr) : - Function("less_than", listOf(left, right)), FilterCondition + Function("lt", listOf(left, right)), FilterCondition data class LessThanOrEqual(val left: Expr, val right: Expr) : - Function("less_than_equal", listOf(left, right)), FilterCondition + Function("lte", listOf(left, right)), FilterCondition - data class NotIn(val left: Expr, val others: List) : - Function("not_in", listOf(left, ListOfExprs(others))), - FilterCondition // For 'not in' + data class In(val left: Expr, val others: List) : + Function("in", listOf(left, ListOfExprs(others))), + FilterCondition // For 'in' - data class And(val conditions: List) : - Function("and", listOf(ListOfConditions(conditions))), FilterCondition + data class And(val conditions: List) : + Function("and", conditions), FilterCondition where T : FilterCondition, T:Expr - data class Or(val conditions: List) : - Function("or", listOf(ListOfConditions(conditions))), FilterCondition + data class Or(val conditions: List) : + Function("or", conditions), FilterCondition where T : FilterCondition, T:Expr data class Not(val condition: Expr) : Function("not", listOf(condition)), FilterCondition - data class Exists(val current: Field) : Function("exists", listOf(current)), - FilterCondition - - data class MapGet(val map: Expr, val key: String) : Function( - "map_get", - listOf( - map, - Constant(Value.getDefaultInstance().toBuilder().setStringValue(key).build()) - ) - ) - data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", listOf(array, element)), FilterCondition @@ -266,12 +291,16 @@ sealed class Function(val name: String, val params: List): Expr, ToProto { data class Count(val value: Expr, override var distinct: Boolean) : Function("count", listOf(value)), Accumulator + data class Min(val value: Expr, override var distinct: Boolean) : + Function("min", listOf(value)), Accumulator + data class Max(val value: Expr, override var distinct: Boolean) : + Function("max", listOf(value)), Accumulator data class CosineDistance(val vector1: Expr, val vector2: Expr) : Function("cosine_distance", listOf(vector1, vector2)) data class DotProductDistance(val vector1: Expr, val vector2: Expr) : - Function("dot_product_distance", listOf(vector1, vector2)) + Function("dot_product", listOf(vector1, vector2)) data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : Function("euclidean_distance", listOf(vector1, vector2)) @@ -283,38 +312,18 @@ sealed class Function(val name: String, val params: List): Expr, ToProto { @JvmStatic fun equal(left: Expr, right: Expr) = Equal(left, right) - @JvmStatic - fun equal(left: Expr, right: String) = Equal(left, Constant.of(right)) - - @JvmStatic - fun equal(left: Expr, right: Number) = Equal(left, Constant.of(right)) - @JvmStatic fun equal(left: Expr, right: Any) = Equal(left, Constant.of(right)) @JvmStatic fun notEqual(left: Expr, right: Expr) = NotEqual(left, right) - @JvmStatic - fun notEqual(left: Expr, right: String) = NotEqual(left, Constant.of(right)) - - @JvmStatic - fun notEqual(left: Expr, right: Number) = NotEqual(left, Constant.of(right)) - @JvmStatic fun notEqual(left: Expr, right: Any) = NotEqual(left, Constant.of(right)) @JvmStatic fun greaterThan(left: Expr, right: Expr) = GreaterThan(left, right) - @JvmStatic - fun greaterThan(left: Expr, right: String) = - GreaterThan(left, Constant.of(right)) - - @JvmStatic - fun greaterThan(left: Expr, right: Number) = - GreaterThan(left, Constant.of(right)) - @JvmStatic fun greaterThan(left: Expr, right: Any) = GreaterThan(left, Constant.of(right)) @@ -322,76 +331,55 @@ sealed class Function(val name: String, val params: List): Expr, ToProto { @JvmStatic fun greaterThanOrEqual(left: Expr, right: Expr) = GreaterThanOrEqual(left, right) - @JvmStatic - fun greaterThanOrEqual(left: Expr, right: String) = GreaterThanOrEqual(left, Constant.of(right)) - - @JvmStatic - fun greaterThanOrEqual(left: Expr, right: Number) = GreaterThanOrEqual(left, Constant.of(right)) - @JvmStatic fun greaterThanOrEqual(left: Expr, right: Any) = GreaterThanOrEqual(left, Constant.of(right)) @JvmStatic fun lessThan(left: Expr, right: Expr) = LessThan(left, right) - @JvmStatic - fun lessThan(left: Expr, right: String) = LessThan(left, Constant.of(right)) - - @JvmStatic - fun lessThan(left: Expr, right: Number) = LessThan(left, Constant.of(right)) - @JvmStatic fun lessThan(left: Expr, right: Any) = LessThan(left, Constant.of(right)) @JvmStatic fun lessThanOrEqual(left: Expr, right: Expr) = LessThanOrEqual(left, right) - @JvmStatic - fun lessThanOrEqual(left: Expr, right: String) = LessThanOrEqual(left, Constant.of(right)) - - @JvmStatic - fun lessThanOrEqual(left: Expr, right: Number) = LessThanOrEqual(left, Constant.of(right)) - @JvmStatic fun lessThanOrEqual(left: Expr, right: Any) = LessThanOrEqual(left, Constant.of(right)) @JvmStatic - fun inAny(left: Expr, values: List) = In(left, values) + fun inAny(left: Expr, values: List) = In(left, values.map { + when (it) { + is Expr -> it + else -> Constant.of(it) + } + }) @JvmStatic - fun notInAny(left: Expr, values: List) = NotIn(left, values) + fun notInAny(left: Expr, values: List) = Not(In(left, values.map { + when (it) { + is Expr -> it + else ->Constant.of(it) + }})) @JvmStatic - fun and(left: FilterCondition, right: FilterCondition) = + fun and(left: T, right: T) where T : FilterCondition, T:Expr = And(listOf(left, right)) @JvmStatic - fun and(left: FilterCondition, vararg other: FilterCondition) = + fun and(left: T, vararg other: T) where T : FilterCondition, T:Expr= And(listOf(left) + other.toList()) @JvmStatic - fun or(left: FilterCondition, right: FilterCondition) = + fun or(left: T, right: T) where T : FilterCondition, T:Expr = Or(listOf(left, right)) @JvmStatic - fun or(left: FilterCondition, vararg other: FilterCondition) = + fun or(left: T, vararg other: T) where T : FilterCondition, T:Expr= Or(listOf(left) + other.toList()) - @JvmStatic - fun exists(expr: Field) = Exists(expr) - - @JvmStatic - fun mapGet(expr: Expr, key: String) = MapGet(expr, key) - @JvmStatic fun arrayContains(expr: Expr, element: Expr) = ArrayContains(expr, element) - @JvmStatic - fun arrayContains(expr: Expr, element: Number) = ArrayContains(expr, Constant.of(element)) - - @JvmStatic - fun arrayContains(expr: Expr, element: String) = ArrayContains(expr, Constant.of(element)) - @JvmStatic fun arrayContains(expr: Expr, element: Any) = ArrayContains(expr, Constant.of(element)) @@ -399,6 +387,10 @@ sealed class Function(val name: String, val params: List): Expr, ToProto { fun arrayContainsAny(expr: Expr, vararg elements: Expr) = ArrayContainsAny(expr, elements.toList()) + @JvmStatic + fun arrayContainsAny(expr: Expr, vararg elements: Any) = + ArrayContainsAny(expr, elements.toList().map { Constant.of(it) }) + @JvmStatic fun isNaN(expr: Expr) = IsNaN(expr) @@ -414,6 +406,12 @@ sealed class Function(val name: String, val params: List): Expr, ToProto { @JvmStatic fun avg(expr: Expr) = Avg(expr, false) + @JvmStatic + fun min(expr: Expr) = Sum(expr, false) + + @JvmStatic + fun max(expr: Expr) = Avg(expr, false) + @JvmStatic fun count(expr: Expr) = Count(expr, false) @@ -438,9 +436,6 @@ sealed class Function(val name: String, val params: List): Expr, ToProto { fun euclideanDistance(expr: Expr, other: DoubleArray) = EuclideanDistance(expr, Constant.ofVector(other)) - @JvmStatic - fun asAlias(expr: Expr, alias: String): Projectable = ExprAsAlias(expr, alias) - @JvmStatic fun function(name: String, params: List) = Generic(name, params) } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index 06e445d01..0ffc10cbe 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -1,41 +1,88 @@ package com.google.cloud.firestore.pipeline -import com.google.firestore.v1.Pipeline +import com.google.cloud.firestore.DocumentReference +import com.google.cloud.firestore.encodeValue +import com.google.firestore.v1.MapValue import com.google.firestore.v1.Value +import java.util.Locale internal interface Stage -internal data class Collection(val path: String) : Stage { +internal data class Collection(val relativePath: String) : Stage { + val name = "collection" +} +internal data class CollectionGroup(val collectionId: String) : Stage { + val name = "collection_group" } -internal data class CollectionGroup(val path: String) : Stage { +internal class Database: Stage { + val name = "database" +} +internal data class Documents(val documents: List): Stage { + val name = "documents" + companion object { + @JvmStatic + fun of(vararg documents: DocumentReference): Documents { + return Documents(documents.map { it.path }) + } + } } internal data class Project(val projections: Map) : Stage { + val name = "project" +} + +internal data class AddFields(val fields: Map) : Stage { + val name = "add_fields" +} + +internal data class Filter (val condition: T) : Stage where T:Function.FilterCondition, T:Expr { + val name = "filter" } -data class Filter(val condition: Function.FilterCondition) : Stage { +internal class Offset(val offset: Int) : Stage { + val name = "offset" } -data class Offset(val offset: Int) : Stage { +internal class Limit(val limit: Int) : Stage { + val name = "limit" } -data class Limit(val limit: Int) : Stage { +class Aggregate internal constructor( + val groups: Map, + val accumulators: Map +) : Stage { + val name = "aggregate" + + internal constructor(vararg aggregators: AggregatorTarget) : + this(emptyMap(), aggregators.associate { it.fieldName to it.accumulator }) } -data class FindNearest internal constructor( +class FindNearest internal constructor( val property: Field, val vector: DoubleArray, + val distanceMeasure: DistanceMeasure, val options: FindNearestOptions ) : Stage { - sealed interface Similarity { - data object Euclidean : Similarity - data object Cosine : Similarity - data object DotProduct : Similarity + val name = "find_nearest" - class GenericSimilarity(val name: String) : Similarity + sealed interface DistanceMeasure { + data object Euclidean : DistanceMeasure + data object Cosine : DistanceMeasure + data object DotProduct : DistanceMeasure + + class GenericDistanceMeasure(val name: String) : DistanceMeasure + + fun toProtoString(): String{ + return when (this) { + is Euclidean -> "euclidean" + is Cosine -> "cosine" + is DotProduct -> "dot_product" + is GenericDistanceMeasure -> name + } + } companion object { @JvmStatic @@ -48,62 +95,204 @@ data class FindNearest internal constructor( fun dotProduct() = DotProduct @JvmStatic - fun generic(name: String) = GenericSimilarity(name) + fun generic(name: String) = GenericDistanceMeasure(name) } } data class FindNearestOptions( - val similarity: Similarity, - val limit: Long, + val limit: Long?, val output: Field? = null ) - } -data class Sort internal constructor( +class Sort internal constructor( val orders: List, val density: Density = Density.UNSPECIFIED, val truncation: Truncation = Truncation.UNSPECIFIED ) : Stage { + val name = "sort" + enum class Density { UNSPECIFIED, - REQUIRED + REQUIRED; + override fun toString(): String + = name.lowercase(Locale.getDefault()) } enum class Truncation { UNSPECIFIED, - DISABLED + DISABLED; + override fun toString(): String + = name.lowercase(Locale.getDefault()) } - data class Ordering internal constructor(val expr: Expr, val dir: Direction = Direction.ASC) { + class Ordering internal constructor(private val expr: Expr, private val dir: Direction = Direction.ASCENDING) { enum class Direction { - ASC, - DESC + ASCENDING, + DESCENDING; + + override fun toString(): String + = name.lowercase(Locale.getDefault()) + } + + internal fun toProto(): Value { + return Value.newBuilder().setMapValue(MapValue.newBuilder() + .putFields("direction", encodeValue(dir.toString())) + .putFields("expression", encodeValue(expr)) + .build()).build() } companion object { @JvmStatic - fun of(expr: Expr, dir: Direction = Direction.ASC): Ordering { + fun of(expr: Expr, dir: Direction = Direction.ASCENDING): Ordering { return Ordering(expr, dir) } @JvmStatic fun of(expr: Expr): Ordering { - return Ordering(expr, Direction.ASC) + return Ordering(expr, Direction.ASCENDING) } @JvmStatic fun ascending(expr: Expr): Ordering { - return Ordering(expr, Direction.ASC) + return Ordering(expr, Direction.ASCENDING) } @JvmStatic fun descending(expr: Expr): Ordering { - return Ordering(expr, Direction.DESC) + return Ordering(expr, Direction.DESCENDING) } } } } -data class GenericStage(val name: String, val params: Map?) : Stage { +// internal class Pagination(): Stage, GenericStage() + +internal open class GenericStage(val name: String, val params: List) : Stage { +} + +internal fun toStageProto(stage: Stage): com.google.firestore.v1.Pipeline.Stage { + return when (stage) { + is Collection -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + Value.newBuilder().setReferenceValue(stage.relativePath).build() + ) + .build() + + is CollectionGroup -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + Value.newBuilder().setReferenceValue("").build() + ) + .addArgs( + encodeValue( + stage.collectionId, + ) + ) + .build() + + is Database -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .build() + + is Documents -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addAllArgs(stage.documents.map { + Value.newBuilder().setReferenceValue(it).build() + }) + .build() + + is Project -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + encodeValue( + stage.projections, + ) + ) + .build() + + is AddFields -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + encodeValue( + stage.fields, + ) + ) + .build() + + is Filter<*> -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + encodeValue( + stage.condition, + ) + ) + .build() + + is Sort -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addAllArgs( + stage.orders.map { it.toProto() } + ) + .putOptions("density", encodeValue(stage.density)) + .putOptions("truncation", encodeValue(stage.truncation)) + .build() + + is Offset -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + encodeValue( + stage.offset + ) + ) + .build() + + is Limit -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + encodeValue( + stage.limit + ) + ) + .build() + + is Aggregate -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.groups)) + .addArgs(encodeValue(stage.accumulators)) + .build() + + is FindNearest -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs( + encodeValue( + stage.property + ) + ) + .addArgs( + encodeValue( + stage.vector + ) + ) + .addArgs( + encodeValue( + stage.distanceMeasure.toProtoString() + ) + ) + .putOptions("limit", encodeValue(stage.options.limit)) + .putOptions("distance_field", encodeValue(stage.options.output)) + .build() + + is GenericStage -> com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addAllArgs( + stage.params.map { encodeValue(it) } + ) + .build() + + else -> { + TODO() + } + } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/FirestoreRpc.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/FirestoreRpc.java index c2172fafb..5c8dd4572 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/FirestoreRpc.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/FirestoreRpc.java @@ -31,6 +31,8 @@ import com.google.firestore.v1.BeginTransactionResponse; import com.google.firestore.v1.CommitRequest; import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListDocumentsRequest; import com.google.firestore.v1.ListenRequest; @@ -62,6 +64,10 @@ public interface FirestoreRpc extends AutoCloseable, ServiceRpc { /** Runs a query. */ ServerStreamingCallable runQueryCallable(); + /** Executes a pipeline. */ + ServerStreamingCallable + executePipelineCallable(); + /** Runs an aggregation query. */ ServerStreamingCallable runAggregationQueryCallable(); diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpc.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpc.java index 9c606e8ab..0a60c62fd 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpc.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpc.java @@ -50,6 +50,8 @@ import com.google.firestore.v1.CommitRequest; import com.google.firestore.v1.CommitResponse; import com.google.firestore.v1.DatabaseRootName; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; import com.google.firestore.v1.ListCollectionIdsRequest; import com.google.firestore.v1.ListDocumentsRequest; import com.google.firestore.v1.ListenRequest; @@ -210,6 +212,12 @@ public ServerStreamingCallable runQueryCallab return firestoreStub.runQueryCallable(); } + @Override + public ServerStreamingCallable + executePipelineCallable() { + return firestoreStub.executePipelineCallable(); + } + @Override public ServerStreamingCallable runAggregationQueryCallable() { diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 393273237..891805f7d 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -22,9 +22,10 @@ import static com.google.cloud.firestore.pipeline.Function.lessThan; import static com.google.cloud.firestore.pipeline.Function.not; import static com.google.cloud.firestore.pipeline.Function.or; -import static com.google.cloud.firestore.pipeline.Ordering.ascending; -import static com.google.cloud.firestore.pipeline.Ordering.descending; +import static com.google.cloud.firestore.pipeline.Sort.Ordering.ascending; +import static com.google.cloud.firestore.pipeline.Sort.Ordering.descending; +import com.google.api.core.ApiFuture; import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; import com.google.cloud.firestore.PaginatingPipeline; @@ -33,9 +34,10 @@ import com.google.cloud.firestore.pipeline.Constant; import com.google.cloud.firestore.pipeline.Field; import com.google.cloud.firestore.pipeline.Fields; -import com.google.cloud.firestore.pipeline.Ordering; -import com.google.cloud.firestore.pipeline.Ordering.Direction; +import com.google.cloud.firestore.pipeline.Sort; +import com.google.cloud.firestore.pipeline.Sort.Ordering.Direction; import java.util.Iterator; +import java.util.List; import org.junit.Before; import org.junit.Test; @@ -50,21 +52,12 @@ public void before() throws Exception { @Test public void projections() throws Exception { - Pipeline p = - Pipeline.fromCollection("coll1") - .project( - Field.of("foo"), - Constant.of("emptyValue").asAlias("emptyField"), - Field.of("embedding").cosineDistance(new double[] {1, 2, 3.0}).asAlias("distance")); + Pipeline p = Pipeline.fromCollection("coll1").project(Field.of("foo")); + ApiFuture> results = p.execute(firestore); // More compact - p = - Pipeline.fromCollection("coll1") - .project(Fields.of("foo", "bar", "baz"), Constant.of(42).asAlias("emptyField")); - p = - Pipeline.fromCollection("coll1") - // basically an addField - .project(Fields.ofAll(), Constant.of(42).asAlias("emptyField")); + p = Pipeline.fromCollection("coll1").project(Fields.of("foo", "bar", "baz")); + results = p.execute(firestore); } @Test @@ -77,6 +70,7 @@ public void filters() throws Exception { Field.of("bar").lessThan(Constant.of(100)), Constant.of("value").equal(Field.of("key")))) .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + ApiFuture> results = p.execute(firestore); p = Pipeline.fromCollectionGroup("coll1") @@ -84,6 +78,7 @@ public void filters() throws Exception { .filter( or(lessThan(Field.of("bar"), 100), equal(Field.of("key"), Constant.of("value")))) .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); + results = p.execute(firestore); } @Test @@ -97,7 +92,7 @@ public void inFilters() throws Exception { public void aggregateWithoutGrouping() throws Exception { Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .filter(Field.of("foo").inAny(42, Field.of("bar"))) .aggregate(avg(Field.of("score")).toField("avg_score_1")); } @@ -107,9 +102,10 @@ public void sorts() throws Exception { Pipeline.fromCollection("coll1") .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) .sort( - Ordering.of(Field.of("rank")), - Ordering.of( - cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESC)) + Field.of("rank").ascending(), + Sort.Ordering.of( + cosineDistance(Field.of("embedding1"), Field.of("embedding2")), + Direction.DESCENDING)) .limit(100); // equivalent but more concise. @@ -128,13 +124,29 @@ public void pagination() throws Exception { Pipeline.fromCollection("coll1") .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) .paginate( - 100, - Ordering.of( - cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)); + 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); Iterator result = firestore.execute(p.firstPage()).get(); - Iterator second = firestore.execute(p.startAfter(result.next())).get(); + // Iterator second = firestore.execute(p.startAfter(result.next())).get(); + } + + @Test + public void limit() throws Exception { + Pipeline p = + Pipeline.fromDatabase() + .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .limit(10); + + Iterator result = firestore.execute(p).get(); + } + + @Test + public void offset() throws Exception { + Pipeline p = + Pipeline.fromDocuments(firestore.document("foo/bar1"), firestore.document("foo/bar2")) + .offset(1); + + Iterator result = firestore.execute(p).get(); } @Test @@ -143,12 +155,10 @@ public void fluentAllTheWay() throws Exception { Pipeline.fromCollection("coll1") .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) .paginate( - 100, - Ordering.of( - cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESC)); + 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); - Iterator result = p.firstPage().execute(firestore).get(); - Iterator second = p.startAfter(result.next()).execute(firestore).get(); + ApiFuture> result = p.firstPage().execute(firestore); + // List second = + // p.startAfter(result.iterator().next()).execute(firestore).get(); } } From ed2d276e8c6e891f93c5ab1fc2ea4aad18665b5b Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Fri, 26 Apr 2024 10:41:33 -0400 Subject: [PATCH 33/45] query to pipeline --- .../com/google/cloud/firestore/Query.java | 7 +++++ .../google/cloud/firestore/it/ITBaseTest.java | 30 ++++++++++++++++++- .../cloud/firestore/it/ITPipelineTest.java | 16 ++++------ 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java index 59ec6f960..1e8e0ee42 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -1955,6 +1955,13 @@ public AggregateQuery aggregate( return new AggregateQuery(this, aggregateFieldList); } + public Pipeline toPipeline() { + Pipeline ppl = Pipeline.fromCollection(this.options.getParentPath().append(this.options.getCollectionId()).getPath()); + for(FilterInternal f: this.options.getFilters()){ + } + return ppl; + } + /** * Returns true if this Query is equal to the provided object. * diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java index a9f0bfb2f..54292a00f 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java @@ -19,6 +19,7 @@ import static com.google.cloud.firestore.LocalFirestoreHelper.autoId; import static com.google.cloud.firestore.it.ITQueryTest.map; +import com.google.api.gax.rpc.TransportChannelProvider; import com.google.cloud.firestore.DocumentReference; import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; @@ -54,7 +55,11 @@ public abstract class ITBaseTest { public void before() throws Exception { FirestoreOptions.Builder optionsBuilder = FirestoreOptions.newBuilder(); - String namedDb = System.getProperty("FIRESTORE_NAMED_DATABASE"); + String dbPropertyName = "FIRESTORE_NAMED_DATABASE"; + String namedDb = System.getProperty(dbPropertyName); + if (namedDb == null) { + namedDb = System.getenv(dbPropertyName); + } if (namedDb != null) { logger.log(Level.INFO, "Integration test using named database " + namedDb); optionsBuilder = optionsBuilder.setDatabaseId(namedDb); @@ -62,7 +67,30 @@ public void before() throws Exception { logger.log(Level.INFO, "Integration test using default database."); } + String targetPropertyName = "FIRESTORE_TARGET_BACKEND"; + String targetBackend = System.getProperty(targetPropertyName); + if (targetBackend == null) { + targetBackend = System.getenv(targetPropertyName); + } + TransportChannelProvider defaultProvider = optionsBuilder.build().getTransportChannelProvider(); + if (targetBackend != null) { + if (targetBackend.equals("PROD")) { + // do nothing to use the default + } else if (targetBackend.equals("QA")) { + optionsBuilder.setChannelProvider( + defaultProvider.withEndpoint("staging-firestore.sandbox.googleapis.com:443")); + } else if (targetBackend.equals("NIGHTLY")) { + optionsBuilder.setChannelProvider( + defaultProvider.withEndpoint("test-firestore.sandbox.googleapis.com:443")); + } else { + throw new IllegalArgumentException("Illegal target backend: " + targetBackend); + } + } + firestoreOptions = optionsBuilder.build(); + logger.log( + Level.INFO, + "Integration test against " + firestoreOptions.getTransportChannelProvider().getEndpoint()); firestore = firestoreOptions.getService(); primeBackend(); } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 891805f7d..3e1b6670b 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -40,24 +40,20 @@ import java.util.List; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; -public class ITPipelineTest { - - protected Firestore firestore; - - @Before - public void before() throws Exception { - firestore = FirestoreOptions.newBuilder().build().getService(); - } +@RunWith(JUnit4.class) +public class ITPipelineTest extends ITBaseTest { @Test public void projections() throws Exception { Pipeline p = Pipeline.fromCollection("coll1").project(Field.of("foo")); - ApiFuture> results = p.execute(firestore); + List results = p.execute(firestore).get(); // More compact p = Pipeline.fromCollection("coll1").project(Fields.of("foo", "bar", "baz")); - results = p.execute(firestore); + results = p.execute(firestore).get(); } @Test From f551073c65c6656843ed84b4933e1ef0a8998d39 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 29 Apr 2024 10:03:58 -0400 Subject: [PATCH 34/45] e2e tests fine tuning --- .../cloud/firestore/AggregateQuery.java | 11 + .../com/google/cloud/firestore/Firestore.java | 3 - .../google/cloud/firestore/FirestoreImpl.java | 7 - .../com/google/cloud/firestore/Pipeline.kt | 207 +++++---- .../google/cloud/firestore/PipelineResult.kt | 31 +- .../google/cloud/firestore/PipelineUtils.kt | 140 ++++++ .../com/google/cloud/firestore/Query.java | 77 +++- .../cloud/firestore/pipeline/Expressions.kt | 277 +++++++----- .../google/cloud/firestore/pipeline/Stages.kt | 269 +++++------- .../cloud/firestore/it/ITPipelineTest.java | 82 ++-- .../cloud/firestore/it/ITQueryTest.java | 403 ++++++++++++------ 11 files changed, 952 insertions(+), 555 deletions(-) create mode 100644 google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java index 1613b74dd..08e206240 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java @@ -24,6 +24,7 @@ import com.google.api.gax.rpc.StatusCode; import com.google.api.gax.rpc.StreamController; import com.google.cloud.Timestamp; +import com.google.cloud.firestore.pipeline.AggregatorTarget; import com.google.cloud.firestore.v1.FirestoreSettings; import com.google.firestore.v1.RunAggregationQueryRequest; import com.google.firestore.v1.RunAggregationQueryResponse; @@ -65,6 +66,16 @@ public Query getQuery() { return query; } + @Nonnull + public Pipeline toPipeline() { + return getQuery() + .toPipeline() + .aggregate( + this.aggregateFieldList.stream() + .map(PipelineUtilsKt::toPipelineAggregatorTarget) + .toArray(AggregatorTarget[]::new)); + } + /** * Executes this query. * diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java index ac552d80d..5bbb1164a 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java @@ -21,7 +21,6 @@ import com.google.api.core.InternalExtensionOnly; import com.google.api.gax.rpc.ApiStreamObserver; import com.google.cloud.Service; -import java.util.Iterator; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -288,8 +287,6 @@ void getAll( @Nonnull FirestoreBundle.Builder bundleBuilder(@Nonnull String bundleId); - ApiFuture> execute(Pipeline pipeline); - /** * Closes the gRPC channels associated with this instance and frees up their resources. This * method blocks until all channels are closed. Once this method is called, this Firestore client diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java index 618b27d0d..796d0c165 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -18,7 +18,6 @@ import com.google.api.core.ApiClock; import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; import com.google.api.core.NanoClock; import com.google.api.core.SettableApiFuture; import com.google.api.gax.rpc.ApiStreamObserver; @@ -46,7 +45,6 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; @@ -410,11 +408,6 @@ public FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId) { return new FirestoreBundle.Builder(id); } - @Override - public ApiFuture> execute(Pipeline pipeline) { - return ApiFutures.immediateFuture(null); - } - /** Returns the name of the Firestore project associated with this client. */ @Override public String getDatabaseName() { diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 422a15816..4e2682bb7 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -29,6 +29,7 @@ import com.google.cloud.firestore.pipeline.Stage import com.google.cloud.firestore.pipeline.toStageProto import com.google.common.base.Preconditions import com.google.common.collect.ImmutableMap +import com.google.firestore.v1.Cursor import com.google.firestore.v1.Document import com.google.firestore.v1.ExecutePipelineRequest import com.google.firestore.v1.ExecutePipelineResponse @@ -39,46 +40,70 @@ import io.opencensus.trace.Tracing import java.util.logging.Level import java.util.logging.Logger -class PaginatingPipeline internal constructor( - val p: Pipeline, - pageSize: Int, - orders: Array +internal fun setStartCursor(pipeline: PaginatingPipeline, cursor: Cursor): PaginatingPipeline { + return pipeline +} + +internal fun setEndCursor(pipeline: PaginatingPipeline, cursor: Cursor): PaginatingPipeline { + return pipeline +} + +class PaginatingPipeline +internal constructor( + internal val p: Pipeline, + internal val pageSize: Int, + internal val orders: List, + private val offset: Int? = null, + private val startCursor: Cursor? = null, + private val endCursor: Cursor? = null, ) { fun firstPage(): Pipeline { return this.p } - fun startAt(result: PipelineResult): Pipeline { + fun lastPage(): Pipeline { return this.p } - fun startAfter(result: PipelineResult): Pipeline { - return this.p + fun startAt(result: PipelineResult): PaginatingPipeline { + return this } - fun endAt(result: PipelineResult): Pipeline { - return this.p + fun startAfter(result: PipelineResult): PaginatingPipeline { + return this } - fun endBefore(result: PipelineResult): Pipeline { - return this.p + fun endAt(result: PipelineResult): PaginatingPipeline { + return this + } + + fun endBefore(result: PipelineResult): PaginatingPipeline { + return this + } + + // Internal as this is only potentially used when converting Query to Pipeline. + internal fun offset(offset: Int): PaginatingPipeline { + return this } } /** - * The Pipeline class provides a flexible and expressive framework for building complex data transformation - * and query pipelines for Firestore. + * The Pipeline class provides a flexible and expressive framework for building complex data + * transformation and query pipelines for Firestore. * - * A pipeline takes data sources such as Firestore collections, collection groups, or even in-memory data, and - * applies a series of operations that are chained together, each operation takes the output from the last - * operation (or the data source) and produces an output for the next operation (or as the final output of the pipeline). + * A pipeline takes data sources such as Firestore collections, collection groups, or even in-memory + * data, and applies a series of operations that are chained together, each operation takes the + * output from the last operation (or the data source) and produces an output for the next operation + * (or as the final output of the pipeline). * - * NOTE: the chained operations are not a prescription of exactly how Firestore will execute the pipeline, - * instead Firestore only guarantee the result is the same as if the chained operations are executed in order. + * NOTE: the chained operations are not a prescription of exactly how Firestore will execute the + * pipeline, instead Firestore only guarantee the result is the same as if the chained operations + * are executed in order. * * Usage Examples: * * **1. Projecting Specific Fields and Renaming:** + * * ```java * Pipeline pipeline = Pipeline.fromCollection("users") * // Select 'name' and 'email' fields, create 'userAge' which is renamed from field 'age'. @@ -86,6 +111,7 @@ class PaginatingPipeline internal constructor( * ``` * * **2. Filtering and Sorting:** + * * ```java * Pipeline pipeline = Pipeline.fromCollectionGroup("reviews") * .filter(Field.of("rating").greaterThan(Expr.Constant.of(3))) // High ratings @@ -93,6 +119,7 @@ class PaginatingPipeline internal constructor( * ``` * * **3. Aggregation with Grouping:** + * * ```java * Pipeline pipeline = Pipeline.fromCollection("orders") * .group(Field.of("customerId")) @@ -130,7 +157,7 @@ class Pipeline private constructor(private val stages: List, private val Preconditions.checkArgument( !collectionId.contains("/"), "Invalid collectionId '%s'. Collection IDs must not contain '/'.", - collectionId + collectionId, ) return Pipeline(CollectionGroup(collectionId)) } @@ -166,7 +193,7 @@ class Pipeline private constructor(private val stages: List, private val return Pipeline(stages.plus(Project(projectablesToMap(*projections))), name) } - fun filter(condition: T): Pipeline where T : Expr, T:Function.FilterCondition{ + fun filter(condition: T): Pipeline where T : Expr, T : Function.FilterCondition { return Pipeline(stages.plus(Filter(condition)), name) } @@ -185,26 +212,26 @@ class Pipeline private constructor(private val stages: List, private val fun findNearest( property: Field, vector: DoubleArray, - options: FindNearest.FindNearestOptions + options: FindNearest.FindNearestOptions, ): Pipeline { return this } fun sort( - orders: List, + orders: List, density: Sort.Density = Sort.Density.UNSPECIFIED, - truncation: Sort.Truncation = Sort.Truncation.UNSPECIFIED + truncation: Sort.Truncation = Sort.Truncation.UNSPECIFIED, ): Pipeline { - return this + return Pipeline(stages.plus(Sort(orders, density, truncation)), name) } // Sugar fun sort(vararg orders: Ordering): Pipeline { - return this + return this.sort(orders.toList()) } fun paginate(pageSize: Int, vararg orders: Ordering): PaginatingPipeline { - return PaginatingPipeline(this, pageSize, orders) + return PaginatingPipeline(this, pageSize, orders.toList()) } fun genericOperation(name: String, params: Map? = null): Pipeline { @@ -215,31 +242,37 @@ class Pipeline private constructor(private val stages: List, private val when (db) { is FirestoreImpl -> { val pipelineValue = toProto() - val request = ExecutePipelineRequest.newBuilder() - .setStructuredPipeline( - StructuredPipeline.newBuilder() - .setPipeline(pipelineValue.pipelineValue).build() - ).build() + val request = + ExecutePipelineRequest.newBuilder() + .setDatabase(db.resourcePath.databaseName.toString()) + .setStructuredPipeline( + StructuredPipeline.newBuilder().setPipeline(pipelineValue.pipelineValue).build() + ) + .build() val futureResult = SettableApiFuture.create>() - pipelineInternalStream(db, request, object : PipelineResultObserver() { - val results = mutableListOf() - override fun onCompleted() { - futureResult.set(results) - } - - override fun onNext(result: PipelineResult?) { - results.add(result!!) - } - - override fun onError(t: Throwable?) { - futureResult.setException(t) - } - }) + pipelineInternalStream( + db, + request, + object : PipelineResultObserver() { + val results = mutableListOf() + + override fun onCompleted() { + futureResult.set(results) + } + + override fun onNext(result: PipelineResult?) { + results.add(result!!) + } + + override fun onError(t: Throwable?) { + futureResult.setException(t) + } + }, + ) return futureResult } - else -> { TODO() } @@ -250,28 +283,32 @@ class Pipeline private constructor(private val stages: List, private val when (db) { is FirestoreImpl -> { val pipelineValue = toProto() - val request = ExecutePipelineRequest.newBuilder() - .setDatabase(db.resourcePath.databaseName.toString()) - .setStructuredPipeline( - StructuredPipeline.newBuilder() - .setPipeline(pipelineValue.pipelineValue).build() - ).build() - - pipelineInternalStream(db, request, object : PipelineResultObserver() { - override fun onCompleted() { - observer.onCompleted() - } - - override fun onNext(result: PipelineResult?) { - observer.onNext(result) - } - - override fun onError(t: Throwable?) { - observer.onError(t) - } - }) + val request = + ExecutePipelineRequest.newBuilder() + .setDatabase(db.resourcePath.databaseName.toString()) + .setStructuredPipeline( + StructuredPipeline.newBuilder().setPipeline(pipelineValue.pipelineValue).build() + ) + .build() + + pipelineInternalStream( + db, + request, + object : PipelineResultObserver() { + override fun onCompleted() { + observer.onCompleted() + } + + override fun onNext(result: PipelineResult?) { + observer.onNext(result) + } + + override fun onError(t: Throwable?) { + observer.onError(t) + } + }, + ) } - else -> { TODO() } @@ -281,24 +318,17 @@ class Pipeline private constructor(private val stages: List, private val fun toProto(): Value { return Value.newBuilder() .setPipelineValue( - com.google.firestore.v1.Pipeline.newBuilder() - .addAllStages(stages.map { toStageProto(it) }) + com.google.firestore.v1.Pipeline.newBuilder().addAllStages(stages.map { toStageProto(it) }) ) .build() } } internal fun encodeValue(value: Any?): Value? { - return UserDataConverter.encodeValue( - FieldPath.empty(), - value, - UserDataConverter.ARGUMENT - ) + return UserDataConverter.encodeValue(FieldPath.empty(), value, UserDataConverter.ARGUMENT) } -private abstract class PipelineResultObserver - - : ApiStreamObserver { +private abstract class PipelineResultObserver : ApiStreamObserver { var executionTime: Timestamp? = null private set @@ -311,7 +341,7 @@ private abstract class PipelineResultObserver private fun pipelineInternalStream( rpcContext: FirestoreImpl, request: ExecutePipelineRequest, - resultObserver: PipelineResultObserver + resultObserver: PipelineResultObserver, ) { val observer: ResponseObserver = object : ResponseObserver { @@ -323,8 +353,7 @@ private fun pipelineInternalStream( // this flag makes sure only the first one is actually processed. var hasCompleted: Boolean = false - override fun onStart(streamController: StreamController) { - } + override fun onStart(streamController: StreamController) {} override fun onResponse(response: ExecutePipelineResponse) { if (!firstResponse) { @@ -334,17 +363,11 @@ private fun pipelineInternalStream( if (response.resultsCount > 0) { numDocuments += response.resultsCount if (numDocuments % 100 == 0) { - Tracing.getTracer() - .currentSpan - .addAnnotation("Firestore.Query: Received 100 documents") + Tracing.getTracer().currentSpan.addAnnotation("Firestore.Query: Received 100 documents") } response.resultsList.forEach { doc: Document -> resultObserver.onNext( - PipelineResult.fromDocument( - rpcContext, - response.executionTime, - doc - ) + PipelineResult.fromDocument(rpcContext, response.executionTime, doc) ) } } @@ -370,15 +393,15 @@ private fun pipelineInternalStream( .addAnnotation( "Firestore.Query: Completed", ImmutableMap.of( - "numDocuments", AttributeValue.longAttributeValue(numDocuments.toLong()) - ) + "numDocuments", + AttributeValue.longAttributeValue(numDocuments.toLong()), + ), ) resultObserver.onCompleted(executionTime) } } - Logger.getLogger("Pipeline") - .log(Level.WARNING, "Sending request: $request") + Logger.getLogger("Pipeline").log(Level.WARNING, "Sending request: $request") rpcContext.streamRequest(request, observer, rpcContext.client.executePipelineCallable()) } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt index ab184c2c9..fa191001e 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -6,13 +6,14 @@ import com.google.firestore.v1.Value import java.util.Date import javax.annotation.Nonnull -data class PipelineResult internal constructor( +data class PipelineResult +internal constructor( private val rpcContext: FirestoreRpcContext<*>?, val reference: DocumentReference?, val protoFields: Map, val readTime: Timestamp, val updateTime: Timestamp?, - val createTime: Timestamp? + val createTime: Timestamp?, ) { val id: String? get() = reference?.id @@ -23,8 +24,8 @@ data class PipelineResult internal constructor( val data: Map? /** - * Returns the fields of the document as a Map or null if the document doesn't exist. Field values - * will be converted to their native Java representation. + * Returns the fields of the document as a Map or null if the document doesn't exist. Field + * values will be converted to their native Java representation. * * @return The fields of the document as a Map or null if the document doesn't exist. */ @@ -46,14 +47,12 @@ data class PipelineResult internal constructor( * * @param valueType The Java class to create * @return The contents of the result in an object of type T or null if the document doesn't - * exist. + * exist. */ fun toObject(@Nonnull valueType: Class): T? { val data = data - return if (data == null) null else CustomClassMapper.convertToCustomClass( - data, valueType, - reference - ) + return if (data == null) null + else CustomClassMapper.convertToCustomClass(data, valueType, reference) } /** @@ -93,10 +92,8 @@ data class PipelineResult internal constructor( fun get(fieldPath: FieldPath, valueType: Class): T? { val data = get(fieldPath) - return if (data == null) null else CustomClassMapper.convertToCustomClass( - data, valueType, - reference - ) + return if (data == null) null + else CustomClassMapper.convertToCustomClass(data, valueType, reference) } fun extractField(fieldPath: FieldPath): Value? { @@ -158,15 +155,17 @@ data class PipelineResult internal constructor( companion object { @JvmStatic internal fun fromDocument( - rpcContext: FirestoreRpcContext<*>?, readTime: com.google.protobuf.Timestamp, document: Document + rpcContext: FirestoreRpcContext<*>?, + readTime: com.google.protobuf.Timestamp, + document: Document, ): PipelineResult { return PipelineResult( rpcContext, document.name?.let { DocumentReference(rpcContext, ResourcePath.create(it)) }, document.fieldsMap, Timestamp.fromProto(readTime), - document.updateTime?.let {Timestamp.fromProto(it)}, - document.createTime?.let {Timestamp.fromProto(it)}, + document.updateTime?.let { Timestamp.fromProto(it) }, + document.createTime?.let { Timestamp.fromProto(it) }, ) } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt new file mode 100644 index 000000000..397300bf4 --- /dev/null +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt @@ -0,0 +1,140 @@ +package com.google.cloud.firestore + +import com.google.cloud.firestore.Query.ComparisonFilterInternal +import com.google.cloud.firestore.Query.CompositeFilterInternal +import com.google.cloud.firestore.Query.FilterInternal +import com.google.cloud.firestore.Query.LimitType +import com.google.cloud.firestore.Query.UnaryFilterInternal +import com.google.cloud.firestore.pipeline.AggregatorTarget +import com.google.cloud.firestore.pipeline.Constant +import com.google.cloud.firestore.pipeline.Field +import com.google.cloud.firestore.pipeline.Function +import com.google.cloud.firestore.pipeline.Function.Companion.countAll +import com.google.cloud.firestore.pipeline.Function.Companion.not +import com.google.firestore.v1.Cursor +import com.google.firestore.v1.StructuredQuery + +internal fun toPipelineFilterCondition(f: FilterInternal): Function.FilterCondition { + return when (f) { + is ComparisonFilterInternal -> { + when (f.operator) { + StructuredQuery.FieldFilter.Operator.OPERATOR_UNSPECIFIED -> { + TODO() + } + StructuredQuery.FieldFilter.Operator.LESS_THAN -> { + Field.of(f.fieldReference.fieldPath).lessThan(f.value) + } + StructuredQuery.FieldFilter.Operator.LESS_THAN_OR_EQUAL -> { + Field.of(f.fieldReference.fieldPath).lessThanOrEqual(f.value) + } + StructuredQuery.FieldFilter.Operator.GREATER_THAN -> { + Field.of(f.fieldReference.fieldPath).greaterThan(f.value) + } + StructuredQuery.FieldFilter.Operator.GREATER_THAN_OR_EQUAL -> { + Field.of(f.fieldReference.fieldPath).greaterThanOrEqual(f.value) + } + StructuredQuery.FieldFilter.Operator.EQUAL -> { + Field.of(f.fieldReference.fieldPath).equal(f.value) + } + StructuredQuery.FieldFilter.Operator.NOT_EQUAL -> { + not(Field.of(f.fieldReference.fieldPath).equal(f.value)) + } + StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS -> { + Field.of(f.fieldReference.fieldPath).arrayContains(f.value) + } + StructuredQuery.FieldFilter.Operator.IN -> { + Function.In( + Field.of(f.fieldReference.fieldPath), + f.value?.arrayValue?.valuesList?.map { Constant.of(it) } ?: emptyList(), + ) + } + StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS_ANY -> { + Function.ArrayContainsAny( + Field.of(f.fieldReference.fieldPath), + f.value?.arrayValue?.valuesList?.map { Constant.of(it) } ?: emptyList(), + ) + } + StructuredQuery.FieldFilter.Operator.NOT_IN -> { + not( + Function.In( + Field.of(f.fieldReference.fieldPath), + f.value?.arrayValue?.valuesList?.map { Constant.of(it) } ?: emptyList(), + ) + ) + } + StructuredQuery.FieldFilter.Operator.UNRECOGNIZED -> { + TODO() + } + } + } + is CompositeFilterInternal -> { + when (f.operator) { + StructuredQuery.CompositeFilter.Operator.OPERATOR_UNSPECIFIED -> { + TODO() + } + StructuredQuery.CompositeFilter.Operator.AND -> { + Function.And(f.filters.map { toPipelineFilterCondition(it) }) + } + StructuredQuery.CompositeFilter.Operator.OR -> { + Function.Or(f.filters.map { toPipelineFilterCondition(it) }) + } + StructuredQuery.CompositeFilter.Operator.UNRECOGNIZED -> { + TODO() + } + } + } + is UnaryFilterInternal -> { + when (f.operator) { + StructuredQuery.UnaryFilter.Operator.IS_NAN -> Field.of(f.fieldReference.fieldPath).isNaN() + StructuredQuery.UnaryFilter.Operator.IS_NULL -> + Field.of(f.fieldReference.fieldPath).isNull() + StructuredQuery.UnaryFilter.Operator.IS_NOT_NAN -> + not(Field.of(f.fieldReference.fieldPath).isNaN()) + StructuredQuery.UnaryFilter.Operator.IS_NOT_NULL -> + not(Field.of(f.fieldReference.fieldPath).isNull()) + StructuredQuery.UnaryFilter.Operator.OPERATOR_UNSPECIFIED -> TODO() + StructuredQuery.UnaryFilter.Operator.UNRECOGNIZED -> TODO() + } + } + else -> { + TODO() + } + } +} + +internal fun toPaginatedPipeline( + pipeline: Pipeline, + start: Cursor?, + end: Cursor?, + limit: Int?, + limitType: LimitType?, + offset: Int?, +): Pipeline { + var paginate: PaginatingPipeline = pipeline.paginate(limit ?: Int.MAX_VALUE) + + start?.let { paginate = setStartCursor(paginate, it) } + end?.let { paginate = setEndCursor(paginate, it) } + offset?.let { paginate = paginate.offset(it) } + + return limitType?.let { + when (it) { + LimitType.First -> paginate.firstPage() + LimitType.Last -> paginate.lastPage() + } + } ?: paginate.firstPage() +} + +internal fun toPipelineAggregatorTarget(f: AggregateField): AggregatorTarget { + return when (f.operator) { + "sum" -> { + Field.of(f.getFieldPath()).sum().toField(f.alias) + } + "count" -> { + countAll().toField(f.alias) + } + "avg" -> { + Field.of(f.getFieldPath()).avg().toField(f.alias) + } + else -> TODO() + } +} diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java index 1e8e0ee42..0eedf2f69 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -16,6 +16,8 @@ package com.google.cloud.firestore; +import static com.google.cloud.firestore.PipelineUtilsKt.toPaginatedPipeline; +import static com.google.cloud.firestore.PipelineUtilsKt.toPipelineFilterCondition; import static com.google.common.collect.Lists.reverse; import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS; import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS_ANY; @@ -38,6 +40,11 @@ import com.google.auto.value.AutoValue; import com.google.cloud.Timestamp; import com.google.cloud.firestore.Query.QueryOptions.Builder; +import com.google.cloud.firestore.pipeline.Field; +import com.google.cloud.firestore.pipeline.Projectable; +import com.google.cloud.firestore.pipeline.Sort.Density; +import com.google.cloud.firestore.pipeline.Sort.Ordering; +import com.google.cloud.firestore.pipeline.Sort.Truncation; import com.google.cloud.firestore.v1.FirestoreSettings; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -54,6 +61,7 @@ import com.google.firestore.v1.StructuredQuery.FieldReference; import com.google.firestore.v1.StructuredQuery.Filter; import com.google.firestore.v1.StructuredQuery.Order; +import com.google.firestore.v1.StructuredQuery.UnaryFilter; import com.google.firestore.v1.Value; import com.google.protobuf.ByteString; import com.google.protobuf.Int32Value; @@ -74,6 +82,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Logger; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.threeten.bp.Duration; @@ -172,6 +181,11 @@ public List getFilters() { return filters; } + @Nonnull + CompositeFilter.Operator getOperator() { + return this.operator; + } + @Nullable @Override public FieldReference getFirstInequalityField() { @@ -237,7 +251,7 @@ public List getFlattenedFilters() { } } - private static class UnaryFilterInternal extends FieldFilterInternal { + static class UnaryFilterInternal extends FieldFilterInternal { private final StructuredQuery.UnaryFilter.Operator operator; @@ -264,6 +278,11 @@ Filter toProto() { return result.build(); } + @Nonnull + UnaryFilter.Operator getOperator() { + return this.operator; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -1955,10 +1974,62 @@ public AggregateQuery aggregate( return new AggregateQuery(this, aggregateFieldList); } + @Nonnull public Pipeline toPipeline() { - Pipeline ppl = Pipeline.fromCollection(this.options.getParentPath().append(this.options.getCollectionId()).getPath()); - for(FilterInternal f: this.options.getFilters()){ + // From + Pipeline ppl = + Pipeline.fromCollection( + this.options.getParentPath().append(this.options.getCollectionId()).getPath()); + + // Filters + for (FilterInternal f : this.options.getFilters()) { + ppl = ppl.filter(toPipelineFilterCondition(f)); + } + + // Projections + if (this.options.getFieldProjections() != null + && !this.options.getFieldProjections().isEmpty()) { + ppl = + ppl.project( + this.options.getFieldProjections().stream() + .map(fieldReference -> Field.of(fieldReference.getFieldPath())) + .toArray(Projectable[]::new)); + } + + // Orders + if (this.options.getFieldOrders() != null && !this.options.getFieldOrders().isEmpty()) { + List orders = + this.options.getFieldOrders().stream() + .map( + fieldOrder -> + Ordering.of( + Field.of(fieldOrder.fieldReference.getFieldPath()), + fieldOrder.direction == Direction.ASCENDING + ? Ordering.Direction.ASCENDING + : Ordering.Direction.DESCENDING)) + .collect(Collectors.toList()); + ppl = ppl.sort(orders, Density.REQUIRED, Truncation.UNSPECIFIED); + } + + // Cursors, Limit and Offset + if (this.options.getStartCursor() != null || this.options.getEndCursor() != null) { + ppl = + toPaginatedPipeline( + ppl, + options.getStartCursor(), + options.getEndCursor(), + options.getLimit(), + options.getLimitType(), + options.getOffset()); + } else { // Limit & Offset without cursors + if (this.options.getOffset() != null) { + ppl = ppl.offset(this.options.getOffset()); + } + if (this.options.getLimit() != null) { + ppl = ppl.limit(this.options.getLimit()); + } } + return ppl; } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 3abecfa5f..1c3892d5a 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -1,5 +1,9 @@ package com.google.cloud.firestore.pipeline +import com.google.cloud.Timestamp +import com.google.cloud.firestore.Blob +import com.google.cloud.firestore.DocumentReference +import com.google.cloud.firestore.GeoPoint import com.google.cloud.firestore.Pipeline import com.google.cloud.firestore.encodeValue import com.google.cloud.firestore.pipeline.Function.ArrayContains @@ -19,23 +23,23 @@ import com.google.cloud.firestore.pipeline.Function.LessThan import com.google.cloud.firestore.pipeline.Function.LessThanOrEqual import com.google.cloud.firestore.pipeline.Function.NotEqual import com.google.cloud.firestore.pipeline.Function.Sum -import com.google.firestore.v1.Value -import com.google.cloud.Timestamp -import com.google.cloud.firestore.Blob -import com.google.cloud.firestore.DocumentReference -import com.google.cloud.firestore.GeoPoint import com.google.cloud.firestore.pipeline.Sort.Ordering import com.google.cloud.firestore.pipeline.Sort.Ordering.Direction import com.google.firestore.v1.ArrayValue +import com.google.firestore.v1.Value import java.util.Date -internal fun exprToValue(expr: Expr): Value{ - return when(expr) { +internal fun exprToValue(expr: Expr): Value { + return when (expr) { is Constant -> expr.toProto() is Field -> expr.toProto() is Function -> expr.toProto() is ListOfExprs -> { - Value.newBuilder().setArrayValue(ArrayValue.newBuilder().addAllValues(expr.conditions.map { exprToValue(it) })).build() + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder().addAllValues(expr.conditions.map { exprToValue(it) }) + ) + .build() } else -> { TODO() @@ -48,45 +52,87 @@ sealed interface Projectable interface Expr { // Infix functions returning Function subclasses infix fun equal(other: Expr) = Equal(this, other) + infix fun equal(other: Any) = Equal(this, Constant.of(other)) + infix fun notEqual(other: Expr) = NotEqual(this, other) + infix fun notEqual(other: Any) = NotEqual(this, Constant.of(other)) + infix fun greaterThan(other: Expr) = GreaterThan(this, other) + infix fun greaterThan(other: Any) = GreaterThan(this, Constant.of(other)) + infix fun greaterThanOrEqual(other: Expr) = GreaterThanOrEqual(this, other) + infix fun greaterThanOrEqual(other: Any) = GreaterThanOrEqual(this, Constant.of(other)) + infix fun lessThan(other: Expr) = LessThan(this, other) + infix fun lessThan(other: Any) = LessThan(this, Constant.of(other)) + infix fun lessThanOrEqual(other: Expr) = LessThanOrEqual(this, other) + infix fun lessThanOrEqual(other: Any) = LessThanOrEqual(this, Constant.of(other)) - fun inAny(vararg other: Any) = In(this, other.toList().map { when(it) { - is Expr -> it - else -> Constant.of(it) }}) - fun notInAny(vararg other: Any) = Function.Not(In(this, other.toList().map { when(it) { - is Expr -> it - else -> Constant.of(it) }})) + + fun inAny(vararg other: Any) = + In( + this, + other.toList().map { + when (it) { + is Expr -> it + else -> Constant.of(it) + } + }, + ) + + fun notInAny(vararg other: Any) = + Function.Not( + In( + this, + other.toList().map { + when (it) { + is Expr -> it + else -> Constant.of(it) + } + }, + ) + ) infix fun arrayContains(element: Expr) = ArrayContains(this, element) + infix fun arrayContains(element: Any) = ArrayContains(this, Constant.of(element)) + fun arrayContainsAny(vararg elements: Expr) = ArrayContainsAny(this, elements.toList()) - fun arrayContainsAny(vararg elements: Any) = ArrayContainsAny(this, elements.toList().map { Constant.of(it) }) + + fun arrayContainsAny(vararg elements: Any) = + ArrayContainsAny(this, elements.toList().map { Constant.of(it) }) + fun isNaN() = IsNaN(this) + fun isNull() = IsNull(this) + fun sum() = Sum(this, false) + fun avg() = Avg(this, false) + fun count() = Count(this, false) + fun min() = Count(this, false) + fun max() = Count(this, false) infix fun cosineDistance(other: Expr) = CosineDistance(this, other) - infix fun cosineDistance(other: DoubleArray) = - CosineDistance(this, Constant.ofVector(other)) + + infix fun cosineDistance(other: DoubleArray) = CosineDistance(this, Constant.ofVector(other)) infix fun euclideanDistance(other: Expr) = EuclideanDistance(this, other) + infix fun euclideanDistance(other: DoubleArray) = EuclideanDistance(this, Constant.ofVector(other)) infix fun dotProductDistance(other: Expr) = DotProductDistance(this, other) + infix fun dotProductDistance(other: DoubleArray) = DotProductDistance(this, Constant.ofVector(other)) @@ -144,6 +190,11 @@ data class Constant internal constructor(val value: Any?) : Expr { return Constant(value) } + @JvmStatic + fun of(value: Value?): Constant { + return Constant(value) + } + @JvmStatic internal fun of(value: Any?): Constant { if (value == null) { @@ -159,22 +210,23 @@ data class Constant internal constructor(val value: Any?) : Expr { is GeoPoint -> of(value) is Blob -> of(value) is DocumentReference -> of(value) + is Value -> of(value) else -> TODO("Unknown type: $value") } } @JvmStatic - fun ofArray(value: Iterable): Constant { + fun ofArray(value: Iterable): Constant { return Constant(value) } @JvmStatic - fun ofArray(value: Array): Constant { + fun ofArray(value: Array): Constant { return Constant(value) } @JvmStatic - fun ofMap(value: Map): Constant { + fun ofMap(value: Map): Constant { return Constant(value) } @@ -190,8 +242,8 @@ data class Constant internal constructor(val value: Any?) : Expr { } } -data class Field internal constructor(val field: String, var pipeline: Pipeline? = null) : Expr, - Projectable{ +data class Field internal constructor(val field: String, var pipeline: Pipeline? = null) : + Expr, Projectable { companion object { const val DOCUMENT_ID: String = "__path__" @@ -199,6 +251,11 @@ data class Field internal constructor(val field: String, var pipeline: Pipeline? fun of(path: String): Field { return Field(path) } + + @JvmStatic + fun ofAll(): Field { + return Field("") + } } fun toProto(): Value { @@ -212,19 +269,25 @@ data class Fields internal constructor(val fs: List? = null) : Expr, Proj fun of(f1: String, vararg f: String): Fields { return Fields(listOf(Field.of(f1)) + f.map(Field.Companion::of)) } + + @JvmStatic + fun ofAll(): Fields { + return Fields(listOf(Field.of(""))) + } } } -data class AggregatorTarget internal constructor( - val accumulator: Function.Accumulator, val fieldName: String, - override var distinct: Boolean -) : Projectable, - Function.Accumulator +data class AggregatorTarget +internal constructor( + val accumulator: Function.Accumulator, + val fieldName: String, + override var distinct: Boolean, +) : Projectable, Function.Accumulator -sealed class Function(val name: String, val params: List): Expr { - interface FilterCondition +sealed class Function(val name: String, val params: List) : Expr { + interface FilterCondition : Expr - interface Accumulator: Expr { + interface Accumulator : Expr { var distinct: Boolean fun distinct(on: Boolean): Accumulator { @@ -236,9 +299,13 @@ sealed class Function(val name: String, val params: List): Expr { } fun toProto(): Value { - return Value.newBuilder().setFunctionValue(com.google.firestore.v1.Function.newBuilder() - .setName(name) - .addAllArgs(params.map { exprToValue(it) })).build() + return Value.newBuilder() + .setFunctionValue( + com.google.firestore.v1.Function.newBuilder() + .setName(name) + .addAllArgs(params.map { exprToValue(it) }) + ) + .build() } data class Equal internal constructor(val left: Expr, val right: Expr) : @@ -260,28 +327,25 @@ sealed class Function(val name: String, val params: List): Expr { Function("lte", listOf(left, right)), FilterCondition data class In(val left: Expr, val others: List) : - Function("in", listOf(left, ListOfExprs(others))), - FilterCondition // For 'in' + Function("in", listOf(left, ListOfExprs(others))), FilterCondition // For 'in' - data class And(val conditions: List) : - Function("and", conditions), FilterCondition where T : FilterCondition, T:Expr + data class And(val conditions: List) : Function("and", conditions), FilterCondition where + T : FilterCondition - data class Or(val conditions: List) : - Function("or", conditions), FilterCondition where T : FilterCondition, T:Expr + data class Or(val conditions: List) : Function("or", conditions), FilterCondition where + T : FilterCondition - data class Not(val condition: Expr) : Function("not", listOf(condition)), - FilterCondition + data class Not(val condition: Expr) : Function("not", listOf(condition)), FilterCondition data class ArrayContains(val array: Expr, val element: Expr) : Function("array_contains", listOf(array, element)), FilterCondition data class ArrayContainsAny(val array: Expr, val elements: List) : - Function("array_contains_any", listOf(array, ListOfExprs(elements))), - FilterCondition + Function("array_contains_any", listOf(array, ListOfExprs(elements))), FilterCondition data class IsNaN(val value: Expr) : Function("is_nan", listOf(value)), FilterCondition - data class IsNull(val value: Expr) : Function("is_null", listOf(value)), - FilterCondition + + data class IsNull(val value: Expr) : Function("is_null", listOf(value)), FilterCondition data class Sum(val value: Expr, override var distinct: Boolean) : Function("sum", listOf(value)), Accumulator @@ -289,10 +353,12 @@ sealed class Function(val name: String, val params: List): Expr { data class Avg(val value: Expr, override var distinct: Boolean) : Function("avg", listOf(value)), Accumulator - data class Count(val value: Expr, override var distinct: Boolean) : - Function("count", listOf(value)), Accumulator + data class Count(val value: Expr?, override var distinct: Boolean) : + Function("count", value?.let { listOf(it) } ?: emptyList()), Accumulator + data class Min(val value: Expr, override var distinct: Boolean) : Function("min", listOf(value)), Accumulator + data class Max(val value: Expr, override var distinct: Boolean) : Function("max", listOf(value)), Accumulator @@ -307,78 +373,74 @@ sealed class Function(val name: String, val params: List): Expr { data class Generic(val n: String, val ps: List) : Function(n, ps) - companion object { - @JvmStatic - fun equal(left: Expr, right: Expr) = Equal(left, right) + @JvmStatic fun equal(left: Expr, right: Expr) = Equal(left, right) - @JvmStatic - fun equal(left: Expr, right: Any) = Equal(left, Constant.of(right)) + @JvmStatic fun equal(left: Expr, right: Any) = Equal(left, Constant.of(right)) - @JvmStatic - fun notEqual(left: Expr, right: Expr) = NotEqual(left, right) + @JvmStatic fun notEqual(left: Expr, right: Expr) = NotEqual(left, right) - @JvmStatic - fun notEqual(left: Expr, right: Any) = NotEqual(left, Constant.of(right)) + @JvmStatic fun notEqual(left: Expr, right: Any) = NotEqual(left, Constant.of(right)) - @JvmStatic - fun greaterThan(left: Expr, right: Expr) = GreaterThan(left, right) + @JvmStatic fun greaterThan(left: Expr, right: Expr) = GreaterThan(left, right) - @JvmStatic - fun greaterThan(left: Expr, right: Any) = - GreaterThan(left, Constant.of(right)) + @JvmStatic fun greaterThan(left: Expr, right: Any) = GreaterThan(left, Constant.of(right)) - @JvmStatic - fun greaterThanOrEqual(left: Expr, right: Expr) = GreaterThanOrEqual(left, right) + @JvmStatic fun greaterThanOrEqual(left: Expr, right: Expr) = GreaterThanOrEqual(left, right) @JvmStatic fun greaterThanOrEqual(left: Expr, right: Any) = GreaterThanOrEqual(left, Constant.of(right)) - @JvmStatic - fun lessThan(left: Expr, right: Expr) = LessThan(left, right) + @JvmStatic fun lessThan(left: Expr, right: Expr) = LessThan(left, right) - @JvmStatic - fun lessThan(left: Expr, right: Any) = LessThan(left, Constant.of(right)) + @JvmStatic fun lessThan(left: Expr, right: Any) = LessThan(left, Constant.of(right)) - @JvmStatic - fun lessThanOrEqual(left: Expr, right: Expr) = LessThanOrEqual(left, right) + @JvmStatic fun lessThanOrEqual(left: Expr, right: Expr) = LessThanOrEqual(left, right) @JvmStatic fun lessThanOrEqual(left: Expr, right: Any) = LessThanOrEqual(left, Constant.of(right)) @JvmStatic - fun inAny(left: Expr, values: List) = In(left, values.map { - when (it) { - is Expr -> it - else -> Constant.of(it) - } - }) + fun inAny(left: Expr, values: List) = + In( + left, + values.map { + when (it) { + is Expr -> it + else -> Constant.of(it) + } + }, + ) @JvmStatic - fun notInAny(left: Expr, values: List) = Not(In(left, values.map { - when (it) { - is Expr -> it - else ->Constant.of(it) - }})) + fun notInAny(left: Expr, values: List) = + Not( + In( + left, + values.map { + when (it) { + is Expr -> it + else -> Constant.of(it) + } + }, + ) + ) @JvmStatic - fun and(left: T, right: T) where T : FilterCondition, T:Expr = - And(listOf(left, right)) + fun and(left: T, right: T) where T : FilterCondition, T : Expr = And(listOf(left, right)) @JvmStatic - fun and(left: T, vararg other: T) where T : FilterCondition, T:Expr= + fun and(left: T, vararg other: T) where T : FilterCondition, T : Expr = And(listOf(left) + other.toList()) @JvmStatic - fun or(left: T, right: T) where T : FilterCondition, T:Expr = - Or(listOf(left, right)) + fun or(left: T, right: T) where T : FilterCondition, T : Expr = Or(listOf(left, right)) @JvmStatic - fun or(left: T, vararg other: T) where T : FilterCondition, T:Expr= + fun or(left: T, vararg other: T) where T : FilterCondition, T : Expr = Or(listOf(left) + other.toList()) - @JvmStatic - fun arrayContains(expr: Expr, element: Expr) = ArrayContains(expr, element) + @JvmStatic fun arrayContains(expr: Expr, element: Expr) = ArrayContains(expr, element) @JvmStatic fun arrayContains(expr: Expr, element: Any) = ArrayContains(expr, Constant.of(element)) @@ -391,53 +453,42 @@ sealed class Function(val name: String, val params: List): Expr { fun arrayContainsAny(expr: Expr, vararg elements: Any) = ArrayContainsAny(expr, elements.toList().map { Constant.of(it) }) - @JvmStatic - fun isNaN(expr: Expr) = IsNaN(expr) + @JvmStatic fun isNaN(expr: Expr) = IsNaN(expr) - @JvmStatic - fun isNull(expr: Expr) = IsNull(expr) + @JvmStatic fun isNull(expr: Expr) = IsNull(expr) - @JvmStatic - fun not(expr: Expr) = Not(expr) + @JvmStatic fun not(expr: Expr) = Not(expr) - @JvmStatic - fun sum(expr: Expr) = Sum(expr, false) + @JvmStatic fun sum(expr: Expr) = Sum(expr, false) - @JvmStatic - fun avg(expr: Expr) = Avg(expr, false) + @JvmStatic fun avg(expr: Expr) = Avg(expr, false) - @JvmStatic - fun min(expr: Expr) = Sum(expr, false) + @JvmStatic fun min(expr: Expr) = Sum(expr, false) - @JvmStatic - fun max(expr: Expr) = Avg(expr, false) + @JvmStatic fun max(expr: Expr) = Avg(expr, false) - @JvmStatic - fun count(expr: Expr) = Count(expr, false) + @JvmStatic fun countAll(expr: Expr) = Count(expr, false) - @JvmStatic - fun cosineDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) + @JvmStatic fun countAll() = Count(null, false) + + @JvmStatic fun cosineDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) @JvmStatic fun cosineDistance(expr: Expr, other: DoubleArray) = CosineDistance(expr, Constant.ofVector(other)) - @JvmStatic - fun dotProductDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) + @JvmStatic fun dotProductDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) @JvmStatic fun dotProductDistance(expr: Expr, other: DoubleArray) = CosineDistance(expr, Constant.ofVector(other)) - @JvmStatic - fun euclideanDistance(expr: Expr, other: Expr) = EuclideanDistance(expr, other) + @JvmStatic fun euclideanDistance(expr: Expr, other: Expr) = EuclideanDistance(expr, other) @JvmStatic fun euclideanDistance(expr: Expr, other: DoubleArray) = EuclideanDistance(expr, Constant.ofVector(other)) - @JvmStatic - fun function(name: String, params: List) = Generic(name, params) + @JvmStatic fun function(name: String, params: List) = Generic(name, params) } } - diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index 0ffc10cbe..df3a76445 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -16,16 +16,17 @@ internal data class CollectionGroup(val collectionId: String) : Stage { val name = "collection_group" } -internal class Database: Stage { +internal class Database : Stage { val name = "database" } -internal data class Documents(val documents: List): Stage { +internal data class Documents(val documents: List) : Stage { val name = "documents" + companion object { @JvmStatic fun of(vararg documents: DocumentReference): Documents { - return Documents(documents.map { it.path }) + return Documents(documents.map { "/" + it.path }) } } } @@ -38,7 +39,9 @@ internal data class AddFields(val fields: Map) : Stage { val name = "add_fields" } -internal data class Filter (val condition: T) : Stage where T:Function.FilterCondition, T:Expr { +internal data class Filter(val condition: T) : Stage where +T : Function.FilterCondition, +T : Expr { val name = "filter" } @@ -50,32 +53,37 @@ internal class Limit(val limit: Int) : Stage { val name = "limit" } -class Aggregate internal constructor( +class Aggregate +internal constructor( val groups: Map, - val accumulators: Map + val accumulators: Map, ) : Stage { val name = "aggregate" - internal constructor(vararg aggregators: AggregatorTarget) : - this(emptyMap(), aggregators.associate { it.fieldName to it.accumulator }) + internal constructor( + vararg aggregators: AggregatorTarget + ) : this(emptyMap(), aggregators.associate { it.fieldName to it.accumulator }) } -class FindNearest internal constructor( +class FindNearest +internal constructor( val property: Field, val vector: DoubleArray, val distanceMeasure: DistanceMeasure, - val options: FindNearestOptions + val options: FindNearestOptions, ) : Stage { val name = "find_nearest" sealed interface DistanceMeasure { data object Euclidean : DistanceMeasure + data object Cosine : DistanceMeasure + data object DotProduct : DistanceMeasure class GenericDistanceMeasure(val name: String) : DistanceMeasure - fun toProtoString(): String{ + fun toProtoString(): String { return when (this) { is Euclidean -> "euclidean" is Cosine -> "cosine" @@ -85,61 +93,59 @@ class FindNearest internal constructor( } companion object { - @JvmStatic - fun euclidean() = Euclidean + @JvmStatic fun euclidean() = Euclidean - @JvmStatic - fun cosine() = Cosine + @JvmStatic fun cosine() = Cosine - @JvmStatic - fun dotProduct() = DotProduct + @JvmStatic fun dotProduct() = DotProduct - @JvmStatic - fun generic(name: String) = GenericDistanceMeasure(name) + @JvmStatic fun generic(name: String) = GenericDistanceMeasure(name) } } - data class FindNearestOptions( - val limit: Long?, - val output: Field? = null - ) + data class FindNearestOptions(val limit: Long?, val output: Field? = null) } -class Sort internal constructor( +class Sort +internal constructor( val orders: List, val density: Density = Density.UNSPECIFIED, - val truncation: Truncation = Truncation.UNSPECIFIED + val truncation: Truncation = Truncation.UNSPECIFIED, ) : Stage { val name = "sort" enum class Density { UNSPECIFIED, REQUIRED; - override fun toString(): String - = name.lowercase(Locale.getDefault()) + + override fun toString(): String = name.lowercase(Locale.getDefault()) } enum class Truncation { UNSPECIFIED, DISABLED; - override fun toString(): String - = name.lowercase(Locale.getDefault()) + + override fun toString(): String = name.lowercase(Locale.getDefault()) } - class Ordering internal constructor(private val expr: Expr, private val dir: Direction = Direction.ASCENDING) { + class Ordering + internal constructor(private val expr: Expr, private val dir: Direction = Direction.ASCENDING) { enum class Direction { ASCENDING, DESCENDING; - override fun toString(): String - = name.lowercase(Locale.getDefault()) + override fun toString(): String = name.lowercase(Locale.getDefault()) } internal fun toProto(): Value { - return Value.newBuilder().setMapValue(MapValue.newBuilder() - .putFields("direction", encodeValue(dir.toString())) - .putFields("expression", encodeValue(expr)) - .build()).build() + return Value.newBuilder() + .setMapValue( + MapValue.newBuilder() + .putFields("direction", encodeValue(dir.toString())) + .putFields("expression", encodeValue(expr)) + .build() + ) + .build() } companion object { @@ -168,129 +174,80 @@ class Sort internal constructor( // internal class Pagination(): Stage, GenericStage() -internal open class GenericStage(val name: String, val params: List) : Stage { -} +internal open class GenericStage(val name: String, val params: List) : Stage {} internal fun toStageProto(stage: Stage): com.google.firestore.v1.Pipeline.Stage { return when (stage) { - is Collection -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - Value.newBuilder().setReferenceValue(stage.relativePath).build() - ) - .build() - - is CollectionGroup -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - Value.newBuilder().setReferenceValue("").build() - ) - .addArgs( - encodeValue( - stage.collectionId, - ) - ) - .build() - - is Database -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .build() - - is Documents -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addAllArgs(stage.documents.map { - Value.newBuilder().setReferenceValue(it).build() - }) - .build() - - is Project -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - encodeValue( - stage.projections, - ) - ) - .build() - - is AddFields -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - encodeValue( - stage.fields, - ) - ) - .build() - - is Filter<*> -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - encodeValue( - stage.condition, - ) - ) - .build() - - is Sort -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addAllArgs( - stage.orders.map { it.toProto() } - ) - .putOptions("density", encodeValue(stage.density)) - .putOptions("truncation", encodeValue(stage.truncation)) - .build() - - is Offset -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - encodeValue( - stage.offset - ) - ) - .build() - - is Limit -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - encodeValue( - stage.limit - ) - ) - .build() - - is Aggregate -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs(encodeValue(stage.groups)) - .addArgs(encodeValue(stage.accumulators)) - .build() - - is FindNearest -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addArgs( - encodeValue( - stage.property - ) - ) - .addArgs( - encodeValue( - stage.vector - ) - ) - .addArgs( - encodeValue( - stage.distanceMeasure.toProtoString() - ) - ) - .putOptions("limit", encodeValue(stage.options.limit)) - .putOptions("distance_field", encodeValue(stage.options.output)) - .build() - - is GenericStage -> com.google.firestore.v1.Pipeline.Stage.newBuilder() - .setName(stage.name) - .addAllArgs( - stage.params.map { encodeValue(it) } - ) - .build() - + is Collection -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(Value.newBuilder().setReferenceValue("").build()) + .addArgs(Value.newBuilder().setStringValue(stage.relativePath).build()) + .build() + is CollectionGroup -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(Value.newBuilder().setReferenceValue("").build()) + .addArgs(encodeValue(stage.collectionId)) + .build() + is Database -> com.google.firestore.v1.Pipeline.Stage.newBuilder().setName(stage.name).build() + is Documents -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addAllArgs(stage.documents.map { Value.newBuilder().setReferenceValue(it).build() }) + .build() + is Project -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.projections)) + .build() + is AddFields -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.fields)) + .build() + is Filter<*> -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.condition)) + .build() + is Sort -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addAllArgs(stage.orders.map { it.toProto() }) + .putOptions("density", encodeValue(stage.density.toString())) + .putOptions("truncation", encodeValue(stage.truncation.toString())) + .build() + is Offset -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.offset)) + .build() + is Limit -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.limit)) + .build() + is Aggregate -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.groups)) + .addArgs(encodeValue(stage.accumulators)) + .build() + is FindNearest -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addArgs(encodeValue(stage.property)) + .addArgs(encodeValue(stage.vector)) + .addArgs(encodeValue(stage.distanceMeasure.toProtoString())) + .putOptions("limit", encodeValue(stage.options.limit)) + .putOptions("distance_field", encodeValue(stage.options.output)) + .build() + is GenericStage -> + com.google.firestore.v1.Pipeline.Stage.newBuilder() + .setName(stage.name) + .addAllArgs(stage.params.map { encodeValue(it) }) + .build() else -> { TODO() } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 3e1b6670b..2494c5dd3 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -16,6 +16,7 @@ package com.google.cloud.firestore.it; +import static com.google.cloud.firestore.it.ITQueryTest.map; import static com.google.cloud.firestore.pipeline.Function.avg; import static com.google.cloud.firestore.pipeline.Function.cosineDistance; import static com.google.cloud.firestore.pipeline.Function.equal; @@ -25,9 +26,8 @@ import static com.google.cloud.firestore.pipeline.Sort.Ordering.ascending; import static com.google.cloud.firestore.pipeline.Sort.Ordering.descending; -import com.google.api.core.ApiFuture; -import com.google.cloud.firestore.Firestore; -import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.LocalFirestoreHelper; import com.google.cloud.firestore.PaginatingPipeline; import com.google.cloud.firestore.Pipeline; import com.google.cloud.firestore.PipelineResult; @@ -36,24 +36,53 @@ import com.google.cloud.firestore.pipeline.Fields; import com.google.cloud.firestore.pipeline.Sort; import com.google.cloud.firestore.pipeline.Sort.Ordering.Direction; -import java.util.Iterator; import java.util.List; -import org.junit.Before; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class ITPipelineTest extends ITBaseTest { + public CollectionReference testCollectionWithDocs(Map> docs) + throws ExecutionException, InterruptedException, TimeoutException { + CollectionReference collection = firestore.collection(LocalFirestoreHelper.autoId()); + for (Map.Entry> doc : docs.entrySet()) { + collection.document(doc.getKey()).set(doc.getValue()).get(5, TimeUnit.SECONDS); + } + return collection; + } + + @Test + public void fromSources() throws Exception { + Map> testDocs = + map( + "doc1", map("a", 1, "b", 0), + "doc2", map("a", 2, "b", 1), + "doc3", map("a", 3, "b", 2), + "doc4", map("a", 1, "b", 3), + "doc5", map("a", 1, "b", 1)); + + CollectionReference collection = testCollectionWithDocs(testDocs); + + Pipeline p = Pipeline.fromCollectionGroup(collection.getId()); + List results = p.execute(firestore).get(); + System.out.println(results.size()); + } @Test public void projections() throws Exception { - Pipeline p = Pipeline.fromCollection("coll1").project(Field.of("foo")); + Pipeline p = Pipeline.fromCollectionGroup("coll1").project(Field.of("foo")); List results = p.execute(firestore).get(); + System.out.println(results.size()); // More compact - p = Pipeline.fromCollection("coll1").project(Fields.of("foo", "bar", "baz")); + p = Pipeline.fromCollectionGroup("coll1").project(Fields.of("foo", "bar", "baz")); results = p.execute(firestore).get(); + System.out.println(results.size()); } @Test @@ -65,65 +94,66 @@ public void filters() throws Exception { or( Field.of("bar").lessThan(Constant.of(100)), Constant.of("value").equal(Field.of("key")))) - .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); - ApiFuture> results = p.execute(firestore); + .filter(not(Constant.of(128).inAny("f1", "f2"))); + List results = p.execute(firestore).get(); p = Pipeline.fromCollectionGroup("coll1") .filter(equal(Field.of("foo"), 42)) .filter( or(lessThan(Field.of("bar"), 100), equal(Field.of("key"), Constant.of("value")))) - .filter(not(Constant.of(128).inAny(Field.of("f1"), Field.of("f2")))); - results = p.execute(firestore); + .filter(not(Constant.of(128).inAny("f1", "f2"))); + results = p.execute(firestore).get(); } @Test public void inFilters() throws Exception { - Pipeline p = - Pipeline.fromCollectionGroup("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))); + Pipeline p = Pipeline.fromCollectionGroup("coll1").filter(Field.of("foo").inAny(42, "42")); + List results = p.execute(firestore).get(); } @Test public void aggregateWithoutGrouping() throws Exception { Pipeline p = - Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(42, Field.of("bar"))) + Pipeline.fromDatabase() + .filter(Field.of("foo").inAny(42, "bar")) .aggregate(avg(Field.of("score")).toField("avg_score_1")); + List results = p.execute(firestore).get(); } @Test public void sorts() throws Exception { Pipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .filter(Field.of("foo").inAny(42, "42")) .sort( Field.of("rank").ascending(), Sort.Ordering.of( cosineDistance(Field.of("embedding1"), Field.of("embedding2")), Direction.DESCENDING)) .limit(100); + List results = p.execute(firestore).get(); // equivalent but more concise. p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .filter(Field.of("foo").inAny(Constant.of(42), Constant.of(false))) .sort( ascending(Field.of("rank")), descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) .limit(100); + results = p.execute(firestore).get(); } @Test public void pagination() throws Exception { PaginatingPipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .filter(Field.of("foo").inAny(Constant.of(42), Constant.of("bar"))) .paginate( 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); - Iterator result = firestore.execute(p.firstPage()).get(); - // Iterator second = firestore.execute(p.startAfter(result.next())).get(); + List results = p.firstPage().execute(firestore).get(); } @Test @@ -133,7 +163,7 @@ public void limit() throws Exception { .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) .limit(10); - Iterator result = firestore.execute(p).get(); + List result = p.execute(firestore).get(); } @Test @@ -142,19 +172,17 @@ public void offset() throws Exception { Pipeline.fromDocuments(firestore.document("foo/bar1"), firestore.document("foo/bar2")) .offset(1); - Iterator result = firestore.execute(p).get(); + List result = p.execute(firestore).get(); } @Test public void fluentAllTheWay() throws Exception { PaginatingPipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) + .filter(Field.of("foo").inAny(Constant.of(42), Constant.of("bar"))) .paginate( 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); - ApiFuture> result = p.firstPage().execute(firestore); - // List second = - // p.startAfter(result.iterator().next()).execute(firestore).get(); + List result = p.firstPage().execute(firestore).get(); } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java index 444d31dd5..3ddd8439b 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java @@ -19,7 +19,6 @@ import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; import static com.google.common.primitives.Ints.asList; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assume.assumeTrue; import com.google.cloud.firestore.*; import com.google.cloud.firestore.Query.Direction; @@ -28,6 +27,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -66,12 +66,26 @@ public CollectionReference testCollectionWithDocs(Map result = + snapshot.getDocuments().stream() + .map(queryDocumentSnapshot -> queryDocumentSnapshot.getReference().getId()) + .collect(Collectors.toList()); + assertThat(result).isEqualTo(Arrays.asList(docs)); + } + + List pipelineResults = query.toPipeline().execute(query.getFirestore()).get(); List result = - snapshot.getDocuments().stream() - .map(queryDocumentSnapshot -> queryDocumentSnapshot.getReference().getId()) + pipelineResults.stream() + .map(pipelineResult -> Objects.requireNonNull(pipelineResult.getReference()).getId()) .collect(Collectors.toList()); assertThat(result).isEqualTo(Arrays.asList(docs)); } @@ -89,7 +103,7 @@ public void orQueries() throws Exception { CollectionReference collection = testCollectionWithDocs(testDocs); // Two equalities: a==1 || b==1. - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))), "doc1", "doc2", @@ -97,7 +111,7 @@ public void orQueries() throws Exception { "doc5"); // (a==1 && b==0) || (a==3 && b==2) - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where( Filter.or( Filter.and(Filter.equalTo("a", 1), Filter.equalTo("b", 0)), @@ -106,7 +120,7 @@ public void orQueries() throws Exception { "doc3"); // a==1 && (b==0 || b==3). - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where( Filter.and( Filter.equalTo("a", 1), Filter.or(Filter.equalTo("b", 0), Filter.equalTo("b", 3)))), @@ -114,7 +128,7 @@ public void orQueries() throws Exception { "doc4"); // (a==2 || b==2) && (a==3 || b==3) - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where( Filter.and( Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 2)), @@ -122,16 +136,13 @@ public void orQueries() throws Exception { "doc3"); // Test with limits without orderBy (the __name__ ordering is the tiebreaker). - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))).limit(1), "doc2"); } @Test public void orQueriesWithCompositeIndexes() throws Exception { - assumeTrue( - "Skip this test when running against production because these queries require a composite index.", - isRunningAgainstFirestoreEmulator(firestore)); Map> testDocs = map( "doc1", map("a", 1, "b", 0), @@ -143,50 +154,56 @@ public void orQueriesWithCompositeIndexes() throws Exception { CollectionReference collection = testCollectionWithDocs(testDocs); // with one inequality: a>2 || b==1. - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where(Filter.or(Filter.greaterThan("a", 2), Filter.equalTo("b", 1))), + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", "doc2", "doc3"); // Test with limits (implicit order by ASC): (a==1) || (b > 0) LIMIT 2 - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where(Filter.or(Filter.equalTo("a", 1), Filter.greaterThan("b", 0))).limit(2), + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", "doc2"); // Test with limits (explicit order by): (a==1) || (b > 0) LIMIT_TO_LAST 2 // Note: The public query API does not allow implicit ordering when limitToLast is used. - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection .where(Filter.or(Filter.equalTo("a", 1), Filter.greaterThan("b", 0))) .limitToLast(2) .orderBy("b"), + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3", "doc4"); // Test with limits (explicit order by ASC): (a==2) || (b == 1) ORDER BY a LIMIT 1 - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) .limit(1) .orderBy("a"), + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5"); // Test with limits (explicit order by DESC): (a==2) || (b == 1) ORDER BY a LIMIT_TO_LAST 1 - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) .limitToLast(1) .orderBy("a"), + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2"); // Test with limits (explicit order by DESC): (a==2) || (b == 1) ORDER BY a DESC LIMIT 1 - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) .limit(1) .orderBy("a", Direction.DESCENDING), + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2"); } @@ -207,14 +224,11 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields() throws Exception { // There's no explicit nor implicit orderBy. Documents with missing 'a' or missing 'b' should be // allowed if the document matches at least one disjunction term. Query query = collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))); - checkQuerySnapshotContainsDocuments(query, "doc1", "doc2", "doc4", "doc5"); + checkResultContainsDocuments(query, "doc1", "doc2", "doc4", "doc5"); } @Test public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception { - assumeTrue( - "Skip this test when running against production because these queries require a composite index.", - isRunningAgainstFirestoreEmulator(firestore)); Map> testDocs = map( "doc1", map("a", 1, "b", 0), @@ -230,19 +244,30 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception // doc2 should not be included because it's missing the field 'a', and we have "orderBy a". Query query1 = collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))).orderBy("a"); - checkQuerySnapshotContainsDocuments(query1, "doc1", "doc4", "doc5"); + checkResultContainsDocuments( + query1, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc1", + "doc4", + "doc5"); // Query: a==1 || b==1 order by b. // doc5 should not be included because it's missing the field 'b', and we have "orderBy b". Query query2 = collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))).orderBy("b"); - checkQuerySnapshotContainsDocuments(query2, "doc1", "doc2", "doc4"); + checkResultContainsDocuments( + query2, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc1", + "doc2", + "doc4"); // Query: a>2 || b==1. // This query has an implicit 'order by a'. // doc2 should not be included because it's missing the field 'a'. Query query3 = collection.where(Filter.or(Filter.greaterThan("a", 2), Filter.equalTo("b", 1))); - checkQuerySnapshotContainsDocuments(query3, "doc3"); + checkResultContainsDocuments( + query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3"); // Query: a>1 || b==1 order by a order by b. // doc6 should not be included because it's missing the field 'b'. @@ -252,7 +277,8 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception .where(Filter.or(Filter.greaterThan("a", 1), Filter.equalTo("b", 1))) .orderBy("a") .orderBy("b"); - checkQuerySnapshotContainsDocuments(query4, "doc3"); + checkResultContainsDocuments( + query4, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3"); } @Test @@ -268,7 +294,7 @@ public void orQueriesWithIn() throws ExecutionException, InterruptedException, T CollectionReference collection = testCollectionWithDocs(testDocs); // a==2 || b in [2,3] - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.inArray("b", asList(2, 3)))), "doc3", "doc4", @@ -278,9 +304,6 @@ public void orQueriesWithIn() throws ExecutionException, InterruptedException, T @Test public void orQueriesWithNotIn() throws ExecutionException, InterruptedException, TimeoutException { - assumeTrue( - "Skip this test when running against production because it is currently not supported.", - isRunningAgainstFirestoreEmulator(firestore)); Map> testDocs = map( "doc1", map("a", 1, "b", 0), @@ -293,8 +316,9 @@ public void orQueriesWithNotIn() // a==2 || b not-in [2,3] // Has implicit orderBy b. - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.notInArray("b", asList(2, 3)))), + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", "doc2"); } @@ -313,14 +337,14 @@ public void orQueriesWithArrayMembership() CollectionReference collection = testCollectionWithDocs(testDocs); // a==2 || b array-contains 7 - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.arrayContains("b", 7))), "doc3", "doc4", "doc6"); // a==2 || b array-contains-any [0, 3] - checkQuerySnapshotContainsDocuments( + checkResultContainsDocuments( collection.where( Filter.or(Filter.equalTo("a", 2), Filter.arrayContainsAny("b", asList(0, 3)))), "doc1", @@ -344,35 +368,31 @@ public void testUsingInWithArrayContains() Query query1 = collection.where( Filter.or(Filter.inArray("a", asList(2, 3)), Filter.arrayContains("b", 3))); - checkQuerySnapshotContainsDocuments(query1, "doc3", "doc4", "doc6"); + checkResultContainsDocuments(query1, "doc3", "doc4", "doc6"); Query query2 = collection.where( Filter.and(Filter.inArray("a", asList(2, 3)), Filter.arrayContains("b", 7))); - checkQuerySnapshotContainsDocuments(query2, "doc3"); + checkResultContainsDocuments(query2, "doc3"); Query query3 = collection.where( Filter.or( Filter.inArray("a", asList(2, 3)), Filter.and(Filter.arrayContains("b", 3), Filter.equalTo("a", 1)))); - checkQuerySnapshotContainsDocuments(query3, "doc3", "doc4", "doc6"); + checkResultContainsDocuments(query3, "doc3", "doc4", "doc6"); Query query4 = collection.where( Filter.and( Filter.inArray("a", asList(2, 3)), Filter.or(Filter.arrayContains("b", 7), Filter.equalTo("a", 1)))); - checkQuerySnapshotContainsDocuments(query4, "doc3"); + checkResultContainsDocuments(query4, "doc3"); } @Test public void testOrderByEquality() throws ExecutionException, InterruptedException, TimeoutException { - assumeTrue( - "Skip this test if running against production because order-by-equality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); Map> testDocs = map( "doc1", map("a", 1, "b", asList(0)), @@ -384,21 +404,21 @@ public void testOrderByEquality() CollectionReference collection = testCollectionWithDocs(testDocs); Query query1 = collection.where(Filter.equalTo("a", 1)).orderBy("a"); - checkQuerySnapshotContainsDocuments(query1, "doc1", "doc4", "doc5"); + checkResultContainsDocuments( + query1, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc1", + "doc4", + "doc5"); Query query2 = collection.where(Filter.inArray("a", asList(2, 3))).orderBy("a"); - checkQuerySnapshotContainsDocuments(query2, "doc6", "doc3"); + checkResultContainsDocuments( + query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc6", "doc3"); } /** Multiple Inequality */ @Test public void multipleInequalityOnDifferentFields() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -412,7 +432,8 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereNotEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereGreaterThan("v", 2); - checkQuerySnapshotContainsDocuments(query1, "doc3"); + checkResultContainsDocuments( + query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3"); // Duplicate inequality fields Query query2 = @@ -420,7 +441,8 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereNotEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereGreaterThan("sort", 1); - checkQuerySnapshotContainsDocuments(query2, "doc4"); + checkResultContainsDocuments( + query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4"); // With multiple IN Query query3 = @@ -429,7 +451,8 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereLessThanOrEqualTo("sort", 2) .whereIn("v", asList(2, 3, 4)) .whereIn("sort", asList(2, 3)); - checkQuerySnapshotContainsDocuments(query3, "doc4"); + checkResultContainsDocuments( + query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4"); // With NOT-IN Query query4 = @@ -437,7 +460,8 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereGreaterThanOrEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereNotIn("v", asList(2, 4, 5)); - checkQuerySnapshotContainsDocuments(query4, "doc1", "doc3"); + checkResultContainsDocuments( + query4, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", "doc3"); // With orderby Query query5 = @@ -445,7 +469,12 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereGreaterThanOrEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .orderBy("v", Direction.DESCENDING); - checkQuerySnapshotContainsDocuments(query5, "doc3", "doc4", "doc1"); + checkResultContainsDocuments( + query5, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc3", + "doc4", + "doc1"); // With limit Query query6 = @@ -454,7 +483,8 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereLessThanOrEqualTo("sort", 2) .orderBy("v", Direction.DESCENDING) .limit(2); - checkQuerySnapshotContainsDocuments(query6, "doc3", "doc4"); + checkResultContainsDocuments( + query6, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3", "doc4"); // With limitToLast Query query7 = @@ -463,17 +493,12 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereLessThanOrEqualTo("sort", 2) .orderBy("v", Direction.DESCENDING) .limitToLast(2); - checkQuerySnapshotContainsDocuments(query7, "doc4", "doc1"); + checkResultContainsDocuments( + query7, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4", "doc1"); } @Test public void multipleInequalityOnSpecialValues() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -485,24 +510,20 @@ public void multipleInequalityOnSpecialValues() throws Exception { "doc6", map("key", "f", "sort", 1, "v", 1))); Query query1 = collection.whereNotEqualTo("key", "a").whereLessThanOrEqualTo("sort", 2); - checkQuerySnapshotContainsDocuments(query1, "doc5", "doc6"); + checkResultContainsDocuments( + query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", "doc6"); Query query2 = collection .whereNotEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereLessThanOrEqualTo("v", 1); - checkQuerySnapshotContainsDocuments(query2, "doc6"); + checkResultContainsDocuments( + query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc6"); } @Test public void multipleInequalityWithArrayMembership() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -526,14 +547,16 @@ public void multipleInequalityWithArrayMembership() throws Exception { .whereNotEqualTo("key", "a") .whereGreaterThanOrEqualTo("sort", 1) .whereArrayContains("v", 0); - checkQuerySnapshotContainsDocuments(query1, "doc2"); + checkResultContainsDocuments( + query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2"); Query query2 = collection .whereNotEqualTo("key", "a") .whereGreaterThanOrEqualTo("sort", 1) .whereArrayContainsAny("v", asList(0, 1)); - checkQuerySnapshotContainsDocuments(query2, "doc2", "doc4"); + checkResultContainsDocuments( + query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc4"); } private static Map nestedObject(int number) { @@ -554,12 +577,6 @@ private static Map nestedObject(int number) { // result with the query fields normalized in the server. @Test public void multipleInequalityWithNestedField() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -577,8 +594,13 @@ public void multipleInequalityWithNestedField() throws Exception { .orderBy("name"); DocumentSnapshot docSnap = collection.document("doc4").get().get(); Query query1WithCursor = query1.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query1, "doc4", "doc1"); - checkQuerySnapshotContainsDocuments(query1WithCursor, "doc4", "doc1"); + checkResultContainsDocuments( + query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4", "doc1"); + checkResultContainsDocuments( + query1WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc4", + "doc1"); // ordered by: name desc, field desc, field.dot desc, field\\slash desc, __name__ desc Query query2 = @@ -589,18 +611,13 @@ public void multipleInequalityWithNestedField() throws Exception { .orderBy("name", Direction.DESCENDING); docSnap = collection.document("doc2").get().get(); Query query2WithCursor = query2.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query2, "doc2", "doc3"); - checkQuerySnapshotContainsDocuments(query2WithCursor, "doc2", "doc3"); + checkResultContainsDocuments( + query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc3"); + checkResultContainsDocuments(query2WithCursor, "doc2", "doc3"); } @Test public void multipleInequalityWithCompositeFilters() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -625,8 +642,20 @@ public void multipleInequalityWithCompositeFilters() throws Exception { Filter.and(Filter.notEqualTo("key", "b"), Filter.greaterThan("v", 4)))); DocumentSnapshot docSnap = collection.document("doc1").get().get(); Query query1WithCursor = query1.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query1, "doc1", "doc6", "doc5", "doc4"); - checkQuerySnapshotContainsDocuments(query1WithCursor, "doc1", "doc6", "doc5", "doc4"); + checkResultContainsDocuments( + query1, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc1", + "doc6", + "doc5", + "doc4"); + checkResultContainsDocuments( + query1WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc1", + "doc6", + "doc5", + "doc4"); // Ordered by: 'sort' desc, 'key' asc, 'v' asc, __name__ asc Query query2 = @@ -639,8 +668,20 @@ public void multipleInequalityWithCompositeFilters() throws Exception { .orderBy("key"); docSnap = collection.document("doc5").get().get(); Query query2WithCursor = query2.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query2, "doc5", "doc4", "doc1", "doc6"); - checkQuerySnapshotContainsDocuments(query2WithCursor, "doc5", "doc4", "doc1", "doc6"); + checkResultContainsDocuments( + query2, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc5", + "doc4", + "doc1", + "doc6"); + checkResultContainsDocuments( + query2WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc5", + "doc4", + "doc1", + "doc6"); // Implicitly ordered by: 'key' asc, 'sort' asc, 'v' asc, __name__ asc Query query3 = @@ -655,19 +696,18 @@ public void multipleInequalityWithCompositeFilters() throws Exception { Filter.and(Filter.lessThan("key", "b"), Filter.greaterThan("v", 0))))); docSnap = collection.document("doc1").get().get(); Query query3WithCursor = query3.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query3, "doc1", "doc2"); - checkQuerySnapshotContainsDocuments(query3WithCursor, "doc1", "doc2"); + checkResultContainsDocuments( + query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", "doc2"); + checkResultContainsDocuments( + query3WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc1", + "doc2"); } @Test public void multipleInequalityFieldsWillBeImplicitlyOrderedLexicographicallyByServer() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -693,8 +733,20 @@ public void multipleInequalityFieldsWillBeImplicitlyOrderedLexicographicallyBySe .whereGreaterThan("sort", 1) .whereIn("v", asList(1, 2, 3, 4)); Query query1WithCursor = query1.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query1, "doc2", "doc4", "doc5", "doc3"); - checkQuerySnapshotContainsDocuments(query1WithCursor, "doc2", "doc4", "doc5", "doc3"); + checkResultContainsDocuments( + query1, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc5", + "doc3"); + checkResultContainsDocuments( + query1WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc5", + "doc3"); // Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc Query query2 = @@ -703,18 +755,24 @@ public void multipleInequalityFieldsWillBeImplicitlyOrderedLexicographicallyBySe .whereNotEqualTo("key", "a") .whereIn("v", asList(1, 2, 3, 4)); Query query2WithCursor = query2.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query2, "doc2", "doc4", "doc5", "doc3"); - checkQuerySnapshotContainsDocuments(query2WithCursor, "doc2", "doc4", "doc5", "doc3"); + checkResultContainsDocuments( + query2, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc5", + "doc3"); + checkResultContainsDocuments( + query2WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc5", + "doc3"); } @Test public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -737,8 +795,20 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { Query query1 = collection.whereGreaterThan("key", "a").whereGreaterThanOrEqualTo("sort", 1).orderBy("v"); Query query1WithCursor = query1.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query1, "doc2", "doc4", "doc3", "doc5"); - checkQuerySnapshotContainsDocuments(query1WithCursor, "doc2", "doc4", "doc3", "doc5"); + checkResultContainsDocuments( + query1, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc3", + "doc5"); + checkResultContainsDocuments( + query1WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc3", + "doc5"); // Ordered by: 'v asc, 'sort' asc, 'key' asc, __name__ asc Query query2 = @@ -748,8 +818,20 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { .orderBy("v") .orderBy("sort"); Query query2WithCursor = query2.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query2, "doc2", "doc5", "doc4", "doc3"); - checkQuerySnapshotContainsDocuments(query2WithCursor, "doc2", "doc5", "doc4", "doc3"); + checkResultContainsDocuments( + query2, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc5", + "doc4", + "doc3"); + checkResultContainsDocuments( + query2WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc5", + "doc4", + "doc3"); docSnap = collection.document("doc5").get().get(); @@ -761,8 +843,20 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { .whereGreaterThanOrEqualTo("sort", 1) .orderBy("v", Direction.DESCENDING); Query query3WithCursor = query3.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query3, "doc5", "doc3", "doc4", "doc2"); - checkQuerySnapshotContainsDocuments(query3WithCursor, "doc5", "doc3", "doc4", "doc2"); + checkResultContainsDocuments( + query3, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc5", + "doc3", + "doc4", + "doc2"); + checkResultContainsDocuments( + query3WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc5", + "doc3", + "doc4", + "doc2"); // Ordered by: 'v desc, 'sort' asc, 'key' asc, __name__ asc Query query4 = @@ -772,18 +866,24 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { .orderBy("v", Direction.DESCENDING) .orderBy("sort"); Query query4WithCursor = query4.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query4, "doc5", "doc4", "doc3", "doc2"); - checkQuerySnapshotContainsDocuments(query4WithCursor, "doc5", "doc4", "doc3", "doc2"); + checkResultContainsDocuments( + query4, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc5", + "doc4", + "doc3", + "doc2"); + checkResultContainsDocuments( + query4WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc5", + "doc4", + "doc3", + "doc2"); } @Test public void multipleInequalityFieldsInAggregateQuery() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -804,18 +904,15 @@ public void multipleInequalityFieldsInAggregateQuery() throws Exception { .whereGreaterThanOrEqualTo("sort", 1) .orderBy("v") .count(); - assertThat(query.get().get().getCount()).isEqualTo(4); + if (isRunningAgainstFirestoreEmulator(firestore)) { + assertThat(query.get().get().getCount()).isEqualTo(4); + } + assertThat(query.toPipeline().execute(query.getQuery().getFirestore()).get()).isNotEmpty(); // TODO(MIEQ): Add sum and average when they are public. } @Test public void multipleInequalityFieldsWithDocumentKey() throws Exception { - // TODO(MIEQ): Enable this test against production when possible. - assumeTrue( - "Skip this test if running against production because multiple inequality is " - + "not supported yet.", - isRunningAgainstFirestoreEmulator(firestore)); - CollectionReference collection = testCollectionWithDocs( map( @@ -840,8 +937,18 @@ public void multipleInequalityFieldsWithDocumentKey() throws Exception { .whereNotEqualTo("key", "a") .whereLessThan(FieldPath.documentId(), "doc5"); Query query1WithCursor = query1.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query1, "doc2", "doc4", "doc3"); - checkQuerySnapshotContainsDocuments(query1WithCursor, "doc2", "doc4", "doc3"); + checkResultContainsDocuments( + query1, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc3"); + checkResultContainsDocuments( + query1WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc3"); // Changing filters order will not affect implicit order. // Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc @@ -851,8 +958,18 @@ public void multipleInequalityFieldsWithDocumentKey() throws Exception { .whereGreaterThan("sort", 1) .whereNotEqualTo("key", "a"); Query query2WithCursor = query2.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query2, "doc2", "doc4", "doc3"); - checkQuerySnapshotContainsDocuments(query2WithCursor, "doc2", "doc4", "doc3"); + checkResultContainsDocuments( + query2, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc3"); + checkResultContainsDocuments( + query2WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc4", + "doc3"); // Ordered by: 'sort' desc, 'key' desc, __name__ desc Query query3 = @@ -862,7 +979,17 @@ public void multipleInequalityFieldsWithDocumentKey() throws Exception { .whereNotEqualTo("key", "a") .orderBy("sort", Direction.DESCENDING); Query query3WithCursor = query3.startAt(docSnap); - checkQuerySnapshotContainsDocuments(query3, "doc2", "doc3", "doc4"); - checkQuerySnapshotContainsDocuments(query3WithCursor, "doc2", "doc3", "doc4"); + checkResultContainsDocuments( + query3, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc3", + "doc4"); + checkResultContainsDocuments( + query3WithCursor, + /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), + "doc2", + "doc3", + "doc4"); } } From 1ceab8ac700fb8dfddc9094538d6a5b1d5e2ae55 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 6 May 2024 10:25:26 -0400 Subject: [PATCH 35/45] visibility changes --- .../com/google/cloud/firestore/Pipeline.kt | 2 +- .../cloud/firestore/pipeline/Expressions.kt | 69 ++++++++++--------- .../google/cloud/firestore/pipeline/Stages.kt | 41 ++++++----- 3 files changed, 58 insertions(+), 54 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 4e2682bb7..4954bb764 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -315,7 +315,7 @@ class Pipeline private constructor(private val stages: List, private val } } - fun toProto(): Value { + internal fun toProto(): Value { return Value.newBuilder() .setPipelineValue( com.google.firestore.v1.Pipeline.newBuilder().addAllStages(stages.map { toStageProto(it) }) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 1c3892d5a..95f62d590 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -47,7 +47,7 @@ internal fun exprToValue(expr: Expr): Value { } } -sealed interface Projectable +interface Projectable interface Expr { // Infix functions returning Function subclasses @@ -148,7 +148,7 @@ interface Expr { // Convenient class for internal usage internal data class ListOfExprs(val conditions: List) : Expr -data class Constant internal constructor(val value: Any?) : Expr { +data class Constant internal constructor(private val value: Any?) : Expr { companion object { @JvmStatic fun of(value: String?): Constant { @@ -237,12 +237,15 @@ data class Constant internal constructor(val value: Any?) : Expr { } } - fun toProto(): Value { + internal fun toProto(): Value { return encodeValue(value)!! } } -data class Field internal constructor(val field: String, var pipeline: Pipeline? = null) : +data class Field internal constructor( + internal val field: String, + private var pipeline: Pipeline? = null +) : Expr, Projectable { companion object { const val DOCUMENT_ID: String = "__path__" @@ -258,12 +261,12 @@ data class Field internal constructor(val field: String, var pipeline: Pipeline? } } - fun toProto(): Value { + internal fun toProto(): Value { return Value.newBuilder().setFieldReferenceValue(field).build() } } -data class Fields internal constructor(val fs: List? = null) : Expr, Projectable { +data class Fields internal constructor(internal val fs: List? = null) : Expr, Projectable { companion object { @JvmStatic fun of(f1: String, vararg f: String): Fields { @@ -279,8 +282,8 @@ data class Fields internal constructor(val fs: List? = null) : Expr, Proj data class AggregatorTarget internal constructor( - val accumulator: Function.Accumulator, - val fieldName: String, + internal val accumulator: Function.Accumulator, + internal val fieldName: String, override var distinct: Boolean, ) : Projectable, Function.Accumulator @@ -298,7 +301,7 @@ sealed class Function(val name: String, val params: List) : Expr { fun toField(target: String) = AggregatorTarget(this, target, this.distinct) } - fun toProto(): Value { + internal fun toProto(): Value { return Value.newBuilder() .setFunctionValue( com.google.firestore.v1.Function.newBuilder() @@ -308,70 +311,72 @@ sealed class Function(val name: String, val params: List) : Expr { .build() } - data class Equal internal constructor(val left: Expr, val right: Expr) : + data class Equal internal constructor(private val left: Expr, private val right: Expr) : Function("eq", listOf(left, right)), FilterCondition - data class NotEqual(val left: Expr, val right: Expr) : + data class NotEqual(private val left: Expr, private val right: Expr) : Function("neq", listOf(left, right)), FilterCondition - data class GreaterThan(val left: Expr, val right: Expr) : + data class GreaterThan(private val left: Expr, private val right: Expr) : Function("gt", listOf(left, right)), FilterCondition - data class GreaterThanOrEqual(val left: Expr, val right: Expr) : + data class GreaterThanOrEqual(private val left: Expr, private val right: Expr) : Function("gte", listOf(left, right)), FilterCondition - data class LessThan(val left: Expr, val right: Expr) : + data class LessThan(private val left: Expr, private val right: Expr) : Function("lt", listOf(left, right)), FilterCondition - data class LessThanOrEqual(val left: Expr, val right: Expr) : + data class LessThanOrEqual(private val left: Expr, private val right: Expr) : Function("lte", listOf(left, right)), FilterCondition - data class In(val left: Expr, val others: List) : + data class In(private val left: Expr, private val others: List) : Function("in", listOf(left, ListOfExprs(others))), FilterCondition // For 'in' - data class And(val conditions: List) : Function("and", conditions), FilterCondition where + data class And(private val conditions: List) : Function("and", conditions), + FilterCondition where T : FilterCondition - data class Or(val conditions: List) : Function("or", conditions), FilterCondition where + data class Or(private val conditions: List) : Function("or", conditions), + FilterCondition where T : FilterCondition - data class Not(val condition: Expr) : Function("not", listOf(condition)), FilterCondition + data class Not(private val condition: Expr) : Function("not", listOf(condition)), FilterCondition - data class ArrayContains(val array: Expr, val element: Expr) : + data class ArrayContains(private val array: Expr, private val element: Expr) : Function("array_contains", listOf(array, element)), FilterCondition - data class ArrayContainsAny(val array: Expr, val elements: List) : + data class ArrayContainsAny(private val array: Expr, private val elements: List) : Function("array_contains_any", listOf(array, ListOfExprs(elements))), FilterCondition - data class IsNaN(val value: Expr) : Function("is_nan", listOf(value)), FilterCondition + data class IsNaN(private val value: Expr) : Function("is_nan", listOf(value)), FilterCondition - data class IsNull(val value: Expr) : Function("is_null", listOf(value)), FilterCondition + data class IsNull(private val value: Expr) : Function("is_null", listOf(value)), FilterCondition - data class Sum(val value: Expr, override var distinct: Boolean) : + data class Sum(private val value: Expr, override var distinct: Boolean) : Function("sum", listOf(value)), Accumulator - data class Avg(val value: Expr, override var distinct: Boolean) : + data class Avg(private val value: Expr, override var distinct: Boolean) : Function("avg", listOf(value)), Accumulator - data class Count(val value: Expr?, override var distinct: Boolean) : + data class Count(private val value: Expr?, override var distinct: Boolean) : Function("count", value?.let { listOf(it) } ?: emptyList()), Accumulator - data class Min(val value: Expr, override var distinct: Boolean) : + data class Min(private val value: Expr, override var distinct: Boolean) : Function("min", listOf(value)), Accumulator - data class Max(val value: Expr, override var distinct: Boolean) : + data class Max(private val value: Expr, override var distinct: Boolean) : Function("max", listOf(value)), Accumulator - data class CosineDistance(val vector1: Expr, val vector2: Expr) : + data class CosineDistance(private val vector1: Expr, private val vector2: Expr) : Function("cosine_distance", listOf(vector1, vector2)) - data class DotProductDistance(val vector1: Expr, val vector2: Expr) : + data class DotProductDistance(private val vector1: Expr, private val vector2: Expr) : Function("dot_product", listOf(vector1, vector2)) - data class EuclideanDistance(val vector1: Expr, val vector2: Expr) : + data class EuclideanDistance(private val vector1: Expr, private val vector2: Expr) : Function("euclidean_distance", listOf(vector1, vector2)) - data class Generic(val n: String, val ps: List) : Function(n, ps) + data class Generic(private val n: String, private val ps: List) : Function(n, ps) companion object { @JvmStatic fun equal(left: Expr, right: Expr) = Equal(left, right) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index df3a76445..433474caa 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -8,11 +8,11 @@ import java.util.Locale internal interface Stage -internal data class Collection(val relativePath: String) : Stage { +internal data class Collection(internal val relativePath: String) : Stage { val name = "collection" } -internal data class CollectionGroup(val collectionId: String) : Stage { +internal data class CollectionGroup(internal val collectionId: String) : Stage { val name = "collection_group" } @@ -20,7 +20,7 @@ internal class Database : Stage { val name = "database" } -internal data class Documents(val documents: List) : Stage { +internal data class Documents(internal val documents: List) : Stage { val name = "documents" companion object { @@ -31,32 +31,32 @@ internal data class Documents(val documents: List) : Stage { } } -internal data class Project(val projections: Map) : Stage { +internal data class Project(internal val projections: Map) : Stage { val name = "project" } -internal data class AddFields(val fields: Map) : Stage { +internal data class AddFields(internal val fields: Map) : Stage { val name = "add_fields" } -internal data class Filter(val condition: T) : Stage where +internal data class Filter(internal val condition: T) : Stage where T : Function.FilterCondition, T : Expr { val name = "filter" } -internal class Offset(val offset: Int) : Stage { +internal class Offset(internal val offset: Int) : Stage { val name = "offset" } -internal class Limit(val limit: Int) : Stage { +internal class Limit(internal val limit: Int) : Stage { val name = "limit" } class Aggregate internal constructor( - val groups: Map, - val accumulators: Map, + internal val groups: Map, + internal val accumulators: Map, ) : Stage { val name = "aggregate" @@ -67,14 +67,14 @@ internal constructor( class FindNearest internal constructor( - val property: Field, - val vector: DoubleArray, - val distanceMeasure: DistanceMeasure, - val options: FindNearestOptions, + internal val property: Field, + internal val vector: DoubleArray, + internal val distanceMeasure: DistanceMeasure, + internal val options: FindNearestOptions, ) : Stage { val name = "find_nearest" - sealed interface DistanceMeasure { + interface DistanceMeasure { data object Euclidean : DistanceMeasure data object Cosine : DistanceMeasure @@ -89,6 +89,7 @@ internal constructor( is Cosine -> "cosine" is DotProduct -> "dot_product" is GenericDistanceMeasure -> name + else -> throw IllegalArgumentException("Unknown distance measure") } } @@ -108,9 +109,9 @@ internal constructor( class Sort internal constructor( - val orders: List, - val density: Density = Density.UNSPECIFIED, - val truncation: Truncation = Truncation.UNSPECIFIED, + internal val orders: List, + internal val density: Density = Density.UNSPECIFIED, + internal val truncation: Truncation = Truncation.UNSPECIFIED, ) : Stage { val name = "sort" @@ -172,9 +173,7 @@ internal constructor( } } -// internal class Pagination(): Stage, GenericStage() - -internal open class GenericStage(val name: String, val params: List) : Stage {} +internal class GenericStage(internal val name: String, internal val params: List) : Stage {} internal fun toStageProto(stage: Stage): com.google.firestore.v1.Pipeline.Stage { return when (stage) { From df21cf2091942572f1b357611d6ce183fbbfb113 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 14 May 2024 14:19:08 -0400 Subject: [PATCH 36/45] refactoring --- .../com/google/cloud/firestore/Pipeline.kt | 2 +- .../google/cloud/firestore/PipelineResult.kt | 2 +- .../com/google/cloud/firestore/Query.java | 2 +- .../cloud/firestore/pipeline/Expressions.kt | 70 +++++++++++++------ .../google/cloud/firestore/pipeline/Stages.kt | 7 +- .../cloud/firestore/it/ITPipelineTest.java | 41 +++-------- 6 files changed, 66 insertions(+), 58 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index 4954bb764..cc2c2342b 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -189,7 +189,7 @@ class Pipeline private constructor(private val stages: List, private val return Pipeline(stages.plus(AddFields(projectablesToMap(*fields))), name) } - fun project(vararg projections: Projectable): Pipeline { + fun select(vararg projections: Projectable): Pipeline { return Pipeline(stages.plus(Project(projectablesToMap(*projections))), name) } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt index fa191001e..6cebcfc46 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -6,7 +6,7 @@ import com.google.firestore.v1.Value import java.util.Date import javax.annotation.Nonnull -data class PipelineResult +class PipelineResult internal constructor( private val rpcContext: FirestoreRpcContext<*>?, val reference: DocumentReference?, diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java index 0eedf2f69..914f665b9 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -1990,7 +1990,7 @@ public Pipeline toPipeline() { if (this.options.getFieldProjections() != null && !this.options.getFieldProjections().isEmpty()) { ppl = - ppl.project( + ppl.select( this.options.getFieldProjections().stream() .map(fieldReference -> Field.of(fieldReference.getFieldPath())) .toArray(Projectable[]::new)); diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 95f62d590..9ce8210ef 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -287,7 +287,7 @@ internal constructor( override var distinct: Boolean, ) : Projectable, Function.Accumulator -sealed class Function(val name: String, val params: List) : Expr { +open class Function(val name: String, val params: List) : Expr { interface FilterCondition : Expr interface Accumulator : Expr { @@ -314,69 +314,93 @@ sealed class Function(val name: String, val params: List) : Expr { data class Equal internal constructor(private val left: Expr, private val right: Expr) : Function("eq", listOf(left, right)), FilterCondition - data class NotEqual(private val left: Expr, private val right: Expr) : + data class NotEqual internal constructor(private val left: Expr, private val right: Expr) : Function("neq", listOf(left, right)), FilterCondition - data class GreaterThan(private val left: Expr, private val right: Expr) : + data class GreaterThan internal constructor(private val left: Expr, private val right: Expr) : Function("gt", listOf(left, right)), FilterCondition - data class GreaterThanOrEqual(private val left: Expr, private val right: Expr) : + data class GreaterThanOrEqual internal constructor( + private val left: Expr, + private val right: Expr + ) : Function("gte", listOf(left, right)), FilterCondition - data class LessThan(private val left: Expr, private val right: Expr) : + data class LessThan internal constructor(private val left: Expr, private val right: Expr) : Function("lt", listOf(left, right)), FilterCondition - data class LessThanOrEqual(private val left: Expr, private val right: Expr) : + data class LessThanOrEqual internal constructor(private val left: Expr, private val right: Expr) : Function("lte", listOf(left, right)), FilterCondition - data class In(private val left: Expr, private val others: List) : + data class In internal constructor(private val left: Expr, private val others: List) : Function("in", listOf(left, ListOfExprs(others))), FilterCondition // For 'in' - data class And(private val conditions: List) : Function("and", conditions), + data class And internal constructor(private val conditions: List) : + Function("and", conditions), FilterCondition where T : FilterCondition - data class Or(private val conditions: List) : Function("or", conditions), + data class Or internal constructor(private val conditions: List) : + Function("or", conditions), FilterCondition where T : FilterCondition - data class Not(private val condition: Expr) : Function("not", listOf(condition)), FilterCondition + data class Not internal constructor(private val condition: Expr) : + Function("not", listOf(condition)), FilterCondition - data class ArrayContains(private val array: Expr, private val element: Expr) : + data class ArrayContains internal constructor( + private val array: Expr, + private val element: Expr + ) : Function("array_contains", listOf(array, element)), FilterCondition - data class ArrayContainsAny(private val array: Expr, private val elements: List) : + data class ArrayContainsAny internal constructor( + private val array: Expr, + private val elements: List + ) : Function("array_contains_any", listOf(array, ListOfExprs(elements))), FilterCondition - data class IsNaN(private val value: Expr) : Function("is_nan", listOf(value)), FilterCondition + data class IsNaN internal constructor(private val value: Expr) : + Function("is_nan", listOf(value)), FilterCondition - data class IsNull(private val value: Expr) : Function("is_null", listOf(value)), FilterCondition + data class IsNull internal constructor(private val value: Expr) : + Function("is_null", listOf(value)), FilterCondition - data class Sum(private val value: Expr, override var distinct: Boolean) : + data class Sum internal constructor(private val value: Expr, override var distinct: Boolean) : Function("sum", listOf(value)), Accumulator - data class Avg(private val value: Expr, override var distinct: Boolean) : + data class Avg internal constructor(private val value: Expr, override var distinct: Boolean) : Function("avg", listOf(value)), Accumulator - data class Count(private val value: Expr?, override var distinct: Boolean) : + data class Count internal constructor(private val value: Expr?, override var distinct: Boolean) : Function("count", value?.let { listOf(it) } ?: emptyList()), Accumulator - data class Min(private val value: Expr, override var distinct: Boolean) : + data class Min internal constructor(private val value: Expr, override var distinct: Boolean) : Function("min", listOf(value)), Accumulator - data class Max(private val value: Expr, override var distinct: Boolean) : + data class Max internal constructor(private val value: Expr, override var distinct: Boolean) : Function("max", listOf(value)), Accumulator - data class CosineDistance(private val vector1: Expr, private val vector2: Expr) : + data class CosineDistance internal constructor( + private val vector1: Expr, + private val vector2: Expr + ) : Function("cosine_distance", listOf(vector1, vector2)) - data class DotProductDistance(private val vector1: Expr, private val vector2: Expr) : + data class DotProductDistance internal constructor( + private val vector1: Expr, + private val vector2: Expr + ) : Function("dot_product", listOf(vector1, vector2)) - data class EuclideanDistance(private val vector1: Expr, private val vector2: Expr) : + data class EuclideanDistance internal constructor( + private val vector1: Expr, + private val vector2: Expr + ) : Function("euclidean_distance", listOf(vector1, vector2)) - data class Generic(private val n: String, private val ps: List) : Function(n, ps) + data class Generic internal constructor(private val n: String, private val ps: List) : + Function(n, ps) companion object { @JvmStatic fun equal(left: Expr, right: Expr) = Equal(left, right) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index 433474caa..43f72d2a9 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -104,7 +104,12 @@ internal constructor( } } - data class FindNearestOptions(val limit: Long?, val output: Field? = null) + class FindNearestOptions(val limit: Long, val output: Field? = null) { + companion object { + @JvmStatic + fun newInstance(limit: Long, output: Field? = null) = FindNearestOptions(limit, output) + } + } } class Sort diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 2494c5dd3..53b3f2bc7 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -34,8 +34,6 @@ import com.google.cloud.firestore.pipeline.Constant; import com.google.cloud.firestore.pipeline.Field; import com.google.cloud.firestore.pipeline.Fields; -import com.google.cloud.firestore.pipeline.Sort; -import com.google.cloud.firestore.pipeline.Sort.Ordering.Direction; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -75,25 +73,20 @@ public void fromSources() throws Exception { @Test public void projections() throws Exception { - Pipeline p = Pipeline.fromCollectionGroup("coll1").project(Field.of("foo")); + Pipeline p = Pipeline.fromCollectionGroup("coll1").select(Field.of("foo")); List results = p.execute(firestore).get(); System.out.println(results.size()); - // More compact - p = Pipeline.fromCollectionGroup("coll1").project(Fields.of("foo", "bar", "baz")); + p = Pipeline.fromCollectionGroup("coll1").select(Fields.of("foo", "bar", "baz")); results = p.execute(firestore).get(); - System.out.println(results.size()); } @Test public void filters() throws Exception { Pipeline p = Pipeline.fromCollectionGroup("coll1") - .filter(Field.of("foo").equal(Constant.of(42))) - .filter( - or( - Field.of("bar").lessThan(Constant.of(100)), - Constant.of("value").equal(Field.of("key")))) + .filter(Field.of("foo").equal(42)) + .filter(or(Field.of("bar").lessThan(100), Constant.of("value").equal(Field.of("key")))) .filter(not(Constant.of(128).inAny("f1", "f2"))); List results = p.execute(firestore).get(); @@ -128,16 +121,14 @@ public void sorts() throws Exception { .filter(Field.of("foo").inAny(42, "42")) .sort( Field.of("rank").ascending(), - Sort.Ordering.of( - cosineDistance(Field.of("embedding1"), Field.of("embedding2")), - Direction.DESCENDING)) + cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()) .limit(100); List results = p.execute(firestore).get(); // equivalent but more concise. p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Constant.of(false))) + .filter(Field.of("foo").inAny(42, false)) .sort( ascending(Field.of("rank")), descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) @@ -149,19 +140,18 @@ public void sorts() throws Exception { public void pagination() throws Exception { PaginatingPipeline p = Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Constant.of("bar"))) + .filter(Field.of("foo").inAny(42, "bar")) .paginate( 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); List results = p.firstPage().execute(firestore).get(); + List secondPage = + p.startAfter(results.get(results.size() - 1)).firstPage().execute(firestore).get(); } @Test public void limit() throws Exception { - Pipeline p = - Pipeline.fromDatabase() - .filter(Field.of("foo").inAny(Constant.of(42), Field.of("bar"))) - .limit(10); + Pipeline p = Pipeline.fromDatabase().filter(Field.of("foo").inAny(42, "bar")).limit(10); List result = p.execute(firestore).get(); } @@ -174,15 +164,4 @@ public void offset() throws Exception { List result = p.execute(firestore).get(); } - - @Test - public void fluentAllTheWay() throws Exception { - PaginatingPipeline p = - Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(Constant.of(42), Constant.of("bar"))) - .paginate( - 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); - - List result = p.firstPage().execute(firestore).get(); - } } From cfea0fda8cc3261fe4cfffe5b5f2f8c604389127 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 16 May 2024 10:50:55 -0400 Subject: [PATCH 37/45] disable failing tests temparorily --- .../cloud/firestore/it/ITPipelineTest.java | 187 +++++++++--------- .../cloud/firestore/it/ITQueryTest.java | 7 +- 2 files changed, 98 insertions(+), 96 deletions(-) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 53b3f2bc7..7be2f404d 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -68,100 +68,99 @@ public void fromSources() throws Exception { Pipeline p = Pipeline.fromCollectionGroup(collection.getId()); List results = p.execute(firestore).get(); - System.out.println(results.size()); } - @Test - public void projections() throws Exception { - Pipeline p = Pipeline.fromCollectionGroup("coll1").select(Field.of("foo")); - List results = p.execute(firestore).get(); - System.out.println(results.size()); - - p = Pipeline.fromCollectionGroup("coll1").select(Fields.of("foo", "bar", "baz")); - results = p.execute(firestore).get(); - } - - @Test - public void filters() throws Exception { - Pipeline p = - Pipeline.fromCollectionGroup("coll1") - .filter(Field.of("foo").equal(42)) - .filter(or(Field.of("bar").lessThan(100), Constant.of("value").equal(Field.of("key")))) - .filter(not(Constant.of(128).inAny("f1", "f2"))); - List results = p.execute(firestore).get(); - - p = - Pipeline.fromCollectionGroup("coll1") - .filter(equal(Field.of("foo"), 42)) - .filter( - or(lessThan(Field.of("bar"), 100), equal(Field.of("key"), Constant.of("value")))) - .filter(not(Constant.of(128).inAny("f1", "f2"))); - results = p.execute(firestore).get(); - } - - @Test - public void inFilters() throws Exception { - Pipeline p = Pipeline.fromCollectionGroup("coll1").filter(Field.of("foo").inAny(42, "42")); - List results = p.execute(firestore).get(); - } - - @Test - public void aggregateWithoutGrouping() throws Exception { - Pipeline p = - Pipeline.fromDatabase() - .filter(Field.of("foo").inAny(42, "bar")) - .aggregate(avg(Field.of("score")).toField("avg_score_1")); - List results = p.execute(firestore).get(); - } - - @Test - public void sorts() throws Exception { - Pipeline p = - Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(42, "42")) - .sort( - Field.of("rank").ascending(), - cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()) - .limit(100); - List results = p.execute(firestore).get(); - - // equivalent but more concise. - p = - Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(42, false)) - .sort( - ascending(Field.of("rank")), - descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) - .limit(100); - results = p.execute(firestore).get(); - } - - @Test - public void pagination() throws Exception { - PaginatingPipeline p = - Pipeline.fromCollection("coll1") - .filter(Field.of("foo").inAny(42, "bar")) - .paginate( - 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); - - List results = p.firstPage().execute(firestore).get(); - List secondPage = - p.startAfter(results.get(results.size() - 1)).firstPage().execute(firestore).get(); - } - - @Test - public void limit() throws Exception { - Pipeline p = Pipeline.fromDatabase().filter(Field.of("foo").inAny(42, "bar")).limit(10); - - List result = p.execute(firestore).get(); - } - - @Test - public void offset() throws Exception { - Pipeline p = - Pipeline.fromDocuments(firestore.document("foo/bar1"), firestore.document("foo/bar2")) - .offset(1); - - List result = p.execute(firestore).get(); - } + // @Test + // public void projections() throws Exception { + // Pipeline p = Pipeline.fromCollectionGroup("coll1").select(Field.of("foo")); + // List results = p.execute(firestore).get(); + // System.out.println(results.size()); + // + // p = Pipeline.fromCollectionGroup("coll1").select(Fields.of("foo", "bar", "baz")); + // results = p.execute(firestore).get(); + // } + // + // @Test + // public void filters() throws Exception { + // Pipeline p = + // Pipeline.fromCollectionGroup("coll1") + // .filter(Field.of("foo").equal(42)) + // .filter(or(Field.of("bar").lessThan(100), Constant.of("value").equal(Field.of("key")))) + // .filter(not(Constant.of(128).inAny("f1", "f2"))); + // List results = p.execute(firestore).get(); + // + // p = + // Pipeline.fromCollectionGroup("coll1") + // .filter(equal(Field.of("foo"), 42)) + // .filter( + // or(lessThan(Field.of("bar"), 100), equal(Field.of("key"), Constant.of("value")))) + // .filter(not(Constant.of(128).inAny("f1", "f2"))); + // results = p.execute(firestore).get(); + // } + // + // @Test + // public void inFilters() throws Exception { + // Pipeline p = Pipeline.fromCollectionGroup("coll1").filter(Field.of("foo").inAny(42, "42")); + // List results = p.execute(firestore).get(); + // } + // + // @Test + // public void aggregateWithoutGrouping() throws Exception { + // Pipeline p = + // Pipeline.fromDatabase() + // .filter(Field.of("foo").inAny(42, "bar")) + // .aggregate(avg(Field.of("score")).toField("avg_score_1")); + // List results = p.execute(firestore).get(); + // } + // + // @Test + // public void sorts() throws Exception { + // Pipeline p = + // Pipeline.fromCollection("coll1") + // .filter(Field.of("foo").inAny(42, "42")) + // .sort( + // Field.of("rank").ascending(), + // cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()) + // .limit(100); + // List results = p.execute(firestore).get(); + // + // // equivalent but more concise. + // p = + // Pipeline.fromCollection("coll1") + // .filter(Field.of("foo").inAny(42, false)) + // .sort( + // ascending(Field.of("rank")), + // descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) + // .limit(100); + // results = p.execute(firestore).get(); + // } + // + // @Test + // public void pagination() throws Exception { + // PaginatingPipeline p = + // Pipeline.fromCollection("coll1") + // .filter(Field.of("foo").inAny(42, "bar")) + // .paginate( + // 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); + // + // List results = p.firstPage().execute(firestore).get(); + // List secondPage = + // p.startAfter(results.get(results.size() - 1)).firstPage().execute(firestore).get(); + // } + // + // @Test + // public void limit() throws Exception { + // Pipeline p = Pipeline.fromDatabase().filter(Field.of("foo").inAny(42, "bar")).limit(10); + // + // List result = p.execute(firestore).get(); + // } + // + // @Test + // public void offset() throws Exception { + // Pipeline p = + // Pipeline.fromDocuments(firestore.document("foo/bar1"), firestore.document("foo/bar2")) + // .offset(1); + // + // List result = p.execute(firestore).get(); + // } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java index 3ddd8439b..612019996 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java @@ -82,12 +82,15 @@ public static void checkResultContainsDocuments(Query query, boolean pipelineOnl assertThat(result).isEqualTo(Arrays.asList(docs)); } + /* List pipelineResults = query.toPipeline().execute(query.getFirestore()).get(); List result = pipelineResults.stream() .map(pipelineResult -> Objects.requireNonNull(pipelineResult.getReference()).getId()) .collect(Collectors.toList()); assertThat(result).isEqualTo(Arrays.asList(docs)); + + */ } @Test @@ -613,7 +616,7 @@ public void multipleInequalityWithNestedField() throws Exception { Query query2WithCursor = query2.startAt(docSnap); checkResultContainsDocuments( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc3"); - checkResultContainsDocuments(query2WithCursor, "doc2", "doc3"); + // checkResultContainsDocuments(query2WithCursor, "doc2", "doc3"); } @Test @@ -907,7 +910,7 @@ public void multipleInequalityFieldsInAggregateQuery() throws Exception { if (isRunningAgainstFirestoreEmulator(firestore)) { assertThat(query.get().get().getCount()).isEqualTo(4); } - assertThat(query.toPipeline().execute(query.getQuery().getFirestore()).get()).isNotEmpty(); + // assertThat(query.toPipeline().execute(query.getQuery().getFirestore()).get()).isNotEmpty(); // TODO(MIEQ): Add sum and average when they are public. } From c2b077163de56cac298b0698e0239b7d27cab8b7 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Thu, 16 May 2024 14:26:32 -0400 Subject: [PATCH 38/45] Revert "disable failing tests temparorily" This reverts commit cfea0fda8cc3261fe4cfffe5b5f2f8c604389127. --- .../cloud/firestore/it/ITPipelineTest.java | 187 +++++++++--------- .../cloud/firestore/it/ITQueryTest.java | 7 +- 2 files changed, 96 insertions(+), 98 deletions(-) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java index 7be2f404d..53b3f2bc7 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -68,99 +68,100 @@ public void fromSources() throws Exception { Pipeline p = Pipeline.fromCollectionGroup(collection.getId()); List results = p.execute(firestore).get(); + System.out.println(results.size()); } - // @Test - // public void projections() throws Exception { - // Pipeline p = Pipeline.fromCollectionGroup("coll1").select(Field.of("foo")); - // List results = p.execute(firestore).get(); - // System.out.println(results.size()); - // - // p = Pipeline.fromCollectionGroup("coll1").select(Fields.of("foo", "bar", "baz")); - // results = p.execute(firestore).get(); - // } - // - // @Test - // public void filters() throws Exception { - // Pipeline p = - // Pipeline.fromCollectionGroup("coll1") - // .filter(Field.of("foo").equal(42)) - // .filter(or(Field.of("bar").lessThan(100), Constant.of("value").equal(Field.of("key")))) - // .filter(not(Constant.of(128).inAny("f1", "f2"))); - // List results = p.execute(firestore).get(); - // - // p = - // Pipeline.fromCollectionGroup("coll1") - // .filter(equal(Field.of("foo"), 42)) - // .filter( - // or(lessThan(Field.of("bar"), 100), equal(Field.of("key"), Constant.of("value")))) - // .filter(not(Constant.of(128).inAny("f1", "f2"))); - // results = p.execute(firestore).get(); - // } - // - // @Test - // public void inFilters() throws Exception { - // Pipeline p = Pipeline.fromCollectionGroup("coll1").filter(Field.of("foo").inAny(42, "42")); - // List results = p.execute(firestore).get(); - // } - // - // @Test - // public void aggregateWithoutGrouping() throws Exception { - // Pipeline p = - // Pipeline.fromDatabase() - // .filter(Field.of("foo").inAny(42, "bar")) - // .aggregate(avg(Field.of("score")).toField("avg_score_1")); - // List results = p.execute(firestore).get(); - // } - // - // @Test - // public void sorts() throws Exception { - // Pipeline p = - // Pipeline.fromCollection("coll1") - // .filter(Field.of("foo").inAny(42, "42")) - // .sort( - // Field.of("rank").ascending(), - // cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()) - // .limit(100); - // List results = p.execute(firestore).get(); - // - // // equivalent but more concise. - // p = - // Pipeline.fromCollection("coll1") - // .filter(Field.of("foo").inAny(42, false)) - // .sort( - // ascending(Field.of("rank")), - // descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) - // .limit(100); - // results = p.execute(firestore).get(); - // } - // - // @Test - // public void pagination() throws Exception { - // PaginatingPipeline p = - // Pipeline.fromCollection("coll1") - // .filter(Field.of("foo").inAny(42, "bar")) - // .paginate( - // 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); - // - // List results = p.firstPage().execute(firestore).get(); - // List secondPage = - // p.startAfter(results.get(results.size() - 1)).firstPage().execute(firestore).get(); - // } - // - // @Test - // public void limit() throws Exception { - // Pipeline p = Pipeline.fromDatabase().filter(Field.of("foo").inAny(42, "bar")).limit(10); - // - // List result = p.execute(firestore).get(); - // } - // - // @Test - // public void offset() throws Exception { - // Pipeline p = - // Pipeline.fromDocuments(firestore.document("foo/bar1"), firestore.document("foo/bar2")) - // .offset(1); - // - // List result = p.execute(firestore).get(); - // } + @Test + public void projections() throws Exception { + Pipeline p = Pipeline.fromCollectionGroup("coll1").select(Field.of("foo")); + List results = p.execute(firestore).get(); + System.out.println(results.size()); + + p = Pipeline.fromCollectionGroup("coll1").select(Fields.of("foo", "bar", "baz")); + results = p.execute(firestore).get(); + } + + @Test + public void filters() throws Exception { + Pipeline p = + Pipeline.fromCollectionGroup("coll1") + .filter(Field.of("foo").equal(42)) + .filter(or(Field.of("bar").lessThan(100), Constant.of("value").equal(Field.of("key")))) + .filter(not(Constant.of(128).inAny("f1", "f2"))); + List results = p.execute(firestore).get(); + + p = + Pipeline.fromCollectionGroup("coll1") + .filter(equal(Field.of("foo"), 42)) + .filter( + or(lessThan(Field.of("bar"), 100), equal(Field.of("key"), Constant.of("value")))) + .filter(not(Constant.of(128).inAny("f1", "f2"))); + results = p.execute(firestore).get(); + } + + @Test + public void inFilters() throws Exception { + Pipeline p = Pipeline.fromCollectionGroup("coll1").filter(Field.of("foo").inAny(42, "42")); + List results = p.execute(firestore).get(); + } + + @Test + public void aggregateWithoutGrouping() throws Exception { + Pipeline p = + Pipeline.fromDatabase() + .filter(Field.of("foo").inAny(42, "bar")) + .aggregate(avg(Field.of("score")).toField("avg_score_1")); + List results = p.execute(firestore).get(); + } + + @Test + public void sorts() throws Exception { + Pipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(42, "42")) + .sort( + Field.of("rank").ascending(), + cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()) + .limit(100); + List results = p.execute(firestore).get(); + + // equivalent but more concise. + p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(42, false)) + .sort( + ascending(Field.of("rank")), + descending(cosineDistance(Field.of("embedding1"), Field.of("embedding2")))) + .limit(100); + results = p.execute(firestore).get(); + } + + @Test + public void pagination() throws Exception { + PaginatingPipeline p = + Pipeline.fromCollection("coll1") + .filter(Field.of("foo").inAny(42, "bar")) + .paginate( + 100, cosineDistance(Field.of("embedding1"), Field.of("embedding2")).descending()); + + List results = p.firstPage().execute(firestore).get(); + List secondPage = + p.startAfter(results.get(results.size() - 1)).firstPage().execute(firestore).get(); + } + + @Test + public void limit() throws Exception { + Pipeline p = Pipeline.fromDatabase().filter(Field.of("foo").inAny(42, "bar")).limit(10); + + List result = p.execute(firestore).get(); + } + + @Test + public void offset() throws Exception { + Pipeline p = + Pipeline.fromDocuments(firestore.document("foo/bar1"), firestore.document("foo/bar2")) + .offset(1); + + List result = p.execute(firestore).get(); + } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java index 612019996..3ddd8439b 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java @@ -82,15 +82,12 @@ public static void checkResultContainsDocuments(Query query, boolean pipelineOnl assertThat(result).isEqualTo(Arrays.asList(docs)); } - /* List pipelineResults = query.toPipeline().execute(query.getFirestore()).get(); List result = pipelineResults.stream() .map(pipelineResult -> Objects.requireNonNull(pipelineResult.getReference()).getId()) .collect(Collectors.toList()); assertThat(result).isEqualTo(Arrays.asList(docs)); - - */ } @Test @@ -616,7 +613,7 @@ public void multipleInequalityWithNestedField() throws Exception { Query query2WithCursor = query2.startAt(docSnap); checkResultContainsDocuments( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc3"); - // checkResultContainsDocuments(query2WithCursor, "doc2", "doc3"); + checkResultContainsDocuments(query2WithCursor, "doc2", "doc3"); } @Test @@ -910,7 +907,7 @@ public void multipleInequalityFieldsInAggregateQuery() throws Exception { if (isRunningAgainstFirestoreEmulator(firestore)) { assertThat(query.get().get().getCount()).isEqualTo(4); } - // assertThat(query.toPipeline().execute(query.getQuery().getFirestore()).get()).isNotEmpty(); + assertThat(query.toPipeline().execute(query.getQuery().getFirestore()).get()).isNotEmpty(); // TODO(MIEQ): Add sum and average when they are public. } From bb16ca128cec4abdc3718ab65622ce344eb9fc5f Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 21 May 2024 10:33:09 -0400 Subject: [PATCH 39/45] Fix missing asAlias --- .../com/google/cloud/firestore/pipeline/Expressions.kt | 6 ++++++ .../java/com/google/cloud/firestore/pipeline/Stages.kt | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 9ce8210ef..5923f487c 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -49,6 +49,8 @@ internal fun exprToValue(expr: Expr): Value { interface Projectable +internal class ExprWithAlias internal constructor(val alias: String, val expr: Expr) : Projectable + interface Expr { // Infix functions returning Function subclasses infix fun equal(other: Expr) = Equal(this, other) @@ -143,6 +145,10 @@ interface Expr { fun descending(): Ordering { return Ordering(this, Direction.DESCENDING) } + + fun asAlias(alias: String): Projectable { + return ExprWithAlias(alias, this) + } } // Convenient class for internal usage diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index 43f72d2a9..f8f540b10 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -104,10 +104,15 @@ internal constructor( } } - class FindNearestOptions(val limit: Long, val output: Field? = null) { + class FindNearestOptions internal constructor( + val limit: Long, + val distanceMeasure: DistanceMeasure, + val output: Field? = null + ) { companion object { @JvmStatic - fun newInstance(limit: Long, output: Field? = null) = FindNearestOptions(limit, output) + fun newInstance(limit: Long, distanceMeasure: DistanceMeasure, output: Field? = null) = + FindNearestOptions(limit, distanceMeasure, output) } } } From 424cf8bc6f6564b97e3320df587dcc008a480e74 Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Tue, 21 May 2024 10:48:05 -0400 Subject: [PATCH 40/45] Rename project to select --- .../java/com/google/cloud/firestore/Pipeline.kt | 14 +++++++------- .../java/com/google/cloud/firestore/Query.java | 4 ++-- .../google/cloud/firestore/pipeline/Expressions.kt | 12 ++++++------ .../com/google/cloud/firestore/pipeline/Stages.kt | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index cc2c2342b..aeb3e6709 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -21,8 +21,8 @@ import com.google.cloud.firestore.pipeline.FindNearest import com.google.cloud.firestore.pipeline.Function import com.google.cloud.firestore.pipeline.Limit import com.google.cloud.firestore.pipeline.Offset -import com.google.cloud.firestore.pipeline.Project -import com.google.cloud.firestore.pipeline.Projectable +import com.google.cloud.firestore.pipeline.Select +import com.google.cloud.firestore.pipeline.Selectable import com.google.cloud.firestore.pipeline.Sort import com.google.cloud.firestore.pipeline.Sort.Ordering import com.google.cloud.firestore.pipeline.Stage @@ -173,9 +173,9 @@ class Pipeline private constructor(private val stages: List, private val } } - private fun projectablesToMap(vararg projectables: Projectable): Map { + private fun projectablesToMap(vararg selectables: Selectable): Map { val projMap = mutableMapOf() - for (proj in projectables) { + for (proj in selectables) { when (proj) { is Field -> projMap[proj.field] = proj is AggregatorTarget -> projMap[proj.fieldName] = proj.accumulator @@ -185,12 +185,12 @@ class Pipeline private constructor(private val stages: List, private val return projMap } - fun addFields(vararg fields: Projectable): Pipeline { + fun addFields(vararg fields: Selectable): Pipeline { return Pipeline(stages.plus(AddFields(projectablesToMap(*fields))), name) } - fun select(vararg projections: Projectable): Pipeline { - return Pipeline(stages.plus(Project(projectablesToMap(*projections))), name) + fun select(vararg projections: Selectable): Pipeline { + return Pipeline(stages.plus(Select(projectablesToMap(*projections))), name) } fun filter(condition: T): Pipeline where T : Expr, T : Function.FilterCondition { diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java index 914f665b9..b6f65678c 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -41,7 +41,7 @@ import com.google.cloud.Timestamp; import com.google.cloud.firestore.Query.QueryOptions.Builder; import com.google.cloud.firestore.pipeline.Field; -import com.google.cloud.firestore.pipeline.Projectable; +import com.google.cloud.firestore.pipeline.Selectable; import com.google.cloud.firestore.pipeline.Sort.Density; import com.google.cloud.firestore.pipeline.Sort.Ordering; import com.google.cloud.firestore.pipeline.Sort.Truncation; @@ -1993,7 +1993,7 @@ public Pipeline toPipeline() { ppl.select( this.options.getFieldProjections().stream() .map(fieldReference -> Field.of(fieldReference.getFieldPath())) - .toArray(Projectable[]::new)); + .toArray(Selectable[]::new)); } // Orders diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 5923f487c..b58941dee 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -47,9 +47,9 @@ internal fun exprToValue(expr: Expr): Value { } } -interface Projectable +interface Selectable -internal class ExprWithAlias internal constructor(val alias: String, val expr: Expr) : Projectable +internal class ExprWithAlias internal constructor(val alias: String, val expr: Expr) : Selectable interface Expr { // Infix functions returning Function subclasses @@ -146,7 +146,7 @@ interface Expr { return Ordering(this, Direction.DESCENDING) } - fun asAlias(alias: String): Projectable { + fun asAlias(alias: String): Selectable { return ExprWithAlias(alias, this) } } @@ -252,7 +252,7 @@ data class Field internal constructor( internal val field: String, private var pipeline: Pipeline? = null ) : - Expr, Projectable { + Expr, Selectable { companion object { const val DOCUMENT_ID: String = "__path__" @@ -272,7 +272,7 @@ data class Field internal constructor( } } -data class Fields internal constructor(internal val fs: List? = null) : Expr, Projectable { +data class Fields internal constructor(internal val fs: List? = null) : Expr, Selectable { companion object { @JvmStatic fun of(f1: String, vararg f: String): Fields { @@ -291,7 +291,7 @@ internal constructor( internal val accumulator: Function.Accumulator, internal val fieldName: String, override var distinct: Boolean, -) : Projectable, Function.Accumulator +) : Selectable, Function.Accumulator open class Function(val name: String, val params: List) : Expr { interface FilterCondition : Expr diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index f8f540b10..350d1a776 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -31,8 +31,8 @@ internal data class Documents(internal val documents: List) : Stage { } } -internal data class Project(internal val projections: Map) : Stage { - val name = "project" +internal data class Select(internal val projections: Map) : Stage { + val name = "select" } internal data class AddFields(internal val fields: Map) : Stage { @@ -205,7 +205,7 @@ internal fun toStageProto(stage: Stage): com.google.firestore.v1.Pipeline.Stage .setName(stage.name) .addAllArgs(stage.documents.map { Value.newBuilder().setReferenceValue(it).build() }) .build() - is Project -> + is Select -> com.google.firestore.v1.Pipeline.Stage.newBuilder() .setName(stage.name) .addArgs(encodeValue(stage.projections)) From 8bc968fe901410c39c22d15ce0c5cee2fa8f978d Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Wed, 22 May 2024 11:25:10 -0400 Subject: [PATCH 41/45] fix countAll --- .../main/java/com/google/cloud/firestore/PipelineUtils.kt | 1 + .../java/com/google/cloud/firestore/pipeline/Expressions.kt | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt index 397300bf4..6c9d188bc 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt @@ -9,6 +9,7 @@ import com.google.cloud.firestore.pipeline.AggregatorTarget import com.google.cloud.firestore.pipeline.Constant import com.google.cloud.firestore.pipeline.Field import com.google.cloud.firestore.pipeline.Function +import com.google.cloud.firestore.pipeline.Function.Companion.count import com.google.cloud.firestore.pipeline.Function.Companion.countAll import com.google.cloud.firestore.pipeline.Function.Companion.not import com.google.firestore.v1.Cursor diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index b58941dee..2020d3256 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -120,9 +120,9 @@ interface Expr { fun count() = Count(this, false) - fun min() = Count(this, false) + fun min() = Function.Min(this, false) - fun max() = Count(this, false) + fun max() = Function.Max(this, false) infix fun cosineDistance(other: Expr) = CosineDistance(this, other) @@ -502,7 +502,7 @@ open class Function(val name: String, val params: List) : Expr { @JvmStatic fun max(expr: Expr) = Avg(expr, false) - @JvmStatic fun countAll(expr: Expr) = Count(expr, false) + @JvmStatic fun count(expr: Expr) = Count(expr, false) @JvmStatic fun countAll() = Count(null, false) From 8c864f7057f91f3a6838d3c13fa1cdf24fd6b45f Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Mon, 27 May 2024 11:41:07 -0400 Subject: [PATCH 42/45] order normalization and field unify --- .../com/google/cloud/firestore/Pipeline.kt | 4 +- .../google/cloud/firestore/PipelineResult.kt | 17 ++ .../com/google/cloud/firestore/Query.java | 5 +- .../cloud/firestore/pipeline/Expressions.kt | 11 +- .../cloud/firestore/it/ITQueryTest.java | 156 ++++++++++-------- 5 files changed, 117 insertions(+), 76 deletions(-) diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt index aeb3e6709..b13f715d8 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt @@ -177,9 +177,9 @@ class Pipeline private constructor(private val stages: List, private val val projMap = mutableMapOf() for (proj in selectables) { when (proj) { - is Field -> projMap[proj.field] = proj + is Field -> projMap[proj.path.encodedPath] = proj is AggregatorTarget -> projMap[proj.fieldName] = proj.accumulator - is Fields -> proj.fs?.forEach { projMap[it.field] = it } + is Fields -> proj.fs?.forEach { projMap[it.path.encodedPath] = it } } } return projMap diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt index 6cebcfc46..c8c09487e 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -1,6 +1,7 @@ package com.google.cloud.firestore import com.google.cloud.Timestamp +import com.google.cloud.firestore.pipeline.Field import com.google.firestore.v1.Document import com.google.firestore.v1.Value import java.util.Date @@ -76,6 +77,10 @@ internal constructor( return this.extractField(fieldPath) != null } + fun contains(field: Field): Boolean { + return this.extractField(field.path) != null + } + fun get(field: String): Any? { return get(FieldPath.fromDotSeparatedString(field)) } @@ -90,12 +95,20 @@ internal constructor( return UserDataConverter.decodeValue(rpcContext, value) } + fun get(field: Field): Any? { + return get(field.path) + } + fun get(fieldPath: FieldPath, valueType: Class): T? { val data = get(fieldPath) return if (data == null) null else CustomClassMapper.convertToCustomClass(data, valueType, reference) } + fun get(field: Field, valueType: Class): T? { + return get(field.path, valueType) + } + fun extractField(fieldPath: FieldPath): Value? { var value: Value? = null @@ -114,6 +127,10 @@ internal constructor( return value } + fun extractField(field: Field): Value? { + return extractField(field.path) + } + fun getBoolean(field: String): Boolean? { return get(field) as Boolean? } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java index b6f65678c..be9bb85b2 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -1997,9 +1997,10 @@ public Pipeline toPipeline() { } // Orders - if (this.options.getFieldOrders() != null && !this.options.getFieldOrders().isEmpty()) { + List normalizedOrderbys = this.createImplicitOrderBy(); + if (normalizedOrderbys != null && !normalizedOrderbys.isEmpty()) { List orders = - this.options.getFieldOrders().stream() + normalizedOrderbys.stream() .map( fieldOrder -> Ordering.of( diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 2020d3256..91185cf06 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -3,6 +3,7 @@ package com.google.cloud.firestore.pipeline import com.google.cloud.Timestamp import com.google.cloud.firestore.Blob import com.google.cloud.firestore.DocumentReference +import com.google.cloud.firestore.FieldPath import com.google.cloud.firestore.GeoPoint import com.google.cloud.firestore.Pipeline import com.google.cloud.firestore.encodeValue @@ -249,26 +250,26 @@ data class Constant internal constructor(private val value: Any?) : Expr { } data class Field internal constructor( - internal val field: String, + internal val path: FieldPath, private var pipeline: Pipeline? = null ) : Expr, Selectable { companion object { - const val DOCUMENT_ID: String = "__path__" + const val DOCUMENT_ID: String = "__name__" @JvmStatic fun of(path: String): Field { - return Field(path) + return Field(FieldPath.of(path)) } @JvmStatic fun ofAll(): Field { - return Field("") + return Field(FieldPath.of("")) } } internal fun toProto(): Value { - return Value.newBuilder().setFieldReferenceValue(field).build() + return Value.newBuilder().setFieldReferenceValue(path.toString()).build() } } diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java index 3ddd8439b..f3ac2cc5e 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java @@ -22,12 +22,14 @@ import com.google.cloud.firestore.*; import com.google.cloud.firestore.Query.Direction; +import com.google.common.collect.Sets; import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -66,12 +68,13 @@ public CollectionReference testCollectionWithDocs(Map result = + snapshot.getDocuments().stream() + .map(queryDocumentSnapshot -> queryDocumentSnapshot.getReference().getId()) + .collect(Collectors.toSet()); + assertThat(result).isEqualTo(Sets.newHashSet(docs)); + } + + List pipelineResults = query.toPipeline().execute(query.getFirestore()).get(); + Set result = + pipelineResults.stream() + .map(pipelineResult -> Objects.requireNonNull(pipelineResult.getReference()).getId()) + .collect(Collectors.toSet()); + assertThat(result).isEqualTo(Sets.newHashSet(docs)); + } + @Test public void orQueries() throws Exception { Map> testDocs = @@ -103,7 +125,7 @@ public void orQueries() throws Exception { CollectionReference collection = testCollectionWithDocs(testDocs); // Two equalities: a==1 || b==1. - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))), "doc1", "doc2", @@ -111,7 +133,7 @@ public void orQueries() throws Exception { "doc5"); // (a==1 && b==0) || (a==3 && b==2) - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where( Filter.or( Filter.and(Filter.equalTo("a", 1), Filter.equalTo("b", 0)), @@ -120,7 +142,7 @@ public void orQueries() throws Exception { "doc3"); // a==1 && (b==0 || b==3). - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where( Filter.and( Filter.equalTo("a", 1), Filter.or(Filter.equalTo("b", 0), Filter.equalTo("b", 3)))), @@ -128,7 +150,7 @@ public void orQueries() throws Exception { "doc4"); // (a==2 || b==2) && (a==3 || b==3) - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where( Filter.and( Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 2)), @@ -136,7 +158,7 @@ public void orQueries() throws Exception { "doc3"); // Test with limits without orderBy (the __name__ ordering is the tiebreaker). - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))).limit(1), "doc2"); } @@ -162,7 +184,7 @@ public void orQueriesWithCompositeIndexes() throws Exception { "doc3"); // Test with limits (implicit order by ASC): (a==1) || (b > 0) LIMIT 2 - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where(Filter.or(Filter.equalTo("a", 1), Filter.greaterThan("b", 0))).limit(2), /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", @@ -170,7 +192,7 @@ public void orQueriesWithCompositeIndexes() throws Exception { // Test with limits (explicit order by): (a==1) || (b > 0) LIMIT_TO_LAST 2 // Note: The public query API does not allow implicit ordering when limitToLast is used. - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection .where(Filter.or(Filter.equalTo("a", 1), Filter.greaterThan("b", 0))) .limitToLast(2) @@ -180,7 +202,7 @@ public void orQueriesWithCompositeIndexes() throws Exception { "doc4"); // Test with limits (explicit order by ASC): (a==2) || (b == 1) ORDER BY a LIMIT 1 - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) .limit(1) @@ -189,7 +211,7 @@ public void orQueriesWithCompositeIndexes() throws Exception { "doc5"); // Test with limits (explicit order by DESC): (a==2) || (b == 1) ORDER BY a LIMIT_TO_LAST 1 - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) .limitToLast(1) @@ -198,7 +220,7 @@ public void orQueriesWithCompositeIndexes() throws Exception { "doc2"); // Test with limits (explicit order by DESC): (a==2) || (b == 1) ORDER BY a DESC LIMIT 1 - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) .limit(1) @@ -224,7 +246,7 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields() throws Exception { // There's no explicit nor implicit orderBy. Documents with missing 'a' or missing 'b' should be // allowed if the document matches at least one disjunction term. Query query = collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))); - checkResultContainsDocuments(query, "doc1", "doc2", "doc4", "doc5"); + checkResultContainsDocumentsInOrder(query, "doc1", "doc2", "doc4", "doc5"); } @Test @@ -244,7 +266,7 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception // doc2 should not be included because it's missing the field 'a', and we have "orderBy a". Query query1 = collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))).orderBy("a"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", @@ -255,7 +277,7 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception // doc5 should not be included because it's missing the field 'b', and we have "orderBy b". Query query2 = collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))).orderBy("b"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", @@ -266,7 +288,7 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception // This query has an implicit 'order by a'. // doc2 should not be included because it's missing the field 'a'. Query query3 = collection.where(Filter.or(Filter.greaterThan("a", 2), Filter.equalTo("b", 1))); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3"); // Query: a>1 || b==1 order by a order by b. @@ -277,7 +299,7 @@ public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception .where(Filter.or(Filter.greaterThan("a", 1), Filter.equalTo("b", 1))) .orderBy("a") .orderBy("b"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query4, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3"); } @@ -294,7 +316,7 @@ public void orQueriesWithIn() throws ExecutionException, InterruptedException, T CollectionReference collection = testCollectionWithDocs(testDocs); // a==2 || b in [2,3] - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.inArray("b", asList(2, 3)))), "doc3", "doc4", @@ -316,7 +338,7 @@ public void orQueriesWithNotIn() // a==2 || b not-in [2,3] // Has implicit orderBy b. - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.notInArray("b", asList(2, 3)))), /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", @@ -337,14 +359,14 @@ public void orQueriesWithArrayMembership() CollectionReference collection = testCollectionWithDocs(testDocs); // a==2 || b array-contains 7 - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where(Filter.or(Filter.equalTo("a", 2), Filter.arrayContains("b", 7))), "doc3", "doc4", "doc6"); // a==2 || b array-contains-any [0, 3] - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( collection.where( Filter.or(Filter.equalTo("a", 2), Filter.arrayContainsAny("b", asList(0, 3)))), "doc1", @@ -368,26 +390,26 @@ public void testUsingInWithArrayContains() Query query1 = collection.where( Filter.or(Filter.inArray("a", asList(2, 3)), Filter.arrayContains("b", 3))); - checkResultContainsDocuments(query1, "doc3", "doc4", "doc6"); + checkResultContainsDocumentsInOrder(query1, "doc3", "doc4", "doc6"); Query query2 = collection.where( Filter.and(Filter.inArray("a", asList(2, 3)), Filter.arrayContains("b", 7))); - checkResultContainsDocuments(query2, "doc3"); + checkResultContainsDocumentsInOrder(query2, "doc3"); Query query3 = collection.where( Filter.or( Filter.inArray("a", asList(2, 3)), Filter.and(Filter.arrayContains("b", 3), Filter.equalTo("a", 1)))); - checkResultContainsDocuments(query3, "doc3", "doc4", "doc6"); + checkResultContainsDocumentsInOrder(query3, "doc3", "doc4", "doc6"); Query query4 = collection.where( Filter.and( Filter.inArray("a", asList(2, 3)), Filter.or(Filter.arrayContains("b", 7), Filter.equalTo("a", 1)))); - checkResultContainsDocuments(query4, "doc3"); + checkResultContainsDocumentsInOrder(query4, "doc3"); } @Test @@ -404,7 +426,7 @@ public void testOrderByEquality() CollectionReference collection = testCollectionWithDocs(testDocs); Query query1 = collection.where(Filter.equalTo("a", 1)).orderBy("a"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", @@ -412,7 +434,7 @@ public void testOrderByEquality() "doc5"); Query query2 = collection.where(Filter.inArray("a", asList(2, 3))).orderBy("a"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc6", "doc3"); } @@ -432,7 +454,7 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereNotEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereGreaterThan("v", 2); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3"); // Duplicate inequality fields @@ -441,7 +463,7 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereNotEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereGreaterThan("sort", 1); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4"); // With multiple IN @@ -451,7 +473,7 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereLessThanOrEqualTo("sort", 2) .whereIn("v", asList(2, 3, 4)) .whereIn("sort", asList(2, 3)); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4"); // With NOT-IN @@ -460,7 +482,7 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereGreaterThanOrEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereNotIn("v", asList(2, 4, 5)); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query4, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", "doc3"); // With orderby @@ -469,7 +491,7 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereGreaterThanOrEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .orderBy("v", Direction.DESCENDING); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query5, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3", @@ -483,7 +505,7 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereLessThanOrEqualTo("sort", 2) .orderBy("v", Direction.DESCENDING) .limit(2); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query6, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc3", "doc4"); // With limitToLast @@ -493,7 +515,7 @@ public void multipleInequalityOnDifferentFields() throws Exception { .whereLessThanOrEqualTo("sort", 2) .orderBy("v", Direction.DESCENDING) .limitToLast(2); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query7, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4", "doc1"); } @@ -510,7 +532,7 @@ public void multipleInequalityOnSpecialValues() throws Exception { "doc6", map("key", "f", "sort", 1, "v", 1))); Query query1 = collection.whereNotEqualTo("key", "a").whereLessThanOrEqualTo("sort", 2); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", "doc6"); Query query2 = @@ -518,7 +540,7 @@ public void multipleInequalityOnSpecialValues() throws Exception { .whereNotEqualTo("key", "a") .whereLessThanOrEqualTo("sort", 2) .whereLessThanOrEqualTo("v", 1); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc6"); } @@ -547,7 +569,7 @@ public void multipleInequalityWithArrayMembership() throws Exception { .whereNotEqualTo("key", "a") .whereGreaterThanOrEqualTo("sort", 1) .whereArrayContains("v", 0); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2"); Query query2 = @@ -555,7 +577,7 @@ public void multipleInequalityWithArrayMembership() throws Exception { .whereNotEqualTo("key", "a") .whereGreaterThanOrEqualTo("sort", 1) .whereArrayContainsAny("v", asList(0, 1)); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc4"); } @@ -594,9 +616,9 @@ public void multipleInequalityWithNestedField() throws Exception { .orderBy("name"); DocumentSnapshot docSnap = collection.document("doc4").get().get(); Query query1WithCursor = query1.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4", "doc1"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc4", @@ -611,9 +633,9 @@ public void multipleInequalityWithNestedField() throws Exception { .orderBy("name", Direction.DESCENDING); docSnap = collection.document("doc2").get().get(); Query query2WithCursor = query2.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc3"); - checkResultContainsDocuments(query2WithCursor, "doc2", "doc3"); + checkResultContainsDocumentsInOrder(query2WithCursor, "doc2", "doc3"); } @Test @@ -642,14 +664,14 @@ public void multipleInequalityWithCompositeFilters() throws Exception { Filter.and(Filter.notEqualTo("key", "b"), Filter.greaterThan("v", 4)))); DocumentSnapshot docSnap = collection.document("doc1").get().get(); Query query1WithCursor = query1.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", "doc6", "doc5", "doc4"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", @@ -668,14 +690,14 @@ public void multipleInequalityWithCompositeFilters() throws Exception { .orderBy("key"); docSnap = collection.document("doc5").get().get(); Query query2WithCursor = query2.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", "doc4", "doc1", "doc6"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", @@ -696,9 +718,9 @@ public void multipleInequalityWithCompositeFilters() throws Exception { Filter.and(Filter.lessThan("key", "b"), Filter.greaterThan("v", 0))))); docSnap = collection.document("doc1").get().get(); Query query3WithCursor = query3.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", "doc2"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc1", @@ -733,14 +755,14 @@ public void multipleInequalityFieldsWillBeImplicitlyOrderedLexicographicallyBySe .whereGreaterThan("sort", 1) .whereIn("v", asList(1, 2, 3, 4)); Query query1WithCursor = query1.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc4", "doc5", "doc3"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", @@ -755,14 +777,14 @@ public void multipleInequalityFieldsWillBeImplicitlyOrderedLexicographicallyBySe .whereNotEqualTo("key", "a") .whereIn("v", asList(1, 2, 3, 4)); Query query2WithCursor = query2.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc4", "doc5", "doc3"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", @@ -795,14 +817,14 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { Query query1 = collection.whereGreaterThan("key", "a").whereGreaterThanOrEqualTo("sort", 1).orderBy("v"); Query query1WithCursor = query1.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc4", "doc3", "doc5"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", @@ -818,14 +840,14 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { .orderBy("v") .orderBy("sort"); Query query2WithCursor = query2.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc5", "doc4", "doc3"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", @@ -843,14 +865,14 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { .whereGreaterThanOrEqualTo("sort", 1) .orderBy("v", Direction.DESCENDING); Query query3WithCursor = query3.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", "doc3", "doc4", "doc2"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", @@ -866,14 +888,14 @@ public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { .orderBy("v", Direction.DESCENDING) .orderBy("sort"); Query query4WithCursor = query4.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query4, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", "doc4", "doc3", "doc2"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query4WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc5", @@ -937,13 +959,13 @@ public void multipleInequalityFieldsWithDocumentKey() throws Exception { .whereNotEqualTo("key", "a") .whereLessThan(FieldPath.documentId(), "doc5"); Query query1WithCursor = query1.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc4", "doc3"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query1WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", @@ -958,13 +980,13 @@ public void multipleInequalityFieldsWithDocumentKey() throws Exception { .whereGreaterThan("sort", 1) .whereNotEqualTo("key", "a"); Query query2WithCursor = query2.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc4", "doc3"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query2WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", @@ -979,13 +1001,13 @@ public void multipleInequalityFieldsWithDocumentKey() throws Exception { .whereNotEqualTo("key", "a") .orderBy("sort", Direction.DESCENDING); Query query3WithCursor = query3.startAt(docSnap); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", "doc3", "doc4"); - checkResultContainsDocuments( + checkResultContainsDocumentsInOrder( query3WithCursor, /*pipelineOnly*/ !isRunningAgainstFirestoreEmulator(firestore), "doc2", From a79e8a7c84046277060e0d60de487a1e61ad726e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 27 May 2024 15:43:52 +0000 Subject: [PATCH 43/45] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 050eb8250..b0b3e92a3 100644 --- a/README.md +++ b/README.md @@ -50,20 +50,20 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.37.0') +implementation platform('com.google.cloud:libraries-bom:26.39.0') implementation 'com.google.cloud:google-cloud-firestore' ``` If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-firestore:3.20.0' +implementation 'com.google.cloud:google-cloud-firestore:3.21.3' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-firestore" % "3.20.0" +libraryDependencies += "com.google.cloud" % "google-cloud-firestore" % "3.21.3" ``` @@ -222,7 +222,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-firestore/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-firestore.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-firestore/3.20.0 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-firestore/3.21.3 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles From 93135a8d1542d31b0b1e06c0d94c43acdafb1aed Mon Sep 17 00:00:00 2001 From: Wu-Hui Date: Wed, 29 May 2024 14:20:40 -0400 Subject: [PATCH 44/45] Add jvmfile name and string as field heuristics --- CONTRIBUTING.md | 2 +- .../cloud/firestore/AggregateQuery.java | 2 +- .../google/cloud/firestore/PipelineResult.kt | 3 + .../google/cloud/firestore/PipelineUtils.kt | 2 +- .../firestore/{Pipeline.kt => Pipelines.kt} | 15 ++- .../com/google/cloud/firestore/Query.java | 4 +- .../cloud/firestore/UserDataConverter.java | 2 +- .../cloud/firestore/pipeline/Expressions.kt | 113 ++++++++++++++++++ .../google/cloud/firestore/pipeline/Stages.kt | 1 + 9 files changed, 137 insertions(+), 7 deletions(-) rename google-cloud-firestore/src/main/java/com/google/cloud/firestore/{Pipeline.kt => Pipelines.kt} (96%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b65dd279c..4f74815c0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,4 +89,4 @@ mvn com.coveo:fmt-maven-plugin:format [1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account [2]: https://maven.apache.org/settings.html#Active_Profiles -[3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md \ No newline at end of file +[3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java index 1d51219a9..5e2c5f673 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java @@ -72,7 +72,7 @@ public Pipeline toPipeline() { .toPipeline() .aggregate( this.aggregateFieldList.stream() - .map(PipelineUtilsKt::toPipelineAggregatorTarget) + .map(PipelineUtils::toPipelineAggregatorTarget) .toArray(AggregatorTarget[]::new)); } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt index c8c09487e..6df882e09 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.kt @@ -7,6 +7,9 @@ import com.google.firestore.v1.Value import java.util.Date import javax.annotation.Nonnull +/** + * Result from a {@code Pipeline} execution. + */ class PipelineResult internal constructor( private val rpcContext: FirestoreRpcContext<*>?, diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt index 6c9d188bc..e0023f041 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.kt @@ -1,3 +1,4 @@ +@file:JvmName("PipelineUtils") package com.google.cloud.firestore import com.google.cloud.firestore.Query.ComparisonFilterInternal @@ -9,7 +10,6 @@ import com.google.cloud.firestore.pipeline.AggregatorTarget import com.google.cloud.firestore.pipeline.Constant import com.google.cloud.firestore.pipeline.Field import com.google.cloud.firestore.pipeline.Function -import com.google.cloud.firestore.pipeline.Function.Companion.count import com.google.cloud.firestore.pipeline.Function.Companion.countAll import com.google.cloud.firestore.pipeline.Function.Companion.not import com.google.firestore.v1.Cursor diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipelines.kt similarity index 96% rename from google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt rename to google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipelines.kt index b13f715d8..6d4ef8341 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipelines.kt @@ -1,3 +1,4 @@ +@file:JvmName("Pipelines") package com.google.cloud.firestore import com.google.api.core.ApiFuture @@ -185,6 +186,14 @@ class Pipeline private constructor(private val stages: List, private val return projMap } + private fun fieldNamesToMap(vararg fields: String): Map { + val projMap = mutableMapOf() + for (field in fields) { + projMap[field] = Field.of(field) + } + return projMap + } + fun addFields(vararg fields: Selectable): Pipeline { return Pipeline(stages.plus(AddFields(projectablesToMap(*fields))), name) } @@ -193,6 +202,10 @@ class Pipeline private constructor(private val stages: List, private val return Pipeline(stages.plus(Select(projectablesToMap(*projections))), name) } + fun select(vararg fields: String): Pipeline { + return Pipeline(stages.plus(Select(fieldNamesToMap(*fields))), name) + } + fun filter(condition: T): Pipeline where T : Expr, T : Function.FilterCondition { return Pipeline(stages.plus(Filter(condition)), name) } @@ -234,7 +247,7 @@ class Pipeline private constructor(private val stages: List, private val return PaginatingPipeline(this, pageSize, orders.toList()) } - fun genericOperation(name: String, params: Map? = null): Pipeline { + fun genericStage(name: String, params: Map? = null): Pipeline { return this } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java index 76dd1a7fb..15ed4cf65 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -16,8 +16,8 @@ package com.google.cloud.firestore; -import static com.google.cloud.firestore.PipelineUtilsKt.toPaginatedPipeline; -import static com.google.cloud.firestore.PipelineUtilsKt.toPipelineFilterCondition; +import static com.google.cloud.firestore.PipelineUtils.toPaginatedPipeline; +import static com.google.cloud.firestore.PipelineUtils.toPipelineFilterCondition; import static com.google.common.collect.Lists.reverse; import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS; import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS_ANY; diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java index 072274bd6..1f077f756 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java @@ -16,7 +16,7 @@ package com.google.cloud.firestore; -import static com.google.cloud.firestore.pipeline.ExpressionsKt.exprToValue; +import static com.google.cloud.firestore.pipeline.Expressions.exprToValue; import com.google.cloud.Timestamp; import com.google.cloud.firestore.pipeline.Expr; diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt index 91185cf06..b4f6ce449 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Expressions.kt @@ -1,3 +1,4 @@ +@file:JvmName("Expressions") package com.google.cloud.firestore.pipeline import com.google.cloud.Timestamp @@ -414,28 +415,56 @@ open class Function(val name: String, val params: List) : Expr { @JvmStatic fun equal(left: Expr, right: Any) = Equal(left, Constant.of(right)) + @JvmStatic + fun equal(left: String, right: Expr) = Equal(Field.of(left), right) + + @JvmStatic + fun equal(left: String, right: Any) = Equal(Field.of(left), Constant.of(right)) + @JvmStatic fun notEqual(left: Expr, right: Expr) = NotEqual(left, right) @JvmStatic fun notEqual(left: Expr, right: Any) = NotEqual(left, Constant.of(right)) + @JvmStatic fun notEqual(left: String, right: Expr) = NotEqual(Field.of(left), right) + + @JvmStatic fun notEqual(left: String, right: Any) = NotEqual(Field.of(left), Constant.of(right)) + @JvmStatic fun greaterThan(left: Expr, right: Expr) = GreaterThan(left, right) @JvmStatic fun greaterThan(left: Expr, right: Any) = GreaterThan(left, Constant.of(right)) + @JvmStatic fun greaterThan(left: String, right: Expr) = GreaterThan(Field.of(left), right) + + @JvmStatic fun greaterThan(left: String, right: Any) = GreaterThan(Field.of(left), Constant.of(right)) + @JvmStatic fun greaterThanOrEqual(left: Expr, right: Expr) = GreaterThanOrEqual(left, right) @JvmStatic fun greaterThanOrEqual(left: Expr, right: Any) = GreaterThanOrEqual(left, Constant.of(right)) + @JvmStatic fun greaterThanOrEqual(left: String, right: Expr) = GreaterThanOrEqual(Field.of(left), right) + + @JvmStatic + fun greaterThanOrEqual(left: String, right: Any) = GreaterThanOrEqual(Field.of(left), Constant.of(right)) + @JvmStatic fun lessThan(left: Expr, right: Expr) = LessThan(left, right) @JvmStatic fun lessThan(left: Expr, right: Any) = LessThan(left, Constant.of(right)) + @JvmStatic fun lessThan(left: String, right: Expr) = LessThan(Field.of(left), right) + + @JvmStatic fun lessThan(left: String, right: Any) = LessThan(Field.of(left), Constant.of(right)) + @JvmStatic fun lessThanOrEqual(left: Expr, right: Expr) = LessThanOrEqual(left, right) @JvmStatic fun lessThanOrEqual(left: Expr, right: Any) = LessThanOrEqual(left, Constant.of(right)) + @JvmStatic fun lessThanOrEqual(left: String, right: Expr) = LessThanOrEqual(Field.of(left), right) + + @JvmStatic + fun lessThanOrEqual(left: String, right: Any) = LessThanOrEqual(Field.of(left), Constant.of(right)) + @JvmStatic fun inAny(left: Expr, values: List) = In( @@ -448,6 +477,18 @@ open class Function(val name: String, val params: List) : Expr { }, ) + @JvmStatic + fun inAny(left: String, values: List) = + In( + Field.of(left), + values.map { + when (it) { + is Expr -> it + else -> Constant.of(it) + } + }, + ) + @JvmStatic fun notInAny(left: Expr, values: List) = Not( @@ -462,6 +503,21 @@ open class Function(val name: String, val params: List) : Expr { ) ) + @JvmStatic + fun notInAny(left: String, values: List) = + Not( + In( + Field.of(left), + values.map { + when (it) { + is Expr -> it + else -> Constant.of(it) + } + }, + ) + ) + + @JvmStatic fun and(left: T, right: T) where T : FilterCondition, T : Expr = And(listOf(left, right)) @@ -478,9 +534,16 @@ open class Function(val name: String, val params: List) : Expr { @JvmStatic fun arrayContains(expr: Expr, element: Expr) = ArrayContains(expr, element) + @JvmStatic + fun arrayContains(field: String, element: Expr) = ArrayContains(Field.of(field), element) + @JvmStatic fun arrayContains(expr: Expr, element: Any) = ArrayContains(expr, Constant.of(element)) + @JvmStatic + fun arrayContains(field: String, element: Any) = + ArrayContains(Field.of(field), Constant.of(element)) + @JvmStatic fun arrayContainsAny(expr: Expr, vararg elements: Expr) = ArrayContainsAny(expr, elements.toList()) @@ -489,22 +552,51 @@ open class Function(val name: String, val params: List) : Expr { fun arrayContainsAny(expr: Expr, vararg elements: Any) = ArrayContainsAny(expr, elements.toList().map { Constant.of(it) }) + @JvmStatic + fun arrayContainsAny(field: String, vararg elements: Expr) = + ArrayContainsAny(Field.of(field), elements.toList()) + + @JvmStatic + fun arrayContainsAny(field: String, vararg elements: Any) = + ArrayContainsAny(Field.of(field), elements.toList().map { Constant.of(it) }) + @JvmStatic fun isNaN(expr: Expr) = IsNaN(expr) + @JvmStatic + fun isNaN(field: String) = IsNaN(Field.of(field)) + @JvmStatic fun isNull(expr: Expr) = IsNull(expr) + @JvmStatic + fun isNull(field: String) = IsNull(Field.of(field)) + @JvmStatic fun not(expr: Expr) = Not(expr) @JvmStatic fun sum(expr: Expr) = Sum(expr, false) + @JvmStatic + fun sum(field: String) = Sum(Field.of(field), false) + @JvmStatic fun avg(expr: Expr) = Avg(expr, false) + @JvmStatic + fun avg(field: String) = Avg(Field.of(field), false) + @JvmStatic fun min(expr: Expr) = Sum(expr, false) + @JvmStatic + fun min(field: String) = Sum(Field.of(field), false) + @JvmStatic fun max(expr: Expr) = Avg(expr, false) + @JvmStatic + fun max(field: String) = Avg(Field.of(field), false) + @JvmStatic fun count(expr: Expr) = Count(expr, false) + @JvmStatic + fun count(field: String) = Count(Field.of(field), false) + @JvmStatic fun countAll() = Count(null, false) @JvmStatic fun cosineDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) @@ -513,18 +605,39 @@ open class Function(val name: String, val params: List) : Expr { fun cosineDistance(expr: Expr, other: DoubleArray) = CosineDistance(expr, Constant.ofVector(other)) + @JvmStatic + fun cosineDistance(field: String, other: Expr) = CosineDistance(Field.of(field), other) + + @JvmStatic + fun cosineDistance(field: String, other: DoubleArray) = + CosineDistance(Field.of(field), Constant.ofVector(other)) + @JvmStatic fun dotProductDistance(expr: Expr, other: Expr) = CosineDistance(expr, other) @JvmStatic fun dotProductDistance(expr: Expr, other: DoubleArray) = CosineDistance(expr, Constant.ofVector(other)) + @JvmStatic + fun dotProductDistance(field: String, other: Expr) = CosineDistance(Field.of(field), other) + + @JvmStatic + fun dotProductDistance(field: String, other: DoubleArray) = + CosineDistance(Field.of(field), Constant.ofVector(other)) + @JvmStatic fun euclideanDistance(expr: Expr, other: Expr) = EuclideanDistance(expr, other) @JvmStatic fun euclideanDistance(expr: Expr, other: DoubleArray) = EuclideanDistance(expr, Constant.ofVector(other)) + @JvmStatic + fun euclideanDistance(field: String, other: Expr) = EuclideanDistance(Field.of(field), other) + + @JvmStatic + fun euclideanDistance(field: String, other: DoubleArray) = + EuclideanDistance(Field.of(field), Constant.ofVector(other)) + @JvmStatic fun function(name: String, params: List) = Generic(name, params) } } diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt index 350d1a776..b415b94f6 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/Stages.kt @@ -1,3 +1,4 @@ +@file:JvmName("Stages") package com.google.cloud.firestore.pipeline import com.google.cloud.firestore.DocumentReference From 38ad69cefaa9787aa54ca2e1dd984ae8d4eec177 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 29 May 2024 18:23:05 +0000 Subject: [PATCH 45/45] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- CONTRIBUTING.md | 2 +- README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f74815c0..b65dd279c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,4 +89,4 @@ mvn com.coveo:fmt-maven-plugin:format [1]: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account [2]: https://maven.apache.org/settings.html#Active_Profiles -[3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md +[3]: https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md \ No newline at end of file diff --git a/README.md b/README.md index b0b3e92a3..a185d65f9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: com.google.cloud libraries-bom - 26.31.0 + 26.39.0 pom import @@ -42,7 +42,7 @@ If you are using Maven without the BOM, add this to your dependencies: com.google.cloud google-cloud-firestore - 3.16.1 + 3.21.1 ``` @@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.39.0') +implementation platform('com.google.cloud:libraries-bom:26.40.0') implementation 'com.google.cloud:google-cloud-firestore' ```