Skip to content

Commit c1ed872

Browse files
feat(camUser): merge alpha
2 parents c6162a6 + 8098b0b commit c1ed872

34 files changed

Lines changed: 1000 additions & 15 deletions

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
# [1.0.0-alpha.7](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/compare/1.0.0-alpha.6...1.0.0-alpha.7) (2022-06-02)
2+
3+
4+
### Features
5+
6+
* **camPolicy:** add camPolicy service ([3b8df16](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/3b8df166c3edd75f6b40f445f6a4375481d2f0ce))
7+
* **camPolicy:** add camPolicy service ([3596551](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/35965518ed7f32da4bf024d780d56828c5250c60))
8+
* **camPolicy:** add camPolicy service ([6c26c84](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/6c26c84f04399ce540f1c33a9e59bac3448def0c))
9+
* **camPolicy:** add tencent cam policy ([123b8dd](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/123b8dd376242fdf07e167f1c10045f13d607c58))
10+
11+
# [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)
12+
13+
14+
### Features
15+
16+
* **vpnConnection:** add vpnConnection service ([f2b0072](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/f2b0072e237e787c2bf0d11358003a7a126e15de))
17+
18+
# [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)
19+
20+
21+
### Features
22+
23+
* **networkAcl:** add networkAcl service ([3665d1e](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/3665d1e14782040d601152a252bd889e64fdef98))
24+
* **securityGroup:** add security group service ([5be1232](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/5be123281dca7d37e29e91617f03ece3b6a2b07c))
25+
* **securityGroupRule:** add securityGroupRule service ([c436eb8](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/c436eb8a15269f6738527a415421638f22e95193))
26+
27+
# [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)
28+
29+
30+
### Features
31+
32+
* **gatewayRoute:** merge alpha ([17d9777](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/17d9777c4a25f9b8ae6ea0799ee67e8a8281c8d7))
33+
* **vpnGatewayRoute:** add vpnGatewayRoute service ([ba42cbe](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/ba42cbe2c892dd5ebfc826c899445f2c42aefc05))
34+
* **vpnGatewayRoute:** add vpnGatewayRoute service ([f56783f](https://github.com/cloudgraphdev/cloudgraph-provider-tencent/commit/f56783f3f20b91bfe25af1dd959dd7ba4bccd0e6))
35+
136
# [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)
237

338

README.md

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

5757
| Service | Relations |
5858
| ------------------- | ------------------- |
59+
| camPolicy | |
5960
| camUser | |
60-
| customerGateway | |
61+
| ccn | ccnAttachment |
62+
| ccnAttachment | ccn |
63+
| customerGateway | vpnConnection |
64+
| networkAcl | subnet, vpc |
6165
| routeTable | vpc, subnet |
6266
| securityGroup | |
6367
| securityGroupRule | |
64-
| ccn | ccnAttachment |
65-
| ccnAttachment | ccn |
66-
| subnet | vpc, routeTable |
67-
| vpc | subnet, vpnGateway, routeTable |
68-
| vpnGateway | vpc |
68+
| subnet | networkAcl, vpc, routeTable |
69+
| vpc | networkAcl, subnet, vpnGateway, routeTable, vpnConnection |
70+
| vpnConnection | vpc, vpnGateway, customerGateway |
71+
| vpnGateway | vpc, vpnGatewayRoute, vpnConnection |
72+
| 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.3",
3+
"version": "1.0.0-alpha.7",
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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ import services from './services'
44
* schemasMap is an object that contains schemas name by resource
55
*/
66
export default {
7+
[services.camPolicy]: 'tencentCamPolicy',
78
[services.camUser]: 'tencentCamUser',
9+
[services.ccn]: 'tencentCcn',
10+
[services.ccnAttachment]: 'tencentCcnAttachment',
811
[services.customerGateway]: 'tencentCustomerGateway',
12+
[services.networkAcl]: 'tencentNetworkAcl',
913
[services.routeTable]: 'tencentRouteTable',
1014
[services.securityGroup]: 'tencentSecurityGroup',
1115
[services.securityGroupRule]: 'tencentSecurityGroupRule',
12-
[services.ccn]: 'tencentCcn',
13-
[services.ccnAttachment]: 'tencentCcnAttachment',
1416
[services.subnet]: 'tencentSubnet',
1517
[services.vpc]: 'tencentVpc',
18+
[services.vpnConnection]: 'tencentVpnConnection',
1619
[services.vpnGateway]: 'tencentVpnGateway',
20+
[services.vpnGatewayRoute]: 'tencentVpnGatewayRoute',
1721
tag: 'tencentTag',
1822
}

src/enums/serviceAliases.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
export default {
2-
routeTable: 'routeTables',
3-
securityGroup: 'securityGroups',
2+
camPolicy: 'camPolicies',
43
ccn: 'ccns',
54
ccnAttachment: 'ccnAttachments',
5+
customerGateway: 'customerGateways',
6+
routeTable: 'routeTables',
7+
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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'
@@ -8,23 +9,30 @@ import TencentVpc from '../services/vpc'
89
import TencentTag from '../services/tag'
910
import TencentRouteTable from '../services/routeTable'
1011
import TencentVpnGateway from '../services/vpnGateway'
12+
import TencentCamPolicy from '../services/camPolicy'
13+
import TencentVpnGatewayRoute from '../services/vpnGatewayRoute'
1114
import TencentCustomerGateway from '../services/customerGateway'
1215
import TencentCamUser from '../services/camUser'
16+
import TencentVpnConnection from '../services/vpnConnection'
1317

1418
/**
1519
* serviceMap is an object that contains all currently supported services
1620
* serviceMap is used by the serviceFactory to produce instances of service classes
1721
*/
1822
export default {
23+
[services.camPolicy]: TencentCamPolicy,
1924
[services.camUser]: TencentCamUser,
25+
[services.ccn]: TencentCcn,
26+
[services.ccnAttachment]: TencentCcnAttachment,
2027
[services.customerGateway]: TencentCustomerGateway,
28+
[services.networkAcl]: TencentNetworkAcl,
2129
[services.routeTable]: TencentRouteTable,
2230
[services.securityGroup]: TencentSecurityGroup,
2331
[services.securityGroupRule]: TencentSecurityGroupRule,
24-
[services.ccn]: TencentCcn,
25-
[services.ccnAttachment]: TencentCcnAttachment,
2632
[services.subnet]: TencentSubnet,
2733
[services.vpc]: TencentVpc,
34+
[services.vpnConnection]: TencentVpnConnection,
2835
[services.vpnGateway]: TencentVpnGateway,
36+
[services.vpnGatewayRoute]: TencentVpnGatewayRoute,
2937
tag: TencentTag,
3038
}

src/enums/services.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
export default {
2+
camPolicy: 'camPolicy',
23
camUser: 'camUser',
4+
ccn: 'ccn',
5+
ccnAttachment: 'ccnAttachment',
36
customerGateway: 'customerGateway',
7+
networkAcl: 'networkAcl',
48
routeTable: 'routeTable',
59
securityGroup: 'securityGroup',
610
securityGroupRule: 'securityGroupRule',
7-
ccn: 'ccn',
8-
ccnAttachment: 'ccnAttachment',
911
subnet: 'subnet',
1012
vpc: 'vpc',
13+
vpnConnection: 'vpnConnection',
1114
vpnGateway: 'vpnGateway',
15+
vpnGatewayRoute: 'vpnGatewayRoute',
1216
}

src/services/camPolicy/data.ts

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

src/services/camPolicy/format.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { TencentCamPolicy } from '../../types/generated'
2+
import { RawTencentCamPolicy } from './data'
3+
4+
export default ({
5+
service,
6+
region,
7+
}: {
8+
service: RawTencentCamPolicy
9+
region: string
10+
}): TencentCamPolicy => {
11+
const {
12+
id,
13+
PolicyId: policyId,
14+
PolicyName: name,
15+
AddTime: addTime,
16+
Type: type,
17+
Description: description,
18+
CreateMode: createMode,
19+
Attachments: attachments,
20+
ServiceType: serviceType,
21+
IsAttached: isAttached = 0,
22+
Deactived: deactived,
23+
DeactivedDetail: deactivedDetail,
24+
IsServiceLinkedPolicy: isServiceLinkedPolicy,
25+
AttachEntityCount: attachEntityCount,
26+
AttachEntityBoundaryCount: attachEntityBoundaryCount,
27+
UpdateTime: updateTime,
28+
} = service
29+
30+
return {
31+
id: `${id}`,
32+
policyId,
33+
region,
34+
name,
35+
addTime,
36+
type,
37+
description,
38+
createMode,
39+
attachments,
40+
serviceType,
41+
isAttached,
42+
deactived,
43+
deactivedDetail,
44+
isServiceLinkedPolicy,
45+
attachEntityCount,
46+
attachEntityBoundaryCount,
47+
updateTime,
48+
}
49+
}

src/services/camPolicy/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 TencentCamPolicy 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)