Skip to content

Commit 3596551

Browse files
feat(camPolicy): add camPolicy service
2 parents 6c26c84 + c3b1747 commit 3596551

38 files changed

+1267
-4
lines changed

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
# [1.0.0-alpha.6](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/compare/1.0.0-alpha.5...1.0.0-alpha.6) (2022-05-31)
2+
3+
4+
### Features
5+
6+
* **vpnConnection:** add vpnConnection service ([f2b0072](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/f2b0072e237e787c2bf0d11358003a7a126e15de))
7+
8+
# [1.0.0-alpha.5](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/compare/1.0.0-alpha.4...1.0.0-alpha.5) (2022-05-26)
9+
10+
11+
### Features
12+
13+
* **networkAcl:** add networkAcl service ([3665d1e](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/3665d1e14782040d601152a252bd889e64fdef98))
14+
* **securityGroup:** add security group service ([5be1232](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/5be123281dca7d37e29e91617f03ece3b6a2b07c))
15+
* **securityGroupRule:** add securityGroupRule service ([c436eb8](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/c436eb8a15269f6738527a415421638f22e95193))
16+
17+
# [1.0.0-alpha.4](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/compare/1.0.0-alpha.3...1.0.0-alpha.4) (2022-05-24)
18+
19+
20+
### Features
21+
22+
* **gatewayRoute:** merge alpha ([17d9777](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/17d9777c4a25f9b8ae6ea0799ee67e8a8281c8d7))
23+
* **vpnGatewayRoute:** add vpnGatewayRoute service ([ba42cbe](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/ba42cbe2c892dd5ebfc826c899445f2c42aefc05))
24+
* **vpnGatewayRoute:** add vpnGatewayRoute service ([f56783f](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/f56783f3f20b91bfe25af1dd959dd7ba4bccd0e6))
25+
26+
# [1.0.0-alpha.3](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/compare/1.0.0-alpha.2...1.0.0-alpha.3) (2022-05-19)
27+
28+
29+
### Features
30+
31+
* **customerGateway:** add customerGateway service ([cdee2e8](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/cdee2e85baa41ce5364051641345af0563e2601f))
32+
33+
# [1.0.0-alpha.2](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/compare/1.0.0-alpha.1...1.0.0-alpha.2) (2022-05-18)
34+
35+
36+
### Features
37+
38+
* **routeTable:** add connection from routeTable to subnet ([6a34907](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/6a3490754dc5da4aa3ebe68072b2f6fe5063130b))
39+
* **routeTable:** add routeTable ([112f1d5](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/112f1d561208e122b36b51e842f2802cf1ee76be))
40+
* **routeTable:** add routeTable service ([76ff05a](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/76ff05ac8cb7cad4ccdf68b5d74633248a350aa8))
41+
* **routeTable:** update README ([f32ffec](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/f32ffecf3e67551826fae5025b3c2bf0e2a1feb4))
42+
* **routeTable:** update README ([3fd9c90](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/3fd9c9080b6ee007ec598b86b108f301e34e41af))
43+
144
# 1.0.0-alpha.1 (2022-05-16)
245

346

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ CloudGraph Tencent Provider will ask you what regions you would like to crawl an
5959
| camPolicy | |
6060
| ccn | ccnAttachment |
6161
| ccnAttachment | ccn |
62+
| customerGateway | vpnConnection |
63+
| networkAcl | subnet, vpc |
64+
| routeTable | vpc, subnet |
6265
| securityGroup | |
6366
| securityGroupRule | |
64-
| subnet | vpc |
65-
| vpc | subnet, vpnGateway |
66-
| vpnGateway | vpc |
67+
| subnet | networkAcl, vpc, routeTable |
68+
| vpc | networkAcl, subnet, vpnGateway, routeTable, vpnConnection |
69+
| vpnConnection | vpc, vpnGateway, customerGateway |
70+
| vpnGateway | vpc, vpnGatewayRoute, vpnConnection |
71+
| vpnGatewayRoute | vpnGateway |

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudgraph/cg-provider-tencent",
3-
"version": "1.0.0-alpha.1",
3+
"version": "1.0.0-alpha.6",
44
"description": "CloudGraph provider plugin for Tencent Cloud used to fetch Tencent Cloud data.",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org/",

