diff --git a/src/windows/WslcSDK/wslcsdk-winrt.idl b/src/windows/WslcSDK/wslcsdk-winrt.idl new file mode 100644 index 000000000..d8b055b78 --- /dev/null +++ b/src/windows/WslcSDK/wslcsdk-winrt.idl @@ -0,0 +1,348 @@ +/*++ + +Copyright (c) Microsoft. All rights reserved. + +Module Name: + + wslcsdk.idl + +Abstract: + + This file contains the public WSL Container SDK api definitions. + +--*/ + +namespace Microsoft.WSL.Containers +{ + [flags] + enum SessionFeatureFlags + { + None = 0x00000000, + EnableGpu = 0x00000004 + }; + + enum SessionTerminationReason + { + Unknown = 0, + Shutdown = 1, + Crashed = 2, + }; + + delegate void SessionTerminationHandler(Session session, SessionTerminationReason reason); + + runtimeclass SessionSettings + { + SessionSettings(String name, String storagePath); + + String Name { get; }; + String StoragePath { get; }; + + UInt32 CpuCount { get; set; }; + UInt32 MemoryMb { get; set; }; + UInt32 TimeoutMS { get; set; }; + VhdRequirements VhdRequirements { get; set; }; + SessionFeatureFlags FeatureFlags { get; set; }; + SessionTerminationHandler TerminationHandler { get; set; }; + }; + + runtimeclass Session + { + static Session Create(SessionSettings settings); + + void Terminate(); + + void PullImage(PullImageOptions options); + + // C# type: System.IO.Stream + void ImportImage(String imageName, Windows.Storage.Streams.IInputStream imageStream, ImportImageOptions options); + void ImportImageFromFile(String imageName, String path, ImportImageOptions options); + + // C# type: System.IO.Stream + void LoadImage(Windows.Storage.Streams.IInputStream imageStream, LoadImageOptions options); + void LoadImageFromFile(String path, LoadImageOptions options); + + void DeleteSessionImage(String nameOrId); + + void CreateSessionVhdVolume(VhdRequirements options); + void DeleteSessionVhdVolume(String name); + + // C# projected type: System.Collections.Generic.IReadOnlyList + IVectorView Images { get; }; + }; + + + enum ContainerNetworkingMode + { + None = 0, + Bridged = 1, + }; + + [flags] + enum ContainerFlags + { + None = 0x00000000, + AutoRemove = 0x00000001, + EnableGpu = 0x00000002, + Privileged = 0x00000004, + }; + + enum PortProtocol + { + TCP = 0, + UDP = 1, + }; + + runtimeclass ContainerPortMapping + { + ContainerPortMapping(UInt16 windowsPort, UInt16 containerPort, PortProtocol protocol); + + UInt16 WindowsPort { get; }; + UInt16 ContainerPort { get; }; + PortProtocol Protocol { get; }; + + // TODO sockaddr_storage* WindowsAddress { get; set; }; + }; + + runtimeclass ContainerVolume + { + ContainerVolume(String windowsPath, String containerPath, Boolean readOnly); + + String WindowsPath { get; }; + String ContainerPath { get; }; + Boolean ReadOnly { get; }; + }; + + runtimeclass ContainerNamedVolume + { + ContainerNamedVolume(String name, String containerPath, Boolean readOnly); + + String Name { get; }; + String ContainerPath { get; }; + Boolean ReadOnly { get; }; + }; + + [flags] + enum ContainerStartFlags + { + None = 0x00000000, + Attach = 0x00000001, + }; + + enum ContainerState + { + Invalid = 0, + Created = 1, + Running = 2, + Exited = 3, + Deleted = 4, + }; + + [flags] + enum DeleteContainerFlags + { + None = 0, + Force = 0x01 + }; + + runtimeclass ContainerSettings + { + ContainerSettings(String imageName); + + String ImageName { get; }; + + String Name { get; set; }; + ProcessSettings InitProcess { get; set; }; + ContainerNetworkingMode NetworkingMode { get; set; }; + String HostName { get; set; }; + String DomainName { get; set; }; + ContainerFlags Flags { get; set; }; + // C# projected type: System.Collections.Generic.IList + IVector PortMappings { get; set; }; + // C# projected type: System.Collections.Generic.IList + IVector Volumes { get; set; }; + // C# projected type: System.Collections.Generic.IList + IVector NamedVolumes { get; set; }; + }; + + enum Signal + { + None = 0, // No signal; reserved for future use + SIGHUP = 1, // SIGHUP: reload / hangup + SIGINT = 2, // SIGINT: interrupt (Ctrl-C) + SIGQUIT = 3, // SIGQUIT: quit with core dump + SIGKILL = 9, // SIGKILL: immediate termination + SIGTERM = 15, // SIGTERM: graceful shutdown + }; + + runtimeclass Container + { + static Container Create(Session session, ContainerSettings containerSettings); + + void Start(ContainerStartFlags flags); + void Stop(Signal signal, UInt32 timeoutSeconds); + void Delete(DeleteContainerFlags flags); + + Process CreateProcess(ProcessSettings newProcessSettings); + + String Inspect(); + + String Id { get; }; + Process InitProcess { get; }; + ContainerState State { get; }; + }; + + enum ProcessOutputHandle + { + StandardOutput = 1, + StandardError = 2, + }; + + delegate void ProcessOutputHandler(UInt8[] data); + + delegate void ProcessExitHandler(Process process, Int32 exitCode); + + runtimeclass ProcessEventHandlers + { + ProcessEventHandlers(); + + ProcessOutputHandler OnStdOut { get; set; }; + ProcessOutputHandler OnStdErr { get; set; }; + ProcessExitHandler OnExit { get; set; }; + }; + + runtimeclass ProcessSettings + { + ProcessSettings(); + + String CurrentDirectory { get; set; }; + // C# projected type: System.Collections.Generic.IList + IVector CmdLine { get; set; }; + // C# equivalent type: System.Collections.Specialized.StringDictionary + // C# projected type: System.Collections.Generic.IDictionary + IMap EnvironmentVariables { get; set; }; + ProcessEventHandlers EventHandlers { get; set; }; + }; + + enum ProcessState + { + Unknown = 0, + Running = 1, + Exited = 2, + Signalled = 3, + }; + + runtimeclass Process + { + UInt32 Pid { get; }; + ProcessState State { get; }; + Int32 ExitCode { get; }; + + void Signal(Signal signal); + // C# type: System.IO.Stream + Windows.Storage.Streams.IInputStream GetOutputStream(ProcessOutputHandle ioHandle); + // C# type: System.IO.Stream + Windows.Storage.Streams.IOutputStream GetInputStream(); + + event ProcessExitHandler Exited; + }; + + [flags] + enum ComponentFlags + { + None = 0, + VirtualMachinePlatform = 1, + WslPackage = 2, + }; + + struct Version + { + UInt32 Major; + UInt32 Minor; + UInt32 Revision; + }; + + delegate void InstallProgressHandler(ComponentFlags component, UInt32 progress, UInt32 total); + + runtimeclass WslcService + { + static Boolean CanRun(out ComponentFlags missingComponents); + static Version GetVersion(); + static void InstallWithDependencies(InstallProgressHandler progressCallback); + }; + + enum VhdType + { + Dynamic = 0, + Fixed = 1, + }; + + runtimeclass VhdRequirements + { + VhdRequirements(String name, UInt64 sizeInBytes, VhdType type); + + String Name { get; }; + UInt64 SizeInBytes { get; }; + VhdType Type { get; }; + }; + + struct ImageProgressDetail + { + UInt64 Current; + UInt64 Total; + }; + + enum ImageProgressStatus + { + Unknown = 0, + Pulling = 1, + Waiting = 2, + Downloading = 3, + Verifying = 4, + Extracting = 5, + Complete = 6, + }; + + struct ImageProgressMessage + { + String Id; + ImageProgressStatus Status; + ImageProgressDetail Detail; + }; + + delegate void ImageProgressHandler(ImageProgressMessage progress); + + runtimeclass RegistryAuthenticationInformation + { + // TBD + String Placeholder {get; set;}; + }; + + runtimeclass PullImageOptions + { + PullImageOptions(String uri); + + String Uri { get; }; + ImageProgressHandler ProgressHandler { get; set; }; + RegistryAuthenticationInformation AuthInfo { get; set; }; + }; + + runtimeclass ImportImageOptions + { + ImageProgressHandler ProgressHandler { get; set; }; + }; + runtimeclass LoadImageOptions + { + ImageProgressHandler ProgressHandler { get; set; }; + }; + + runtimeclass ImageInfo + { + String Name { get; }; + // C# equivalent type: byte[] + Windows.Storage.Streams.IBuffer Sha256 { get; }; + UInt64 SizeBytes { get; }; + // C# equivalent type: System.DateTime + // C# projected type: System.DateTimeOffset + Windows.Foundation.DateTime CreatedTimestamp { get; }; + }; +} \ No newline at end of file