MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

document-warehouse/get-document-schema.js:17–71  ·  view source on GitHub ↗
(
  projectNumber = 'YOUR_PROJECT_NUMBER',
  location = 'YOUR_PROJECT_LOCATION',
  documentSchemaId = 'YOUR_DOCUMENT_SCHEMA_ID'
)

Source from the content-addressed store, hash-verified

15
16'use strict';
17async function main(
18 projectNumber = 'YOUR_PROJECT_NUMBER',
19 location = 'YOUR_PROJECT_LOCATION',
20 documentSchemaId = 'YOUR_DOCUMENT_SCHEMA_ID'
21) {
22 // [START contentwarehouse_get_document_schema]
23
24 /**
25 * TODO(developer): Uncomment these variables before running the sample.
26 * const projectNumber = 'YOUR_PROJECT_NUMBER';
27 * const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu'
28 * const schemaId = 'YOUR_DOCUMENT_SCHEMA_ID';
29 */
30
31 // Import from google cloud
32 const {DocumentSchemaServiceClient} =
33 require('@google-cloud/contentwarehouse').v1;
34
35 const apiEndpoint =
36 location === 'us'
37 ? 'contentwarehouse.googleapis.com'
38 : `${location}-contentwarehouse.googleapis.com`;
39
40 // Create service client
41 const serviceClient = new DocumentSchemaServiceClient({
42 apiEndpoint: apiEndpoint,
43 });
44
45 // Get Document Schema
46 async function getDocumentSchema() {
47 // Initialize request argument(s)
48 const request = {};
49
50 // The full resource name of the location, e.g.:
51 // projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}
52 const name = serviceClient.documentSchemaPath(
53 projectNumber,
54 location,
55 documentSchemaId
56 );
57 request.name = name;
58
59 // Make Request
60 const response = serviceClient.getDocumentSchema(request);
61
62 // Print out response
63 response.then(
64 result => console.log(`Schema Found: ${JSON.stringify(result)}`),
65 error => console.log(`${error}`)
66 );
67 }
68
69 // [END contentwarehouse_get_document_schema]
70 await getDocumentSchema();
71}
72
73main(...process.argv.slice(2)).catch(err => {
74 console.error(err);

Callers 1

Calls 1

getDocumentSchemaFunction · 0.85

Tested by

no test coverage detected