src/enums/schemasMap.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ export default {
77
[services.camPolicy]: 'tencentCamPolicy',
88
[services.ccn]: 'tencentCcn',
99
[services.ccnAttachment]: 'tencentCcnAttachment',
10+
[services.customerGateway]: 'tencentCustomerGateway',
11+
[services.networkAcl]: 'tencentNetworkAcl',
12+
[services.routeTable]: 'tencentRouteTable',
1013
[services.securityGroup]: 'tencentSecurityGroup',
1114
[services.securityGroupRule]: 'tencentSecurityGroupRule',
1215
[services.subnet]: 'tencentSubnet',
1316
[services.vpc]: 'tencentVpc',
17+
[services.vpnConnection]: 'tencentVpnConnection',
1418
[services.vpnGateway]: 'tencentVpnGateway',
19+
[services.vpnGatewayRoute]: 'tencentVpnGatewayRoute',
1520
tag: 'tencentTag',
1621
}

src/enums/serviceAliases.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ export default {
22
camPolicy: 'camPolicies',
33
ccn: 'ccns',
44
ccnAttachment: 'ccnAttachments',
5+
customerGateway: 'customerGateways',
6+
routeTable: 'routeTables',
57
securityGroup: 'securityGroups',
68
subnet: 'subnets',
79
vpc: 'vpcInstances',
10+
vpnConnection: 'vpnConnections',
811
vpnGateway: 'vpnGateways',
12+
vpnGatewayRoute: 'vpnGatewayRoutes',
913
}

src/enums/serviceMap.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import services from './services'
2+
import TencentNetworkAcl from '../services/networkAcl'
23
import TencentSecurityGroup from '../services/securityGroup'
34
import TencentSecurityGroupRule from '../services/securityGroupRule'
45
import TencentCcn from '../services/ccn'
56
import TencentCcnAttachment from '../services/ccnAttachment'
67
import TencentSubnet from '../services/subnet'
78
import TencentVpc from '../services/vpc'
89
import TencentTag from '../services/tag'
10+
import TencentRouteTable from '../services/routeTable'
911
import TencentVpnGateway from '../services/vpnGateway'
1012
import TencentCamPolicy from '../services/camPolicy'
13+
import TencentVpnGatewayRoute from '../services/vpnGatewayRoute'
14+
import TencentCustomerGateway from '../services/customerGateway'
15+
import TencentVpnConnection from '../services/vpnConnection'
1116

