@@ -31,31 +31,38 @@ async function main(
3131 const { DocumentSchemaServiceClient} =
3232 require ( '@google-cloud/contentwarehouse' ) . v1 ;
3333
34+ const apiEndpoint =
35+ location === 'us'
36+ ? 'contentwarehouse.googleapis.com'
37+ : `${ location } -contentwarehouse.googleapis.com` ;
38+
3439 // Create service client
35- const serviceClient = new DocumentSchemaServiceClient ( ) ;
40+ const serviceClient = new DocumentSchemaServiceClient ( {
41+ apiEndpoint : apiEndpoint ,
42+ } ) ;
3643
3744 // Create Document Schema
3845 async function createDocumentSchema ( ) {
39- // Initialize request argument(s)
40- const request = { } ;
41-
42- // Property Definition
43- const propertyDefinition = { } ;
44- propertyDefinition . name = 'testPropertyDefinitionName' ; // Must be unique within a document schema (case insensitive)
45- propertyDefinition . displayName = 'searchable text' ;
46- propertyDefinition . isSearchable = true ;
47- propertyDefinition . textTypeOptions = { } ;
48-
49- // Document Schema
50- const documentSchema = { } ;
51- documentSchema . displayName = 'My Test Schema' ;
52- documentSchema . propertyDefinitions = [ propertyDefinition ] ;
53-
54- request . documentSchema = documentSchema ;
55-
5646 // The full resource name of the location, e.g.:
5747 // projects/{project_number}/locations/{location}
58- request . parent = `projects/${ projectNumber } /locations/${ location } ` ;
48+ const parent = `projects/${ projectNumber } /locations/${ location } ` ;
49+ // Initialize request argument(s)
50+ const request = {
51+ parent : parent ,
52+ // Document Schema
53+ documentSchema : {
54+ displayName : 'My Test Schema' ,
55+ // Property Definition
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+ } ;
5966
6067 // Make Request
6168 const response = serviceClient . createDocumentSchema ( request ) ;
0 commit comments