( projectNumber = 'YOUR_PROJECT_NUMBER', location = 'YOUR_PROJECT_LOCATION', userId = 'user:xxx@example.com' )
| 15 | |
| 16 | 'use strict'; |
| 17 | async function main( |
| 18 | projectNumber = 'YOUR_PROJECT_NUMBER', |
| 19 | location = 'YOUR_PROJECT_LOCATION', |
| 20 | userId = 'user:xxx@example.com' |
| 21 | ) { |
| 22 | // [START contentwarehouse_quickstart] |
| 23 | /** |
| 24 | * TODO(developer): Uncomment these variables before running the sample. |
| 25 | * const projectNumber = 'YOUR_PROJECT_NUMBER'; |
| 26 | * const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu' |
| 27 | * const userId = 'user:xxx@example.com'; // Format is "user:xxx@example.com" |
| 28 | */ |
| 29 | |
| 30 | // Import from google cloud |
| 31 | const {DocumentSchemaServiceClient, DocumentServiceClient} = |
| 32 | require('@google-cloud/contentwarehouse').v1; |
| 33 | |
| 34 | const apiEndpoint = |
| 35 | location === 'us' |
| 36 | ? 'contentwarehouse.googleapis.com' |
| 37 | : `${location}-contentwarehouse.googleapis.com`; |
| 38 | |
| 39 | // Create service client |
| 40 | const schemaClient = new DocumentSchemaServiceClient({ |
| 41 | apiEndpoint: apiEndpoint, |
| 42 | }); |
| 43 | const serviceClient = new DocumentServiceClient({apiEndpoint: apiEndpoint}); |
| 44 | |
| 45 | // Get Document Schema |
| 46 | async function quickstart() { |
| 47 | // The full resource name of the location, e.g.: |
| 48 | // projects/{project_number}/locations/{location} |
| 49 | const parent = `projects/${projectNumber}/locations/${location}`; |
| 50 | |
| 51 | // Initialize request argument(s) |
| 52 | const schemaRequest = { |
| 53 | parent: parent, |
| 54 | documentSchema: { |
| 55 | displayName: 'My Test Schema', |
| 56 | propertyDefinitions: [ |
| 57 | { |
| 58 | name: 'testPropertyDefinitionName', // Must be unique within a document schema (case insensitive) |
| 59 | displayName: 'searchable text', |
| 60 | isSearchable: true, |
| 61 | textTypeOptions: {}, |
| 62 | }, |
| 63 | ], |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | // Create Document Schema |
| 68 | const documentSchema = |
| 69 | await schemaClient.createDocumentSchema(schemaRequest); |
| 70 | |
| 71 | const documentRequest = { |
| 72 | parent: parent, |
| 73 | document: { |
| 74 | displayName: 'My Test Document', |
no test coverage detected