Skip to content

Commit

Permalink
fix rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb-Hurshman committed Dec 10, 2024
1 parent dac6a6b commit 1f91ded
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 42 deletions.
20 changes: 10 additions & 10 deletions receiver/splunksearchapireceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
type splunkSearchAPIClient interface {
CreateSearchJob(search string) (CreateJobResponse, error)
GetJobStatus(searchID string) (SearchJobStatusResponse, error)
GetSearchResults(searchID string, offset int, batchSize int) (SearchResultsResponse, error)
GetSearchResults(searchID string, offset int, batchSize int) (SearchResults, error)
}

type defaultSplunkSearchAPIClient struct {
Expand Down Expand Up @@ -140,37 +140,37 @@ func (c defaultSplunkSearchAPIClient) GetJobStatus(sid string) (SearchJobStatusR
return jobStatusResponse, nil
}

func (c defaultSplunkSearchAPIClient) GetSearchResults(sid string) (SearchResultsResponse, error) {
endpoint := fmt.Sprintf("%s/services/search/v2/jobs/%s/results?output_mode=json", c.endpoint, sid)
func (c defaultSplunkSearchAPIClient) GetSearchResults(sid string, offset int, batchSize int) (SearchResults, error) {
endpoint := fmt.Sprintf("%s/services/search/v2/jobs/%s/results?output_mode=json&offset=%d&count=%d", c.endpoint, sid, offset, batchSize)
req, err := http.NewRequest("GET", endpoint, nil)
if err != nil {
return SearchResultsResponse{}, err
return SearchResults{}, err
}

err = c.SetSplunkRequestAuth(req)
if err != nil {
return SearchResultsResponse{}, err
return SearchResults{}, err
}

resp, err := c.client.Do(req)
if err != nil {
return SearchResultsResponse{}, err
return SearchResults{}, err
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return SearchResultsResponse{}, fmt.Errorf("failed to get search job results: %d", resp.StatusCode)
return SearchResults{}, fmt.Errorf("failed to get search job results: %d", resp.StatusCode)
}

var searchResults SearchResultsResponse
var searchResults SearchResults
body, err := io.ReadAll(resp.Body)
if err != nil {
return SearchResultsResponse{}, fmt.Errorf("failed to read search job results response: %v", err)
return SearchResults{}, fmt.Errorf("failed to read search job results response: %v", err)
}
// fmt.Println("Body: ", string(body))
err = json.Unmarshal(body, &searchResults)
if err != nil {
return SearchResultsResponse{}, fmt.Errorf("failed to unmarshal search job results response: %v", err)
return SearchResults{}, fmt.Errorf("failed to unmarshal search job results response: %v", err)
}

return searchResults, nil
Expand Down
16 changes: 11 additions & 5 deletions receiver/splunksearchapireceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.113.0
go.opentelemetry.io/collector/consumer v0.113.0
go.opentelemetry.io/collector/consumer/consumertest v0.112.0
go.opentelemetry.io/collector/consumer/consumertest v0.113.0
go.opentelemetry.io/collector/extension/experimental/storage v0.113.0
go.opentelemetry.io/collector/pdata v1.19.0
go.opentelemetry.io/collector/receiver v0.113.0
go.opentelemetry.io/collector/receiver/receivertest v0.113.0
Expand All @@ -28,6 +29,7 @@ require (
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
Expand All @@ -49,15 +51,19 @@ require (
go.opentelemetry.io/collector/config/configopaque v1.19.0 // indirect
go.opentelemetry.io/collector/config/configtls v1.19.0 // indirect
go.opentelemetry.io/collector/config/internal v0.113.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.112.0 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.112.0 // indirect
go.opentelemetry.io/collector/confmap v1.19.0 // indirect
go.opentelemetry.io/collector/consumer/consumererror v0.113.0 // indirect
go.opentelemetry.io/collector/consumer/consumerprofiles v0.113.0 // indirect
go.opentelemetry.io/collector/extension v0.113.0 // indirect
go.opentelemetry.io/collector/extension/auth v0.113.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.112.0 // indirect
go.opentelemetry.io/collector/receiver/receiverprofiles v0.112.0 // indirect
go.opentelemetry.io/collector/featuregate v1.19.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.113.0 // indirect
go.opentelemetry.io/collector/receiver/receiverprofiles v0.113.0 // indirect
go.opentelemetry.io/collector/semconv v0.113.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
Loading

0 comments on commit 1f91ded

Please sign in to comment.