IDscModule.cs (4031B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="IDscModule.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.Management.Configuration.Processor.PowerShell.DscModules 8 { 9 using System.Collections.Generic; 10 using System.Management.Automation; 11 using Microsoft.Management.Configuration.Processor.PowerShell.DscResourcesInfo; 12 using Microsoft.PowerShell.Commands; 13 using Windows.Foundation.Collections; 14 15 /// <summary> 16 /// Interface for defining a PSDesiredStateConfiguration module. 17 /// </summary> 18 internal interface IDscModule 19 { 20 /// <summary> 21 /// Gets the module specification. 22 /// </summary> 23 ModuleSpecification ModuleSpecification { get; } 24 25 /// <summary> 26 /// Gets the name of the Get-DscResource Cmdlet. 27 /// </summary> 28 string GetDscResourceCmd { get; } 29 30 /// <summary> 31 /// Gets the name of the Invoke-DscResource Cmdlet. 32 /// </summary> 33 string InvokeDscResourceCmd { get; } 34 35 /// <summary> 36 /// Gets all DSC resource. 37 /// </summary> 38 /// <param name="pwsh">PowerShell.</param> 39 /// <returns>A list with the DSC resource.</returns> 40 IReadOnlyList<DscResourceInfoInternal> GetAllDscResources(PowerShell pwsh); 41 42 /// <summary> 43 /// Gets all resources in a module. 44 /// </summary> 45 /// <param name="pwsh">PowerShell.</param> 46 /// <param name="moduleSpecification">Module specification.</param> 47 /// <returns>List of resources of that module and version.</returns> 48 IReadOnlyList<DscResourceInfoInternal> GetDscResourcesInModule(PowerShell pwsh, ModuleSpecification moduleSpecification); 49 50 /// <summary> 51 /// Gets a DSC Resource. 52 /// </summary> 53 /// <param name="pwsh">PowerShell.</param> 54 /// <param name="name">Name.</param> 55 /// <param name="moduleSpecification">Module specification.</param> 56 /// <returns>DSC Resource from that module and version.</returns> 57 DscResourceInfoInternal? GetDscResource(PowerShell pwsh, string name, ModuleSpecification? moduleSpecification); 58 59 /// <summary> 60 /// Calls Invoke-DscResource -Method Get from this module. 61 /// </summary> 62 /// <param name="pwsh">PowerShell.</param> 63 /// <param name="settings">Settings.</param> 64 /// <param name="name">Name.</param> 65 /// <param name="moduleSpecification">Module specification.</param> 66 /// <returns>Properties of resource.</returns> 67 ValueSet InvokeGetResource(PowerShell pwsh, ValueSet settings, string name, ModuleSpecification? moduleSpecification); 68 69 /// <summary> 70 /// Calls Invoke-DscResource -Method Test from this module. 71 /// </summary> 72 /// <param name="pwsh">PowerShell.</param> 73 /// <param name="settings">Settings.</param> 74 /// <param name="name">Name.</param> 75 /// <param name="moduleSpecification">Module specification.</param> 76 /// <returns>Is in desired state.</returns> 77 bool InvokeTestResource(PowerShell pwsh, ValueSet settings, string name, ModuleSpecification? moduleSpecification); 78 79 /// <summary> 80 /// Calls Invoke-DscResource -Method Set from this module. 81 /// </summary> 82 /// <param name="pwsh">PowerShell.</param> 83 /// <param name="settings">Settings.</param> 84 /// <param name="name">Name.</param> 85 /// <param name="moduleSpecification">Module specification.</param> 86 /// <returns>If a reboot is required.</returns> 87 bool InvokeSetResource(PowerShell pwsh, ValueSet settings, string name, ModuleSpecification? moduleSpecification); 88 } 89 }