File tree Expand file tree Collapse file tree 5 files changed +51
-0
lines changed Expand file tree Collapse file tree 5 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { ServiceConnection } from '@cloudgraph/sdk'
2
+ import { RawTencentRouteTable } from './data'
3
+ import services from '../../enums/services'
4
+ import aliases from '../../enums/serviceAliases'
5
+
6
+ export default ( {
7
+ service,
8
+ data,
9
+ region,
10
+ } : {
11
+ service : RawTencentRouteTable
12
+ data : { name : string ; data : { [ property : string ] : any [ ] } } [ ]
13
+ region : string
14
+ } ) : {
15
+ [ property : string ] : ServiceConnection [ ]
16
+ } => {
17
+ const { id } = service
18
+ const connections : ServiceConnection [ ] = [ ]
19
+
20
+ const subnetSets = service . AssociationSet . map ( ( { SubnetId} ) => SubnetId )
21
+
22
+ const instances : {
23
+ name : string
24
+ data : { [ property : string ] : any [ ] }
25
+ } = data . find ( ( { name } ) => name === services . subnet )
26
+
27
+ if ( instances ?. data ?. [ region ] ) {
28
+ for ( const service of instances . data [ region ] ) {
29
+ if ( subnetSets . includes ( service . id ) ) {
30
+ connections . push ( {
31
+ id : service . id ,
32
+ resourceType : services . subnet ,
33
+ relation : 'child' ,
34
+ field : aliases [ services . subnet ]
35
+ } )
36
+ }
37
+ }
38
+ }
39
+
40
+ const result = {
41
+ [ id ] : connections ,
42
+ }
43
+ return result
44
+ }
Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ import { Service } from '@cloudgraph/sdk'
2
2
import BaseService from '../base'
3
3
import format from './format'
4
4
import getData , { serviceName } from './data'
5
+ import getConnections from './connections'
5
6
import { getMutation } from '../../utils'
6
7
7
8
export default class TencentRouteTable extends BaseService implements Service {
8
9
format = format . bind ( this )
9
10
10
11
getData = getData . bind ( this )
12
+
13
+ getConnections = getConnections . bind ( this )
11
14
12
15
mutation = getMutation ( serviceName )
13
16
}
Original file line number Diff line number Diff line change @@ -54,4 +54,5 @@ type tencentRouteTable implements tencentBaseService @key(fields: "id") {
54
54
tags : [tencentRawTag ]
55
55
localCidrForCcn : [tencentRouteTableLocalCidrForCcnn ]
56
56
vpcInstances : [tencentVpc ] @hasInverse (field : routeTables )
57
+ subnets : [tencentSubnet ] @hasInverse (field : routeTables )
57
58
}
Original file line number Diff line number Diff line change @@ -15,4 +15,5 @@ type tencentSubnet implements tencentBaseService @key(fields: "id") {
15
15
cdcId : String @search (by : [hash , regexp ])
16
16
isCdcSubnet : Int @search
17
17
vpcInstances : [tencentVpc ] @hasInverse (field : subnets )
18
+ routeTables : [tencentRouteTable ] @hasInverse (field : subnets )
18
19
}
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export type TencentRouteTable = TencentBaseService & {
37
37
routeSet ?: Maybe < Array < Maybe < TencentRouteTableRoute > > > ;
38
38
routeTableId ?: Maybe < Scalars [ 'String' ] > ;
39
39
routeTableName ?: Maybe < Scalars [ 'String' ] > ;
40
+ subnets ?: Maybe < Array < Maybe < TencentSubnet > > > ;
40
41
tags ?: Maybe < Array < Maybe < TencentRawTag > > > ;
41
42
vpcInstances ?: Maybe < Array < Maybe < TencentVpc > > > ;
42
43
} ;
@@ -82,6 +83,7 @@ export type TencentSubnet = TencentBaseService & {
82
83
name ?: Maybe < Scalars [ 'String' ] > ;
83
84
networkAclId ?: Maybe < Scalars [ 'String' ] > ;
84
85
routeTableId ?: Maybe < Scalars [ 'String' ] > ;
86
+ routeTables ?: Maybe < Array < Maybe < TencentRouteTable > > > ;
85
87
tags ?: Maybe < Array < Maybe < TencentRawTag > > > ;
86
88
totalIpAddressCount ?: Maybe < Scalars [ 'Int' ] > ;
87
89
vpcInstances ?: Maybe < Array < Maybe < TencentVpc > > > ;
You can’t perform that action at this time.
0 commit comments