Skip to content

Commit 07c4587

Browse files
authored
chore(scc-samples): update comments to include new parent resources (#3326)
* chore(scc-samples): update comments to include new parent resources * fix header check failure
1 parent c1266c6 commit 07c4587

19 files changed

+183
-135
lines changed

security-center/snippets/v1/addDeleteSecurityMarks.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'use strict';
1515

1616
/**
17-
* Demostrates adding/updating at the same time as deleting security
17+
* Demonstrates adding/updating at the same time as deleting security
1818
* marks from an asset.
1919
*/
2020
function main(assetName = 'full asset path to add marks to') {
@@ -27,10 +27,10 @@ function main(assetName = 'full asset path to add marks to') {
2727

2828
async function addDeleteSecurityMarks() {
2929
// assetName is the full resource path for the asset to update.
30-
/*
31-
* TODO(developer): Uncomment the following lines
32-
*/
33-
// assetName = "organizations/123123342/assets/12312321";
30+
// Specify the value of 'assetName' in one of the following formats:
31+
// `organizations/${org-id}/assets/${asset-id}`;
32+
// `projects/${project-id}/assets/${asset-id}`;
33+
// `folders/${folder-id}/assets/${asset-id}`;
3434
const [newMarks] = await client.updateSecurityMarks({
3535
securityMarks: {
3636
name: `${assetName}/securityMarks`,

security-center/snippets/v1/addFindingSecurityMarks.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ function main(findingName = 'full finding path to add marks to') {
2929
/*
3030
* TODO(developer): Uncomment the following lines
3131
*/
32-
// const findingName =
33-
// "organizations/123123342/sources/1213/findings/findingid";
32+
// Specify the value of 'findingName' in one of the following formats:
33+
// `organizations/${org-id}/assets/${asset-id}/findings/${finding-id}`;
34+
// `projects/${project-id}/assets/${asset-id}/findings/${finding-id}`;
35+
// `folders/${folder-id}/assets/${asset-id}/findings/${finding-id}`;
3436
const [newMarks] = await client.updateSecurityMarks({
3537
securityMarks: {
3638
name: `${findingName}/securityMarks`,

security-center/snippets/v1/addSecurityMarks.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ function main(assetName = 'full asset path to add marks to') {
3030
/*
3131
* TODO(developer): Uncomment the following lines
3232
*/
33+
// Specify the value of 'assetName' in one of the following formats:
34+
// `organizations/${org-id}/assets/${asset-id}`;
35+
// `projects/${project-id}/assets/${asset-id}`;
36+
// `folders/${folder-id}/assets/${asset-id}`;
3337
// const assetName = "organizations/123123342/assets/12312321";
3438
const [newMarks] = await client.updateSecurityMarks({
3539
securityMarks: {

security-center/snippets/v1/createNotificationConfig.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ function main(
2424

2525
const client = new SecurityCenterClient();
2626

27-
// organizationId = "your-org-id";
27+
// parent: must be in one of the following formats:
28+
// `organizations/${organization_id}`
29+
// `projects/${project_id}`
30+
// `folders/${folder_id}`
2831
// configId = "your-config-name";
2932
// pubsubTopic = "projects/{your-project}/topics/{your-topic}";
3033
// Ensure this Service Account has the "pubsub.topics.setIamPolicy" permission on this topic.
31-
32-
const orgName = client.organizationPath(organizationId);
34+
const parent = `organizations/${organizationId}`;
3335

3436
async function createNotificationConfig() {
3537
const [response] = await client.createNotificationConfig({
36-
parent: orgName,
38+
parent: parent,
3739
configId: configId,
3840
notificationConfig: {
3941
description: 'Sample config for node.js',

security-center/snippets/v1/deleteNotificationConfig.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ function main(organizationId = 'your-org-id', configId = 'your-config-id') {
2020

2121
const client = new SecurityCenterClient();
2222

23-
// organizationId = "your-org-id";
23+
// formattedConfigName: You can also use
24+
// `client.projectNotificationConfigPath(projectId, configId)` or
25+
// `client.folderNotificationConfigPath(folderId, configId)`.
2426
// configId = "your-config-id";
2527
const formattedConfigName = client.organizationNotificationConfigPath(
2628
organizationId,

security-center/snippets/v1/deleteSecurityMarks.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ function main(assetName = 'full asset path to add marks to') {
3030
/*
3131
* TODO(developer): Uncomment the following lines
3232
*/
33+
// Specify the value of 'assetName' in one of the following formats:
34+
// `organizations/${org-id}/assets/${asset-id}`;
35+
// `projects/${project-id}/assets/${asset-id}`;
36+
// `folders/${folder-id}/assets/${asset-id}`;
3337
// const assetName = "organizations/123123342/assets/12312321";
3438
const [newMarks] = await client.updateSecurityMarks({
3539
securityMarks: {

security-center/snippets/v1/getNotificationConfig.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ function main(organizationId = 'your-org-id', configId = 'your-config-id') {
2020

2121
const client = new SecurityCenterClient();
2222

23-
// organizationId = "your-org-id";
23+
// formattedConfigName: You can also use
24+
// `client.projectNotificationConfigPath(projectId, configId)` or
25+
// `client.folderNotificationConfigPath(folderId, configId)`.
2426
// configId = "your-config-id";
2527
const formattedConfigName = client.organizationNotificationConfigPath(
2628
organizationId,

security-center/snippets/v1/listAllAssets.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ function main(organizationId = 'YOUR_NUMERIC_ORG_ID') {
2626
/*
2727
* TODO(developer): Uncomment the following lines
2828
*/
29-
// const organizationId = "111122222444";
30-
const orgName = client.organizationPath(organizationId);
29+
// parent: must be in one of the following formats:
30+
// `organizations/${organization_id}`
31+
// `projects/${project_id}`
32+
// `folders/${folder_id}`
33+
const parent = `organizations/${organizationId}`;
3134
// Call the API with automatic pagination.
3235
async function listAssets() {
33-
const [response] = await client.listAssets({parent: orgName});
36+
const [response] = await client.listAssets({parent: parent});
3437
let count = 0;
3538
Array.from(response).forEach(result =>
3639
console.log(

security-center/snippets/v1/listAllFindings.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
/*
2-
* Copyright 2019, Google, LLC.
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-
*/
1+
// Copyright 2019 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+
// http://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.
1514
'use strict';
1615

1716
/** Prints all findings across all sources. */
@@ -31,6 +30,10 @@ function main(organizationId = 'YOUR_NUMERIC_ORG_ID') {
3130
async function listAllFindings() {
3231
const [response] = await client.listFindings({
3332
// List findings across all sources.
33+
// parent: must be in one of the following formats:
34+
// `organizations/${organization_id}/sources/-`
35+
// `projects/${project_id}/sources/-`
36+
// `folders/${folder_id}/sources/-`
3437
parent: `organizations/${organizationId}/sources/-`,
3538
});
3639
let count = 0;

security-center/snippets/v1/listAllSources.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ function main(organizationId = 'YOUR_NUMERIC_ORG_ID') {
2626
/*
2727
* TODO(developer): Uncomment the following lines
2828
*/
29-
// const organizaionId = "111122222444";
30-
const orgName = client.organizationPath(organizationId);
29+
// parent: must be in one of the following formats:
30+
// `organizations/${organization_id}`
31+
// `projects/${project_id}`
32+
// `folders/${folder_id}`
33+
const parent = `organizations/${organizationId}`;
3134
// Call the API with automatic pagination.
3235
async function listSources() {
33-
const [response] = await client.listSources({parent: orgName});
36+
const [response] = await client.listSources({parent: parent});
3437
let count = 0;
3538
console.log('Sources:');
3639
Array.from(response).forEach(source =>

security-center/snippets/v1/listAssetsAndChanges.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ function main(organizationId = 'YOUR_NUMERIC_ORG_ID') {
2929
/*
3030
* TODO(developer): Uncomment the following lines
3131
*/
32-
// const organizationId = "1234567777";
33-
const orgName = client.organizationPath(organizationId);
32+
// parent: must be in one of the following formats:
33+
// `organizations/${organization_id}`
34+
// `projects/${project_id}`
35+
// `folders/${folder_id}`
36+
const parent = `organizations/${organizationId}`;
3437
// Call the API with automatic pagination.
3538
async function listAssetsAndChanges() {
3639
const [response] = await client.listAssets({
37-
parent: orgName,
40+
parent: parent,
3841
compareDuration: {seconds: 30 * /*Second in Day=*/ 86400, nanos: 0},
3942
filter:
4043
'security_center_properties.resource_type="google.cloud.resourcemanager.Project"',

security-center/snippets/v1/listAssetsAtTime.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
/*
2-
* Copyright 2019, Google, LLC.
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-
*/
1+
// Copyright 2019 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+
// http://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.
1514
'use strict';
1615

1716
/**
@@ -28,16 +27,19 @@ function main(organizationId = 'YOUR_NUMERIC_ORG_ID') {
2827
/*
2928
* TODO(developer): Uncomment the following lines
3029
*/
31-
// const organizationId = "1234567777";
32-
const orgName = client.organizationPath(organizationId);
30+
// parent: must be in one of the following formats:
31+
// `organizations/${organization_id}`
32+
// `projects/${project_id}`
33+
// `folders/${folder_id}`
34+
const parent = `organizations/${organizationId}`;
3335

3436
const oneDayAgo = new Date();
3537
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
3638

3739
// Call the API with automatic pagination.
3840
async function listAssetsAtTime() {
3941
const [response] = await client.listAssets({
40-
parent: orgName,
42+
parent: parent,
4143
filter:
4244
'security_center_properties.resource_type="google.cloud.resourcemanager.Project"',
4345
// readTime must be in the form of a google.protobuf.Timestamp object

security-center/snippets/v1/listAssetsWithSecurityMarks.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
/*
2-
* Copyright 2019, Google, LLC.
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-
*/
1+
// Copyright 2019 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+
// http://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.
1514
'use strict';
1615

1716
/**
@@ -28,13 +27,16 @@ function main(organizationId = 'YOUR_NUMERIC_ORG_ID') {
2827
/*
2928
* TODO(developer): Uncomment the following lines
3029
*/
31-
// const organizationId = "1234567777";
32-
const orgName = client.organizationPath(organizationId);
30+
// parent: must be in one of the following formats:
31+
// `organizations/${organization_id}`
32+
// `projects/${project_id}`
33+
// `folders/${folder_id}`
34+
const parent = `organizations/${organizationId}`;
3335

3436
// Call the API with automatic pagination.
3537
async function listAssetsWithSecurityMarks() {
3638
const [response] = await client.listAssets({
37-
parent: orgName,
39+
parent: parent,
3840
filter: 'security_marks.marks.key_a="value_a"',
3941
});
4042
let count = 0;

security-center/snippets/v1/listFilteredAssets.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
/*
2-
* Copyright 2019, Google, LLC.
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-
*/
1+
// Copyright 2019 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+
// http://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.
1514
'use strict';
1615

1716
/**
@@ -32,6 +31,8 @@ function main(organizationId = 'YOUR_NUMERIC_ORG_ID') {
3231
const orgName = client.organizationPath(organizationId);
3332

3433
// Call the API with automatic pagination.
34+
// You can also list assets in a project/ folder. To do so, modify the parent
35+
// value and filter condition.
3536
async function listFilteredAssets() {
3637
const [response] = await client.listAssets({
3738
parent: orgName,

security-center/snippets/v1/listFilteredFindings.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
/*
2-
* Copyright 2019, Google, LLC.
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-
*/
1+
// Copyright 2019 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+
// http://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.
1514
'use strict';
1615

1716
/** Demonstrates listing only specific findings. */
@@ -27,8 +26,12 @@ function main(sourceName = 'YOUR_NUMERIC_ORG_ID') {
2726
/*
2827
* TODO(developer): Uncomment the following lines
2928
*/
30-
// const sourceName = "organizations/111122222444/sources/1234";
31-
29+
// const sourceName = `${parent}/sources/${sourceId}`;
30+
// where,
31+
// parent: must be in one of the following formats:
32+
// `organizations/${organization_id}`
33+
// `projects/${project_id}`
34+
// `folders/${folder_id}`
3235
async function listFilteredFindings() {
3336
const [response] = await client.listFindings({
3437
// List findings across all sources.

0 commit comments

Comments
 (0)