Merged in feature/jobcollector (pull request #30)

Initial Job Collector (changes pending)

* movearroundtocleancollector

* internalgetfunctions

* completecollectorquery

* simplify

* fixtests

* addvendor

* noplaceholder
This commit is contained in:
Michael McGuinness
2025-01-21 12:28:46 +00:00
parent b888e3450f
commit 4ccb980593
46 changed files with 951 additions and 655 deletions
+88 -203
View File
@@ -97,20 +97,47 @@ type IdMessage struct {
// JobCollector JobCollector model.
type JobCollector struct {
// ExampleProperty Example property for JobCollector.
ExampleProperty *string `json:"example_property,omitempty"`
// ActiveVersion The active version of the collector.
ActiveVersion int32 `json:"active_version"`
// Fields The fields in the job collector.
Fields []JobCollectorField `json:"fields"`
// JobId The ID of the associated job.
JobId string `json:"job_id"`
// LatestVersion The latest version of the collector.
LatestVersion int32 `json:"latest_version"`
// MinimumCleanerVersion The minimum version for the document cleaner.
MinimumCleanerVersion int32 `json:"minimum_cleaner_version"`
// MinimumTextVersion The minimum version for the text parser.
MinimumTextVersion int32 `json:"minimum_text_version"`
}
// JobCollectorCreate Payload for creating a JobCollector.
type JobCollectorCreate struct {
// ExampleProperty Example property for JobCollectorCreate.
ExampleProperty *string `json:"example_property,omitempty"`
// JobCollectorField The field properties for the job collector.
type JobCollectorField struct {
// Name The output field name.
Name string `json:"name"`
// QueryId The query id that will populate the result.
QueryId string `json:"query_id"`
}
// JobCollectorUpdate Payload for updating a JobCollector.
type JobCollectorUpdate struct {
// ExampleProperty Example property for JobCollectorUpdate.
ExampleProperty *string `json:"example_property,omitempty"`
// ActiveVersion The active version of the collector.
ActiveVersion *int32 `json:"active_version,omitempty"`
// Fields The fields in the job collector.
Fields *[]JobCollectorField `json:"fields,omitempty"`
// MinimumCleanerVersion The minimum version for the document cleaner.
MinimumCleanerVersion *int32 `json:"minimum_cleaner_version,omitempty"`
// MinimumTextVersion The minimum version for the text parser.
MinimumTextVersion *int32 `json:"minimum_text_version,omitempty"`
}
// ListQueries defines model for ListQueries.
@@ -185,11 +212,8 @@ type QueryUpdate struct {
// TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType.
type TriggerExportJSONRequestBody = ExportTrigger
// CreateJobCollectorJSONRequestBody defines body for CreateJobCollector for application/json ContentType.
type CreateJobCollectorJSONRequestBody = JobCollectorCreate
// UpdateJobCollectorJSONRequestBody defines body for UpdateJobCollector for application/json ContentType.
type UpdateJobCollectorJSONRequestBody = JobCollectorUpdate
// UpdateJobCollectorByJobIdJSONRequestBody defines body for UpdateJobCollectorByJobId for application/json ContentType.
type UpdateJobCollectorByJobIdJSONRequestBody = JobCollectorUpdate
// CreateQueryJSONRequestBody defines body for CreateQuery for application/json ContentType.
type CreateQueryJSONRequestBody = QueryCreate
@@ -281,18 +305,13 @@ type ClientInterface interface {
// ExportState request
ExportState(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)
// CreateJobCollectorWithBody request with any body
CreateJobCollectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetJobCollectorByJobId request
GetJobCollectorByJobId(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)
CreateJobCollector(ctx context.Context, body CreateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// UpdateJobCollectorByJobIdWithBody request with any body
UpdateJobCollectorByJobIdWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
// GetJobCollectorById request
GetJobCollectorById(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)
// UpdateJobCollectorWithBody request with any body
UpdateJobCollectorWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
UpdateJobCollector(ctx context.Context, id string, body UpdateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
UpdateJobCollectorByJobId(ctx context.Context, id string, body UpdateJobCollectorByJobIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
// ListQueries request
ListQueries(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
@@ -355,8 +374,8 @@ func (c *Client) ExportState(ctx context.Context, id string, reqEditors ...Reque
return c.Client.Do(req)
}
func (c *Client) CreateJobCollectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateJobCollectorRequestWithBody(c.Server, contentType, body)
func (c *Client) GetJobCollectorByJobId(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGetJobCollectorByJobIdRequest(c.Server, id)
if err != nil {
return nil, err
}
@@ -367,8 +386,8 @@ func (c *Client) CreateJobCollectorWithBody(ctx context.Context, contentType str
return c.Client.Do(req)
}
func (c *Client) CreateJobCollector(ctx context.Context, body CreateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewCreateJobCollectorRequest(c.Server, body)
func (c *Client) UpdateJobCollectorByJobIdWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateJobCollectorByJobIdRequestWithBody(c.Server, id, contentType, body)
if err != nil {
return nil, err
}
@@ -379,32 +398,8 @@ func (c *Client) CreateJobCollector(ctx context.Context, body CreateJobCollector
return c.Client.Do(req)
}
func (c *Client) GetJobCollectorById(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewGetJobCollectorByIdRequest(c.Server, id)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) UpdateJobCollectorWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateJobCollectorRequestWithBody(c.Server, id, contentType, body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
return nil, err
}
return c.Client.Do(req)
}
func (c *Client) UpdateJobCollector(ctx context.Context, id string, body UpdateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateJobCollectorRequest(c.Server, id, body)
func (c *Client) UpdateJobCollectorByJobId(ctx context.Context, id string, body UpdateJobCollectorByJobIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
req, err := NewUpdateJobCollectorByJobIdRequest(c.Server, id, body)
if err != nil {
return nil, err
}
@@ -543,7 +538,7 @@ func NewTriggerExportRequestWithBody(server string, contentType string, body io.
return nil, err
}
operationPath := fmt.Sprintf("/export")
operationPath := fmt.Sprintf("/job/export")
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
@@ -579,7 +574,7 @@ func NewExportStateRequest(server string, id string) (*http.Request, error) {
return nil, err
}
operationPath := fmt.Sprintf("/export/%s", pathParam0)
operationPath := fmt.Sprintf("/job/export/%s", pathParam0)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
@@ -597,48 +592,8 @@ func NewExportStateRequest(server string, id string) (*http.Request, error) {
return req, nil
}
// NewCreateJobCollectorRequest calls the generic CreateJobCollector builder with application/json body
func NewCreateJobCollectorRequest(server string, body CreateJobCollectorJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
buf, err := json.Marshal(body)
if err != nil {
return nil, err
}
bodyReader = bytes.NewReader(buf)
return NewCreateJobCollectorRequestWithBody(server, "application/json", bodyReader)
}
// NewCreateJobCollectorRequestWithBody generates requests for CreateJobCollector with any type of body
func NewCreateJobCollectorRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
var err error
serverURL, err := url.Parse(server)
if err != nil {
return nil, err
}
operationPath := fmt.Sprintf("/job-collectors")
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
queryURL, err := serverURL.Parse(operationPath)
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", queryURL.String(), body)
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", contentType)
return req, nil
}
// NewGetJobCollectorByIdRequest generates requests for GetJobCollectorById
func NewGetJobCollectorByIdRequest(server string, id string) (*http.Request, error) {
// NewGetJobCollectorByJobIdRequest generates requests for GetJobCollectorByJobId
func NewGetJobCollectorByJobIdRequest(server string, id string) (*http.Request, error) {
var err error
var pathParam0 string
@@ -653,7 +608,7 @@ func NewGetJobCollectorByIdRequest(server string, id string) (*http.Request, err
return nil, err
}
operationPath := fmt.Sprintf("/job-collectors/%s", pathParam0)
operationPath := fmt.Sprintf("/job/%s/collector", pathParam0)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
@@ -671,19 +626,19 @@ func NewGetJobCollectorByIdRequest(server string, id string) (*http.Request, err
return req, nil
}
// NewUpdateJobCollectorRequest calls the generic UpdateJobCollector builder with application/json body
func NewUpdateJobCollectorRequest(server string, id string, body UpdateJobCollectorJSONRequestBody) (*http.Request, error) {
// NewUpdateJobCollectorByJobIdRequest calls the generic UpdateJobCollectorByJobId builder with application/json body
func NewUpdateJobCollectorByJobIdRequest(server string, id string, body UpdateJobCollectorByJobIdJSONRequestBody) (*http.Request, error) {
var bodyReader io.Reader
buf, err := json.Marshal(body)
if err != nil {
return nil, err
}
bodyReader = bytes.NewReader(buf)
return NewUpdateJobCollectorRequestWithBody(server, id, "application/json", bodyReader)
return NewUpdateJobCollectorByJobIdRequestWithBody(server, id, "application/json", bodyReader)
}
// NewUpdateJobCollectorRequestWithBody generates requests for UpdateJobCollector with any type of body
func NewUpdateJobCollectorRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {
// NewUpdateJobCollectorByJobIdRequestWithBody generates requests for UpdateJobCollectorByJobId with any type of body
func NewUpdateJobCollectorByJobIdRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) {
var err error
var pathParam0 string
@@ -698,7 +653,7 @@ func NewUpdateJobCollectorRequestWithBody(server string, id string, contentType
return nil, err
}
operationPath := fmt.Sprintf("/job-collectors/%s", pathParam0)
operationPath := fmt.Sprintf("/job/%s/collector", pathParam0)
if operationPath[0] == '/' {
operationPath = "." + operationPath
}
@@ -708,7 +663,7 @@ func NewUpdateJobCollectorRequestWithBody(server string, id string, contentType
return nil, err
}
req, err := http.NewRequest("PUT", queryURL.String(), body)
req, err := http.NewRequest("PATCH", queryURL.String(), body)
if err != nil {
return nil, err
}
@@ -998,18 +953,13 @@ type ClientWithResponsesInterface interface {
// ExportStateWithResponse request
ExportStateWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ExportStateResponse, error)
// CreateJobCollectorWithBodyWithResponse request with any body
CreateJobCollectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error)
// GetJobCollectorByJobIdWithResponse request
GetJobCollectorByJobIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetJobCollectorByJobIdResponse, error)
CreateJobCollectorWithResponse(ctx context.Context, body CreateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error)
// UpdateJobCollectorByJobIdWithBodyWithResponse request with any body
UpdateJobCollectorByJobIdWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJobCollectorByJobIdResponse, error)
// GetJobCollectorByIdWithResponse request
GetJobCollectorByIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetJobCollectorByIdResponse, error)
// UpdateJobCollectorWithBodyWithResponse request with any body
UpdateJobCollectorWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJobCollectorResponse, error)
UpdateJobCollectorWithResponse(ctx context.Context, id string, body UpdateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJobCollectorResponse, error)
UpdateJobCollectorByJobIdWithResponse(ctx context.Context, id string, body UpdateJobCollectorByJobIdJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJobCollectorByJobIdResponse, error)
// ListQueriesWithResponse request
ListQueriesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListQueriesResponse, error)
@@ -1080,36 +1030,14 @@ func (r ExportStateResponse) StatusCode() int {
return 0
}
type CreateJobCollectorResponse struct {
Body []byte
HTTPResponse *http.Response
JSON201 *IdMessage
}
// Status returns HTTPResponse.Status
func (r CreateJobCollectorResponse) Status() string {
if r.HTTPResponse != nil {
return r.HTTPResponse.Status
}
return http.StatusText(0)
}
// StatusCode returns HTTPResponse.StatusCode
func (r CreateJobCollectorResponse) StatusCode() int {
if r.HTTPResponse != nil {
return r.HTTPResponse.StatusCode
}
return 0
}
type GetJobCollectorByIdResponse struct {
type GetJobCollectorByJobIdResponse struct {
Body []byte
HTTPResponse *http.Response
JSON200 *JobCollector
}
// Status returns HTTPResponse.Status
func (r GetJobCollectorByIdResponse) Status() string {
func (r GetJobCollectorByJobIdResponse) Status() string {
if r.HTTPResponse != nil {
return r.HTTPResponse.Status
}
@@ -1117,20 +1045,20 @@ func (r GetJobCollectorByIdResponse) Status() string {
}
// StatusCode returns HTTPResponse.StatusCode
func (r GetJobCollectorByIdResponse) StatusCode() int {
func (r GetJobCollectorByJobIdResponse) StatusCode() int {
if r.HTTPResponse != nil {
return r.HTTPResponse.StatusCode
}
return 0
}
type UpdateJobCollectorResponse struct {
type UpdateJobCollectorByJobIdResponse struct {
Body []byte
HTTPResponse *http.Response
}
// Status returns HTTPResponse.Status
func (r UpdateJobCollectorResponse) Status() string {
func (r UpdateJobCollectorByJobIdResponse) Status() string {
if r.HTTPResponse != nil {
return r.HTTPResponse.Status
}
@@ -1138,7 +1066,7 @@ func (r UpdateJobCollectorResponse) Status() string {
}
// StatusCode returns HTTPResponse.StatusCode
func (r UpdateJobCollectorResponse) StatusCode() int {
func (r UpdateJobCollectorByJobIdResponse) StatusCode() int {
if r.HTTPResponse != nil {
return r.HTTPResponse.StatusCode
}
@@ -1301,47 +1229,30 @@ func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id st
return ParseExportStateResponse(rsp)
}
// CreateJobCollectorWithBodyWithResponse request with arbitrary body returning *CreateJobCollectorResponse
func (c *ClientWithResponses) CreateJobCollectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error) {
rsp, err := c.CreateJobCollectorWithBody(ctx, contentType, body, reqEditors...)
// GetJobCollectorByJobIdWithResponse request returning *GetJobCollectorByJobIdResponse
func (c *ClientWithResponses) GetJobCollectorByJobIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetJobCollectorByJobIdResponse, error) {
rsp, err := c.GetJobCollectorByJobId(ctx, id, reqEditors...)
if err != nil {
return nil, err
}
return ParseCreateJobCollectorResponse(rsp)
return ParseGetJobCollectorByJobIdResponse(rsp)
}
func (c *ClientWithResponses) CreateJobCollectorWithResponse(ctx context.Context, body CreateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error) {
rsp, err := c.CreateJobCollector(ctx, body, reqEditors...)
// UpdateJobCollectorByJobIdWithBodyWithResponse request with arbitrary body returning *UpdateJobCollectorByJobIdResponse
func (c *ClientWithResponses) UpdateJobCollectorByJobIdWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJobCollectorByJobIdResponse, error) {
rsp, err := c.UpdateJobCollectorByJobIdWithBody(ctx, id, contentType, body, reqEditors...)
if err != nil {
return nil, err
}
return ParseCreateJobCollectorResponse(rsp)
return ParseUpdateJobCollectorByJobIdResponse(rsp)
}
// GetJobCollectorByIdWithResponse request returning *GetJobCollectorByIdResponse
func (c *ClientWithResponses) GetJobCollectorByIdWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetJobCollectorByIdResponse, error) {
rsp, err := c.GetJobCollectorById(ctx, id, reqEditors...)
func (c *ClientWithResponses) UpdateJobCollectorByJobIdWithResponse(ctx context.Context, id string, body UpdateJobCollectorByJobIdJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJobCollectorByJobIdResponse, error) {
rsp, err := c.UpdateJobCollectorByJobId(ctx, id, body, reqEditors...)
if err != nil {
return nil, err
}
return ParseGetJobCollectorByIdResponse(rsp)
}
// UpdateJobCollectorWithBodyWithResponse request with arbitrary body returning *UpdateJobCollectorResponse
func (c *ClientWithResponses) UpdateJobCollectorWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJobCollectorResponse, error) {
rsp, err := c.UpdateJobCollectorWithBody(ctx, id, contentType, body, reqEditors...)
if err != nil {
return nil, err
}
return ParseUpdateJobCollectorResponse(rsp)
}
func (c *ClientWithResponses) UpdateJobCollectorWithResponse(ctx context.Context, id string, body UpdateJobCollectorJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJobCollectorResponse, error) {
rsp, err := c.UpdateJobCollector(ctx, id, body, reqEditors...)
if err != nil {
return nil, err
}
return ParseUpdateJobCollectorResponse(rsp)
return ParseUpdateJobCollectorByJobIdResponse(rsp)
}
// ListQueriesWithResponse request returning *ListQueriesResponse
@@ -1474,41 +1385,15 @@ func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error)
return response, nil
}
// ParseCreateJobCollectorResponse parses an HTTP response from a CreateJobCollectorWithResponse call
func ParseCreateJobCollectorResponse(rsp *http.Response) (*CreateJobCollectorResponse, error) {
// ParseGetJobCollectorByJobIdResponse parses an HTTP response from a GetJobCollectorByJobIdWithResponse call
func ParseGetJobCollectorByJobIdResponse(rsp *http.Response) (*GetJobCollectorByJobIdResponse, error) {
bodyBytes, err := io.ReadAll(rsp.Body)
defer func() { _ = rsp.Body.Close() }()
if err != nil {
return nil, err
}
response := &CreateJobCollectorResponse{
Body: bodyBytes,
HTTPResponse: rsp,
}
switch {
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201:
var dest IdMessage
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
return nil, err
}
response.JSON201 = &dest
}
return response, nil
}
// ParseGetJobCollectorByIdResponse parses an HTTP response from a GetJobCollectorByIdWithResponse call
func ParseGetJobCollectorByIdResponse(rsp *http.Response) (*GetJobCollectorByIdResponse, error) {
bodyBytes, err := io.ReadAll(rsp.Body)
defer func() { _ = rsp.Body.Close() }()
if err != nil {
return nil, err
}
response := &GetJobCollectorByIdResponse{
response := &GetJobCollectorByJobIdResponse{
Body: bodyBytes,
HTTPResponse: rsp,
}
@@ -1526,15 +1411,15 @@ func ParseGetJobCollectorByIdResponse(rsp *http.Response) (*GetJobCollectorByIdR
return response, nil
}
// ParseUpdateJobCollectorResponse parses an HTTP response from a UpdateJobCollectorWithResponse call
func ParseUpdateJobCollectorResponse(rsp *http.Response) (*UpdateJobCollectorResponse, error) {
// ParseUpdateJobCollectorByJobIdResponse parses an HTTP response from a UpdateJobCollectorByJobIdWithResponse call
func ParseUpdateJobCollectorByJobIdResponse(rsp *http.Response) (*UpdateJobCollectorByJobIdResponse, error) {
bodyBytes, err := io.ReadAll(rsp.Body)
defer func() { _ = rsp.Body.Close() }()
if err != nil {
return nil, err
}
response := &UpdateJobCollectorResponse{
response := &UpdateJobCollectorByJobIdResponse{
Body: bodyBytes,
HTTPResponse: rsp,
}