Skip to content

Commit 1444c71

Browse files
committed
Move ML job types to models
1 parent 8dee653 commit 1444c71

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

internal/clients/elasticsearch/ml_job.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,6 @@ import (
1515
"github.com/hashicorp/terraform-plugin-framework/diag"
1616
)
1717

18-
// MLJobStats represents the statistics structure for an ML job
19-
type MLJobStats struct {
20-
Jobs []MLJob `json:"jobs"`
21-
}
22-
23-
// MLJob represents a single ML job in the stats response
24-
type MLJob struct {
25-
JobId string `json:"job_id"`
26-
State string `json:"state"`
27-
Node *MLJobNode `json:"node,omitempty"`
28-
}
29-
30-
// MLJobNode represents the node information for an ML job
31-
type MLJobNode struct {
32-
Id string `json:"id"`
33-
Name string `json:"name"`
34-
Attributes map[string]interface{} `json:"attributes"`
35-
}
36-
3718
// OpenMLJob opens a machine learning job
3819
func OpenMLJob(ctx context.Context, apiClient *clients.ApiClient, jobId string) diag.Diagnostics {
3920
var diags diag.Diagnostics
@@ -120,7 +101,7 @@ func CloseMLJob(ctx context.Context, apiClient *clients.ApiClient, jobId string,
120101
}
121102

122103
// GetMLJobStats retrieves the stats for a specific machine learning job
123-
func GetMLJobStats(ctx context.Context, apiClient *clients.ApiClient, jobId string) (*MLJob, diag.Diagnostics) {
104+
func GetMLJobStats(ctx context.Context, apiClient *clients.ApiClient, jobId string) (*models.MLJob, diag.Diagnostics) {
124105
var diags diag.Diagnostics
125106

126107
esClient, err := apiClient.GetESClient()
@@ -148,8 +129,7 @@ func GetMLJobStats(ctx context.Context, apiClient *clients.ApiClient, jobId stri
148129
if diags.HasError() {
149130
return nil, diags
150131
}
151-
152-
var jobStats MLJobStats
132+
var jobStats models.MLJobStats
153133
if err := json.NewDecoder(res.Body).Decode(&jobStats); err != nil {
154134
diags.AddError("Failed to decode ML job stats response", err.Error())
155135
return nil, diags

internal/models/ml.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,22 @@ type DatafeedNode struct {
124124

125125
// DatafeedRunning represents the running state of a datafeed
126126
type DatafeedRunning struct {
127-
RealTimeConfigured bool `json:"real_time_configured"`
128-
RealTimeRunning bool `json:"real_time_running"`
129-
SearchInterval *int64 `json:"search_interval,omitempty"`
130-
LastEndTime *time.Time `json:"last_end_time,omitempty"`
127+
128+
// MLJobStats represents the statistics structure for an ML job
129+
type MLJobStats struct {
130+
Jobs []MLJob `json:"jobs"`
131+
}
132+
133+
// MLJob represents a single ML job in the stats response
134+
type MLJob struct {
135+
JobId string `json:"job_id"`
136+
State string `json:"state"`
137+
Node *MLJobNode `json:"node,omitempty"`
138+
}
139+
140+
// MLJobNode represents the node information for an ML job
141+
type MLJobNode struct {
142+
Id string `json:"id"`
143+
Name string `json:"name"`
144+
Attributes map[string]interface{} `json:"attributes"`
131145
}

0 commit comments

Comments
 (0)