|
| 1 | +private import bicep |
| 2 | +private import Network |
| 3 | + |
| 4 | +/** |
| 5 | + * A resource of type Microsoft.Compute/virtualMachines |
| 6 | + */ |
| 7 | +module Compute { |
| 8 | + class ComputeResource extends Resource { |
| 9 | + ComputeResource() { this.getResourceType().regexpMatch("^Microsoft.Compute/.*") } |
| 10 | + } |
| 11 | + |
| 12 | + /** |
| 13 | + * A resource of type Microsoft.Compute/virtualMachines |
| 14 | + * https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines |
| 15 | + */ |
| 16 | + class VirtualMachines extends ComputeResource { |
| 17 | + VirtualMachines() { |
| 18 | + this.getResourceType().regexpMatch("^Microsoft.Compute/virtualMachines@.*") |
| 19 | + } |
| 20 | + |
| 21 | + override string toString() { result = "VirtualMachines Resource" } |
| 22 | + |
| 23 | + VirtualMachinesProperties::Properties getProperties() { |
| 24 | + result = this.getProperty("properties") |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * The the hardware network interfaces of the virtual machine |
| 29 | + */ |
| 30 | + Network::NetworkInterfaces getNetworkInterfaces() { |
| 31 | + result = this.getProperties().getNetworkProfile().getNetworkInterfaces() |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * The properties module for Microsoft.Compute/virtualMachines |
| 37 | + */ |
| 38 | + module VirtualMachinesProperties { |
| 39 | + /** |
| 40 | + * The properties object for the Microsoft.Compute/virtualMachines type |
| 41 | + */ |
| 42 | + class Properties extends Object { |
| 43 | + private VirtualMachines virtualMachines; |
| 44 | + |
| 45 | + Properties() { this = virtualMachines.getProperty("properties") } |
| 46 | + |
| 47 | + VirtualMachines getVirtualMachine() { result = virtualMachines } |
| 48 | + |
| 49 | + HardwareProfile getHardwareProfile() { result = this.getProperty("hardwareProfile") } |
| 50 | + |
| 51 | + NetworkProfile getNetworkProfile() { result = this.getProperty("networkProfile") } |
| 52 | + |
| 53 | + OsProfile getOsProfile() { result = this.getProperty("osProfile") } |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * The hardwareProfile property object for the Microsoft.Compute/virtualMachines type |
| 58 | + */ |
| 59 | + class HardwareProfile extends Object { |
| 60 | + private Properties properties; |
| 61 | + |
| 62 | + HardwareProfile() { this = properties.getProperty("hardwareProfile") } |
| 63 | + |
| 64 | + string toString() { result = "HardwareProfile" } |
| 65 | + |
| 66 | + Expr getVmSize() { result = this.getProperty("vmSize") } |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * A NetworkProfile for the Microsoft.Compute/virtualMachines type |
| 71 | + */ |
| 72 | + class NetworkProfile extends Object { |
| 73 | + private Properties properties; |
| 74 | + |
| 75 | + NetworkProfile() { this = properties.getProperty("networkProfile") } |
| 76 | + |
| 77 | + string toString() { result = "NetworkProfile" } |
| 78 | + |
| 79 | + Network::NetworkInterfaces getNetworkInterfaces() { |
| 80 | + result = resolveResource(this.getNetworkInterfacesObject()) |
| 81 | + } |
| 82 | + |
| 83 | + private Object getNetworkInterfacesObject() { |
| 84 | + result = this.getProperty("networkInterfaces").(Array).getElements() |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + */ |
| 90 | + class StorageProfile extends Object { |
| 91 | + private Properties properties; |
| 92 | + |
| 93 | + StorageProfile() { this = properties.getProperty("storageProfile") } |
| 94 | + |
| 95 | + ImageReference getImageReference() { result = this.getProperty("imageReference") } |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * A ImageReference for the Microsoft.Compute/virtualMachines type |
| 100 | + * https://learn.microsoft.com/en-us/azure/templates/microsoft.compute/virtualmachines?pivots=deployment-language-bicep#imagereference |
| 101 | + */ |
| 102 | + class ImageReference extends Object { |
| 103 | + private StorageProfile storageProfile; |
| 104 | + |
| 105 | + ImageReference() { this = storageProfile.getProperty("imageReference") } |
| 106 | + |
| 107 | + Expr getPublisher() { result = this.getProperty("publisher") } |
| 108 | + |
| 109 | + Expr getOffer() { result = this.getProperty("offer") } |
| 110 | + |
| 111 | + Expr getSku() { result = this.getProperty("sku") } |
| 112 | + |
| 113 | + Expr getVersion() { result = this.getProperty("version") } |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * The OsProfile object for the Microsoft.Compute/virtualMachines type |
| 118 | + */ |
| 119 | + class OsProfile extends Object { |
| 120 | + private Properties properties; |
| 121 | + |
| 122 | + OsProfile() { this = properties.getProperty("osProfile") } |
| 123 | + |
| 124 | + Expr getComputerName() { result = this.getProperty("computerName") } |
| 125 | + |
| 126 | + Expr getAdminUsername() { result = this.getProperty("adminUsername") } |
| 127 | + |
| 128 | + Expr getAdminPassword() { result = this.getProperty("adminPassword") } |
| 129 | + } |
| 130 | + } |
| 131 | +} |
0 commit comments