Skip to content

Commit e4e153e

Browse files
authored
Merge branch 'main' into gemini-batch-prediction
2 parents aa76120 + 7a89075 commit e4e153e

11 files changed

+721
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
async function main(parent, secretId, annotationKey, annotationValue) {
18+
// [START secretmanager_create_secret_with_annotations]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const parent = 'projects/my-project';
23+
// const secretId = 'my-secret';
24+
// const annotationKey = 'exampleannotationkey';
25+
// const annotationValue = 'exampleannotationvalue';
26+
27+
// Imports the Secret Manager library
28+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
29+
30+
// Instantiates a client
31+
const client = new SecretManagerServiceClient();
32+
33+
async function createSecretWithAnnotations() {
34+
const [secret] = await client.createSecret({
35+
parent: parent,
36+
secretId: secretId,
37+
secret: {
38+
replication: {
39+
automatic: {},
40+
},
41+
annotations: {
42+
[annotationKey]: annotationValue,
43+
},
44+
},
45+
});
46+
47+
console.log(`Created secret ${secret.name}`);
48+
}
49+
50+
createSecretWithAnnotations();
51+
// [END secretmanager_create_secret_with_annotations]
52+
}
53+
54+
const args = process.argv.slice(2);
55+
main(...args).catch(console.error);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
async function main(name, annotationKey, annotationValue) {
18+
// [START secretmanager_edit_secret_annotations]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const name = 'projects/my-project/secrets/my-secret';
23+
// const annotationKey = 'updatedannotationkey';
24+
// const annotationValue = 'updatedannotationvalue';
25+
26+
// Imports the Secret Manager library
27+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
28+
29+
// Instantiates a client
30+
const client = new SecretManagerServiceClient();
31+
32+
async function getSecret() {
33+
const [secret] = await client.getSecret({
34+
name: name,
35+
});
36+
37+
return secret;
38+
}
39+
40+
async function editSecretAnnotations() {
41+
const oldSecret = await getSecret();
42+
oldSecret.annotations[annotationKey] = annotationValue;
43+
const [secret] = await client.updateSecret({
44+
secret: {
45+
name: name,
46+
annotations: oldSecret.annotations,
47+
},
48+
updateMask: {
49+
paths: ['annotations'],
50+
},
51+
});
52+
53+
console.info(`Updated secret ${secret.name}`);
54+
}
55+
56+
editSecretAnnotations();
57+
// [END secretmanager_edit_secret_annotations]
58+
}
59+
60+
const args = process.argv.slice(2);
61+
main(...args).catch(console.error);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
async function main(
18+
projectId,
19+
locationId,
20+
secretId,
21+
annotationKey,
22+
annotationValue
23+
) {
24+
// [START secretmanager_create_regional_secret_with_annotations]
25+
/**
26+
* TODO(developer): Uncomment these variables before running the sample.
27+
*/
28+
// const projectId = 'my-project'
29+
// const locationId = 'locationId';
30+
// const secretId = 'my-secret';
31+
// const annotationKey = 'exampleannotationkey';
32+
// const annotationValue = 'exampleannotationvalue';
33+
34+
const parent = `projects/${projectId}/locations/${locationId}`;
35+
36+
// Imports the Secret Manager library
37+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
38+
39+
// Adding the endpoint to call the regional secret manager sever
40+
const options = {};
41+
options.apiEndpoint = `secretmanager.${locationId}.rep.googleapis.com`;
42+
// Instantiates a client
43+
const client = new SecretManagerServiceClient(options);
44+
45+
async function createRegionalSecretWithAnnotations() {
46+
const [secret] = await client.createSecret({
47+
parent: parent,
48+
secretId: secretId,
49+
secret: {
50+
annotations: {
51+
[annotationKey]: annotationValue,
52+
},
53+
},
54+
});
55+
56+
console.log(`Created secret ${secret.name}`);
57+
}
58+
59+
createRegionalSecretWithAnnotations();
60+
// [END secretmanager_create_regional_secret_with_annotations]
61+
}
62+
63+
const args = process.argv.slice(2);
64+
main(...args).catch(console.error);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
async function main(projectId, locationId, secretId, labelKey, labelValue) {
18+
// [START secretmanager_create_regional_secret_with_labels]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const project = 'my-project';
23+
// const locationId = 'my-location';
24+
// const secretId = 'my-secret';
25+
// const labelKey = 'secretmanager';
26+
// const labelValue = 'rocks';
27+
const parent = `projects/${projectId}/locations/${locationId}`;
28+
29+
// Imports the Secret Manager library
30+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
31+
32+
// Adding the endpoint to call the regional secret manager sever
33+
const options = {};
34+
options.apiEndpoint = `secretmanager.${locationId}.rep.googleapis.com`;
35+
36+
// Instantiates a client
37+
const client = new SecretManagerServiceClient(options);
38+
39+
async function createRegionalSecretWithLabels() {
40+
const [secret] = await client.createSecret({
41+
parent: parent,
42+
secretId: secretId,
43+
secret: {
44+
labels: {
45+
[labelKey]: labelValue,
46+
},
47+
},
48+
});
49+
50+
console.log(`Created secret ${secret.name}`);
51+
}
52+
53+
createRegionalSecretWithLabels();
54+
// [END secretmanager_create_regional_secret_with_labels]
55+
}
56+
57+
const args = process.argv.slice(2);
58+
main(...args).catch(console.error);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
async function main(projectId, locationId, secretId, labelKey) {
18+
// [START secretmanager_delete_regional_secret_label]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
// const projectId = 'my-project'
23+
// const locationId = 'locationId';
24+
// const secretId = 'my-secret';
25+
// const labelKey = 'secretmanager';
26+
const name = `projects/${projectId}/locations/${locationId}/secrets/${secretId}`;
27+
28+
// Imports the Secret Manager library
29+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
30+
31+
// Adding the endpoint to call the regional secret manager sever
32+
const options = {};
33+
options.apiEndpoint = `secretmanager.${locationId}.rep.googleapis.com`;
34+
35+
// Instantiates a client
36+
const client = new SecretManagerServiceClient(options);
37+
38+
async function getSecret() {
39+
const [secret] = await client.getSecret({
40+
name: name,
41+
});
42+
43+
return secret;
44+
}
45+
46+
async function deleteRegionalSecretLabel() {
47+
const oldSecret = await getSecret();
48+
delete oldSecret.labels[labelKey];
49+
const [secret] = await client.updateSecret({
50+
secret: {
51+
name: name,
52+
labels: oldSecret.labels,
53+
},
54+
updateMask: {
55+
paths: ['labels'],
56+
},
57+
});
58+
59+
console.info(`Updated secret ${secret.name}`);
60+
}
61+
62+
deleteRegionalSecretLabel();
63+
// [END secretmanager_delete_regional_secret_label]
64+
}
65+
66+
const args = process.argv.slice(2);
67+
main(...args).catch(console.error);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
async function main(
18+
projectId,
19+
locationId,
20+
secretId,
21+
annotationKey,
22+
annotationValue
23+
) {
24+
// [START secretmanager_edit_regional_secret_annotations]
25+
/**
26+
* TODO(developer): Uncomment these variables before running the sample.
27+
*/
28+
// const projectId = 'my-project'
29+
// const locationId = 'locationId';
30+
// const secretId = 'my-secret';
31+
// const annotationKey = 'updatedannotationkey';
32+
// const annotationValue = 'updatedannotationvalue';
33+
34+
const name = `projects/${projectId}/locations/${locationId}/secrets/${secretId}`;
35+
36+
// Imports the Secret Manager library
37+
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
38+
39+
// Adding the endpoint to call the regional secret manager sever
40+
const options = {};
41+
options.apiEndpoint = `secretmanager.${locationId}.rep.googleapis.com`;
42+
// Instantiates a client
43+
const client = new SecretManagerServiceClient(options);
44+
45+
async function getSecret() {
46+
const [secret] = await client.getSecret({
47+
name: name,
48+
});
49+
50+
return secret;
51+
}
52+
53+
async function editRegionalSecretAnnotations() {
54+
const oldSecret = await getSecret();
55+
oldSecret.annotations[annotationKey] = annotationValue;
56+
const [secret] = await client.updateSecret({
57+
secret: {
58+
name: name,
59+
annotations: oldSecret.annotations,
60+
},
61+
updateMask: {
62+
paths: ['annotations'],
63+
},
64+
});
65+
66+
console.info(`Updated secret ${secret.name}`);
67+
}
68+
69+
editRegionalSecretAnnotations();
70+
// [END secretmanager_edit_regional_secret_annotations]
71+
}
72+
73+
const args = process.argv.slice(2);
74+
main(...args).catch(console.error);

0 commit comments

Comments
 (0)