vpc.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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