vpc.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # frozen_string_literal: true
  2. require 'neo4j'
  3. # Provide Neo4J Model for VPCs
  4. class Vpc
  5. include Neo4j::ActiveNode
  6. property :vpc_id, constraint: :unique
  7. property :name
  8. property :cidr
  9. property :default
  10. property :state
  11. has_one :out, :region, rel_class: :VpcRegion
  12. has_one :out, :owned, rel_class: :AccountVpc
  13. has_many :out, :az, rel_class: :VpcAz
  14. end
  15. # Provide the subnet information
  16. class Subnet
  17. include Neo4j::ActiveNode
  18. property :subnet_id, constraint: :unique
  19. property :name
  20. property :cidr
  21. property :ip_count
  22. property :state
  23. has_one :out, :az, rel_class: :SubnetAz
  24. has_one :out, :subnet, rel_class: :VpcSubnet
  25. end
  26. ###############################################################################
  27. # Relationships go below here
  28. ###############################################################################
  29. # Provide Neo4J Model for VPC Owners
  30. class AccountVpc
  31. include Neo4j::ActiveRel
  32. from_class :Vpc
  33. to_class :AwsAccount
  34. type :owned
  35. end
  36. # Relationship between Subnet and VPC
  37. class VpcSubnet
  38. include Neo4j::ActiveRel
  39. from_class :Subnet
  40. to_class :Vpc
  41. type :subnet
  42. end
  43. # Relationship between the VPC and the Region
  44. class VpcRegion
  45. include Neo4j::ActiveRel
  46. from_class :Vpc
  47. to_class :Region
  48. type :region
  49. end
  50. # Relationship between the Subnet and the AZ
  51. class SubnetAz
  52. include Neo4j::ActiveRel
  53. from_class :Subnet
  54. to_class :Az
  55. type :az
  56. end