Skip to content

Commit 9a4de20

Browse files
Merge branch 'main' into feature/CG-664-ai-platform-notebook
2 parents b0b7785 + 261c099 commit 9a4de20

30 files changed

Lines changed: 525 additions & 113 deletions

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# [0.31.0](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/compare/0.30.0...0.31.0) (2022-02-18)
2+
3+
4+
### Bug Fixes
5+
6+
* **label:** pluralize secretManager ([853d37b](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/853d37bfd2854070998ca60d6e68d9e0721f7320))
7+
8+
9+
### Features
10+
11+
* **label/tag:** add labels/tags as services ([d07fdd5](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/d07fdd58530c2efb48ac55914179c8f84f64a182))
12+
13+
# [0.30.0](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/compare/0.29.0...0.30.0) (2022-02-16)
14+
15+
16+
### Features
17+
18+
* **firestore:** add firestore databasecd ([e692909](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/e69290991881b91f57165af4d418f5251eae6bb4))
19+
* **firestore:** add project connection ([6b93c39](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/commit/6b93c39186f7220453d6781117ffcb3cfde3de45))
20+
121
# [0.29.0](https://gitlab.com/auto-cloud/cloudgraph/provider/cloudgraph-provider-gcp/compare/0.28.2...0.29.0) (2022-02-11)
222

323

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ CloudGraph GCP Provider will ask you what regions you would like to crawl and wi
8787
| kmsCryptoKeys | aiPlatformNotebooks, iamPolicy, kmsKeyRing, project |
8888
| dnsManagedZone | project |
8989
| dnsPolicy | project, network |
90+
| firestores | project |
9091
| firewall | network, project |
9192
| folder | iamPolicy, organization, project |
9293
| kmsKeyRing | kmsCryptoKeys, project |

package.json

Lines changed: 3 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.29.0",
3+
"version": "0.31.0",
44
"description": "CloudGraph provider plugin for GCP used to fetch GCP cloud data.",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org/",
@@ -40,7 +40,9 @@
4040
"@google-cloud/bigquery-reservation": "^1.4.0",
4141
"@google-cloud/compute": "^3.0.0",
4242
"@google-cloud/dataproc": "^3.2.0",
43+
"@google-cloud/datastore": "^6.6.2",
4344
"@google-cloud/dns": "^2.2.3",
45+
"@google-cloud/firestore": "^5.0.2",
4446
"@google-cloud/functions": "^1.2.0",
4547
"@google-cloud/kms": "^2.10.0",
4648
"@google-cloud/logging": "^9.6.4",

src/enums/schemasMap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ export default {
4848
[services.dataprocJob]: 'gcpDataprocJob',
4949
[services.dataprocWorkflowTemplate]: 'gcpDataprocWorkflowTemplate',
5050
[services.aiPlatformNotebook]: 'gcpAiPlatformNotebook',
51+
[services.firestoreDatabase]: 'gcpFirestoreDatabase',
5152
tag: 'gcpTag',
5253
}

src/enums/serviceMap.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import GcpCdnUrlMap from '../services/cdnUrlMap'
1515
import GcpDnsManagedZone from '../services/dnsManagedZone'
1616
import GcpVpc from '../services/vpc'
1717
import GcpIam from '../services/iam'
18-
import GcpTag from '../services/tag'
1918
import GcpLogBucket from '../services/logBucket'
2019
import GcpLogSink from '../services/logSink'
2120
import GcpLogView from '../services/logView'
@@ -44,6 +43,9 @@ import GcpDataprocAutoscalingPolicy from '../services/dataprocAutoscalingPolicy'
4443
import GcpDataprocJob from '../services/dataprocJob'
4544
import GcpDataprocWorkflowTemplate from '../services/dataprocWorkflowTemplate'
4645
import GcpAiPlatformNotebook from '../services/aiPlatformNotebook'
46+
import GcpFirestoreDatabase from '../services/firestore'
47+
import GcpLabel from '../services/label'
48+
import GcpTag from '../services/tag'
4749

