Skip to content

Commit

Permalink
Microsoft.ScVmm TypeSpec onboarding (#26644)
Browse files Browse the repository at this point in the history
* Init tsp for Microsoft.ScVmm

* Some changes towards passing tsv

* Updates to fix lint errors, remove unused types, regenerate examples, etc.

* Created shareable 'force' param

* Figured out the incantation to rename a file case-sensitively

* Restored string bool enums.

* Removed all examples

* Regenerate examples

* Updated ARM ID properties. Added script to sort output to compare with sorted old swagger

* Additional changes.

* Removed unused XXUpdate models, Added @secret for password,

* Fixed #8, #6, #5

* Fixed #2

* Update swagger to be in sync with previous fixes.

* Workaround for CloudCapacity readonly

* Additional fixes.

* fix ModelValidation

* update void

* VM Instance Update Properties changes

* spell check and prettier validation fix

* fix for identifier bug

* workaround for Azure/typespec-azure#449

* format

* spell and prettier check improvements

* use encodedName replace projectdName

* Add summary annotations

* summary

* update kind and void

* lro azure-async-operation

* fix

* tsp compilation warning

* TypeSpec Validation fix

* Update tspconfig.yaml

* config change

* Removed Read Only Property from Examples to fix Swagger ModelValidation

* Revert Boolean to Enum with type Union in TypeSpec

* specs-pr repo PR review changes to specs repo

* Remove sorted json file used for comparison

* Fix TypeSpec PR pipeline failure

* make extendedLocation for VM Instance read and create

* typespec validation fix

---------

Co-authored-by: Will Temple <will@wtemple.net>
Co-authored-by: Allen Zhang <allenzhang@live.com>
Co-authored-by: Alancere <804873052@qq.com>
Co-authored-by: Harshit Surana <hsurana@microsoft.com>
  • Loading branch information
5 people authored Jun 4, 2024
1 parent 12ff370 commit 0031475
Show file tree
Hide file tree
Showing 274 changed files with 13,455 additions and 4,638 deletions.
67 changes: 67 additions & 0 deletions specification/scvmm/ScVmm.Management/AvailabilitySet.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using OpenAPI;

namespace Microsoft.ScVmm;
/** The AvailabilitySets resource definition. */
model AvailabilitySet is TrackedResource<AvailabilitySetProperties> {
/** Name of the AvailabilitySet. */
@maxLength(54)
@minLength(1)
@pattern("[a-zA-Z0-9-_\\.]")
@path
@key("availabilitySetResourceName")
@segment("availabilitySets")
name: string;

/** The extended location. */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "This property is allowed but not recognized by the linter"
extendedLocation: ExtendedLocation;
}

@armResourceOperations
interface AvailabilitySets {
/** Implements AvailabilitySet GET method. */
@summary("Gets an AvailabilitySet.")
get is ArmResourceRead<AvailabilitySet>;
/** Onboards the ScVmm availability set as an Azure resource. */
@summary("Implements AvailabilitySets PUT method.")
createOrUpdate is ArmResourceCreateOrReplaceAsync<
AvailabilitySet,
LroHeaders = ArmAsyncOperationHeader &
Azure.Core.Foundations.RetryAfterHeader
>;
/** Updates the AvailabilitySets resource. */
@summary("Implements the AvailabilitySets PATCH method.")
@extension(
"x-ms-long-running-operation-options",
{
`final-state-via`: "azure-async-operation",
}
)
update is ArmTagsPatchAsync<AvailabilitySet>;
/** Deregisters the ScVmm availability set from Azure. */
@summary("Implements AvailabilitySet DELETE method.")
delete is ArmResourceDeleteWithoutOkAsync<
AvailabilitySet,
{
...Foundations.BaseParameters<AvailabilitySet>;
...QueryForceDelete;
},
LroHeaders = ArmAsyncOperationHeader &
ArmLroLocationHeader &
Azure.Core.Foundations.RetryAfterHeader
>;
/** List of AvailabilitySets in a resource group. */
@summary("Implements GET AvailabilitySets in a resource group.")
listByResourceGroup is ArmResourceListByParent<AvailabilitySet>;
/** List of AvailabilitySets in a subscription. */
@summary("Implements GET AvailabilitySets in a subscription.")
listBySubscription is ArmListBySubscription<AvailabilitySet>;
}
3 changes: 3 additions & 0 deletions specification/scvmm/ScVmm.Management/BackCompat.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "@azure-tools/typespec-azure-core";

@@visibility(Azure.Core.Page.nextLink, "read");
66 changes: 66 additions & 0 deletions specification/scvmm/ScVmm.Management/Cloud.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using OpenAPI;

namespace Microsoft.ScVmm;
/** The Clouds resource definition. */
model Cloud is TrackedResource<CloudProperties> {
/** Name of the Cloud. */
@maxLength(54)
@minLength(1)
@pattern("[a-zA-Z0-9-_\\.]")
@path
@key("cloudResourceName")
@segment("clouds")
name: string;

/** The extended location. */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "This property is allowed but not recognized by the linter"
extendedLocation: ExtendedLocation;
}

@armResourceOperations
interface Clouds {
/** Implements Cloud GET method. */
@summary("Gets a Cloud.")
get is ArmResourceRead<Cloud>;
/** Onboards the ScVmm fabric cloud as an Azure cloud resource. */
@summary("Implements Clouds PUT method.")
createOrUpdate is ArmResourceCreateOrReplaceAsync<Cloud>;
/** Updates the Clouds resource. */
@summary("Implements the Clouds PATCH method.")
@extension(
"x-ms-long-running-operation-options",
{
`final-state-via`: "azure-async-operation",
}
)
update is ArmTagsPatchAsync<Cloud>;
/** Deregisters the ScVmm fabric cloud from Azure. */
@summary("Implements Cloud resource DELETE method.")
@extension(
"x-ms-long-running-operation-options",
{
`final-state-via`: "azure-async-operation",
}
)
delete is ArmResourceDeleteWithoutOkAsync<
Cloud,
{
...Foundations.BaseParameters<Cloud>;
...QueryForceDelete;
}
>;
/** List of Clouds in a resource group. */
@summary("Implements GET Clouds in a resource group.")
listByResourceGroup is ArmResourceListByParent<Cloud>;
/** List of Clouds in a subscription. */
@summary("Implements GET Clouds in a subscription.")
listBySubscription is ArmListBySubscription<Cloud>;
}
41 changes: 41 additions & 0 deletions specification/scvmm/ScVmm.Management/GuestAgent.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./models.tsp";
import "./VirtualMachineInstance.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;

namespace Microsoft.ScVmm;
/** Defines the GuestAgent. */
@parentResource(VirtualMachineInstance)
@singleton
model GuestAgent is ProxyResource<GuestAgentProperties> {
/** Name of the guest agent. */
@key("guestAgentName")
@segment("guestAgents")
@visibility("read")
@maxLength(54)
@minLength(1)
@pattern("[a-zA-Z0-9-_\\.]")
@path
name: string;
}

@armResourceOperations
interface GuestAgents {
/** Implements GuestAgent GET method. */
@summary("Gets GuestAgent.")
get is ArmResourceRead<GuestAgent>;
/** Create Or Update GuestAgent. */
@summary("Implements GuestAgent PUT method.")
create is ArmResourceCreateOrReplaceAsync<GuestAgent>;
/** Implements GuestAgent DELETE method. */
@summary("Deletes a GuestAgent resource.")
delete is ArmResourceDeleteSync<GuestAgent>;
/** Returns the list of GuestAgent of the given vm. */
@summary("Implements GET GuestAgent in a vm.")
listByVirtualMachineInstance is ArmResourceListByParent<GuestAgent>;
}
41 changes: 41 additions & 0 deletions specification/scvmm/ScVmm.Management/InventoryItem.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./models.tsp";
import "./VmmServer.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;

namespace Microsoft.ScVmm;
/** Defines the inventory item. */
@parentResource(VmmServer)
model InventoryItem is ProxyResource<InventoryItemProperties> {
/** Name of the inventoryItem. */
@pattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
@path
@key("inventoryItemResourceName")
@segment("inventoryItems")
name: string;

/** Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "This property is allowed but not recognized by the linter"
kind?: string;
}

@armResourceOperations
interface InventoryItems {
/** Shows an inventory item. */
@summary("Implements GET InventoryItem method.")
get is ArmResourceRead<InventoryItem>;
/** Create Or Update InventoryItem. */
@summary("Implements InventoryItem PUT method.")
create is ArmResourceCreateOrReplaceSync<InventoryItem>;
/** Deletes an inventoryItem. */
@summary("Implements inventoryItem DELETE method.")
delete is ArmResourceDeleteSync<InventoryItem>;
/** Returns the list of inventoryItems in the given VmmServer. */
@summary("Implements GET for the list of Inventory Items in the VMMServer.")
listByVmmServer is ArmResourceListByParent<InventoryItem>;
}
132 changes: 132 additions & 0 deletions specification/scvmm/ScVmm.Management/VirtualMachineInstance.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.ScVmm;
/** Define the virtualMachineInstance. */
@singleton
model VirtualMachineInstance
is ExtensionResource<VirtualMachineInstanceProperties> {
/** Name of the virtual machine instance. */
@key
@segment("virtualMachineInstances")
@visibility("read")
@maxLength(54)
@minLength(1)
@pattern("[a-zA-Z0-9-_\\.]")
@path
name: string;

/** Gets or sets the extended location. */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "This property is allowed but not recognized by the linter"
@visibility("read", "create")
extendedLocation: ExtendedLocation;
}

/** The type used for update operations of the VirtualMachineInstance. */
model VirtualMachineInstanceUpdate
is UpdateableProperties<OmitProperties<
VirtualMachineInstance,
"properties"
>> {
/** The update properties of the VirtualMachineInstance. */
@extension("x-ms-client-flatten", true)
properties?: VirtualMachineInstanceUpdateProperties;
}

/** Delete From Host */
union DeleteFromHost {
/** Enable delete from host. */
`true`: "true",

/** Disable delete from host. */
`false`: "false",

string,
}

@armResourceOperations
interface VirtualMachineInstances {
/** Retrieves information about a virtual machine instance. */
@summary("Gets a virtual machine.")
get is ArmResourceRead<VirtualMachineInstance>;
/** The operation to create or update a virtual machine instance. Please note some properties can be set only during virtual machine instance creation. */
@summary("Implements virtual machine PUT method.")
createOrUpdate is ArmResourceCreateOrUpdateAsync<VirtualMachineInstance>;
/** The operation to update a virtual machine instance. */
@summary("Updates a virtual machine.")
@extension(
"x-ms-long-running-operation-options",
{
`final-state-via`: "azure-async-operation",
}
)
update is ArmCustomPatchAsync<
VirtualMachineInstance,
VirtualMachineInstanceUpdate
>;
/** The operation to delete a virtual machine instance. */
@summary("Deletes an virtual machine.")
@extension(
"x-ms-long-running-operation-options",
{
`final-state-via`: "azure-async-operation",
}
)
delete is ArmResourceDeleteWithoutOkAsync<
VirtualMachineInstance,
{
...Foundations.BaseParameters<VirtualMachineInstance>;
...QueryForceDelete;

/** Whether to disable the VM from azure and also delete it from Vmm. */
@query("deleteFromHost")
deleteFromHost?: DeleteFromHost;
}
>;
/** Lists all of the virtual machine instances within the specified parent resource. */
@summary("Implements List virtual machine instances.")
listByArm is ArmResourceListByParent<VirtualMachineInstance>;
/** The operation to power off (stop) a virtual machine instance. */
@summary("Implements the operation to stop a virtual machine.")
stop is ArmResourceActionNoResponseContentAsync<
VirtualMachineInstance,
StopVirtualMachineOptions
>;
/** The operation to start a virtual machine instance. */
@summary("Implements the operation to start a virtual machine.")
start is ArmResourceActionNoResponseContentAsync<
VirtualMachineInstance,
void
>;
/** The operation to restart a virtual machine instance. */
@summary("Implements the operation to restart a virtual machine.")
restart is ArmResourceActionNoResponseContentAsync<
VirtualMachineInstance,
void
>;
/** Creates a checkpoint in virtual machine instance. */
@summary("Implements the operation to creates a checkpoint in a virtual machine instance.")
createCheckpoint is ArmResourceActionNoResponseContentAsync<
VirtualMachineInstance,
VirtualMachineCreateCheckpoint
>;
/** Deletes a checkpoint in virtual machine instance. */
@summary("Implements the operation to delete a checkpoint in a virtual machine instance.")
deleteCheckpoint is ArmResourceActionNoResponseContentAsync<
VirtualMachineInstance,
VirtualMachineDeleteCheckpoint
>;
/** Restores to a checkpoint in virtual machine instance. */
@summary("Implements the operation to restores to a checkpoint in a virtual machine instance.")
restoreCheckpoint is ArmResourceActionNoResponseContentAsync<
VirtualMachineInstance,
VirtualMachineRestoreCheckpoint
>;
}
Loading

0 comments on commit 0031475

Please sign in to comment.