DocumentsClient

DocumentsClient

Manages documents of a knowledge base.

Constructor

new DocumentsClient(optionsopt)

Construct an instance of DocumentsClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

(static) port

The port for this API service.

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

(static) servicePath

The DNS address for this API service.

Methods

close()

Terminate the GRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

createDocument(request, optionsopt) → {Promise}

Creates a new document.

Note: The projects.agent.knowledgeBases.documents resource is deprecated; only use projects.knowledgeBases.documents.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The knoweldge base to create a document for. Format: projects/<Project ID>/knowledgeBases/<Knowledge Base ID>.

document google.cloud.dialogflow.v2beta1.Document

Required. The document to create.

options object <optional>

Call options. See CallOptions for more details.

deleteDocument(request, optionsopt) → {Promise}

Deletes the specified document.

Note: The projects.agent.knowledgeBases.documents resource is deprecated; only use projects.knowledgeBases.documents.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the document to delete. Format: projects/<Project ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>.

options object <optional>

Call options. See CallOptions for more details.

environmentPath(project, environment) → {string}

Return a fully-qualified environment resource name string.

Parameters:
Name Type Description
project string
environment string

getDocument(request, optionsopt) → {Promise}

Retrieves the specified document.

Note: The projects.agent.knowledgeBases.documents resource is deprecated; only use projects.knowledgeBases.documents.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the document to retrieve. Format projects/<Project ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>.

options object <optional>

Call options. See CallOptions for more details.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

listDocuments(request, optionsopt) → {Promise}

Returns the list of all documents of the knowledge base.

Note: The projects.agent.knowledgeBases.documents resource is deprecated; only use projects.knowledgeBases.documents.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The knowledge base to list all documents for. Format: projects/<Project ID>/knowledgeBases/<Knowledge Base ID>.

pageSize number

Optional. The maximum number of items to return in a single page. By default 10 and at most 100.

pageToken string

Optional. The next_page_token value returned from a previous list request.

options object <optional>

Call options. See CallOptions for more details.

listDocumentsAsync(request, optionsopt) → {Object}

Equivalent to listDocuments, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The knowledge base to list all documents for. Format: projects/<Project ID>/knowledgeBases/<Knowledge Base ID>.

pageSize number

Optional. The maximum number of items to return in a single page. By default 10 and at most 100.

pageToken string

Optional. The next_page_token value returned from a previous list request.

options object <optional>

Call options. See CallOptions for more details.

listDocumentsStream(request, optionsopt) → {Stream}

Equivalent to listDocuments, but returns a NodeJS Stream object.

This fetches the paged responses for listDocuments continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The knowledge base to list all documents for. Format: projects/<Project ID>/knowledgeBases/<Knowledge Base ID>.

pageSize number

Optional. The maximum number of items to return in a single page. By default 10 and at most 100.

pageToken string

Optional. The next_page_token value returned from a previous list request.

options object <optional>

Call options. See CallOptions for more details.

See:

matchEnvironmentFromEnvironmentName(environmentName) → {string}

Parse the environment from Environment resource.

Parameters:
Name Type Description
environmentName string

A fully-qualified path representing Environment resource.

matchIntentFromProjectAgentIntentName(projectAgentIntentName) → {string}

Parse the intent from ProjectAgentIntent resource.

Parameters:
Name Type Description
projectAgentIntentName string

A fully-qualified path representing project_agent_intent resource.

matchIntentFromProjectLocationAgentIntentName(projectLocationAgentIntentName) → {string}

Parse the intent from ProjectLocationAgentIntent resource.

Parameters:
Name Type Description
projectLocationAgentIntentName string

A fully-qualified path representing project_location_agent_intent resource.

matchLocationFromProjectLocationAgentIntentName(projectLocationAgentIntentName) → {string}

Parse the location from ProjectLocationAgentIntent resource.

Parameters:
Name Type Description
projectLocationAgentIntentName string

A fully-qualified path representing project_location_agent_intent resource.

matchLocationFromProjectLocationAgentName(projectLocationAgentName) → {string}

Parse the location from ProjectLocationAgent resource.

Parameters:
Name Type Description
projectLocationAgentName string

A fully-qualified path representing project_location_agent resource.

matchProjectFromEnvironmentName(environmentName) → {string}

Parse the project from Environment resource.

Parameters:
Name Type Description
environmentName string

A fully-qualified path representing Environment resource.

matchProjectFromProjectAgentIntentName(projectAgentIntentName) → {string}

Parse the project from ProjectAgentIntent resource.

Parameters:
Name Type Description
projectAgentIntentName string

A fully-qualified path representing project_agent_intent resource.

matchProjectFromProjectAgentName(projectAgentName) → {string}

Parse the project from ProjectAgent resource.

Parameters:
Name Type Description
projectAgentName string

A fully-qualified path representing project_agent resource.

matchProjectFromProjectLocationAgentIntentName(projectLocationAgentIntentName) → {string}

Parse the project from ProjectLocationAgentIntent resource.

Parameters:
Name Type Description
projectLocationAgentIntentName string

A fully-qualified path representing project_location_agent_intent resource.

matchProjectFromProjectLocationAgentName(projectLocationAgentName) → {string}

Parse the project from ProjectLocationAgent resource.

Parameters:
Name Type Description
projectLocationAgentName string

A fully-qualified path representing project_location_agent resource.

projectAgentIntentPath(project, intent) → {string}

Return a fully-qualified projectAgentIntent resource name string.

Parameters:
Name Type Description
project string
intent string

projectAgentPath(project) → {string}

Return a fully-qualified projectAgent resource name string.

Parameters:
Name Type Description
project string

projectLocationAgentIntentPath(project, location, intent) → {string}

Return a fully-qualified projectLocationAgentIntent resource name string.

Parameters:
Name Type Description
project string
location string
intent string

projectLocationAgentPath(project, location) → {string}

Return a fully-qualified projectLocationAgent resource name string.

Parameters:
Name Type Description
project string
location string

reloadDocument(request, optionsopt) → {Promise}

Reloads the specified document from its specified source, content_uri or content. The previously loaded content of the document will be deleted. Note: Even when the content of the document has not changed, there still may be side effects because of internal implementation changes.

Note: The projects.agent.knowledgeBases.documents resource is deprecated; only use projects.knowledgeBases.documents.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the document to reload. Format: projects/<Project ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>

gcsSource google.cloud.dialogflow.v2beta1.GcsSource

Optional. The path for a Cloud Storage source file for reloading document content. If not provided, the Document's existing source will be reloaded.

options object <optional>

Call options. See CallOptions for more details.

updateDocument(request, optionsopt) → {Promise}

Updates the specified document.

Note: The projects.agent.knowledgeBases.documents resource is deprecated; only use projects.knowledgeBases.documents.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
document google.cloud.dialogflow.v2beta1.Document

Required. The document to update.

updateMask google.protobuf.FieldMask

Optional. Not specified means update all. Currently, only display_name can be updated, an InvalidArgument will be returned for attempting to update other fields.

options object <optional>

Call options. See CallOptions for more details.