Developer Knowledge V1 API - Class Google::Developers::DeveloperKnowledge::V1::DeveloperKnowledge::Client (v0.2.0)

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::Configuration

Configure the DeveloperKnowledge Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# 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::BatchGetDocumentsResponse

Retrieves multiple documents, each with its full Markdown content.

Overloads
def batch_get_documents(request, options = nil) -> ::Google::Developers::DeveloperKnowledge::V1::BatchGetDocumentsResponse
Pass arguments to batch_get_documents via a request object, either of type BatchGetDocumentsRequest or an equivalent Hash.
Parameters
  • 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::BatchGetDocumentsResponse
Pass arguments to batch_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).
Parameters
  • 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 names in 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.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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::Configuration

Configure 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.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#get_document

def get_document(request, options = nil) -> ::Google::Developers::DeveloperKnowledge::V1::Document
def get_document(name: nil, view: nil) -> ::Google::Developers::DeveloperKnowledge::V1::Document

Retrieves a single document with its full Markdown content.

Overloads
def get_document(request, options = nil) -> ::Google::Developers::DeveloperKnowledge::V1::Document
Pass arguments to get_document via a request object, either of type GetDocumentRequest or an equivalent Hash.
Parameters
  • 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::Document
Pass arguments to get_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).
Parameters
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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| ... } -> Client

Create a new DeveloperKnowledge client object.

Yields
  • (config) — Configure the DeveloperKnowledge client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# 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() -> Logger

The logger used for request/response debug logging.

Returns
  • (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.

Overloads
def search_document_chunks(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Developers::DeveloperKnowledge::V1::DocumentChunk>
Pass arguments to search_document_chunks via a request object, either of type SearchDocumentChunksRequest or an equivalent Hash.
Parameters
  • 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>
Pass arguments to 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).
Parameters
  • 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 SearchDocumentChunks call. 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 SearchDocumentChunks returns DocumentChunks, the filter is applied to DocumentChunk.document fields.

    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, and NOT (or -) logical operators. OR has higher precedence than AND. 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 filter string must not exceed 500 characters; values longer than 500 characters will result in an INVALID_ARGUMENT error.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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() -> String

The effective universe domain

Returns
  • (String)