@@ -31,31 +31,38 @@ async function main(
31
31
const { DocumentSchemaServiceClient} =
32
32
require ( '@google-cloud/contentwarehouse' ) . v1 ;
33
33
34
+ const apiEndpoint =
35
+ location === 'us'
36
+ ? 'contentwarehouse.googleapis.com'
37
+ : `${ location } -contentwarehouse.googleapis.com` ;
38
+
34
39
// Create service client
35
- const serviceClient = new DocumentSchemaServiceClient ( ) ;
40
+ const serviceClient = new DocumentSchemaServiceClient ( {
41
+ apiEndpoint : apiEndpoint ,
42
+ } ) ;
36
43
37
44
// Create Document Schema
38
45
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
-
56
46
// The full resource name of the location, e.g.:
57
47
// 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
+ } ;
59
66
60
67
// Make Request
61
68
const response = serviceClient . createDocumentSchema ( request ) ;
0 commit comments