#![warn(missing_docs)]
use super::protos::{
Envelope, GetDocumentVersionRequest, CustomCommandRequest, ListCollectionsRequest, DropCollectionRequest, CreateCollectionRequest,
GetIndexesRequest, CreateIndexRequest, DropIndexRequest, EnsureCustomerRequest, InvokeOpenRpaRequest, CreateWorkflowInstanceRequest,
Customer, StripeCustomer
};
impl GetDocumentVersionRequest {
pub fn byid(collectionname: &str, documentid: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
id: documentid.to_string(),
decrypt: true,
version: 0,
}
}
pub fn byversion(collectionname: &str, documentid: &str, version : i32) -> Self {
Self {
collectionname: collectionname.to_string(),
id: documentid.to_string(),
decrypt: true,
version,
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.GetDocumentVersionRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "getdocumentversion".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl CustomCommandRequest {
pub fn bycommand(command: &str) -> Self {
Self {
command: command.to_string(),
data: "".to_string(),
id: "".to_string(),
name: "".to_string(),
}
}
pub fn bydata(command: &str, data: &str) -> Self {
Self {
command: command.to_string(),
data: data.to_string(),
id: "".to_string(),
name: "".to_string(),
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.CustomCommandRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "customcommand".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl ListCollectionsRequest {
pub fn new(includehist: bool) -> Self {
Self {
includehist,
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.ListCollectionsRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "listcollections".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl DropCollectionRequest {
pub fn byname(collectionname: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.DropCollectionRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "dropcollection".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl CreateCollectionRequest {
pub fn byname(collectionname: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
..Default::default()
}
}
pub fn with_ttl(collectionname: &str, ttl: i32) -> Self {
Self {
collectionname: collectionname.to_string(),
expire_after_seconds: ttl,
..Default::default()
}
}
pub fn timeseries(collectionname: &str, timefield: &str, granularity: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
timeseries: Some(
crate::protos::ColTimeseries {
time_field: timefield.to_string(),
granularity: granularity.to_string(),
meta_field: "".to_string(),
},
),
..Default::default()
}
}
pub fn timeseries_with_meta(collectionname: &str, timefield: &str, meta_field: &str, granularity: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
timeseries: Some(
crate::protos::ColTimeseries {
time_field: timefield.to_string(),
granularity: granularity.to_string(),
meta_field: meta_field.to_string(),
},
),
..Default::default()
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.CreateCollectionRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "createcollection".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl GetIndexesRequest {
pub fn bycollectionname(collectionname: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.GetIndexesRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "getindexes".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl CreateIndexRequest {
pub fn bycollectionname(collectionname: &str, index_def: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
index: index_def.to_string(),
options: "".to_string(),
name: "".to_string(),
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.CreateIndexRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "createindex".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl DropIndexRequest {
pub fn bycollectionname(collectionname: &str, indexname: &str) -> Self {
Self {
collectionname: collectionname.to_string(),
name: indexname.to_string(),
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.DropIndexRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "dropindex".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl Customer {
pub fn byname(name: &str) -> Self {
Self {
name: name.to_string(),
..Default::default()
}
}
pub fn byuserid(name: &str, userid: &str) -> Self {
Self {
name: name.to_string(),
userid: userid.to_string(),
..Default::default()
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.Customer".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "customer".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl StripeCustomer {
pub fn byname(name: &str, email: &str) -> Self {
Self {
name: name.to_string(),
email: email.to_string(),
..Default::default()
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.StripeCustomer".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "stripecustomer".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl EnsureCustomerRequest {
pub fn new(customer: Option<Customer>, ensureas: &str, stripe: Option<StripeCustomer>) -> Self {
Self {
customer,
ensureas: ensureas.to_string(),
stripe
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.EnsureCustomerRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "ensurecustomer".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl InvokeOpenRpaRequest {
pub fn new(robotid: &str, workflowid: &str, payload: &str, rpc: bool) -> Self {
Self {
robotid: robotid.to_string(),
workflowid: workflowid.to_string(),
payload: payload.to_string(),
rpc
}
}
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.InvokeOpenRpaRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "invokeopenrpa".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}
impl CreateWorkflowInstanceRequest {
pub fn to_envelope(&self) -> Envelope {
let any_message = prost_types::Any {
type_url: "type.googleapis.com/openiap.CreateWorkflowInstanceRequest".to_string(),
value: {
let mut buf = Vec::new();
prost::Message::encode(self, &mut buf).unwrap_or(());
buf
},
};
Envelope {
command: "createworkflowinstance".into(),
data: Some(any_message.clone()),
..Default::default()
}
}
}