Skip to content

Commit 2d64203

Browse files
authored
Merge pull request #22 from cloudgraphdev/beta
Release 0.36.0
2 parents d6cde0c + 58210db commit 2d64203

File tree

14 files changed

+171
-5
lines changed

14 files changed

+171
-5
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# [0.36.0-beta.1](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/compare/0.35.1...0.36.0-beta.1) (2022-12-12)
2+
3+
4+
### Features
5+
6+
* **CG-1312:** add essential contacts ([305da4f](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/commit/305da4fa52a319b36a07a141dae2eb1a5572079e))
7+
* **CG-1312:** remove a debug text ([4bc8b5b](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/commit/4bc8b5bfad7702945d5fe6e8891c53d64c7337a4))
8+
* **CG-1312:** update fetch data and README ([07d58db](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/commit/07d58db8db3a1e55aaf18a4fd55959170b8012fa))
9+
10+
# [0.36.0-alpha.1](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/compare/0.35.1...0.36.0-alpha.1) (2022-12-12)
11+
12+
13+
### Features
14+
15+
* **CG-1312:** add essential contacts ([305da4f](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/commit/305da4fa52a319b36a07a141dae2eb1a5572079e))
16+
* **CG-1312:** remove a debug text ([4bc8b5b](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/commit/4bc8b5bfad7702945d5fe6e8891c53d64c7337a4))
17+
* **CG-1312:** update fetch data and README ([07d58db](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/commit/07d58db8db3a1e55aaf18a4fd55959170b8012fa))
18+
119
## [0.35.1](https://github.com/cloudgraphdev/cloudgraph-provider-gcp/compare/0.35.0...0.35.1) (2022-11-28)
220

321

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ CloudGraph GCP Provider will ask you what regions you would like to crawl and wi
9090
| kmsCryptoKeys | aiPlatformNotebooks, iamPolicy, kmsKeyRing, project |
9191
| dnsManagedZone | project |
9292
| dnsPolicy | project, network |
93+
| essentialContacts | project |
9394
| firestoreDatabases | project |
9495
| firewall | network, project |
9596
| folder | iamPolicy, organization, project |
@@ -105,10 +106,10 @@ CloudGraph GCP Provider will ask you what regions you would like to crawl and wi
105106
| secretManager | project |
106107
| serviceAccounts | project |
107108
| sqlInstances | project, network |
108-
| sslPolicies | project, targetHttpsProxies, targetSslProxies |
109+
| sslPolicies | project, targetHttpsProxies, targetSslProxies |
109110
| storageBucket | project |
110111
| subnet | project, network, vmInstance, vpcConnectors, aiPlatformNotebooks |
111-
| targetSslProxies | project, sslPolicies |
112-
| targetHttpsProxies | project, sslPolicies |
112+
| targetSslProxies | project, sslPolicies |
113+
| targetHttpsProxies | project, sslPolicies |
113114
| vmInstance | project, network, subnet |
114115
| vpcConnectors | cloudFunction, project, network, subnet |

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudgraph/cg-provider-gcp",
3-
"version": "0.35.1",
3+
"version": "0.36.0-beta.1",
44
"description": "CloudGraph provider plugin for GCP used to fetch GCP cloud data.",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org/",
@@ -42,6 +42,7 @@
4242
"@google-cloud/dataproc": "^3.2.0",
4343
"@google-cloud/datastore": "^6.6.2",
4444
"@google-cloud/dns": "^2.2.3",
45+
"@google-cloud/essential-contacts": "^2.0.2",
4546
"@google-cloud/firestore": "^5.0.2",
4647
"@google-cloud/functions": "^1.2.0",
4748
"@google-cloud/kms": "^2.10.0",

src/enums/schemasMap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ export default {
5353
[services.apiGatewayApi]: 'gcpApiGatewayApi',
5454
[services.apiGatewayApiConfig]: 'gcpApiGatewayApiConfig',
5555
[services.firestoreDatabase]: 'gcpFirestoreDatabase',
56+
[services.essentialContacts]: 'gcpEssentialContact',
5657
tag: 'gcpTag',
5758
}

src/enums/serviceMap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import GcpFirestoreDatabase from '../services/firestore'
5050
import GcpLabel from '../services/label'
5151
import GcpTag from '../services/tag'
5252
import GcpBilling from '../services/billing'
53+
import GcpEssentialContacts from '../services/essentialContacts'
5354

