-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into renovate/c8-8.x
- Loading branch information
Showing
14 changed files
with
337 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# 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. | ||
|
||
name: document-warehouse | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'document-warehouse/**' | ||
- '.github/workflows/document-warehouse.yaml' | ||
pull_request: | ||
paths: | ||
- 'document-warehouse/**' | ||
- '.github/workflows/document-warehouse.yaml' | ||
pull_request_target: | ||
types: [labeled] | ||
paths: | ||
- 'document-warehouse/**' | ||
- '.github/workflows/document-warehouse.yaml' | ||
schedule: | ||
- cron: '0 0 * * 0' | ||
jobs: | ||
test: | ||
# Ref: https://github.com/google-github-actions/auth#usage | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' | ||
uses: ./.github/workflows/test.yaml | ||
with: | ||
name: 'document-warehouse' | ||
path: 'document-warehouse' | ||
remove_label: | ||
# Ref: https://github.com/google-github-actions/auth#usage | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
if: | | ||
github.event.action == 'labeled' && | ||
github.event.label.name == 'actions:force-run' && | ||
always() | ||
uses: ./.github/workflows/remove-label.yaml | ||
flakybot: | ||
# Ref: https://github.com/google-github-actions/auth#usage | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
if: github.event_name == 'schedule' && always() # always() submits logs even if tests fail | ||
uses: ./.github/workflows/flakybot.yaml | ||
needs: [test] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 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. | ||
--- | ||
rules: | ||
no-console: off | ||
node/no-unsupported-features/node-builtins: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** 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', | ||
userId = 'user:xxxx@example.com', | ||
documentId = 'YOUR_DOCUMENT_ID' | ||
) { | ||
// [START contentwarehouse_fetch_acl] | ||
|
||
/** | ||
* 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 documentId = 'YOUR_DOCUMENT_ID', | ||
* const userId = "user:xxxx@example.com" // Format is "user:xxxx@example.com" | ||
*/ | ||
|
||
// Import from google cloud | ||
const {DocumentServiceClient} = require('@google-cloud/contentwarehouse').v1; | ||
|
||
// Create service client | ||
const serviceClient = new DocumentServiceClient(); | ||
|
||
// Fetches access control policies on project or document level. | ||
async function fetchACL() { | ||
// Initialize request argument(s) | ||
const request = {}; | ||
if (documentId !== 'YOUR_DOCUMENT_ID') { | ||
// Full document resource name, e.g.: | ||
// projects/{project_id}/locations/{location}/documents/{document_id} | ||
request.resource = `projects/${projectId}/locations/${location}/documents/${documentId}`; | ||
request.requestMetadata = {userInfo: {id: userId}}; | ||
} else { | ||
// Full document resource name, e.g.: projects/{project_id} | ||
request.resource = `projects/${projectId}`; | ||
request.projectOwner = true; | ||
} | ||
|
||
// Make Request | ||
const response = serviceClient.fetchAcl(request); | ||
|
||
// Print out response | ||
response.then( | ||
result => console.log(`Success! Response: \n${JSON.stringify(result)}`), | ||
error => console.log(`Failed! Response: \n${error}`) | ||
); | ||
} | ||
|
||
// [END contentwarehouse_fetch_acl] | ||
await fetchACL(); | ||
} | ||
|
||
main(...process.argv.slice(2)).catch(err => { | ||
console.error(err); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "nodejs-document-warehouse-samples", | ||
"private": true, | ||
"license": "Apache-2.0", | ||
"author": "Google LLC", | ||
"scripts": { | ||
"test": "c8 mocha test/*.js --timeout 600000" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/contentwarehouse": "^0.5.1", | ||
"assert": "^2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 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. | ||
--- | ||
env: | ||
mocha: true | ||
rules: | ||
node/no-extraneous-require: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** 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'; | ||
|
||
const cp = require('child_process'); | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
|
||
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); | ||
const cwd = path.join(__dirname, '..'); | ||
const PROJECT_ID_PASS = 'YOUR_PROJECT_ID'; | ||
const PROJECT_ID_FAILED = 'PROJECT_ID_WITHOUT_ACL'; | ||
const LOCATION = 'us'; | ||
const USER_ID = 'user:xxxx@example.com'; | ||
const DOCUMENT_ID = 'YOUR_DOCUMENT_ID'; | ||
|
||
describe('Fetch document acl', () => { | ||
it('should get acl given only a projectId', async () => { | ||
const stdout = execSync(`node ./fetch-acl.js ${PROJECT_ID_PASS} `, {cwd}); | ||
assert(stdout.startsWith('Success!')); | ||
}); | ||
|
||
it('should get acl given a documentId', async () => { | ||
const stdout = execSync( | ||
`node ./fetch-acl.js ${PROJECT_ID_PASS} ${LOCATION} ${USER_ID} ${DOCUMENT_ID}`, | ||
{cwd} | ||
); | ||
assert(stdout.startsWith('Success!')); | ||
}); | ||
|
||
it('should fail given an incorrect projectId', async () => { | ||
const stdout = execSync(`node ./fetch-acl.js ${PROJECT_ID_FAILED}`, {cwd}); | ||
assert(stdout.startsWith('Failed!')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Node.js sample for "Invoke a VPC Service Controls-compliant private endpoint" | ||
|
||
This is the sample application for the | ||
[Invoke a VPC Service Controls-compliant private endpoint](https://cloud.google.com/workflows/docs/invoke-private-endpoint-vpc) | ||
page found in the [Google Cloud Workflows](https://cloud.google.com/workflows/docs) documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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'; | ||
|
||
// [START workflows_private_endpoint] | ||
const express = require('express'); | ||
const app = express(); | ||
|
||
app.get('/', (req, res) => { | ||
res.status(200).send('Hello, world!').end(); | ||
}); | ||
|
||
app.listen(3000, () => { | ||
console.log('Sample app listening on port 3000.'); | ||
}); | ||
// [END workflows_private_endpoint] | ||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "workflows-hello-private-endpoint", | ||
"description": "Simple Hello World Node.js sample for Workflows", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "Apache-2.0", | ||
"author": "Google Inc.", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"scripts": { | ||
"start": "node app.js", | ||
"test": "c8 mocha --exit test/*.test.js" | ||
}, | ||
"dependencies": { | ||
"express": "^4.17.1" | ||
}, | ||
"devDependencies": { | ||
"c8": "^7.13.0", | ||
"mocha": "^10.0.0", | ||
"supertest": "^6.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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. | ||
|
||
const app = require('../app'); | ||
const request = require('supertest'); | ||
|
||
describe('workflows_private_endpoint', () => { | ||
describe('GET /', () => { | ||
it('should get 200', done => { | ||
request(app).get('/').expect(200, done); | ||
}); | ||
|
||
it('should get Hello World', done => { | ||
request(app).get('/').expect('Hello, world!', done); | ||
}); | ||
}); | ||
}); |