File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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'
22import BaseService from '../base'
33import format from './format'
44import getData , { serviceName } from './data'
5+ import getConnections from './connections'
56import { getMutation } from '../../utils'
67
78export default class TencentRouteTable extends BaseService implements Service {
89 format = format . bind ( this )
910
1011 getData = getData . bind ( this )
12+
13+ getConnections = getConnections . bind ( this )
1114
1215 mutation = getMutation ( serviceName )
1316}
Original file line number Diff line number Diff line change @@ -54,4 +54,5 @@ type tencentRouteTable implements tencentBaseService @key(fields: "id") {
5454 tags : [tencentRawTag ]
5555 localCidrForCcn : [tencentRouteTableLocalCidrForCcnn ]
5656 vpcInstances : [tencentVpc ] @hasInverse (field : routeTables )
57+ subnets : [tencentSubnet ] @hasInverse (field : routeTables )
5758}
Original file line number Diff line number Diff line change @@ -15,4 +15,5 @@ type tencentSubnet implements tencentBaseService @key(fields: "id") {
1515 cdcId : String @search (by : [hash , regexp ])
1616 isCdcSubnet : Int @search
1717 vpcInstances : [tencentVpc ] @hasInverse (field : subnets )
18+ routeTables : [tencentRouteTable ] @hasInverse (field : subnets )
1819}
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export type TencentRouteTable = TencentBaseService & {
3737 routeSet ?: Maybe < Array < Maybe < TencentRouteTableRoute > > > ;
3838 routeTableId ?: Maybe < Scalars [ 'String' ] > ;
3939 routeTableName ?: Maybe < Scalars [ 'String' ] > ;
40+ subnets ?: Maybe < Array < Maybe < TencentSubnet > > > ;
4041 tags ?: Maybe < Array < Maybe < TencentRawTag > > > ;
4142 vpcInstances ?: Maybe < Array < Maybe < TencentVpc > > > ;
4243} ;
@@ -82,6 +83,7 @@ export type TencentSubnet = TencentBaseService & {
8283 name ?: Maybe < Scalars [ 'String' ] > ;
8384 networkAclId ?: Maybe < Scalars [ 'String' ] > ;
8485 routeTableId ?: Maybe < Scalars [ 'String' ] > ;
86+ routeTables ?: Maybe < Array < Maybe < TencentRouteTable > > > ;
8587 tags ?: Maybe < Array < Maybe < TencentRawTag > > > ;
8688 totalIpAddressCount ?: Maybe < Scalars [ 'Int' ] > ;
8789 vpcInstances ?: Maybe < Array < Maybe < TencentVpc > > > ;
You can’t perform that action at this time.
0 commit comments