1217
/**
1318
* serviceMap is an object that contains all currently supported services
@@ -17,10 +22,15 @@ export default {
1722
[services.camPolicy]: TencentCamPolicy,
1823
[services.ccn]: TencentCcn,
1924
[services.ccnAttachment]: TencentCcnAttachment,
25+
[services.customerGateway]: TencentCustomerGateway,
26+
[services.networkAcl]: TencentNetworkAcl,
27+
[services.routeTable]: TencentRouteTable,
2028
[services.securityGroup]: TencentSecurityGroup,
2129
[services.securityGroupRule]: TencentSecurityGroupRule,
2230
[services.subnet]: TencentSubnet,
2331
[services.vpc]: TencentVpc,
32+
[services.vpnConnection]: TencentVpnConnection,
2433
[services.vpnGateway]: TencentVpnGateway,
34+
[services.vpnGatewayRoute]: TencentVpnGatewayRoute,
2535
tag: TencentTag,
2636
}

src/enums/services.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ export default {
22
camPolicy: 'camPolicy',
33
ccn: 'ccn',
44
ccnAttachment: 'ccnAttachment',
5+
customerGateway: 'customerGateway',
6+
routeTable: 'routeTable',
7+
networkAcl: 'networkAcl',
58
securityGroup: 'securityGroup',
69
securityGroupRule: 'securityGroupRule',
710
subnet: 'subnet',
811
vpc: 'vpc',
12+
vpnConnection: 'vpnConnection',
913
vpnGateway: 'vpnGateway',
14+
vpnGatewayRoute: 'vpnGatewayRoute',
1015
}

src/services/customerGateway/data.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import * as tencentcloud from 'tencentcloud-sdk-nodejs'
2+
import { CustomerGateway, Tag } from 'tencentcloud-sdk-nodejs/tencentcloud/services/vpc/v20170312/vpc_models'
3+
import { ClientConfig } from 'tencentcloud-sdk-nodejs/tencentcloud/common/interface'
4+
import CloudGraph from '@cloudgraph/sdk'
5+
import groupBy from 'lodash/groupBy'
6+
import isEmpty from 'lodash/isEmpty'
7+
import loggerText from '../../properties/logger'
8+
import { TencentServiceInput } from '../../types'
9+
import { initTestEndpoint, generateTencentErrorLog } from '../../utils'
10+
11+
const lt = { ...loggerText }
12+
const { logger } = CloudGraph
13+
export const serviceName = 'CustomerGateway'
14+
const apiEndpoint = initTestEndpoint(serviceName)
15+
16+
export interface RawTencentCustomerGateway extends CustomerGateway {
17+
id: string
18+
region: string
19+
TagSet: Array<Tag>
20+
}
21+
22+
export default async ({
23+
regions,
24+
config,
25+
}: TencentServiceInput): Promise<{
26+
[region: string]: RawTencentCustomerGateway[]
27+
}> =>
28+
new Promise(async resolve => {
29+
const customerGatewayList: RawTencentCustomerGateway[] = []
30+
31+
for (const region of regions.split(',')) {
32+
/**
33+
* Get all the vpn gateways
34+
*/
35+
try {
36+
const VpcClient = tencentcloud.vpc.v20170312.Client
37+
const clientConfig: ClientConfig = { credential: config, region, profile: { httpProfile: { endpoint: apiEndpoint } } }
38+
const vpc = new VpcClient(clientConfig)
39+
const response = await vpc.DescribeCustomerGateways(null)
40+
41+
if (response && !isEmpty(response.CustomerGatewaySet)) {
42+
for (const instance of response.CustomerGatewaySet) {
43+
customerGatewayList.push({
44+
id: instance.CustomerGatewayId,
45+
...instance,
46+
region,
47+
TagSet: (instance as any).TagSet,
48+
})
49+
}
50+
}
51+
52+
} catch (error) {
53+
generateTencentErrorLog(serviceName, 'vpc:DescribeCustomerGateways', error)
54+
}
55+
}
56+
57+
logger.debug(lt.foundResources(serviceName, customerGatewayList.length))
58+
resolve(groupBy(customerGatewayList, 'region'))
59+
})
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { TencentCustomerGateway } from '../../types/generated'
2+
import { formatTagSet } from '../../utils/format'
3+
import { RawTencentCustomerGateway } from './data'
4+
5+
export default ({
6+
service,
7+
region,
8+
}: {
9+
service: RawTencentCustomerGateway
10+
region: string
11+
}): TencentCustomerGateway=> {
12+
const {
13+
id,
14+
CustomerGatewayName: name,
15+
IpAddress: ipAddress,
16+
CreatedTime: createdTime,
17+
TagSet,
18+
} = service
19+
20+
return {
21+
id,
22+
region,
23+
name,
24+
ipAddress,
25+
createdTime,
26+
tags: formatTagSet(TagSet),
27+
}
28+
}

