Reference documentation and code samples for the Developer Knowledge V1 API class Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client.
Client for the DeveloperKnowledge service.
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.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::ConfigurationConfigure the DeveloperKnowledge Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all DeveloperKnowledge clients ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client.configure do |config| config.timeout = 10.0 end
#batch_get_documents
def batch_get_documents(request, options = nil) -> ::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponse
def batch_get_documents(names: nil, view: nil) -> ::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponseRetrieves multiple documents, each with its full Markdown content.
def batch_get_documents(request, options = nil) -> ::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponsebatch_get_documents via a request object, either of type
BatchGetDocumentsRequest or an equivalent Hash.
- request (::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def batch_get_documents(names: nil, view: nil) -> ::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponsebatch_get_documents via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
names (::Array<::String>) — Required. Specifies the names of the documents to retrieve. A maximum of 20
documents can be retrieved in a batch. The documents are returned in the
same order as the
namesin the request.Format:
documents/{uri_without_scheme}Example:documents/docs.cloud.google.com/storage/docs/creating-buckets -
view (::Google::Developers::DeveloperKnowledge::V1::DocumentView) — Optional. Specifies the
DocumentView of the
document. If unspecified,
DeveloperKnowledge.BatchGetDocuments
defaults to
DOCUMENT_VIEW_CONTENT.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/developers/developer_knowledge/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsRequest.new # Call the batch_get_documents method. result = client.batch_get_documents request # The returned object is of type Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponse. p result
#configure
def configure() { |config| ... } -> Client::ConfigurationConfigure the DeveloperKnowledge Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#get_document
def get_document(request, options = nil) -> ::Google::Developers::DeveloperKnowledge::V1::Document
def get_document(name: nil, view: nil) -> ::Google::Developers::DeveloperKnowledge::V1::DocumentRetrieves a single document with its full Markdown content.
def get_document(request, options = nil) -> ::Google::Developers::DeveloperKnowledge::V1::Documentget_document via a request object, either of type
GetDocumentRequest or an equivalent Hash.
- request (::Google::Developers::DeveloperKnowledge::V1::GetDocumentRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_document(name: nil, view: nil) -> ::Google::Developers::DeveloperKnowledge::V1::Documentget_document via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. Specifies the name of the document to retrieve.
Format:
documents/{uri_without_scheme}Example:documents/docs.cloud.google.com/storage/docs/creating-buckets -
view (::Google::Developers::DeveloperKnowledge::V1::DocumentView) — Optional. Specifies the
DocumentView of the
document. If unspecified,
DeveloperKnowledge.GetDocument
defaults to
DOCUMENT_VIEW_CONTENT.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Developers::DeveloperKnowledge::V1::Document)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/developers/developer_knowledge/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Developers::DeveloperKnowledge::V1::GetDocumentRequest.new # Call the get_document method. result = client.get_document request # The returned object is of type Google::Developers::DeveloperKnowledge::V1::Document. p result
#initialize
def initialize() { |config| ... } -> ClientCreate a new DeveloperKnowledge client object.
- (config) — Configure the DeveloperKnowledge client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client.new # Create a client using a custom configuration client = ::Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client.new do |config| config.timeout = 10.0 end
#logger
def logger() -> LoggerThe logger used for request/response debug logging.
- (Logger)
#search_document_chunks
def search_document_chunks(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>
def search_document_chunks(query: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>Searches for developer knowledge across Google's developer documentation. Returns {::Google::Developers::DeveloperKnowledge::V1::DocumentChunk DocumentChunk}s 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.
def search_document_chunks(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>search_document_chunks via a request object, either of type
SearchDocumentChunksRequest or an equivalent Hash.
- request (::Google::Developers::DeveloperKnowledge::V1::SearchDocumentChunksRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def search_document_chunks(query: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>search_document_chunks via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- query (::String) — Required. Provides the raw query string provided by the user, such as "How to create a Cloud Storage bucket?".
-
page_size (::Integer) — Optional. Specifies the maximum number of results to return. The service
may return fewer than this value.
If unspecified, at most 5 results will be returned.
The maximum value is 20; values above 20 will result in an INVALID_ARGUMENT error.
-
page_token (::String) — Optional. Contains a page token, received from a previous
SearchDocumentChunkscall. Provide this to retrieve the subsequent page. -
filter (::String) — Optional. Applies a strict filter to the search results. The expression
supports a subset of the syntax described at https://google.aip.dev/160.
While
SearchDocumentChunksreturns DocumentChunks, the filter is applied toDocumentChunk.documentfields.Supported fields for filtering:
data_source(STRING): The source of the document, e.g.docs.cloud.google.com. See https://developers.google.com/knowledge/reference/corpus-reference for the complete list of data sources in the corpus.update_time(TIMESTAMP): The timestamp of when the document was last meaningfully updated. A meaningful update is one that changes document's markdown content or metadata.uri(STRING): The document URI, e.g.https://docs.cloud.google.com/bigquery/docs/tables.
STRING fields support
=(equals) and!=(not equals) operators for exact match on the whole string. Partial match, prefix match, and regexp match are not supported.TIMESTAMP fields support
=,<,<=,>, and>=operators. Timestamps must be in RFC-3339 format, e.g.,"2025-01-01T00:00:00Z".You can combine expressions using
AND,OR, andNOT(or-) logical operators.ORhas higher precedence thanAND. Use parentheses for explicit precedence grouping.Examples:
data_source = "docs.cloud.google.com" OR data_source = "firebase.google.com"data_source != "firebase.google.com"update_time < "2024-01-01T00:00:00Z"update_time >= "2025-01-22T00:00:00Z" AND (data_source = "developer.chrome.com" OR data_source = "web.dev")uri = "https://docs.cloud.google.com/release-notes"
The
filterstring must not exceed 500 characters; values longer than 500 characters will result in anINVALID_ARGUMENTerror.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/developers/developer_knowledge/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Developers::DeveloperKnowledge::V1::SearchDocumentChunksRequest.new # Call the search_document_chunks method. result = client.search_document_chunks request # The returned object is of type Gapic::PagedEnumerable. You can iterate # over elements, and API calls will be issued to fetch pages as needed. result.each do |item| # Each element is of type ::Google::Developers::DeveloperKnowledge::V1::DocumentChunk. p item end
#universe_domain
def universe_domain() -> StringThe effective universe domain
- (String)