// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/docs.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const docs = google.docs('v1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/documents',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await docs.documents.create({
// Request body metadata
requestBody: {
// request body parameters
// {
// "body": {},
// "documentId": "my_documentId",
// "documentStyle": {},
// "footers": {},
// "footnotes": {},
// "headers": {},
// "inlineObjects": {},
// "lists": {},
// "namedRanges": {},
// "namedStyles": {},
// "positionedObjects": {},
// "revisionId": "my_revisionId",
// "suggestedDocumentStyleChanges": {},
// "suggestedNamedStylesChanges": {},
// "suggestionsViewMode": "my_suggestionsViewMode",
// "title": "my_title"
// }
},
});
console.log(res.data);
// Example response
// {
// "body": {},
// "documentId": "my_documentId",
// "documentStyle": {},
// "footers": {},
// "footnotes": {},
// "headers": {},
// "inlineObjects": {},
// "lists": {},
// "namedRanges": {},
// "namedStyles": {},
// "positionedObjects": {},
// "revisionId": "my_revisionId",
// "suggestedDocumentStyleChanges": {},
// "suggestedNamedStylesChanges": {},
// "suggestionsViewMode": "my_suggestionsViewMode",
// "title": "my_title"
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/dialogflow.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const dialogflow = google.dialogflow('v2beta1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/dialogflow',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await dialogflow.projects.agent.knowledgeBases.documents.create({
// Whether to import custom metadata from Google Cloud Storage. Only valid when the document source is Google Cloud Storage URI.
importGcsCustomMetadata: 'placeholder-value',
// Required. The knowledge base to create a document for. Format: `projects//locations//knowledgeBases/`.
parent: 'projects/my-project/agent/knowledgeBases/my-knowledgeBase',
// Request body metadata
requestBody: {
// request body parameters
// {
// "content": "my_content",
// "contentUri": "my_contentUri",
// "displayName": "my_displayName",
// "enableAutoReload": false,
// "knowledgeTypes": [],
// "latestReloadStatus": {},
// "metadata": {},
// "mimeType": "my_mimeType",
// "name": "my_name",
// "rawContent": "my_rawContent"
// }
},
});
console.log(res.data);
// Example response
// {
// "done": false,
// "error": {},
// "metadata": {},
// "name": "my_name",
// "response": {}
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/dialogflow.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const dialogflow = google.dialogflow('v2beta1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/dialogflow',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res =
await dialogflow.projects.locations.knowledgeBases.documents.create({
// Whether to import custom metadata from Google Cloud Storage. Only valid when the document source is Google Cloud Storage URI.
importGcsCustomMetadata: 'placeholder-value',
// Required. The knowledge base to create a document for. Format: `projects//locations//knowledgeBases/`.
parent:
'projects/my-project/locations/my-location/knowledgeBases/my-knowledgeBase',
// Request body metadata
requestBody: {
// request body parameters
// {
// "content": "my_content",
// "contentUri": "my_contentUri",
// "displayName": "my_displayName",
// "enableAutoReload": false,
// "knowledgeTypes": [],
// "latestReloadStatus": {},
// "metadata": {},
// "mimeType": "my_mimeType",
// "name": "my_name",
// "rawContent": "my_rawContent"
// }
},
});
console.log(res.data);
// Example response
// {
// "done": false,
// "error": {},
// "metadata": {},
// "name": "my_name",
// "response": {}
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/firestore.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const firestore = google.firestore('v1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/datastore',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await firestore.projects.databases.documents.get({
// The list of field paths in the mask. See Document.fields for a field path syntax reference.
'mask.fieldPaths': 'placeholder-value',
// Required. The resource name of the Document to get. In the format: `projects/{project_id\}/databases/{database_id\}/documents/{document_path\}`.
name: 'projects/my-project/databases/my-database/documents/my-document/.*',
// Reads the version of the document at the given time. This may not be older than 270 seconds.
readTime: 'placeholder-value',
// Reads the document in a transaction.
transaction: 'placeholder-value',
});
console.log(res.data);
// Example response
// {
// "createTime": "my_createTime",
// "fields": {},
// "name": "my_name",
// "updateTime": "my_updateTime"
// }
}
main().catch(e => {
console.error(e);
throw e;
});
// Before running the sample:
// - Enable the API at:
// https://console.developers.google.com/apis/api/dialogflow.googleapis.com
// - Login into gcloud by running:
// `$ gcloud auth application-default login`
// - Install the npm module by running:
// `$ npm install googleapis`
const {google} = require('googleapis');
const dialogflow = google.dialogflow('v2beta1');
async function main() {
const auth = new google.auth.GoogleAuth({
// Scopes can be specified either as an array or as a single, space-delimited string.
scopes: [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/dialogflow',
],
});
// Acquire an auth client, and bind it to all future calls
const authClient = await auth.getClient();
google.options({auth: authClient});
// Do the magic
const res = await dialogflow.projects.knowledgeBases.documents.create({
// Whether to import custom metadata from Google Cloud Storage. Only valid when the document source is Google Cloud Storage URI.
importGcsCustomMetadata: 'placeholder-value',
// Required. The knowledge base to create a document for. Format: `projects//locations//knowledgeBases/`.
parent: 'projects/my-project/knowledgeBases/my-knowledgeBase',
// Request body metadata
requestBody: {
// request body parameters
// {
// "content": "my_content",
// "contentUri": "my_contentUri",
// "displayName": "my_displayName",
// "enableAutoReload": false,
// "knowledgeTypes": [],
// "latestReloadStatus": {},
// "metadata": {},
// "mimeType": "my_mimeType",
// "name": "my_name",
// "rawContent": "my_rawContent"
// }
},
});
console.log(res.data);
// Example response
// {
// "done": false,
// "error": {},
// "metadata": {},
// "name": "my_name",
// "response": {}
// }
}
main().catch(e => {
console.error(e);
throw e;
});