src/services/customerGateway/index.ts

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, { serviceName } from './data'
5+
import { getMutation } from '../../utils'
6+
7+
export default class TencentCustomerGateway extends BaseService implements Service {
8+
format = format.bind(this)
9+
10+
getData = getData.bind(this)
11+
12+
mutation = getMutation(serviceName)
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type tencentCustomerGateway implements tencentBaseService @key(fields: "id") {
2+
name: String @search(by: [hash, regexp])
3+
ipAddress: String @search(by: [hash, regexp])
4+
createdTime: String @search(by: [hash, regexp])
5+
tags: [tencentRawTag]
6+
vpnConnections: [tencentVpnConnection] @hasInverse(field: customerGateways)
7+
}

src/services/networkAcl/data.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import * as tencentcloud from 'tencentcloud-sdk-nodejs'
2+
import { NetworkAcl } from 'tencentcloud-sdk-nodejs/tencentcloud/services/vpc/v20170312/vpc_models'
3+
import { ClientConfig } from 'tencentcloud-sdk-nodejs/tencentcloud/common/interface'
4+
import CloudGraph from '@cloudgraph/sdk'
5+
import groupBy from 'lodash/groupBy'
6+
import isEmpty from 'lodash/isEmpty'
7+
import loggerText from '../../properties/logger'
8+
import { TencentServiceInput } from '../../types'
9+
import { initTestEndpoint, generateTencentErrorLog } from '../../utils'
10+
11+
const lt = { ...loggerText }
12+
const { logger } = CloudGraph
13+
export const serviceName = 'NetworkAcl'
14+
const apiEndpoint = initTestEndpoint(serviceName)
15+
16+
export interface RawTencentNetworkAcl extends NetworkAcl {
17+
id: string
18+
region: string
19+
subnets: string[]
20+
}
21+
22+
export default async ({
23+
regions,
24+
config,
25+
}: TencentServiceInput): Promise<{
26+
[region: string]: RawTencentNetworkAcl[]
27+
}> =>
28+
new Promise(async resolve => {
29+
const naclList: RawTencentNetworkAcl[] = []
30+
31+
for (const region of regions.split(',')) {
32+
/**
33+
* Get all NetworkACLs
34+
*/
35+
try {
36+
const VpcClient = tencentcloud.vpc.v20170312.Client
37+
const clientConfig: ClientConfig = { credential: config, region, profile: { httpProfile: { endpoint: apiEndpoint } } }
38+
const vpc = new VpcClient(clientConfig)
39+
const response = await vpc.DescribeNetworkAcls(null)
40+
41+
if (response && !isEmpty(response.NetworkAclSet)) {
42+
for (const instance of response.NetworkAclSet) {
43+
naclList.push({
44+
id: instance.NetworkAclId,
45+
...instance,
46+
subnets: instance?.SubnetSet?.map(subnet => subnet.SubnetId),
47+
region,
48+
})
49+
}
50+
}
51+
} catch (error) {
52+
generateTencentErrorLog(serviceName, 'vpc:DescribeNetworkAcls', error)
53+
}
54+
}
55+
56+
logger.debug(lt.foundResources(serviceName, naclList.length))
57+
resolve(groupBy(naclList, 'region'))
58+
})

src/services/networkAcl/format.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import cuid from 'cuid'
2+
import { TencentNetworkAcl } from '../../types/generated'
3+
import { RawTencentNetworkAcl } from './data'
4+
5+
export default ({
6+
service,
7+
account,
8+
region,
9+
}: {
10+
service: RawTencentNetworkAcl
11+
account: string
12+
region: string
13+
}): TencentNetworkAcl => {
14+
const {
15+
id,
16+
NetworkAclName: name,
17+
VpcId: vpcId,
18+
CreatedTime: createdTime,
19+
IngressEntries,
20+
EgressEntries,
21+
} = service
22+
23+
return {
24+
id,
25+
region,
26+
name,
27+
vpcId,
28+
createdTime,
29+
ingressEntries: IngressEntries?.map(naclEntry => ({
30+
id: cuid(),
31+
...naclEntry,
32+
})),
33+
egressEntries: EgressEntries?.map(naclEntry => ({
34+
id: cuid(),
35+
...naclEntry,
36+
})),
37+
}
38+
}

src/services/networkAcl/index.ts

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, { serviceName } from './data'
5+
import { getMutation } from '../../utils'
6+
7+
export default class TencentNetworkAcl extends BaseService implements Service {
8+
format = format.bind(this)
9+
10+
getData = getData.bind(this)
11+
12+
mutation = getMutation(serviceName)
13+
}

0 commit comments

Comments
 (0)