|
| 1 | +// Licensed to Elasticsearch B.V under one or more agreements. |
| 2 | +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. |
| 3 | +// See the LICENSE file in the project root for more information |
| 4 | + |
| 5 | +using System.Text; |
| 6 | +using YamlDotNet.Serialization; |
| 7 | + |
| 8 | +namespace Elastic.Documentation.AppliesTo; |
| 9 | + |
| 10 | +[YamlSerializable] |
| 11 | +public record ProductApplicability |
| 12 | +{ |
| 13 | + [YamlMember(Alias = "ecctl")] |
| 14 | + public AppliesCollection? Ecctl { get; set; } |
| 15 | + |
| 16 | + [YamlMember(Alias = "curator")] |
| 17 | + public AppliesCollection? Curator { get; set; } |
| 18 | + |
| 19 | + [YamlMember(Alias = "apm-agent-android")] |
| 20 | + public AppliesCollection? ApmAgentAndroid { get; set; } |
| 21 | + |
| 22 | + [YamlMember(Alias = "apm-agent-dotnet")] |
| 23 | + public AppliesCollection? ApmAgentDotnet { get; set; } |
| 24 | + |
| 25 | + [YamlMember(Alias = "apm-agent-go")] |
| 26 | + public AppliesCollection? ApmAgentGo { get; set; } |
| 27 | + |
| 28 | + [YamlMember(Alias = "apm-agent-ios")] |
| 29 | + public AppliesCollection? ApmAgentIos { get; set; } |
| 30 | + |
| 31 | + [YamlMember(Alias = "apm-agent-java")] |
| 32 | + public AppliesCollection? ApmAgentJava { get; set; } |
| 33 | + |
| 34 | + [YamlMember(Alias = "apm-agent-node")] |
| 35 | + public AppliesCollection? ApmAgentNode { get; set; } |
| 36 | + |
| 37 | + [YamlMember(Alias = "apm-agent-php")] |
| 38 | + public AppliesCollection? ApmAgentPhp { get; set; } |
| 39 | + |
| 40 | + [YamlMember(Alias = "apm-agent-python")] |
| 41 | + public AppliesCollection? ApmAgentPython { get; set; } |
| 42 | + |
| 43 | + [YamlMember(Alias = "apm-agent-ruby")] |
| 44 | + public AppliesCollection? ApmAgentRuby { get; set; } |
| 45 | + |
| 46 | + [YamlMember(Alias = "apm-agent-rum-js")] |
| 47 | + public AppliesCollection? ApmAgentRumJs { get; set; } |
| 48 | + |
| 49 | + [YamlMember(Alias = "edot-ios")] |
| 50 | + public AppliesCollection? EdotIos { get; set; } |
| 51 | + |
| 52 | + [YamlMember(Alias = "edot-android")] |
| 53 | + public AppliesCollection? EdotAndroid { get; set; } |
| 54 | + |
| 55 | + [YamlMember(Alias = "edot-dotnet")] |
| 56 | + public AppliesCollection? EdotDotnet { get; set; } |
| 57 | + |
| 58 | + [YamlMember(Alias = "edot-java")] |
| 59 | + public AppliesCollection? EdotJava { get; set; } |
| 60 | + |
| 61 | + [YamlMember(Alias = "edot-node")] |
| 62 | + public AppliesCollection? EdotNode { get; set; } |
| 63 | + |
| 64 | + [YamlMember(Alias = "edot-php")] |
| 65 | + public AppliesCollection? EdotPhp { get; set; } |
| 66 | + |
| 67 | + [YamlMember(Alias = "edot-python")] |
| 68 | + public AppliesCollection? EdotPython { get; set; } |
| 69 | + |
| 70 | + [YamlMember(Alias = "edot-cf-aws")] |
| 71 | + public AppliesCollection? EdotCfAws { get; set; } |
| 72 | + |
| 73 | + [YamlMember(Alias = "edot-cf-azure")] |
| 74 | + public AppliesCollection? EdotCfAzure { get; set; } |
| 75 | + |
| 76 | + [YamlMember(Alias = "edot-cf-gcp")] |
| 77 | + public AppliesCollection? EdotCfGcp { get; set; } |
| 78 | + |
| 79 | + [YamlMember(Alias = "edot-collector")] |
| 80 | + public AppliesCollection? EdotCollector { get; set; } |
| 81 | + |
| 82 | + /// <inheritdoc /> |
| 83 | + public override string ToString() |
| 84 | + { |
| 85 | + var sb = new StringBuilder(); |
| 86 | + var hasContent = false; |
| 87 | + |
| 88 | + void AppendProduct(string name, AppliesCollection? value) |
| 89 | + { |
| 90 | + if (value is null) |
| 91 | + return; |
| 92 | + if (hasContent) |
| 93 | + _ = sb.Append(": not null } => "); |
| 94 | + _ = sb.Append(name).Append('=').Append(value); |
| 95 | + hasContent = true; |
| 96 | + } |
| 97 | + |
| 98 | + AppendProduct("ecctl", Ecctl); |
| 99 | + AppendProduct("curator", Curator); |
| 100 | + AppendProduct("apm-agent-android", ApmAgentAndroid); |
| 101 | + AppendProduct("apm-agent-dotnet", ApmAgentDotnet); |
| 102 | + AppendProduct("apm-agent-go", ApmAgentGo); |
| 103 | + AppendProduct("apm-agent-ios", ApmAgentIos); |
| 104 | + AppendProduct("apm-agent-java", ApmAgentJava); |
| 105 | + AppendProduct("apm-agent-node", ApmAgentNode); |
| 106 | + AppendProduct("apm-agent-php", ApmAgentPhp); |
| 107 | + AppendProduct("apm-agent-python", ApmAgentPython); |
| 108 | + AppendProduct("apm-agent-ruby", ApmAgentRuby); |
| 109 | + AppendProduct("apm-agent-rum-js", ApmAgentRumJs); |
| 110 | + AppendProduct("edot-ios", EdotIos); |
| 111 | + AppendProduct("edot-android", EdotAndroid); |
| 112 | + AppendProduct("edot-dotnet", EdotDotnet); |
| 113 | + AppendProduct("edot-java", EdotJava); |
| 114 | + AppendProduct("edot-node", EdotNode); |
| 115 | + AppendProduct("edot-php", EdotPhp); |
| 116 | + AppendProduct("edot-python", EdotPython); |
| 117 | + AppendProduct("edot-cf-aws", EdotCfAws); |
| 118 | + AppendProduct("edot-cf-azure", EdotCfAzure); |
| 119 | + AppendProduct("edot-cf-gcp", EdotCfGcp); |
| 120 | + AppendProduct("edot-collector", EdotCollector); |
| 121 | + |
| 122 | + return sb.ToString(); |
| 123 | + } |
| 124 | +} |
| 125 | + |
| 126 | +public static class ProductApplicabilityConversion |
| 127 | +{ |
| 128 | + public static string? ProductApplicabilityToProductId(ProductApplicability p) => p switch |
| 129 | + { |
| 130 | + { Ecctl: not null } => "cloud-control-ecctl", |
| 131 | + { Curator: not null } => "curator", |
| 132 | + { ApmAgentAndroid: not null } => "edot-android", |
| 133 | + { ApmAgentDotnet: not null } => "apm-agent-dotnet", |
| 134 | + { ApmAgentGo: not null } => "apm-agent-go", |
| 135 | + { ApmAgentIos: not null } => "edot-ios", |
| 136 | + { ApmAgentJava: not null } => "apm-agent-java", |
| 137 | + { ApmAgentNode: not null } => "apm-agent-node", |
| 138 | + { ApmAgentPhp: not null } => "apm-agent-php", |
| 139 | + { ApmAgentPython: not null } => "apm-agent-python", |
| 140 | + { ApmAgentRuby: not null } => "apm-agent-ruby", |
| 141 | + { ApmAgentRumJs: not null } => "apm-agent-rum-js", |
| 142 | + { EdotIos: not null } => "edot-ios", |
| 143 | + { EdotAndroid: not null } => "edot-android", |
| 144 | + { EdotDotnet: not null } => "edot-dotnet", |
| 145 | + { EdotJava: not null } => "edot-java", |
| 146 | + { EdotNode: not null } => "edot-node", |
| 147 | + { EdotPhp: not null } => "edot-php", |
| 148 | + { EdotPython: not null } => "edot-python", |
| 149 | + { EdotCfAws: not null } => "edot-cf-aws", |
| 150 | + { EdotCfAzure: not null } => "edot-cf-azure", |
| 151 | + { EdotCfGcp: not null } => "edot-cf-gcp", |
| 152 | + { EdotCollector: not null } => "edot-collector", |
| 153 | + _ => null |
| 154 | + }; |
| 155 | +} |
0 commit comments