Skip to content

Commit 00ea0f1

Browse files
Merge branch 'model-armor-sanitization-snippets' of github.com:rudrakhsha-crest/nodejs-docs-samples into model-armor-sanitization-snippets
2 parents 31bb0c3 + e21f39d commit 00ea0f1

File tree

5 files changed

+29
-30
lines changed

5 files changed

+29
-30
lines changed

.github/workflows/custard-ci-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4141
with:
4242
repository: GoogleCloudPlatform/cloud-samples-tools
43-
ref: v0.2.1
43+
ref: v0.2.5
4444
path: cloud-samples-tools
4545
- name: Create `bin` directory for cloud-samples-tools binaries
4646
run: mkdir bin

.github/workflows/custard-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4242
with:
4343
repository: GoogleCloudPlatform/cloud-samples-tools
44-
ref: v0.2.1
44+
ref: v0.2.5
4545
path: cloud-samples-tools
4646
- name: Create `bin` directory for cloud-samples-tools binaries
4747
run: mkdir bin

.github/workflows/custard-run-dev.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ on:
4545

4646
jobs:
4747
affected:
48-
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/affected.yaml@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
48+
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/affected.yaml@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
4949
permissions:
5050
statuses: write
5151
with:
@@ -73,23 +73,23 @@ jobs:
7373
GOOGLE_SERVICE_ACCOUNT: [email protected]
7474
steps:
7575
- name: Check queued
76-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
76+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
7777
id: queued
7878
with:
7979
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
8080
name: (experimental / dev) Custard CI / ${{ github.job }} (${{ matrix.path }})
8181
job-name: ${{ github.job }} (${{ matrix.path }})
8282
if: ${{ !!github.event.workflow_run }}
8383
- name: Setup Custard
84-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
84+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
8585
with:
8686
path: ${{ matrix.path }}
8787
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
8888
project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
8989
workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
9090
service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
9191
- name: Check in_progress
92-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
92+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
9393
id: in_progress
9494
with:
9595
check: ${{ steps.queued.outputs.check }}
@@ -99,12 +99,12 @@ jobs:
9999
timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \
100100
make test dir=${{ matrix.path }}
101101
- name: Check success
102-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
102+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
103103
with:
104104
check: ${{ steps.in_progress.outputs.check }}
105105
status: success
106106
- name: Check failure
107-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
107+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
108108
if: failure()
109109
with:
110110
check: ${{ steps.in_progress.outputs.check }}
@@ -118,7 +118,7 @@ jobs:
118118
statuses: write
119119
steps:
120120
- name: Check success
121-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
121+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
122122
with:
123123
check: ${{ needs.affected.outputs.check }}
124124
status: success

.github/workflows/custard-run.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ on:
5050

