Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
384162d
add sample code for set acl
Jun 24, 2023
3948b79
lint fix
Jun 24, 2023
777d0a5
add main function
Jun 24, 2023
8ead25e
add search function
Jun 24, 2023
50df4ec
add search function
Jun 24, 2023
96a3003
start creating request
Jun 24, 2023
7cbe4c2
fix package.json
Jun 24, 2023
2b8a028
working on printing result
Jun 27, 2023
c9fff50
Merge branch 'main' of https://github.com/paulinawins/nodejs-docs-sam…
Jun 27, 2023
073034b
add sample code for set acl
Jun 24, 2023
8441f73
lint fix
Jun 24, 2023
039cf26
add main function
Jun 24, 2023
08abf08
add search function
Jun 24, 2023
be57cca
add search function
Jun 24, 2023
bc721f6
start creating request
Jun 24, 2023
041d783
fix package.json
Jun 24, 2023
d0e8729
working on printing result
Jun 27, 2023
2459014
Delete search-document.js
paulinawins Jun 27, 2023
fa3f49f
remove search document sample. accidental add to this branch
Jun 27, 2023
c797658
Merge branch 'set-acl' of https://github.com/paulinawins/nodejs-docs-…
Jun 27, 2023
40d373a
Merge branch 'GoogleCloudPlatform:main' into main
paulinawins Jul 19, 2023
1ba8ba6
add sample file
Jul 26, 2023
c44505e
working on property definition
Jul 26, 2023
9f3cd43
debugging
Aug 1, 2023
4d0317e
delete schema sample
Aug 1, 2023
f9679c3
Merge branch 'GoogleCloudPlatform:main' into main
paulinawins Aug 1, 2023
f0761a1
modifications
Aug 1, 2023
ef3ebd8
remove create schema from this branch
Aug 1, 2023
3c641b6
Merge branch 'main' into delete-schema
kweinmeister Aug 2, 2023
9aca036
Merge branch 'main' into delete-schema
pattishin Aug 4, 2023
71c5e49
Merge branch 'main' into delete-schema
kweinmeister Aug 8, 2023
28e3f18
add test and fix code based on comments
Aug 9, 2023
d24dcb5
Merge branch 'main' into delete-schema
paulinawins Aug 9, 2023
36d08a9
fix styles for test file
Aug 9, 2023
8c70ef4
Merge branch 'delete-schema' of https://github.com/paulinawins/nodejs…
Aug 9, 2023
fbd26c9
remove trailing spaces:
Aug 9, 2023
5b84f6e
github action workflow created
Aug 9, 2023
b0297f6
remove test directory
Aug 9, 2023
17693d4
add workflow changes
Aug 9, 2023
8883833
Merge branch 'main' into delete-schema
paulinawins Aug 12, 2023
ed93fc1
Merge branch 'main' into delete-schema
paulinawins Aug 14, 2023
5b0faa5
Merge branch 'main' into delete-schema
paulinawins Aug 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions document-warehouse/delete-document-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/** Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

async function main(
projectId = 'YOUR_PROJECT_ID',
location = 'YOUR_PROJECT_LOCATION',
documentSchemaId = 'YOUR_DOCUMENT_SCHEMA_ID'
) {
// [START contentwarehouse_delete_document_schema]

/**
* TODO(developer): Uncomment these variables before running the sample.
* const projectId = 'YOUR_PROJECT_ID';
* const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu'
* const documentSchemaId = 'YOUR_DOCUMENT_SCHEMA_ID';
*/

// Import from google cloud
const {DocumentSchemaServiceClient} =
require('@google-cloud/contentwarehouse').v1;

// Create service client
const serviceClient = new DocumentSchemaServiceClient();

// Delete Document Schema
async function deleteDocumentSchema() {
// Initialize request argument(s)
const request = {
// The full resource name of the location, e.g.:
// projects/{project_number}/locations/{location}/documentSchemas/{document_schema_id}
name: `projects/${projectId}/locations/${location}/documentSchemas/${documentSchemaId}`,
};

// Make Request
const response = await serviceClient.deleteDocumentSchema(request);

// Print out response
console.log(`Document Schema Deleted: ${response}`);
}

// [END contentwarehouse_delete_document_schema]
await deleteDocumentSchema();
}

exports.deleteDocumentSchema = main;
10 changes: 7 additions & 3 deletions document-warehouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
"license": "Apache-2.0",
"author": "Google LLC",
"scripts": {
"test": "c8 mocha test/*.js --timeout 600000"
"test": "c8 mocha test/*.test.js --timeout 600000"
},
"dependencies": {
"@google-cloud/contentwarehouse": "^0.5.1"
"@google-cloud/contentwarehouse": "^0.5.1",
"c8": "^8.0.1",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"sinon": "^15.2.0"
},
"devDependencies": {
"assert": "^2.0.0"
"assert": "^2.0.0"
}
}
42 changes: 42 additions & 0 deletions document-warehouse/test/delete-document-schema.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const {describe, it} = require('mocha');
const {assert} = require('chai');
const sinon = require('sinon');

const text = 'Document Schema Deleted';

const {deleteDocumentSchema} = require('../delete-document-schema');

// TODO(developer): Fill in the variables below before running this test.
const projectId = 'YOUR_PROJECT_ID';
const location = 'YOUR_PROJECT_LOCATION'; // Format is 'us' or 'eu'
const documentSchemaId = 'YOUR_DOCUMENT_SCHEMA_ID';

describe('Delete document schema', () => {
const stubConsole = function () {
sinon.stub(console, 'error');
sinon.stub(console, 'log');
};

beforeEach(stubConsole);

it('should delete a document schema', async () => {
await deleteDocumentSchema(projectId, location, documentSchemaId);
assert.include(console.log.firstCall.args[0], text);
});
});