33// See the LICENSE file in the project root for more information
44
55using System . Collections ;
6+ using System . Text ;
67using System . Text . Json . Serialization ;
78using Elastic . Documentation . Diagnostics ;
89using YamlDotNet . Serialization ;
@@ -34,6 +35,7 @@ public interface IApplicableToElement
3435}
3536
3637[ YamlSerializable ]
38+ [ JsonConverter ( typeof ( ApplicableToJsonConverter ) ) ]
3739public record ApplicableTo
3840{
3941 [ YamlMember ( Alias = "stack" ) ]
@@ -61,6 +63,58 @@ public record ApplicableTo
6163 Deployment = DeploymentApplicability . All ,
6264 Product = AppliesCollection . GenerallyAvailable
6365 } ;
66+
67+ public static ApplicableTo Default { get ; } = new ( )
68+ {
69+ Stack = new AppliesCollection ( [ new Applicability { Version = new SemVersion ( 9 , 0 , 0 ) , Lifecycle = ProductLifecycle . GenerallyAvailable } ] ) ,
70+ Serverless = ServerlessProjectApplicability . All
71+ } ;
72+
73+ /// <inheritdoc />
74+ public override string ToString ( )
75+ {
76+ var sb = new StringBuilder ( ) ;
77+ var hasContent = false ;
78+
79+ if ( Stack is not null )
80+ {
81+ _ = sb . Append ( "stack: " ) . Append ( Stack ) ;
82+ hasContent = true ;
83+ }
84+
85+ if ( Deployment is not null )
86+ {
87+ if ( hasContent )
88+ _ = sb . Append ( ", " ) ;
89+ _ = sb . Append ( "deployment: " ) . Append ( Deployment ) ;
90+ hasContent = true ;
91+ }
92+
93+ if ( Serverless is not null )
94+ {
95+ if ( hasContent )
96+ _ = sb . Append ( ", " ) ;
97+ _ = sb . Append ( "serverless: " ) . Append ( Serverless ) ;
98+ hasContent = true ;
99+ }
100+
101+ if ( Product is not null )
102+ {
103+ if ( hasContent )
104+ _ = sb . Append ( ", " ) ;
105+ _ = sb . Append ( "product: " ) . Append ( Product ) ;
106+ hasContent = true ;
107+ }
108+
109+ if ( ProductApplicability is not null )
110+ {
111+ if ( hasContent )
112+ _ = sb . Append ( ", " ) ;
113+ _ = sb . Append ( "products: " ) . Append ( ProductApplicability ) ;
114+ }
115+
116+ return sb . ToString ( ) ;
117+ }
64118}
65119
66120[ YamlSerializable ]
@@ -85,6 +139,44 @@ public record DeploymentApplicability
85139 Ess = AppliesCollection . GenerallyAvailable ,
86140 Self = AppliesCollection . GenerallyAvailable
87141 } ;
142+
143+ /// <inheritdoc />
144+ public override string ToString ( )
145+ {
146+ var sb = new StringBuilder ( ) ;
147+ var hasContent = false ;
148+
149+ if ( Self is not null )
150+ {
151+ _ = sb . Append ( "self=" ) . Append ( Self ) ;
152+ hasContent = true ;
153+ }
154+
155+ if ( Ece is not null )
156+ {
157+ if ( hasContent )
158+ _ = sb . Append ( ", " ) ;
159+ _ = sb . Append ( "ece=" ) . Append ( Ece ) ;
160+ hasContent = true ;
161+ }
162+
163+ if ( Eck is not null )
164+ {
165+ if ( hasContent )
166+ _ = sb . Append ( ", " ) ;
167+ _ = sb . Append ( "eck=" ) . Append ( Eck ) ;
168+ hasContent = true ;
169+ }
170+
171+ if ( Ess is not null )
172+ {
173+ if ( hasContent )
174+ _ = sb . Append ( ", " ) ;
175+ _ = sb . Append ( "ess=" ) . Append ( Ess ) ;
176+ }
177+
178+ return sb . ToString ( ) ;
179+ }
88180}
89181
90182[ YamlSerializable ]
@@ -113,6 +205,36 @@ public record ServerlessProjectApplicability
113205 Observability = AppliesCollection . GenerallyAvailable ,
114206 Security = AppliesCollection . GenerallyAvailable
115207 } ;
208+
209+ /// <inheritdoc />
210+ public override string ToString ( )
211+ {
212+ var sb = new StringBuilder ( ) ;
213+ var hasContent = false ;
214+
215+ if ( Elasticsearch is not null )
216+ {
217+ _ = sb . Append ( "elasticsearch=" ) . Append ( Elasticsearch ) ;
218+ hasContent = true ;
219+ }
220+
221+ if ( Observability is not null )
222+ {
223+ if ( hasContent )
224+ _ = sb . Append ( ", " ) ;
225+ _ = sb . Append ( "observability=" ) . Append ( Observability ) ;
226+ hasContent = true ;
227+ }
228+
229+ if ( Security is not null )
230+ {
231+ if ( hasContent )
232+ _ = sb . Append ( ", " ) ;
233+ _ = sb . Append ( "security=" ) . Append ( Security ) ;
234+ }
235+
236+ return sb . ToString ( ) ;
237+ }
116238}
117239
118240[ YamlSerializable ]
@@ -183,4 +305,46 @@ public record ProductApplicability
183305
184306 [ YamlMember ( Alias = "edot-collector" ) ]
185307 public AppliesCollection ? EdotCollector { get ; set ; }
308+
309+ /// <inheritdoc />
310+ public override string ToString ( )
311+ {
312+ var sb = new StringBuilder ( ) ;
313+ var hasContent = false ;
314+
315+ void AppendProduct ( string name , AppliesCollection ? value )
316+ {
317+ if ( value is null )
318+ return ;
319+ if ( hasContent )
320+ _ = sb . Append ( ", " ) ;
321+ _ = sb . Append ( name ) . Append ( '=' ) . Append ( value ) ;
322+ hasContent = true ;
323+ }
324+
325+ AppendProduct ( "ecctl" , Ecctl ) ;
326+ AppendProduct ( "curator" , Curator ) ;
327+ AppendProduct ( "apm-agent-android" , ApmAgentAndroid ) ;
328+ AppendProduct ( "apm-agent-dotnet" , ApmAgentDotnet ) ;
329+ AppendProduct ( "apm-agent-go" , ApmAgentGo ) ;
330+ AppendProduct ( "apm-agent-ios" , ApmAgentIos ) ;
331+ AppendProduct ( "apm-agent-java" , ApmAgentJava ) ;
332+ AppendProduct ( "apm-agent-node" , ApmAgentNode ) ;
333+ AppendProduct ( "apm-agent-php" , ApmAgentPhp ) ;
334+ AppendProduct ( "apm-agent-python" , ApmAgentPython ) ;
335+ AppendProduct ( "apm-agent-ruby" , ApmAgentRuby ) ;
336+ AppendProduct ( "apm-agent-rum-js" , ApmAgentRumJs ) ;
337+ AppendProduct ( "edot-ios" , EdotIos ) ;
338+ AppendProduct ( "edot-android" , EdotAndroid ) ;
339+ AppendProduct ( "edot-dotnet" , EdotDotnet ) ;
340+ AppendProduct ( "edot-java" , EdotJava ) ;
341+ AppendProduct ( "edot-node" , EdotNode ) ;
342+ AppendProduct ( "edot-php" , EdotPhp ) ;
343+ AppendProduct ( "edot-python" , EdotPython ) ;
344+ AppendProduct ( "edot-cf-aws" , EdotCfAws ) ;
345+ AppendProduct ( "edot-cf-azure" , EdotCfAzure ) ;
346+ AppendProduct ( "edot-collector" , EdotCollector ) ;
347+
348+ return sb . ToString ( ) ;
349+ }
186350}
0 commit comments