#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PartitionId {
#[prost(string, tag = "2")]
pub project_id: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub namespace_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Key {
#[prost(message, optional, tag = "1")]
pub partition_id: ::core::option::Option<PartitionId>,
#[prost(message, repeated, tag = "2")]
pub path: ::prost::alloc::vec::Vec<key::PathElement>,
}
pub mod key {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PathElement {
#[prost(string, tag = "1")]
pub kind: ::prost::alloc::string::String,
#[prost(oneof = "path_element::IdType", tags = "2, 3")]
pub id_type: ::core::option::Option<path_element::IdType>,
}
pub mod path_element {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum IdType {
#[prost(int64, tag = "2")]
Id(i64),
#[prost(string, tag = "3")]
Name(::prost::alloc::string::String),
}
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ArrayValue {
#[prost(message, repeated, tag = "1")]
pub values: ::prost::alloc::vec::Vec<Value>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Value {
#[prost(int32, tag = "14")]
pub meaning: i32,
#[prost(bool, tag = "19")]
pub exclude_from_indexes: bool,
#[prost(
oneof = "value::ValueType",
tags = "11, 1, 2, 3, 10, 5, 17, 18, 8, 6, 9"
)]
pub value_type: ::core::option::Option<value::ValueType>,
}
pub mod value {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ValueType {
#[prost(enumeration = "::prost_types::NullValue", tag = "11")]
NullValue(i32),
#[prost(bool, tag = "1")]
BooleanValue(bool),
#[prost(int64, tag = "2")]
IntegerValue(i64),
#[prost(double, tag = "3")]
DoubleValue(f64),
#[prost(message, tag = "10")]
TimestampValue(::prost_types::Timestamp),
#[prost(message, tag = "5")]
KeyValue(super::Key),
#[prost(string, tag = "17")]
StringValue(::prost::alloc::string::String),
#[prost(bytes, tag = "18")]
BlobValue(::prost::alloc::vec::Vec<u8>),
#[prost(message, tag = "8")]
GeoPointValue(super::super::super::r#type::LatLng),
#[prost(message, tag = "6")]
EntityValue(super::Entity),
#[prost(message, tag = "9")]
ArrayValue(super::ArrayValue),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Entity {
#[prost(message, optional, tag = "1")]
pub key: ::core::option::Option<Key>,
#[prost(map = "string, message", tag = "3")]
pub properties: ::std::collections::HashMap<::prost::alloc::string::String, Value>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EntityResult {
#[prost(message, optional, tag = "1")]
pub entity: ::core::option::Option<Entity>,
#[prost(int64, tag = "4")]
pub version: i64,
#[prost(bytes = "vec", tag = "3")]
pub cursor: ::prost::alloc::vec::Vec<u8>,
}
pub mod entity_result {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ResultType {
Unspecified = 0,
Full = 1,
Projection = 2,
KeyOnly = 3,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Query {
#[prost(message, repeated, tag = "2")]
pub projection: ::prost::alloc::vec::Vec<Projection>,
#[prost(message, repeated, tag = "3")]
pub kind: ::prost::alloc::vec::Vec<KindExpression>,
#[prost(message, optional, tag = "4")]
pub filter: ::core::option::Option<Filter>,
#[prost(message, repeated, tag = "5")]
pub order: ::prost::alloc::vec::Vec<PropertyOrder>,
#[prost(message, repeated, tag = "6")]
pub distinct_on: ::prost::alloc::vec::Vec<PropertyReference>,
#[prost(bytes = "vec", tag = "7")]
pub start_cursor: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "8")]
pub end_cursor: ::prost::alloc::vec::Vec<u8>,
#[prost(int32, tag = "10")]
pub offset: i32,
#[prost(message, optional, tag = "12")]
pub limit: ::core::option::Option<i32>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KindExpression {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PropertyReference {
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Projection {
#[prost(message, optional, tag = "1")]
pub property: ::core::option::Option<PropertyReference>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PropertyOrder {
#[prost(message, optional, tag = "1")]
pub property: ::core::option::Option<PropertyReference>,
#[prost(enumeration = "property_order::Direction", tag = "2")]
pub direction: i32,
}
pub mod property_order {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Direction {
Unspecified = 0,
Ascending = 1,
Descending = 2,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Filter {
#[prost(oneof = "filter::FilterType", tags = "1, 2")]
pub filter_type: ::core::option::Option<filter::FilterType>,
}
pub mod filter {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum FilterType {
#[prost(message, tag = "1")]
CompositeFilter(super::CompositeFilter),
#[prost(message, tag = "2")]
PropertyFilter(super::PropertyFilter),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompositeFilter {
#[prost(enumeration = "composite_filter::Operator", tag = "1")]
pub op: i32,
#[prost(message, repeated, tag = "2")]
pub filters: ::prost::alloc::vec::Vec<Filter>,
}
pub mod composite_filter {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Operator {
Unspecified = 0,
And = 1,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PropertyFilter {
#[prost(message, optional, tag = "1")]
pub property: ::core::option::Option<PropertyReference>,
#[prost(enumeration = "property_filter::Operator", tag = "2")]
pub op: i32,
#[prost(message, optional, tag = "3")]
pub value: ::core::option::Option<Value>,
}
pub mod property_filter {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Operator {
Unspecified = 0,
LessThan = 1,
LessThanOrEqual = 2,
GreaterThan = 3,
GreaterThanOrEqual = 4,
Equal = 5,
HasAncestor = 11,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GqlQuery {
#[prost(string, tag = "1")]
pub query_string: ::prost::alloc::string::String,
#[prost(bool, tag = "2")]
pub allow_literals: bool,
#[prost(map = "string, message", tag = "5")]
pub named_bindings:
::std::collections::HashMap<::prost::alloc::string::String, GqlQueryParameter>,
#[prost(message, repeated, tag = "4")]
pub positional_bindings: ::prost::alloc::vec::Vec<GqlQueryParameter>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GqlQueryParameter {
#[prost(oneof = "gql_query_parameter::ParameterType", tags = "2, 3")]
pub parameter_type: ::core::option::Option<gql_query_parameter::ParameterType>,
}
pub mod gql_query_parameter {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ParameterType {
#[prost(message, tag = "2")]
Value(super::Value),
#[prost(bytes, tag = "3")]
Cursor(::prost::alloc::vec::Vec<u8>),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryResultBatch {
#[prost(int32, tag = "6")]
pub skipped_results: i32,
#[prost(bytes = "vec", tag = "3")]
pub skipped_cursor: ::prost::alloc::vec::Vec<u8>,
#[prost(enumeration = "entity_result::ResultType", tag = "1")]
pub entity_result_type: i32,
#[prost(message, repeated, tag = "2")]
pub entity_results: ::prost::alloc::vec::Vec<EntityResult>,
#[prost(bytes = "vec", tag = "4")]
pub end_cursor: ::prost::alloc::vec::Vec<u8>,
#[prost(enumeration = "query_result_batch::MoreResultsType", tag = "5")]
pub more_results: i32,
#[prost(int64, tag = "7")]
pub snapshot_version: i64,
}
pub mod query_result_batch {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MoreResultsType {
Unspecified = 0,
NotFinished = 1,
MoreResultsAfterLimit = 2,
MoreResultsAfterCursor = 4,
NoMoreResults = 3,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LookupRequest {
#[prost(string, tag = "8")]
pub project_id: ::prost::alloc::string::String,
#[prost(message, optional, tag = "1")]
pub read_options: ::core::option::Option<ReadOptions>,
#[prost(message, repeated, tag = "3")]
pub keys: ::prost::alloc::vec::Vec<Key>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LookupResponse {
#[prost(message, repeated, tag = "1")]
pub found: ::prost::alloc::vec::Vec<EntityResult>,
#[prost(message, repeated, tag = "2")]
pub missing: ::prost::alloc::vec::Vec<EntityResult>,
#[prost(message, repeated, tag = "3")]
pub deferred: ::prost::alloc::vec::Vec<Key>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RunQueryRequest {
#[prost(string, tag = "8")]
pub project_id: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub partition_id: ::core::option::Option<PartitionId>,
#[prost(message, optional, tag = "1")]
pub read_options: ::core::option::Option<ReadOptions>,
#[prost(oneof = "run_query_request::QueryType", tags = "3, 7")]
pub query_type: ::core::option::Option<run_query_request::QueryType>,
}
pub mod run_query_request {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum QueryType {
#[prost(message, tag = "3")]
Query(super::Query),
#[prost(message, tag = "7")]
GqlQuery(super::GqlQuery),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RunQueryResponse {
#[prost(message, optional, tag = "1")]
pub batch: ::core::option::Option<QueryResultBatch>,
#[prost(message, optional, tag = "2")]
pub query: ::core::option::Option<Query>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BeginTransactionRequest {
#[prost(string, tag = "8")]
pub project_id: ::prost::alloc::string::String,
#[prost(message, optional, tag = "10")]
pub transaction_options: ::core::option::Option<TransactionOptions>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BeginTransactionResponse {
#[prost(bytes = "vec", tag = "1")]
pub transaction: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RollbackRequest {
#[prost(string, tag = "8")]
pub project_id: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "1")]
pub transaction: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RollbackResponse {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommitRequest {
#[prost(string, tag = "8")]
pub project_id: ::prost::alloc::string::String,
#[prost(enumeration = "commit_request::Mode", tag = "5")]
pub mode: i32,
#[prost(message, repeated, tag = "6")]
pub mutations: ::prost::alloc::vec::Vec<Mutation>,
#[prost(oneof = "commit_request::TransactionSelector", tags = "1")]
pub transaction_selector: ::core::option::Option<commit_request::TransactionSelector>,
}
pub mod commit_request {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Mode {
Unspecified = 0,
Transactional = 1,
NonTransactional = 2,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum TransactionSelector {
#[prost(bytes, tag = "1")]
Transaction(::prost::alloc::vec::Vec<u8>),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommitResponse {
#[prost(message, repeated, tag = "3")]
pub mutation_results: ::prost::alloc::vec::Vec<MutationResult>,
#[prost(int32, tag = "4")]
pub index_updates: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AllocateIdsRequest {
#[prost(string, tag = "8")]
pub project_id: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "1")]
pub keys: ::prost::alloc::vec::Vec<Key>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AllocateIdsResponse {
#[prost(message, repeated, tag = "1")]
pub keys: ::prost::alloc::vec::Vec<Key>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReserveIdsRequest {
#[prost(string, tag = "8")]
pub project_id: ::prost::alloc::string::String,
#[prost(string, tag = "9")]
pub database_id: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "1")]
pub keys: ::prost::alloc::vec::Vec<Key>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReserveIdsResponse {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Mutation {
#[prost(oneof = "mutation::Operation", tags = "4, 5, 6, 7")]
pub operation: ::core::option::Option<mutation::Operation>,
#[prost(oneof = "mutation::ConflictDetectionStrategy", tags = "8")]
pub conflict_detection_strategy: ::core::option::Option<mutation::ConflictDetectionStrategy>,
}
pub mod mutation {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Operation {
#[prost(message, tag = "4")]
Insert(super::Entity),
#[prost(message, tag = "5")]
Update(super::Entity),
#[prost(message, tag = "6")]
Upsert(super::Entity),
#[prost(message, tag = "7")]
Delete(super::Key),
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ConflictDetectionStrategy {
#[prost(int64, tag = "8")]
BaseVersion(i64),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MutationResult {
#[prost(message, optional, tag = "3")]
pub key: ::core::option::Option<Key>,
#[prost(int64, tag = "4")]
pub version: i64,
#[prost(bool, tag = "5")]
pub conflict_detected: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadOptions {
#[prost(oneof = "read_options::ConsistencyType", tags = "1, 2")]
pub consistency_type: ::core::option::Option<read_options::ConsistencyType>,
}
pub mod read_options {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ReadConsistency {
Unspecified = 0,
Strong = 1,
Eventual = 2,
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum ConsistencyType {
#[prost(enumeration = "ReadConsistency", tag = "1")]
ReadConsistency(i32),
#[prost(bytes, tag = "2")]
Transaction(::prost::alloc::vec::Vec<u8>),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransactionOptions {
#[prost(oneof = "transaction_options::Mode", tags = "1, 2")]
pub mode: ::core::option::Option<transaction_options::Mode>,
}
pub mod transaction_options {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadWrite {
#[prost(bytes = "vec", tag = "1")]
pub previous_transaction: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ReadOnly {}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Mode {
#[prost(message, tag = "1")]
ReadWrite(ReadWrite),
#[prost(message, tag = "2")]
ReadOnly(ReadOnly),
}
}
#[doc = r" Generated client implementations."]
pub mod datastore_client {
#![allow(unused_variables, dead_code, missing_docs)]
use tonic::codegen::*;
#[doc = " Each RPC normalizes the partition IDs of the keys in its input entities,"]
#[doc = " and always returns entities with keys with normalized partition IDs."]
#[doc = " This applies to all keys and entities, including those in values, except keys"]
#[doc = " with both an empty path and an empty or unset partition ID. Normalization of"]
#[doc = " input keys sets the project ID (if not already set) to the project ID from"]
#[doc = " the request."]
#[doc = ""]
pub struct DatastoreClient<T> {
inner: tonic::client::Grpc<T>,
}
impl DatastoreClient<tonic::transport::Channel> {
#[doc = r" Attempt to create a new client by connecting to a given endpoint."]
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: std::convert::TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> DatastoreClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::ResponseBody: Body + HttpBody + Send + 'static,
T::Error: Into<StdError>,
<T::ResponseBody as HttpBody>::Error: Into<StdError> + Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_interceptor(inner: T, interceptor: impl Into<tonic::Interceptor>) -> Self {
let inner = tonic::client::Grpc::with_interceptor(inner, interceptor);
Self { inner }
}
#[doc = " Looks up entities by key."]
pub async fn lookup(
&mut self,
request: impl tonic::IntoRequest<super::LookupRequest>,
) -> Result<tonic::Response<super::LookupResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path =
http::uri::PathAndQuery::from_static("/google.datastore.v1.Datastore/Lookup");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Queries for entities."]
pub async fn run_query(
&mut self,
request: impl tonic::IntoRequest<super::RunQueryRequest>,
) -> Result<tonic::Response<super::RunQueryResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path =
http::uri::PathAndQuery::from_static("/google.datastore.v1.Datastore/RunQuery");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Begins a new transaction."]
pub async fn begin_transaction(
&mut self,
request: impl tonic::IntoRequest<super::BeginTransactionRequest>,
) -> Result<tonic::Response<super::BeginTransactionResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/google.datastore.v1.Datastore/BeginTransaction",
);
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Commits a transaction, optionally creating, deleting or modifying some"]
#[doc = " entities."]
pub async fn commit(
&mut self,
request: impl tonic::IntoRequest<super::CommitRequest>,
) -> Result<tonic::Response<super::CommitResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path =
http::uri::PathAndQuery::from_static("/google.datastore.v1.Datastore/Commit");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Rolls back a transaction."]
pub async fn rollback(
&mut self,
request: impl tonic::IntoRequest<super::RollbackRequest>,
) -> Result<tonic::Response<super::RollbackResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path =
http::uri::PathAndQuery::from_static("/google.datastore.v1.Datastore/Rollback");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Allocates IDs for the given keys, which is useful for referencing an entity"]
#[doc = " before it is inserted."]
pub async fn allocate_ids(
&mut self,
request: impl tonic::IntoRequest<super::AllocateIdsRequest>,
) -> Result<tonic::Response<super::AllocateIdsResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path =
http::uri::PathAndQuery::from_static("/google.datastore.v1.Datastore/AllocateIds");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Prevents the supplied keys' IDs from being auto-allocated by Cloud"]
#[doc = " Datastore."]
pub async fn reserve_ids(
&mut self,
request: impl tonic::IntoRequest<super::ReserveIdsRequest>,
) -> Result<tonic::Response<super::ReserveIdsResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path =
http::uri::PathAndQuery::from_static("/google.datastore.v1.Datastore/ReserveIds");
self.inner.unary(request.into_request(), path, codec).await
}
}
impl<T: Clone> Clone for DatastoreClient<T> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
}
}
}
impl<T> std::fmt::Debug for DatastoreClient<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "DatastoreClient {{ ... }}")
}
}
}