@@ -407,6 +407,14 @@ func (a *ApiClient) versionFromElasticsearch(ctx context.Context) (*version.Vers
407407}
408408
409409func (a * ApiClient ) ServerFlavor (ctx context.Context ) (string , diag.Diagnostics ) {
410+ if a .elasticsearch != nil {
411+ return a .flavorFromElasticsearch (ctx )
412+ }
413+
414+ return a .flavorFromKibana ()
415+ }
416+
417+ func (a * ApiClient ) flavorFromElasticsearch (ctx context.Context ) (string , diag.Diagnostics ) {
410418 info , diags := a .serverInfo (ctx )
411419 if diags .HasError () {
412420 return "" , diags
@@ -415,6 +423,32 @@ func (a *ApiClient) ServerFlavor(ctx context.Context) (string, diag.Diagnostics)
415423 return info .Version .BuildFlavor , nil
416424}
417425
426+ func (a * ApiClient ) flavorFromKibana () (string , diag.Diagnostics ) {
427+ kibClient , err := a .GetKibanaClient ()
428+ if err != nil {
429+ return "" , diag .Errorf ("failed to get flavor from Kibana API: %s, " +
430+ "please ensure a working 'kibana' endpoint is configured" , err .Error ())
431+ }
432+
433+ status , err := kibClient .KibanaStatus .Get ()
434+ if err != nil {
435+ return "" , diag .Errorf ("failed to get flavor from Kibana API: %s, " +
436+ "Please ensure a working 'kibana' endpoint is configured" , err .Error ())
437+ }
438+
439+ vMap , ok := status ["version" ].(map [string ]interface {})
440+ if ! ok {
441+ return "" , diag .Errorf ("failed to get flavor from Kibana API" )
442+ }
443+
444+ serverFlavor , ok := vMap ["build_flavor" ].(string )
445+ if ! ok {
446+ return "" , diag .Errorf ("failed to get build flavor from Kibana status" )
447+ }
448+
449+ return serverFlavor , nil
450+ }
451+
418452func (a * ApiClient ) ClusterID (ctx context.Context ) (* string , diag.Diagnostics ) {
419453 info , diags := a .serverInfo (ctx )
420454 if diags .HasError () {
0 commit comments