Class DeveloperKnowledgeClient
DeveloperKnowledge client wrapper, for convenient use.
Namespace: Google.Developers.DeveloperKnowledge.V1
Assembly: Google.Developers.DeveloperKnowledge.V1.dll
Syntax
public abstract class DeveloperKnowledgeClient
Remarks
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][google.developers.knowledge.v1.DeveloperKnowledge.SearchDocumentChunks] to find relevant page URIs based on a query, and then use [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument] or [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments] to fetch the full content of the top results.
All document content is provided in Markdown format.
Properties
DefaultEndpoint
The default endpoint for the DeveloperKnowledge service, which is a host of "developerknowledge.googleapis.com" and a port of 443.
Declaration
public static string DefaultEndpoint { get; }
Property Value
| Type | Description |
|---|---|
| string |
DefaultScopes
The default DeveloperKnowledge scopes.
Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
Remarks
The default DeveloperKnowledge scopes are:
- https://www.googleapis.com/auth/cloud-platform
GrpcClient
The underlying gRPC DeveloperKnowledge client
Declaration
public virtual DeveloperKnowledge.DeveloperKnowledgeClient GrpcClient { get; }
Property Value
| Type | Description |
|---|---|
| DeveloperKnowledge.DeveloperKnowledgeClient |
ServiceMetadata
The service metadata associated with this client type.
Declaration
public static ServiceMetadata ServiceMetadata { get; }
Property Value
| Type | Description |
|---|---|
| ServiceMetadata |
Methods
BatchGetDocuments(BatchGetDocumentsRequest, CallSettings)
Retrieves multiple documents, each with its full Markdown content.
Declaration
public virtual BatchGetDocumentsResponse BatchGetDocuments(BatchGetDocumentsRequest request, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| BatchGetDocumentsRequest | request | The request object containing all of the parameters for the API call. |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| BatchGetDocumentsResponse | The RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = DeveloperKnowledgeClient.Create();
// Initialize request argument(s)
BatchGetDocumentsRequest request = new BatchGetDocumentsRequest
{
DocumentNames =
{
DocumentName.FromDocument("[DOCUMENT]"),
},
View = DocumentView.Unspecified,
};
// Make the request
BatchGetDocumentsResponse response = developerKnowledgeClient.BatchGetDocuments(request);
BatchGetDocumentsAsync(BatchGetDocumentsRequest, CallSettings)
Retrieves multiple documents, each with its full Markdown content.
Declaration
public virtual Task<BatchGetDocumentsResponse> BatchGetDocumentsAsync(BatchGetDocumentsRequest request, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| BatchGetDocumentsRequest | request | The request object containing all of the parameters for the API call. |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| Task<BatchGetDocumentsResponse> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
BatchGetDocumentsRequest request = new BatchGetDocumentsRequest
{
DocumentNames =
{
DocumentName.FromDocument("[DOCUMENT]"),
},
View = DocumentView.Unspecified,
};
// Make the request
BatchGetDocumentsResponse response = await developerKnowledgeClient.BatchGetDocumentsAsync(request);
BatchGetDocumentsAsync(BatchGetDocumentsRequest, CancellationToken)
Retrieves multiple documents, each with its full Markdown content.
Declaration
public virtual Task<BatchGetDocumentsResponse> BatchGetDocumentsAsync(BatchGetDocumentsRequest request, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| BatchGetDocumentsRequest | request | The request object containing all of the parameters for the API call. |
| CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
| Type | Description |
|---|---|
| Task<BatchGetDocumentsResponse> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
BatchGetDocumentsRequest request = new BatchGetDocumentsRequest
{
DocumentNames =
{
DocumentName.FromDocument("[DOCUMENT]"),
},
View = DocumentView.Unspecified,
};
// Make the request
BatchGetDocumentsResponse response = await developerKnowledgeClient.BatchGetDocumentsAsync(request);
Create()
Synchronously creates a DeveloperKnowledgeClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use DeveloperKnowledgeClientBuilder .
Declaration
public static DeveloperKnowledgeClient Create()
Returns
| Type | Description |
|---|---|
| DeveloperKnowledgeClient | The created DeveloperKnowledgeClient. |
CreateAsync(CancellationToken)
Asynchronously creates a DeveloperKnowledgeClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use DeveloperKnowledgeClientBuilder .
Declaration
public static Task<DeveloperKnowledgeClient> CreateAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | The CancellationToken to use while creating the client. |
Returns
| Type | Description |
|---|---|
| Task<DeveloperKnowledgeClient> | The task representing the created DeveloperKnowledgeClient. |
GetDocument(DocumentName, CallSettings)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Document GetDocument(DocumentName name, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentName | name | Required. Specifies the name of the document to retrieve.
Format: |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| Document | The RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = DeveloperKnowledgeClient.Create();
// Initialize request argument(s)
DocumentName name = DocumentName.FromDocument("[DOCUMENT]");
// Make the request
Document response = developerKnowledgeClient.GetDocument(name);
GetDocument(GetDocumentRequest, CallSettings)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Document GetDocument(GetDocumentRequest request, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| GetDocumentRequest | request | The request object containing all of the parameters for the API call. |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| Document | The RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = DeveloperKnowledgeClient.Create();
// Initialize request argument(s)
GetDocumentRequest request = new GetDocumentRequest
{
DocumentName = DocumentName.FromDocument("[DOCUMENT]"),
View = DocumentView.Unspecified,
};
// Make the request
Document response = developerKnowledgeClient.GetDocument(request);
GetDocument(string, CallSettings)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Document GetDocument(string name, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Required. Specifies the name of the document to retrieve.
Format: |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| Document | The RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = DeveloperKnowledgeClient.Create();
// Initialize request argument(s)
string name = "documents/[DOCUMENT]";
// Make the request
Document response = developerKnowledgeClient.GetDocument(name);
GetDocumentAsync(DocumentName, CallSettings)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Task<Document> GetDocumentAsync(DocumentName name, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentName | name | Required. Specifies the name of the document to retrieve.
Format: |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| Task<Document> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
DocumentName name = DocumentName.FromDocument("[DOCUMENT]");
// Make the request
Document response = await developerKnowledgeClient.GetDocumentAsync(name);
GetDocumentAsync(DocumentName, CancellationToken)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Task<Document> GetDocumentAsync(DocumentName name, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentName | name | Required. Specifies the name of the document to retrieve.
Format: |
| CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
| Type | Description |
|---|---|
| Task<Document> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
DocumentName name = DocumentName.FromDocument("[DOCUMENT]");
// Make the request
Document response = await developerKnowledgeClient.GetDocumentAsync(name);
GetDocumentAsync(GetDocumentRequest, CallSettings)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Task<Document> GetDocumentAsync(GetDocumentRequest request, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| GetDocumentRequest | request | The request object containing all of the parameters for the API call. |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| Task<Document> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
GetDocumentRequest request = new GetDocumentRequest
{
DocumentName = DocumentName.FromDocument("[DOCUMENT]"),
View = DocumentView.Unspecified,
};
// Make the request
Document response = await developerKnowledgeClient.GetDocumentAsync(request);
GetDocumentAsync(GetDocumentRequest, CancellationToken)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Task<Document> GetDocumentAsync(GetDocumentRequest request, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| GetDocumentRequest | request | The request object containing all of the parameters for the API call. |
| CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
| Type | Description |
|---|---|
| Task<Document> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
GetDocumentRequest request = new GetDocumentRequest
{
DocumentName = DocumentName.FromDocument("[DOCUMENT]"),
View = DocumentView.Unspecified,
};
// Make the request
Document response = await developerKnowledgeClient.GetDocumentAsync(request);
GetDocumentAsync(string, CallSettings)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Task<Document> GetDocumentAsync(string name, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Required. Specifies the name of the document to retrieve.
Format: |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| Task<Document> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
string name = "documents/[DOCUMENT]";
// Make the request
Document response = await developerKnowledgeClient.GetDocumentAsync(name);
GetDocumentAsync(string, CancellationToken)
Retrieves a single document with its full Markdown content.
Declaration
public virtual Task<Document> GetDocumentAsync(string name, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Required. Specifies the name of the document to retrieve.
Format: |
| CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
| Type | Description |
|---|---|
| Task<Document> | A Task containing the RPC response. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
string name = "documents/[DOCUMENT]";
// Make the request
Document response = await developerKnowledgeClient.GetDocumentAsync(name);
SearchDocumentChunks(SearchDocumentChunksRequest, CallSettings)
Searches for developer knowledge across Google's developer documentation. Returns [DocumentChunk][google.developers.knowledge.v1.DocumentChunk]s based on the user's query. There may be many chunks from the same [Document][google.developers.knowledge.v1.Document]. To retrieve full documents, use [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument] or [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments] with the [DocumentChunk.parent][google.developers.knowledge.v1.DocumentChunk.parent] returned in the [SearchDocumentChunksResponse.results][google.developers.knowledge.v1.SearchDocumentChunksResponse.results].
Declaration
public virtual PagedEnumerable<SearchDocumentChunksResponse, DocumentChunk> SearchDocumentChunks(SearchDocumentChunksRequest request, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchDocumentChunksRequest | request | The request object containing all of the parameters for the API call. |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| PagedEnumerable<SearchDocumentChunksResponse, DocumentChunk> | A pageable sequence of DocumentChunk resources. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = DeveloperKnowledgeClient.Create();
// Initialize request argument(s)
SearchDocumentChunksRequest request = new SearchDocumentChunksRequest
{
Query = "",
Filter = "",
};
// Make the request
PagedEnumerable<SearchDocumentChunksResponse, DocumentChunk> response = developerKnowledgeClient.SearchDocumentChunks(request);
// Iterate over all response items, lazily performing RPCs as required
foreach (DocumentChunk item in response)
{
// Do something with each item
Console.WriteLine(item);
}
// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (SearchDocumentChunksResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (DocumentChunk item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}
// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DocumentChunk> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DocumentChunk item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
SearchDocumentChunksAsync(SearchDocumentChunksRequest, CallSettings)
Searches for developer knowledge across Google's developer documentation. Returns [DocumentChunk][google.developers.knowledge.v1.DocumentChunk]s based on the user's query. There may be many chunks from the same [Document][google.developers.knowledge.v1.Document]. To retrieve full documents, use [DeveloperKnowledge.GetDocument][google.developers.knowledge.v1.DeveloperKnowledge.GetDocument] or [DeveloperKnowledge.BatchGetDocuments][google.developers.knowledge.v1.DeveloperKnowledge.BatchGetDocuments] with the [DocumentChunk.parent][google.developers.knowledge.v1.DocumentChunk.parent] returned in the [SearchDocumentChunksResponse.results][google.developers.knowledge.v1.SearchDocumentChunksResponse.results].
Declaration
public virtual PagedAsyncEnumerable<SearchDocumentChunksResponse, DocumentChunk> SearchDocumentChunksAsync(SearchDocumentChunksRequest request, CallSettings callSettings = null)
Parameters
| Type | Name | Description |
|---|---|---|
| SearchDocumentChunksRequest | request | The request object containing all of the parameters for the API call. |
| CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
| Type | Description |
|---|---|
| PagedAsyncEnumerable<SearchDocumentChunksResponse, DocumentChunk> | A pageable asynchronous sequence of DocumentChunk resources. |
Sample code
// Create client
DeveloperKnowledgeClient developerKnowledgeClient = await DeveloperKnowledgeClient.CreateAsync();
// Initialize request argument(s)
SearchDocumentChunksRequest request = new SearchDocumentChunksRequest
{
Query = "",
Filter = "",
};
// Make the request
PagedAsyncEnumerable<SearchDocumentChunksResponse, DocumentChunk> response = developerKnowledgeClient.SearchDocumentChunksAsync(request);
// Iterate over all response items, lazily performing RPCs as required
await foreach (DocumentChunk item in response)
{
// Do something with each item
Console.WriteLine(item);
}
// Or iterate over pages (of server-defined size), performing one RPC per page
await foreach (SearchDocumentChunksResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (DocumentChunk item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}
// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<DocumentChunk> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (DocumentChunk item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
ShutdownDefaultChannelsAsync()
Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.
Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
| Type | Description |
|---|---|
| Task | A task representing the asynchronous shutdown operation. |
Remarks
After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.