5455
/**
5556
* serviceMap is an object that contains all currently supported services
@@ -105,6 +106,7 @@ export default {
105106
[services.apiGatewayApi]: GcpApiGatewayApi,
106107
[services.apiGatewayApiConfig]: GcpApiGatewayApiConfig,
107108
[services.firestoreDatabase]: GcpFirestoreDatabase,
109+
[services.essentialContacts]: GcpEssentialContacts,
108110
label: GcpLabel,
109111
tag: GcpTag,
110112
}

src/enums/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default {
7575
// cloudShell: 'cloud-shell',
7676
// debug: 'debug',
7777
// deploymentManager: 'deployment-manager',
78-
// essentialContacts: 'essential-contacts',
78+
essentialContacts: 'essentialContacts',
7979
logBucket: 'logBucket',
8080
logMetric: 'logMetric',
8181
logSink: 'logSink',
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { EssentialContactsServiceClient } from '@google-cloud/essential-contacts'
2+
import { google } from '@google-cloud/essential-contacts/build/protos/protos'
3+
import CloudGraph from '@cloudgraph/sdk'
4+
import groupBy from 'lodash/groupBy'
5+
import gcpLoggerText from '../../properties/logger'
6+
import { GcpServiceInput } from '../../types'
7+
import { initTestEndpoint, generateGcpErrorLog } from '../../utils'
8+
import { GLOBAL_REGION } from '../../config/constants'
9+
10+
const lt = { ...gcpLoggerText }
11+
const { logger } = CloudGraph
12+
const serviceName = 'EssentialContacts'
13+
const apiEndpoint = initTestEndpoint(serviceName)
14+
15+
export interface RawGcpEssentialContact extends google.cloud.essentialcontacts.v1.IContact {
16+
id: string
17+
projectId: string
18+
region: string
19+
}
20+
21+
export default async ({
22+
config,
23+
}: GcpServiceInput): Promise<{
24+
[region: string]: RawGcpEssentialContact[]
25+
}> =>
26+
new Promise(async resolve => {
27+
const essentialContactList: RawGcpEssentialContact[] = []
28+
const { projectId } = config
29+
30+
/**
31+
* Get all EssentialContacts
32+
*/
33+
try {
34+
const essentialContactsClient = new EssentialContactsServiceClient({ ...config, apiEndpoint });
35+
const iterable = essentialContactsClient.listContactsAsync({
36+
parent: `projects/${projectId}`,
37+
})
38+
39+
for await (const response of iterable) {
40+
if (response) {
41+
essentialContactList.push({
42+
id: response.name,
43+
projectId,
44+
region: GLOBAL_REGION,
45+
...response,
46+
})
47+
}
48+
}
49+
} catch (error) {
50+
generateGcpErrorLog(serviceName, 'essentialContacts:listContactsAsync', error)
51+
}
52+
53+
logger.debug(lt.foundResources(serviceName, essentialContactList.length))
54+
resolve(groupBy(essentialContactList, 'region'))
55+
})
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { google } from '@google-cloud/essential-contacts/build/protos/protos'
2+
import { GcpEssentialContact } from '../../types/generated'
3+
import { RawGcpEssentialContact } from './data'
4+
import { toISOString } from '../../utils/dateutils'
5+
import { enumKeyToString } from '../../utils/format'
6+
7+
export default ({
8+
service,
9+
}: {
10+
service: RawGcpEssentialContact
11+
region: string
12+
}): GcpEssentialContact => {
13+
const {
14+
id,
15+
projectId,
16+
region,
17+
name,
18+
email,
19+
notificationCategorySubscriptions,
20+
languageTag,
21+
validationState,
22+
validateTime,
23+
} = service
24+
25+
return {
26+
id,
27+
projectId,
28+
region,
29+
name,
30+
email,
31+
notificationCategorySubscriptions: notificationCategorySubscriptions.map(subscription =>
32+
enumKeyToString(google.cloud.essentialcontacts.v1.NotificationCategory, subscription)
33+
),
34+
languageTag,
35+
validationState: enumKeyToString(google.cloud.essentialcontacts.v1.ValidationState, validationState),
36+
validateTime: toISOString(validateTime?.seconds?.toString()),
37+
}
38+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Service } from '@cloudgraph/sdk'
2+
import BaseService from '../base'
3+
import format from './format'
4+
import getData from './data'
5+
import mutation from './mutation'
6+
7+
export default class GcpEssentialContacts extends BaseService implements Service {
8+
format = format.bind(this)
9+
10+
getData = getData.bind(this)
11+
12+
mutation = mutation
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default `mutation($input: [AddgcpEssentialContactInput!]!) {
2+
addgcpEssentialContact(input: $input, upsert: true) {
3+
numUids
4+
}
5+
}`;

0 commit comments

Comments
 (0)