4850
/**
4951
* serviceMap is an object that contains all currently supported services
@@ -94,5 +96,7 @@ export default {
9496
[services.dataprocJob]: GcpDataprocJob,
9597
[services.dataprocWorkflowTemplate]: GcpDataprocWorkflowTemplate,
9698
[services.aiPlatformNotebook]: GcpAiPlatformNotebook,
99+
[services.firestoreDatabase]: GcpFirestoreDatabase,
100+
label: GcpLabel,
97101
tag: GcpTag,
98102
}

src/enums/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
bigQueryDataTransferRun: 'bigQueryDataTransferRun',
4848
// databaseMigration: 'database-migration',
4949
// datastore: 'datastore',
50-
// firestore: 'firestore',
50+
firestoreDatabase: 'firestoreDatabases',
5151
cloudRouter: 'cloudRouters',
5252
firewall: 'firewall',
5353
// spanner: 'spanner',
@@ -68,7 +68,7 @@ export default {
6868
// recaptcha: 'recaptcha',
6969
// resourceManager: 'resource-manager',
7070
// resourceSettings: 'resource-settings',
71-
secretManager: 'secretManager',
71+
secretManager: 'secrets',
7272
// iot: 'iot',
7373
// cloudShell: 'cloud-shell',
7474
// debug: 'debug',

src/services/alertPolicy/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default ({
3535
region,
3636
displayName,
3737
documentation,
38-
userLabels: formatLabelsFromMap(userLabels),
38+
labels: formatLabelsFromMap(userLabels),
3939
conditions: conditions?.map(condition => ({
4040
id: cuid(),
4141
name: condition?.name,

src/services/alertPolicy/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type gcpAlertPolicy implements gcpBaseResource @key(fields: "id") {
22
displayName: String @search(by: [hash, regexp])
33
documentation: gcpAlertPolicyDocumentation
4-
userLabels: [gcpRawLabel]
4+
labels: [gcpRawLabel]
55
conditions: [gcpAlertPolicyCondition]
66
combiner: String @search(by: [hash, regexp])
77
enabled: gcpBoolValue

src/services/firestore/data.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import CloudGraph from '@cloudgraph/sdk'
2+
import groupBy from 'lodash/groupBy'
3+
import { Datastore } from '@google-cloud/datastore'
4+
import gcpLoggerText from '../../properties/logger'
5+
import { GcpServiceInput } from '../../types'
6+
import { initTestEndpoint, generateGcpErrorLog } from '../../utils'
7+
import { GLOBAL_REGION } from '../../config/constants'
8+
import { listData } from '../../utils/fetchUtils'
9+
10+
const lt = { ...gcpLoggerText }
11+
const { logger } = CloudGraph
12+
const serviceName = 'Firestore Database'
13+
const apiEndpoint = initTestEndpoint(serviceName)
14+
15+
export interface RawGcpFirestoreDatabase {
16+
id: string
17+
projectId: string
18+
region: string
19+
name: string
20+
createTime: string
21+
updateTime: string
22+
locationId: string
23+
type: string
24+
concurrencyMode: string
25+
appEngineIntegrationMode: string
26+
keyPrefix: string
27+
}
28+
29+
export default async ({
30+
config,
31+
}: GcpServiceInput): Promise<{
32+
[region: string]: RawGcpFirestoreDatabase[]
33+
}> =>
34+
new Promise(async resolve => {
35+
const firestoreDatabaseList: RawGcpFirestoreDatabase[] = []
36+
const { projectId } = config
37+
38+
try {
39+
const service = new Datastore({ ...config, apiEndpoint })
40+
const data = await listData({
41+
accessToken: await service.auth.getAccessToken(),
42+
apiUri: `https://firestore.googleapis.com/v1/projects/${projectId}/databases`,
43+
dataFieldName: 'databases',
44+
})
45+
46+
for (const {name, createTime, updateTime, locationId, type, concurrencyMode, appEngineIntegrationMode, keyPrefix} of data) {
47+
firestoreDatabaseList.push({
48+
id: name,
49+
projectId,
50+
region: GLOBAL_REGION,
51+
name,
52+
createTime,
53+
updateTime,
54+
locationId,
55+
type,
56+
concurrencyMode,
57+
appEngineIntegrationMode,
58+
keyPrefix,
59+
})
60+
}
61+
} catch (error) {
62+
generateGcpErrorLog(serviceName, 'firestore:listDatabase', error)
63+
}
64+
65+
logger.debug(lt.foundResources(serviceName, firestoreDatabaseList.length))
66+
resolve(groupBy(firestoreDatabaseList, 'region'))
67+
})

src/services/firestore/format.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { GcpFirestoreDatabase } from '../../types/generated'
2+
import { RawGcpFirestoreDatabase } from './data'
3+
4+
export default ({
5+
service,
6+
}: {
7+
service: RawGcpFirestoreDatabase
8+
region: string
9+
}): GcpFirestoreDatabase => {
10+
const {
11+
id,
12+
projectId,
13+
region,
14+
name,
15+
createTime,
16+
updateTime,
17+
locationId,
18+
type,
19+
concurrencyMode,
20+
appEngineIntegrationMode,
21+
keyPrefix,
22+
} = service
23+
24+
return {
25+
id,
26+
projectId,
27+
region,
28+
name,
29+
createTime,
30+
updateTime,
31+
locationId,
32+
type,
33+
concurrencyMode,
34+
appEngineIntegrationMode,
35+
keyPrefix,
36+
}
37+
}

0 commit comments

Comments
 (0)