2025-11-28 00:35:46 +09:00

284 lines
14 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<ResourceMetadata xmlns="http://schemas.microsoft.com/powershell-web-services/2010/09">
<SchemaNamespace>VMSystem</SchemaNamespace>
<ContainerName>MyContainer</ContainerName>
<Resources>
<Resource>
<!--PhysicalMachine set will be addressed as PhysicalMachines from the client side-->
<RelativeUrl>PhysicalMachines</RelativeUrl>
<Class>VMSystem_PhysicalMachine</Class>
</Resource>
<Resource>
<RelativeUrl>VirtualMachines</RelativeUrl>
<Class>VMSystem_VirtualMachine</Class>
</Resource>
<Resource>
<RelativeUrl>Systems</RelativeUrl>
<Class>VMSystem_System</Class>
</Resource>
</Resources>
<ClassImplementations>
<Class>
<Name>VMSystem_PhysicalMachine</Name>
<CmdletImplementation>
<Query>
<Cmdlet>Get-PhysicalMachine</Cmdlet>
<FieldParameterMap>
<Field>
<FieldName>Name</FieldName>
<ParameterName>MachineName</ParameterName>
</Field>
</FieldParameterMap>
<ParameterSets>
<ParameterSet>
<Name>Default</Name>
<Parameter>
<Name>MachineName</Name>
</Parameter>
</ParameterSet>
</ParameterSets>
</Query>
<Associations>
<!--Navigation property does not include any Add/Remove reference cmdlets, so VMs cannot be added or removed using navigation property -->
<NavigationProperty>
<Name>VMs</Name>
<!--Property type = Instance indicate that the foreign keys will be embedded inside an instance.
For getting associated VMs, collection of foreign keys is extracted from this navigation property inside PhysicalMachine entity instance
and Get-VM method is called for each VM-->
<PropertyType>Instance</PropertyType>
</NavigationProperty>
</Associations>
</CmdletImplementation>
</Class>
<Class>
<Name>VMSystem_VirtualMachine</Name>
<CmdletImplementation>
<Query>
<Cmdlet>Get-VM</Cmdlet>
<FieldParameterMap>
<Field>
<FieldName>MachineName</FieldName>
<ParameterName>MachineName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>VmId</ParameterName>
</Field>
</FieldParameterMap>
<ParameterSets>
<ParameterSet>
<Name>Default</Name>
<Parameter>
<Name>MachineName</Name>
</Parameter>
<Parameter>
<Name>VmId</Name>
</Parameter>
</ParameterSet>
</ParameterSets>
</Query>
<Create>
<Cmdlet>New-VM</Cmdlet>
<FieldParameterMap>
<Field>
<FieldName>MachineName</FieldName>
<ParameterName>MachineName</ParameterName>
</Field>
<Field>
<FieldName>OS</FieldName>
<ParameterName>OperatingSystem</ParameterName>
</Field>
</FieldParameterMap>
<ParameterSets>
<ParameterSet>
<Name>Default</Name>
<Parameter>
<Name>MachineName</Name>
</Parameter>
<Parameter>
<Name>OperatingSystem</Name>
</Parameter>
</ParameterSet>
</ParameterSets>
</Create>
<Update>
<Cmdlet>Set-VM</Cmdlet>
<FieldParameterMap>
<Field>
<FieldName>MachineName</FieldName>
<ParameterName>MachineName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>VmId</ParameterName>
</Field>
<Field>
<FieldName>OS</FieldName>
<ParameterName>OperatingSystem</ParameterName>
</Field>
</FieldParameterMap>
<ParameterSets>
<ParameterSet>
<Name>Default</Name>
<Parameter>
<Name>MachineName</Name>
</Parameter>
<Parameter>
<Name>VmId</Name>
</Parameter>
<Parameter>
<Name>OperatingSystem</Name>
</Parameter>
</ParameterSet>
</ParameterSets>
</Update>
<Delete>
<Cmdlet>Remove-VM</Cmdlet>
<FieldParameterMap>
<Field>
<FieldName>MachineName</FieldName>
<ParameterName>MachineName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>VmId</ParameterName>
</Field>
</FieldParameterMap>
<ParameterSets>
<ParameterSet>
<Name>Default</Name>
<Parameter>
<Name>MachineName</Name>
</Parameter>
<Parameter>
<Name>VmId</Name>
</Parameter>
</ParameterSet>
</ParameterSets>
</Delete>
<Associations>
<!--Navigation property points to a reference instance not a reference set. So it cannot have Get/Add/Remove reference cmdlet associated with it-->
<NavigationProperty>
<Name>System</Name>
<!--Property type = Instance indicate that the foreign keys will be embedded inside an instance
The other option KeyOnly is applicable only for Entity types with simple key and System entity has compound key, so it can have only Instance type-->
<PropertyType>Instance</PropertyType>
</NavigationProperty>
<!--Navigation property points to a reference instance not a reference set. So it cannot have Get/Add/Remove reference cmdlet associated with it-->
<NavigationProperty>
<Name>PhysicalMachine</Name>
<!--PropertyType=Instance means that the VirtualMachine's "PhysicalMachine" property is a .NET object; its sub-property named "Name" is the name of the physical machine (i.e., its key).
PropertyType=KeyOnly would mean that the VirtualMachine's "PhysicalMachine" property is a simple string containing the name of the physical machine.
Other option could have been KeyOnly. In that case the PhysicalMachine navigation points to foreign key of the PhysicalMachine entity instance-->
<PropertyType>Instance</PropertyType>
</NavigationProperty>
</Associations>
</CmdletImplementation>
</Class>
<Class>
<Name>VMSystem_System</Name>
<CmdletImplementation>
<Query>
<Cmdlet>Get-System</Cmdlet>
<FieldParameterMap>
<Field>
<FieldName>Name</FieldName>
<ParameterName>SystemName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>SystemId</ParameterName>
</Field>
</FieldParameterMap>
<ParameterSets>
<ParameterSet>
<Name>Default</Name>
<Parameter>
<Name>SystemName</Name>
</Parameter>
<Parameter>
<Name>SystemId</Name>
</Parameter>
</ParameterSet>
</ParameterSets>
</Query>
<Associations>
<NavigationProperty>
<Name>VMs</Name>
<!--Navigation property contains a GetReference cmdlet, so GET operation for associated virtual machines triggers an invocation of Get-VMForSystem cmdlet
This cmdlet accepts key of System entity instance-->
<GetReference>
<Cmdlet>Get-VMForSystem</Cmdlet>
<!--Mapping of System instance keys to the cmdlet parameters-->
<ParameterForThisObject>
<Field>
<FieldName>Name</FieldName>
<ParameterName>SystemName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>SystemId</ParameterName>
</Field>
</ParameterForThisObject>
</GetReference>
<!--Navigation property contains a AddReference cmdlet, so addition of a virtual machine instance result into invocation of Add-VMToSystem cmdlet.
This cmdlet accepts key of System entity instance and key of virtual machine to be added-->
<AddReference>
<Cmdlet>Add-VMToSystem</Cmdlet>
<!--Mapping of System entity instance keys and cmdlet parameters-->
<ParameterForThisObject>
<Field>
<FieldName>Name</FieldName>
<ParameterName>SystemName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>SystemId</ParameterName>
</Field>
</ParameterForThisObject>
<!--Mapping of VirtualMachine entity instance keys and cmdlet parameters-->
<ParameterForReferredObject>
<Field>
<FieldName>MachineName</FieldName>
<ParameterName>MachineName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>VmId</ParameterName>
</Field>
</ParameterForReferredObject>
</AddReference>
<!--Navigation property contains a RemoveReference cmdlet, so removal of a virtual machine instance result into invocation of Remove-VMFromSystem cmdlet
This cmdlet accepts key of System entity instance and key of virtual machine to be removed-->
<RemoveReference>
<Cmdlet>Remove-VMFromSystem</Cmdlet>
<!--Mapping of System entity instance keys and cmdlet parameters-->
<ParameterForThisObject>
<Field>
<FieldName>Name</FieldName>
<ParameterName>SystemName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>SystemId</ParameterName>
</Field>
</ParameterForThisObject>
<!--Mapping of VirtualMachine entity instance keys and cmdlet parameters-->
<ParameterForReferredObject>
<Field>
<FieldName>MachineName</FieldName>
<ParameterName>MachineName</ParameterName>
</Field>
<Field>
<FieldName>Id</FieldName>
<ParameterName>VmId</ParameterName>
</Field>
</ParameterForReferredObject>
</RemoveReference>
</NavigationProperty>
</Associations>
</CmdletImplementation>
</Class>
</ClassImplementations>
</ResourceMetadata>