|
| 1 | +import "@azure-tools/typespec-azure-core"; |
| 2 | +import "@azure-tools/typespec-azure-resource-manager"; |
| 3 | +import "@typespec/rest"; |
| 4 | +import "./models.tsp"; |
| 5 | + |
| 6 | +using TypeSpec.Rest; |
| 7 | +using Azure.ResourceManager; |
| 8 | +using TypeSpec.Http; |
| 9 | +using TypeSpec.OpenAPI; |
| 10 | + |
| 11 | +namespace Microsoft.ScVmm; |
| 12 | +/** Define the virtualMachineInstance. */ |
| 13 | +@singleton |
| 14 | +model VirtualMachineInstance |
| 15 | + is ExtensionResource<VirtualMachineInstanceProperties> { |
| 16 | + /** Name of the virtual machine instance. */ |
| 17 | + @key |
| 18 | + @segment("virtualMachineInstances") |
| 19 | + @visibility("read") |
| 20 | + @maxLength(54) |
| 21 | + @minLength(1) |
| 22 | + @pattern("[a-zA-Z0-9-_\\.]") |
| 23 | + @path |
| 24 | + name: string; |
| 25 | + |
| 26 | + /** Gets or sets the extended location. */ |
| 27 | + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "This property is allowed but not recognized by the linter" |
| 28 | + @visibility("read", "create") |
| 29 | + extendedLocation: ExtendedLocation; |
| 30 | +} |
| 31 | + |
| 32 | +/** The type used for update operations of the VirtualMachineInstance. */ |
| 33 | +model VirtualMachineInstanceUpdate |
| 34 | + is UpdateableProperties<OmitProperties< |
| 35 | + VirtualMachineInstance, |
| 36 | + "properties" |
| 37 | + >> { |
| 38 | + /** The update properties of the VirtualMachineInstance. */ |
| 39 | + @extension("x-ms-client-flatten", true) |
| 40 | + properties?: VirtualMachineInstanceUpdateProperties; |
| 41 | +} |
| 42 | + |
| 43 | +/** Delete From Host */ |
| 44 | +union DeleteFromHost { |
| 45 | + /** Enable delete from host. */ |
| 46 | + `true`: "true", |
| 47 | + |
| 48 | + /** Disable delete from host. */ |
| 49 | + `false`: "false", |
| 50 | + |
| 51 | + string, |
| 52 | +} |
| 53 | + |
| 54 | +@armResourceOperations |
| 55 | +interface VirtualMachineInstances { |
| 56 | + /** Retrieves information about a virtual machine instance. */ |
| 57 | + @summary("Gets a virtual machine.") |
| 58 | + get is ArmResourceRead<VirtualMachineInstance>; |
| 59 | + /** The operation to create or update a virtual machine instance. Please note some properties can be set only during virtual machine instance creation. */ |
| 60 | + @summary("Implements virtual machine PUT method.") |
| 61 | + createOrUpdate is ArmResourceCreateOrUpdateAsync<VirtualMachineInstance>; |
| 62 | + /** The operation to update a virtual machine instance. */ |
| 63 | + @summary("Updates a virtual machine.") |
| 64 | + @extension( |
| 65 | + "x-ms-long-running-operation-options", |
| 66 | + { |
| 67 | + `final-state-via`: "azure-async-operation", |
| 68 | + } |
| 69 | + ) |
| 70 | + update is ArmCustomPatchAsync< |
| 71 | + VirtualMachineInstance, |
| 72 | + VirtualMachineInstanceUpdate |
| 73 | + >; |
| 74 | + /** The operation to delete a virtual machine instance. */ |
| 75 | + @summary("Deletes an virtual machine.") |
| 76 | + @extension( |
| 77 | + "x-ms-long-running-operation-options", |
| 78 | + { |
| 79 | + `final-state-via`: "azure-async-operation", |
| 80 | + } |
| 81 | + ) |
| 82 | + delete is ArmResourceDeleteWithoutOkAsync< |
| 83 | + VirtualMachineInstance, |
| 84 | + { |
| 85 | + ...Foundations.BaseParameters<VirtualMachineInstance>; |
| 86 | + ...QueryForceDelete; |
| 87 | + |
| 88 | + /** Whether to disable the VM from azure and also delete it from Vmm. */ |
| 89 | + @query("deleteFromHost") |
| 90 | + deleteFromHost?: DeleteFromHost; |
| 91 | + } |
| 92 | + >; |
| 93 | + /** Lists all of the virtual machine instances within the specified parent resource. */ |
| 94 | + @summary("Implements List virtual machine instances.") |
| 95 | + listByArm is ArmResourceListByParent<VirtualMachineInstance>; |
| 96 | + /** The operation to power off (stop) a virtual machine instance. */ |
| 97 | + @summary("Implements the operation to stop a virtual machine.") |
| 98 | + stop is ArmResourceActionNoResponseContentAsync< |
| 99 | + VirtualMachineInstance, |
| 100 | + StopVirtualMachineOptions |
| 101 | + >; |
| 102 | + /** The operation to start a virtual machine instance. */ |
| 103 | + @summary("Implements the operation to start a virtual machine.") |
| 104 | + start is ArmResourceActionNoResponseContentAsync< |
| 105 | + VirtualMachineInstance, |
| 106 | + void |
| 107 | + >; |
| 108 | + /** The operation to restart a virtual machine instance. */ |
| 109 | + @summary("Implements the operation to restart a virtual machine.") |
| 110 | + restart is ArmResourceActionNoResponseContentAsync< |
| 111 | + VirtualMachineInstance, |
| 112 | + void |
| 113 | + >; |
| 114 | + /** Creates a checkpoint in virtual machine instance. */ |
| 115 | + @summary("Implements the operation to creates a checkpoint in a virtual machine instance.") |
| 116 | + createCheckpoint is ArmResourceActionNoResponseContentAsync< |
| 117 | + VirtualMachineInstance, |
| 118 | + VirtualMachineCreateCheckpoint |
| 119 | + >; |
| 120 | + /** Deletes a checkpoint in virtual machine instance. */ |
| 121 | + @summary("Implements the operation to delete a checkpoint in a virtual machine instance.") |
| 122 | + deleteCheckpoint is ArmResourceActionNoResponseContentAsync< |
| 123 | + VirtualMachineInstance, |
| 124 | + VirtualMachineDeleteCheckpoint |
| 125 | + >; |
| 126 | + /** Restores to a checkpoint in virtual machine instance. */ |
| 127 | + @summary("Implements the operation to restores to a checkpoint in a virtual machine instance.") |
| 128 | + restoreCheckpoint is ArmResourceActionNoResponseContentAsync< |
| 129 | + VirtualMachineInstance, |
| 130 | + VirtualMachineRestoreCheckpoint |
| 131 | + >; |
| 132 | +} |
0 commit comments