#![allow(rustdoc::bare_urls)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::invalid_html_tags)]
#![allow(rustdoc::redundant_explicit_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gaxi;
extern crate google_cloud_gax;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;
mod debug;
mod deserialize;
mod serialize;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Document {
pub name: std::string::String,
pub uri: std::string::String,
pub content: std::string::String,
pub description: std::string::String,
pub data_source: std::string::String,
pub title: std::string::String,
pub update_time: std::option::Option<wkt::Timestamp>,
pub view: crate::model::DocumentView,
pub content_length_bytes: i32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Document {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.uri = v.into();
self
}
pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.content = v.into();
self
}
pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.description = v.into();
self
}
pub fn set_data_source<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.data_source = v.into();
self
}
pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.title = v.into();
self
}
pub fn set_update_time<T>(mut self, v: T) -> Self
where
T: std::convert::Into<wkt::Timestamp>,
{
self.update_time = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<wkt::Timestamp>,
{
self.update_time = v.map(|x| x.into());
self
}
pub fn set_view<T: std::convert::Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
self.view = v.into();
self
}
pub fn set_content_length_bytes<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.content_length_bytes = v.into();
self
}
}
impl wkt::message::Message for Document {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.Document"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SearchDocumentChunksRequest {
pub query: std::string::String,
pub page_size: i32,
pub page_token: std::string::String,
pub filter: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl SearchDocumentChunksRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.query = v.into();
self
}
pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.page_size = v.into();
self
}
pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.page_token = v.into();
self
}
pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.filter = v.into();
self
}
}
impl wkt::message::Message for SearchDocumentChunksRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.SearchDocumentChunksRequest"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SearchDocumentChunksResponse {
pub results: std::vec::Vec<crate::model::DocumentChunk>,
pub next_page_token: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl SearchDocumentChunksResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_results<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::DocumentChunk>,
{
use std::iter::Iterator;
self.results = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.next_page_token = v.into();
self
}
}
impl wkt::message::Message for SearchDocumentChunksResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.SearchDocumentChunksResponse"
}
}
#[doc(hidden)]
impl google_cloud_gax::paginator::internal::PageableResponse for SearchDocumentChunksResponse {
type PageItem = crate::model::DocumentChunk;
fn items(self) -> std::vec::Vec<Self::PageItem> {
self.results
}
fn next_page_token(&self) -> std::string::String {
use std::clone::Clone;
self.next_page_token.clone()
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetDocumentRequest {
pub name: std::string::String,
pub view: crate::model::DocumentView,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl GetDocumentRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.name = v.into();
self
}
pub fn set_view<T: std::convert::Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
self.view = v.into();
self
}
}
impl wkt::message::Message for GetDocumentRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.GetDocumentRequest"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BatchGetDocumentsRequest {
pub names: std::vec::Vec<std::string::String>,
pub view: crate::model::DocumentView,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl BatchGetDocumentsRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_names<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<std::string::String>,
{
use std::iter::Iterator;
self.names = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_view<T: std::convert::Into<crate::model::DocumentView>>(mut self, v: T) -> Self {
self.view = v.into();
self
}
}
impl wkt::message::Message for BatchGetDocumentsRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.BatchGetDocumentsRequest"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BatchGetDocumentsResponse {
pub documents: std::vec::Vec<crate::model::Document>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl BatchGetDocumentsResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_documents<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::Document>,
{
use std::iter::Iterator;
self.documents = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for BatchGetDocumentsResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.BatchGetDocumentsResponse"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnswerQueryRequest {
pub query: std::string::String,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnswerQueryRequest {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_query<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.query = v.into();
self
}
}
impl wkt::message::Message for AnswerQueryRequest {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.AnswerQueryRequest"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnswerQueryResponse {
pub answer: std::option::Option<crate::model::Answer>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnswerQueryResponse {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_answer<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Answer>,
{
self.answer = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_answer<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Answer>,
{
self.answer = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for AnswerQueryResponse {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.AnswerQueryResponse"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Answer {
pub answer_text: std::string::String,
pub citations: std::vec::Vec<crate::model::answer::AnswerCitation>,
pub references: std::vec::Vec<crate::model::answer::AnswerReference>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl Answer {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_answer_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.answer_text = v.into();
self
}
pub fn set_citations<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::answer::AnswerCitation>,
{
use std::iter::Iterator;
self.citations = v.into_iter().map(|i| i.into()).collect();
self
}
pub fn set_references<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::answer::AnswerReference>,
{
use std::iter::Iterator;
self.references = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for Answer {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.Answer"
}
}
pub mod answer {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnswerCitation {
pub start_index: i32,
pub end_index: i32,
pub sources: std::vec::Vec<crate::model::answer::CitationSource>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnswerCitation {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_start_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.start_index = v.into();
self
}
pub fn set_end_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.end_index = v.into();
self
}
pub fn set_sources<T, V>(mut self, v: T) -> Self
where
T: std::iter::IntoIterator<Item = V>,
V: std::convert::Into<crate::model::answer::CitationSource>,
{
use std::iter::Iterator;
self.sources = v.into_iter().map(|i| i.into()).collect();
self
}
}
impl wkt::message::Message for AnswerCitation {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.Answer.AnswerCitation"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CitationSource {
pub reference_index: i32,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl CitationSource {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_reference_index<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
self.reference_index = v.into();
self
}
}
impl wkt::message::Message for CitationSource {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.Answer.CitationSource"
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AnswerReference {
pub content: std::option::Option<crate::model::answer::answer_reference::Content>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl AnswerReference {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_content<
T: std::convert::Into<
std::option::Option<crate::model::answer::answer_reference::Content>,
>,
>(
mut self,
v: T,
) -> Self {
self.content = v.into();
self
}
pub fn document_reference(
&self,
) -> std::option::Option<&std::boxed::Box<crate::model::answer::DocumentReference>>
{
#[allow(unreachable_patterns)]
self.content.as_ref().and_then(|v| match v {
crate::model::answer::answer_reference::Content::DocumentReference(v) => {
std::option::Option::Some(v)
}
_ => std::option::Option::None,
})
}
pub fn set_document_reference<
T: std::convert::Into<std::boxed::Box<crate::model::answer::DocumentReference>>,
>(
mut self,
v: T,
) -> Self {
self.content = std::option::Option::Some(
crate::model::answer::answer_reference::Content::DocumentReference(v.into()),
);
self
}
}
impl wkt::message::Message for AnswerReference {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.Answer.AnswerReference"
}
}
pub mod answer_reference {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Content {
DocumentReference(std::boxed::Box<crate::model::answer::DocumentReference>),
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DocumentReference {
pub document_chunk: std::option::Option<crate::model::DocumentChunk>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl DocumentReference {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_document_chunk<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::DocumentChunk>,
{
self.document_chunk = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document_chunk<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::DocumentChunk>,
{
self.document_chunk = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for DocumentReference {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.Answer.DocumentReference"
}
}
}
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DocumentChunk {
pub parent: std::string::String,
pub id: std::string::String,
pub content: std::string::String,
pub document: std::option::Option<crate::model::Document>,
pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}
impl DocumentChunk {
pub fn new() -> Self {
std::default::Default::default()
}
pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.parent = v.into();
self
}
pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.id = v.into();
self
}
pub fn set_content<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
self.content = v.into();
self
}
pub fn set_document<T>(mut self, v: T) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = std::option::Option::Some(v.into());
self
}
pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
where
T: std::convert::Into<crate::model::Document>,
{
self.document = v.map(|x| x.into());
self
}
}
impl wkt::message::Message for DocumentChunk {
fn typename() -> &'static str {
"type.googleapis.com/google.developers.knowledge.v1.DocumentChunk"
}
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum DocumentView {
Unspecified,
Basic,
Full,
Content,
UnknownValue(document_view::UnknownValue),
}
#[doc(hidden)]
pub mod document_view {
#[allow(unused_imports)]
use super::*;
#[derive(Clone, Debug, PartialEq)]
pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}
impl DocumentView {
pub fn value(&self) -> std::option::Option<i32> {
match self {
Self::Unspecified => std::option::Option::Some(0),
Self::Basic => std::option::Option::Some(1),
Self::Full => std::option::Option::Some(2),
Self::Content => std::option::Option::Some(3),
Self::UnknownValue(u) => u.0.value(),
}
}
pub fn name(&self) -> std::option::Option<&str> {
match self {
Self::Unspecified => std::option::Option::Some("DOCUMENT_VIEW_UNSPECIFIED"),
Self::Basic => std::option::Option::Some("DOCUMENT_VIEW_BASIC"),
Self::Full => std::option::Option::Some("DOCUMENT_VIEW_FULL"),
Self::Content => std::option::Option::Some("DOCUMENT_VIEW_CONTENT"),
Self::UnknownValue(u) => u.0.name(),
}
}
}
impl std::default::Default for DocumentView {
fn default() -> Self {
use std::convert::From;
Self::from(0)
}
}
impl std::fmt::Display for DocumentView {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
wkt::internal::display_enum(f, self.name(), self.value())
}
}
impl std::convert::From<i32> for DocumentView {
fn from(value: i32) -> Self {
match value {
0 => Self::Unspecified,
1 => Self::Basic,
2 => Self::Full,
3 => Self::Content,
_ => Self::UnknownValue(document_view::UnknownValue(
wkt::internal::UnknownEnumValue::Integer(value),
)),
}
}
}
impl std::convert::From<&str> for DocumentView {
fn from(value: &str) -> Self {
use std::string::ToString;
match value {
"DOCUMENT_VIEW_UNSPECIFIED" => Self::Unspecified,
"DOCUMENT_VIEW_BASIC" => Self::Basic,
"DOCUMENT_VIEW_FULL" => Self::Full,
"DOCUMENT_VIEW_CONTENT" => Self::Content,
_ => Self::UnknownValue(document_view::UnknownValue(
wkt::internal::UnknownEnumValue::String(value.to_string()),
)),
}
}
}
impl serde::ser::Serialize for DocumentView {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Unspecified => serializer.serialize_i32(0),
Self::Basic => serializer.serialize_i32(1),
Self::Full => serializer.serialize_i32(2),
Self::Content => serializer.serialize_i32(3),
Self::UnknownValue(u) => u.0.serialize(serializer),
}
}
}
impl<'de> serde::de::Deserialize<'de> for DocumentView {
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
deserializer.deserialize_any(wkt::internal::EnumVisitor::<DocumentView>::new(
".google.developers.knowledge.v1.DocumentView",
))
}
}