Skip to content

Commit 17d9777

Browse files
feat(gatewayRoute): merge alpha
2 parents ba42cbe + b4a985a commit 17d9777

19 files changed

Lines changed: 449 additions & 4 deletions

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# [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)
2+
3+
4+
### Features
5+
6+
* **customerGateway:** add customerGateway service ([cdee2e8](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/cdee2e85baa41ce5364051641345af0563e2601f))
7+
8+
# [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)
9+
10+
11+
### Features
12+
13+
* **routeTable:** add connection from routeTable to subnet ([6a34907](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/6a3490754dc5da4aa3ebe68072b2f6fe5063130b))
14+
* **routeTable:** add routeTable ([112f1d5](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/112f1d561208e122b36b51e842f2802cf1ee76be))
15+
* **routeTable:** add routeTable service ([76ff05a](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/76ff05ac8cb7cad4ccdf68b5d74633248a350aa8))
16+
* **routeTable:** update README ([f32ffec](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/f32ffecf3e67551826fae5025b3c2bf0e2a1feb4))
17+
* **routeTable:** update README ([3fd9c90](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/3fd9c9080b6ee007ec598b86b108f301e34e41af))
18+
119
# 1.0.0-alpha.1 (2022-05-16)
220

321

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ CloudGraph Tencent Provider will ask you what regions you would like to crawl an
5656

5757
| Service | Relations |
5858
| ------------------- | ------------------- |
59+
| customerGateway | |
60+
| routeTable | vpc, subnet |
5961
| securityGroup | |
6062
| securityGroupRule | |
6163
| ccn | ccnAttachment |
6264
| ccnAttachment | ccn |
63-
| subnet | vpc |
64-
| vpc | subnet, vpnGateway |
65+
| subnet | vpc, routeTable |
66+
| vpc | subnet, vpnGateway, routeTable |
6567
| vpnGateway | vpc, vpnGatewayRoute |
66-
| vpnGatewayRoute | vpnGateway |
68+
| 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.3",
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import services from './services'
44
* schemasMap is an object that contains schemas name by resource
55
*/
66
export default {
7+
[services.customerGateway]: 'tencentCustomerGateway',
8+
[services.routeTable]: 'tencentRouteTable',
79
[services.securityGroup]: 'tencentSecurityGroup',
810
[services.securityGroupRule]: 'tencentSecurityGroupRule',
911
[services.ccn]: 'tencentCcn',

src/enums/serviceAliases.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export default {
2+
routeTable: 'routeTables',
23
securityGroup: 'securityGroups',
34
ccn: 'ccns',
45
ccnAttachment: 'ccnAttachments',

src/enums/serviceMap.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ import TencentCcnAttachment from '../services/ccnAttachment'
66
import TencentSubnet from '../services/subnet'
77
import TencentVpc from '../services/vpc'
88
import TencentTag from '../services/tag'
9+
import TencentRouteTable from '../services/routeTable'
910
import TencentVpnGateway from '../services/vpnGateway'
1011
import TencentVpnGatewayRoute from '../services/vpnGatewayRoute'
12+
import TencentCustomerGateway from '../services/customerGateway'
1113

1214
/**
1315
* serviceMap is an object that contains all currently supported services
1416
* serviceMap is used by the serviceFactory to produce instances of service classes
1517
*/
1618
export default {
19+
[services.customerGateway]: TencentCustomerGateway,
20+
[services.routeTable]: TencentRouteTable,
1721
[services.securityGroup]: TencentSecurityGroup,
1822
[services.securityGroupRule]: TencentSecurityGroupRule,
1923
[services.ccn]: TencentCcn,

src/enums/services.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export default {
2+
customerGateway: 'customerGateway',
3+
routeTable: 'routeTable',
24
securityGroup: 'securityGroup',
35
securityGroupRule: 'securityGroupRule',
46
ccn: 'ccn',
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+
}
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+
}

0 commit comments

Comments
 (0)