5151
jobs:
5252
affected:
53-
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/affected.yaml@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
53+
uses: GoogleCloudPlatform/cloud-samples-tools/.github/workflows/affected.yaml@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
5454
permissions:
5555
statuses: write
5656
with:
@@ -68,7 +68,7 @@ jobs:
6868
timeout-minutes: 5
6969
steps:
7070
- name: Check in_progress
71-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
71+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
7272
id: in_progress
7373
with:
7474
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
@@ -83,17 +83,17 @@ jobs:
8383
node-version: 20
8484
- run: npm install
8585
- name: npx gtx lint (${{ needs.affected.outputs.num-paths }} packages)
86-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/map-run@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
86+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/map-run@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
8787
with:
8888
command: npx gts lint
8989
paths: ${{ needs.affected.outputs.paths }}
9090
- name: Check success
91-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
91+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
9292
with:
9393
check: ${{ steps.in_progress.outputs.check }}
9494
status: success
9595
- name: Check failure
96-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
96+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
9797
if: failure()
9898
with:
9999
check: ${{ steps.in_progress.outputs.check }}
@@ -117,23 +117,23 @@ jobs:
117117
GOOGLE_SERVICE_ACCOUNT: [email protected]
118118
steps:
119119
- name: Check queued
120-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
120+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/create-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
121121
id: queued
122122
with:
123123
sha: ${{ github.event.workflow_run.head_sha || inputs.ref || github.sha }}
124124
name: (experimental) Custard CI / ${{ github.job }} (${{ matrix.path }})
125125
job-name: ${{ github.job }} (${{ matrix.path }})
126126
if: ${{ !!github.event.workflow_run }}
127127
- name: Setup Custard
128-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
128+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/setup-custard@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
129129
with:
130130
path: ${{ matrix.path }}
131131
ci-setup: ${{ toJson(fromJson(needs.affected.outputs.ci-setups)[matrix.path]) }}
132132
project-id: ${{ env.GOOGLE_SAMPLES_PROJECT }}
133133
workload-identity-provider: projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider
134134
service-account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
135135
- name: Check in_progress
136-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
136+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
137137
id: in_progress
138138
with:
139139
check: ${{ steps.queued.outputs.check }}
@@ -143,12 +143,12 @@ jobs:
143143
timeout ${{ fromJson(needs.affected.outputs.ci-setups)[matrix.path].timeout-minutes }}m \
144144
make test dir=${{ matrix.path }}
145145
- name: Check success
146-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
146+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
147147
with:
148148
check: ${{ steps.in_progress.outputs.check }}
149149
status: success
150150
- name: Check failure
151-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
151+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
152152
if: failure()
153153
with:
154154
check: ${{ steps.in_progress.outputs.check }}
@@ -162,7 +162,7 @@ jobs:
162162
statuses: write
163163
steps:
164164
- name: Check success
165-
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@967334777b636ec212c32bf60e69b6635971b593 # v0.2.3
165+
uses: GoogleCloudPlatform/cloud-samples-tools/actions/steps/update-check@34b34881006f34d210c4af9d0f7ba9b2d681621d # v0.2.5
166166
with:
167167
check: ${{ needs.affected.outputs.check }}
168168
status: success

translate/v3/translate_translate_text.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,41 @@ function main(
2121
) {
2222
// [START translate_v3_translate_text]
2323
/**
24-
* TODO(developer): Uncomment these variables before running the sample.
24+
* TODO(developer): Uncomment these variables before running the sample
2525
*/
2626
// const projectId = 'YOUR_PROJECT_ID';
2727
// const location = 'global';
2828
// const text = 'text to translate';
2929

30-
// [START translate_v3_translate_text_0]
3130
// Imports the Google Cloud Translation library
31+
// [START translate_v3_import_client_library]
3232
const {TranslationServiceClient} = require('@google-cloud/translate');
33-
// [END translate_v3_translate_text_0]
33+
// [END translate_v3_import_client_library]
3434

35-
// [START translate_v3_translate_text_1]
3635
// Instantiates a client
3736
const translationClient = new TranslationServiceClient();
38-
// [END translate_v3_translate_text_1]
3937

4038
async function translateText() {
41-
// [START translate_v3_translate_text_2]
39+
// MIME type of the content to translate
40+
// Supported MIME types:
41+
// https://cloud.google.com/translate/docs/supported-formats
42+
const mimeType = 'text/plain';
43+
4244
// Construct request
4345
const request = {
4446
parent: `projects/${projectId}/locations/${location}`,
4547
contents: [text],
46-
mimeType: 'text/plain', // mime types: text/plain, text/html
48+
mimeType: mimeType,
4749
sourceLanguageCode: 'en',
4850
targetLanguageCode: 'sr-Latn',
4951
};
50-
// [END translate_v3_translate_text_2]
5152

52-
// [START translate_v3_translate_text_3]
5353
// Run request
5454
const [response] = await translationClient.translateText(request);
5555

5656
for (const translation of response.translations) {
5757
console.log(`Translation: ${translation.translatedText}`);
5858
}
59-
// [END translate_v3_translate_text_3]
6059
}
6160

6261
translateText();

0 commit comments

Comments
 (0)