-
Notifications
You must be signed in to change notification settings - Fork 2k
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/google-cloud-aiplatform-3.x
- Loading branch information
Showing
13 changed files
with
586 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// 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'; | ||
|
||
// sample-metadata: | ||
// title: Create an inspection job | ||
// description: Create an inspection job | ||
// usage: node createJob.js my-project bucket-url | ||
function main(projectId, cloudFileUrl) { | ||
// [START dlp_create_job] | ||
// Imports the Google Cloud Data Loss Prevention library | ||
const DLP = require('@google-cloud/dlp'); | ||
|
||
// Initialize google DLP Client | ||
const dlp = new DLP.DlpServiceClient(); | ||
|
||
async function jobsCreate() { | ||
// Construct cloud storage configuration | ||
const cloudStorageConfig = { | ||
cloudStorageOptions: { | ||
fileSet: { | ||
url: cloudFileUrl, | ||
}, | ||
}, | ||
timespanConfig: { | ||
enableAutoPopulationOfTimespanConfig: true, | ||
}, | ||
}; | ||
|
||
// Construct inspect job configuration | ||
const inspectJob = { | ||
storageConfig: cloudStorageConfig, | ||
}; | ||
|
||
// Construct inspect configuration | ||
const inspectConfig = { | ||
infoTypes: [ | ||
{name: 'EMAIL_ADDRESS'}, | ||
{name: 'PERSON_NAME'}, | ||
{name: 'LOCATION'}, | ||
{name: 'PHONE_NUMBER'}, | ||
], | ||
includeQuote: true, | ||
minLikelihood: DLP.protos.google.privacy.dlp.v2.Likelihood.LIKELY, | ||
excludeInfoTypes: false, | ||
}; | ||
|
||
// Combine configurations into a request for the service. | ||
const request = { | ||
parent: `projects/${projectId}/locations/global`, | ||
inspectJob: inspectJob, | ||
inspectConfig: inspectConfig, | ||
}; | ||
|
||
// Send the request and receive response from the service | ||
const [response] = await dlp.createDlpJob(request); | ||
// Print the results | ||
console.log(`Job created successfully: ${response.name}`); | ||
} | ||
|
||
jobsCreate(); | ||
// [END dlp_create_job] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
|
||
main(...process.argv.slice(2)); |
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,54 @@ | ||
// 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'; | ||
|
||
// sample-metadata: | ||
// title: Get an inspection job | ||
// description: Get DLP inspection job using job name. | ||
// usage: node getJob.js jobName | ||
function main(jobName) { | ||
// [START dlp_get_job] | ||
// Imports the Google Cloud Data Loss Prevention library | ||
const DLP = require('@google-cloud/dlp'); | ||
|
||
// Instantiates a client | ||
const dlp = new DLP.DlpServiceClient(); | ||
|
||
// Job name to look for | ||
// const jobName = 'your-job-name'; | ||
|
||
async function getJob() { | ||
// Construct request for finding job using job name. | ||
const request = { | ||
name: jobName, | ||
}; | ||
|
||
// Send the request and receive response from the service | ||
const [job] = await dlp.getDlpJob(request); | ||
|
||
// Print results. | ||
console.log(`Job ${job.name} status: ${job.state}`); | ||
} | ||
|
||
getJob(); | ||
// [END dlp_get_job] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
|
||
main(...process.argv.slice(2)); |
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
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. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
function main(projectId, location, assetId, assetUri) { | ||
// [START livestream_create_asset] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// projectId = 'my-project-id'; | ||
// location = 'us-central1'; | ||
// assetId = 'my-asset'; | ||
// assetUri = 'gs://my-bucket/my-video.mp4'; | ||
|
||
// Imports the Livestream library | ||
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1; | ||
|
||
// Instantiates a client | ||
const livestreamServiceClient = new LivestreamServiceClient(); | ||
|
||
async function createAsset() { | ||
// Construct request | ||
const request = { | ||
parent: livestreamServiceClient.locationPath(projectId, location), | ||
assetId: assetId, | ||
asset: { | ||
video: { | ||
uri: assetUri, | ||
}, | ||
}, | ||
}; | ||
|
||
// Run request | ||
const [operation] = await livestreamServiceClient.createAsset(request); | ||
const response = await operation.promise(); | ||
const [asset] = response; | ||
console.log(`Asset: ${asset.name}`); | ||
} | ||
|
||
createAsset(); | ||
// [END livestream_create_asset] | ||
} | ||
|
||
// node createAsset.js <projectId> <location> <assetId> <assetUri> | ||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
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,54 @@ | ||
/** | ||
* 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'; | ||
|
||
function main(projectId, location, assetId) { | ||
// [START livestream_delete_asset] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// projectId = 'my-project-id'; | ||
// location = 'us-central1'; | ||
// assetId = 'my-asset'; | ||
|
||
// Imports the Livestream library | ||
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1; | ||
|
||
// Instantiates a client | ||
const livestreamServiceClient = new LivestreamServiceClient(); | ||
|
||
async function deleteAsset() { | ||
// Construct request | ||
const request = { | ||
name: livestreamServiceClient.assetPath(projectId, location, assetId), | ||
}; | ||
|
||
// Run request | ||
const [operation] = await livestreamServiceClient.deleteAsset(request); | ||
await operation.promise(); | ||
console.log('Deleted asset'); | ||
} | ||
|
||
deleteAsset(); | ||
// [END livestream_delete_asset] | ||
} | ||
|
||
// node deleteAsset.js <projectId> <location> <assetId> | ||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
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,51 @@ | ||
/** | ||
* 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'; | ||
|
||
function main(projectId, location, assetId) { | ||
// [START livestream_get_asset] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// projectId = 'my-project-id'; | ||
// location = 'us-central1'; | ||
// assetId = 'my-asset'; | ||
|
||
// Imports the Livestream library | ||
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1; | ||
|
||
// Instantiates a client | ||
const livestreamServiceClient = new LivestreamServiceClient(); | ||
|
||
async function getAsset() { | ||
// Construct request | ||
const request = { | ||
name: livestreamServiceClient.assetPath(projectId, location, assetId), | ||
}; | ||
const [asset] = await livestreamServiceClient.getAsset(request); | ||
console.log(`Asset: ${asset.name}`); | ||
} | ||
|
||
getAsset(); | ||
// [END livestream_get_asset] | ||
} | ||
|
||
// node getAsset.js <projectId> <location> <assetId> | ||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
main(...process.argv.slice(2)); |
Oops, something went wrong.