pub struct DeveloperKnowledge { /* private fields */ }Expand description
Implements a client for the Developer Knowledge API.
§Example
async fn sample(
document_id: &str,
) -> anyhow::Result<()> {
let client = DeveloperKnowledge::builder().build().await?;
let response = client.get_document()
.set_name(format!("documents/{document_id}"))
.send().await?;
println!("response {:?}", response);
Ok(())
}§Service Description
The Developer Knowledge API provides programmatic access to Google’s public developer documentation, enabling you to integrate this knowledge base into your own applications and workflows.
The API is designed to be the canonical source for machine-readable access to Google’s developer documentation.
A typical use case is to first use DeveloperKnowledge.SearchDocumentChunks to find relevant page URIs based on a query, and then use DeveloperKnowledge.GetDocument or DeveloperKnowledge.BatchGetDocuments to fetch the full content of the top results.
All document content is provided in Markdown format.
§Configuration
To configure DeveloperKnowledge use the with_* methods in the type returned
by builder(). The default configuration should
work for most applications. Common configuration changes include
- with_endpoint(): by default this client uses the global default endpoint
(
https://developerknowledge.googleapis.com). Applications using regional endpoints or running in restricted networks (e.g. a network configured with Private Google Access with VPC Service Controls) may want to override this default. - with_credentials(): by default this client uses Application Default Credentials. Applications using custom authentication may need to override this default.
§Pooling and Cloning
DeveloperKnowledge holds a connection pool internally, it is advised to
create one and reuse it. You do not need to wrap DeveloperKnowledge in
an Rc or Arc to reuse it, because it
already uses an Arc internally.
Implementations§
Source§impl DeveloperKnowledge
impl DeveloperKnowledge
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a builder for DeveloperKnowledge.
let client = DeveloperKnowledge::builder().build().await?;Sourcepub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: DeveloperKnowledge + 'static,
pub fn from_stub<T>(stub: impl Into<Arc<T>>) -> Selfwhere
T: DeveloperKnowledge + 'static,
Creates a new client from the provided stub.
The most common case for calling this function is in tests mocking the client’s behavior.
Sourcepub fn search_document_chunks(&self) -> SearchDocumentChunks
pub fn search_document_chunks(&self) -> SearchDocumentChunks
Searches for developer knowledge across Google’s developer documentation. Returns DocumentChunks based on the user’s query. There may be many chunks from the same Document. To retrieve full documents, use DeveloperKnowledge.GetDocument or DeveloperKnowledge.BatchGetDocuments with the DocumentChunk.parent returned in the SearchDocumentChunksResponse.results.
§Example
use google_cloud_gax::paginator::ItemPaginator as _;
use google_developers_knowledge_v1::Result;
async fn sample(
client: &DeveloperKnowledge
) -> Result<()> {
let mut list = client.search_document_chunks()
/* set fields */
.by_item();
while let Some(item) = list.next().await.transpose()? {
println!("{:?}", item);
}
Ok(())
}Sourcepub fn get_document(&self) -> GetDocument
pub fn get_document(&self) -> GetDocument
Retrieves a single document with its full Markdown content.
§Example
use google_developers_knowledge_v1::Result;
async fn sample(
client: &DeveloperKnowledge, document_id: &str
) -> Result<()> {
let response = client.get_document()
.set_name(format!("documents/{document_id}"))
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn batch_get_documents(&self) -> BatchGetDocuments
pub fn batch_get_documents(&self) -> BatchGetDocuments
Retrieves multiple documents, each with its full Markdown content.
§Example
use google_developers_knowledge_v1::Result;
async fn sample(
client: &DeveloperKnowledge
) -> Result<()> {
let response = client.batch_get_documents()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Sourcepub fn answer_query(&self) -> AnswerQuery
pub fn answer_query(&self) -> AnswerQuery
Answers a query using grounded generation.
§Example
use google_developers_knowledge_v1::Result;
async fn sample(
client: &DeveloperKnowledge
) -> Result<()> {
let response = client.answer_query()
/* set fields */
.send().await?;
println!("response {:?}", response);
Ok(())
}Trait Implementations§
Source§impl Clone for DeveloperKnowledge
impl Clone for DeveloperKnowledge
Source§fn clone(&self) -> DeveloperKnowledge
fn clone(&self) -> DeveloperKnowledge
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more