ResourceListItem.cs (4057B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="ResourceListItem.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.Management.Configuration.Processor.DSCv3.Schema_2024_04.Outputs 8 { 9 using System.Text.Json.Nodes; 10 using System.Text.Json.Serialization; 11 using Microsoft.Management.Configuration.Processor.DSCv3.Model; 12 13 /// <summary> 14 /// The object type from a single JSON line output by the `resource list` command. 15 /// </summary> 16 internal class ResourceListItem : IResourceListItem 17 { 18 /// <summary> 19 /// Gets or sets the type of the resource. 20 /// Should match the regex "^\\w+(\\.\\w+){0,2}\\/\\w+$". 21 /// </summary> 22 [JsonRequired] 23 required public string Type { get; set; } 24 25 /// <summary> 26 /// Gets or sets the kind of the resource. 27 /// </summary> 28 public Definitions.ResourceKind Kind { get; set; } = Definitions.ResourceKind.Unknown; 29 30 /// <inheritdoc /> 31 [JsonIgnore] 32 Model.ResourceKind IResourceListItem.Kind => this.Kind switch 33 { 34 Definitions.ResourceKind.Unknown => Model.ResourceKind.Unknown, 35 Definitions.ResourceKind.Resource => Model.ResourceKind.Resource, 36 Definitions.ResourceKind.Adapter => Model.ResourceKind.Adapter, 37 Definitions.ResourceKind.Group => Model.ResourceKind.Group, 38 Definitions.ResourceKind.Import => Model.ResourceKind.Importer, 39 _ => throw new System.IO.InvalidDataException($"Unknown ResourceKind: {this.Kind}") 40 }; 41 42 /// <summary> 43 /// Gets or sets the version of the resource. 44 /// This is a semver version. 45 /// </summary> 46 public string? Version { get; set; } 47 48 /// <summary> 49 /// Gets or sets the capabilities of the resource. 50 /// </summary> 51 [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1010:Opening square brackets should be spaced correctly", Justification = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3687 pending SC 1.2 release")] 52 public ResourceCapability[] Capabilities { get; set; } = []; 53 54 /// <summary> 55 /// Gets or sets the description of the resource. 56 /// </summary> 57 public string? Description { get; set; } 58 59 /// <summary> 60 /// Gets or sets the path to the resource definition file. 61 /// </summary> 62 public string? Path { get; set; } 63 64 /// <summary> 65 /// Gets or sets the path to the directory containing the resource. 66 /// </summary> 67 public string? Directory { get; set; } 68 69 /// <summary> 70 /// Gets or sets a value that indicates implementation details of the resource. 71 /// </summary> 72 public JsonNode? ImplementedAs { get; set; } 73 74 /// <summary> 75 /// Gets or sets the author of the resource. 76 /// </summary> 77 public string? Author { get; set; } 78 79 /// <summary> 80 /// Gets or sets the names of the properties of the resource. 81 /// </summary> 82 [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1010:Opening square brackets should be spaced correctly", Justification = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3687 pending SC 1.2 release")] 83 public string[] Properties { get; set; } = []; 84 85 /// <summary> 86 /// Gets or sets the adapter required by the resource. 87 /// </summary> 88 public string? RequireAdapter { get; set; } 89 90 /// <summary> 91 /// Gets or sets the resource definition manifest. 92 /// </summary> 93 public JsonObject? Manifest { get; set; } 94 } 95 }