Skip to content

Commit

Permalink
Use parsers v2 API
Browse files Browse the repository at this point in the history
Fallback to deprecated functionality for versions prior to LogScale 1.129.0
  • Loading branch information
SaaldjorMike committed Jun 10, 2024
1 parent 15157fb commit c2df0e5
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 56 deletions.
4 changes: 3 additions & 1 deletion api/internal/humiographql/filter-alerts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package humiographql

import graphql "github.com/cli/shurcooL-graphql"
import (
graphql "github.com/cli/shurcooL-graphql"
)

type FilterAlert struct {
ID graphql.String `graphql:"id"`
Expand Down
79 changes: 79 additions & 0 deletions api/internal/humiographql/parsers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package humiographql

import (
graphql "github.com/cli/shurcooL-graphql"
)

type UpdateParserScriptInput struct {
Script graphql.String `json:"script"`
}

type ParserTestEventInput struct {
RawString graphql.String `json:"rawString"`
}

type FieldHasValueInput struct {
FieldName graphql.String `json:"fieldName"`
ExpectedValue graphql.String `json:"expectedValue"`
}

type ParserTestCaseOutputAssertionsInput struct {
FieldsNotPresent []graphql.String `json:"fieldsNotPresent"`
FieldsHaveValues []FieldHasValueInput `json:"fieldsHaveValues"`
}

type ParserTestCaseAssertionsForOutputInput struct {
OutputEventIndex graphql.Int `json:"outputEventIndex"`
Assertions ParserTestCaseOutputAssertionsInput `json:"assertions"`
}

type ParserTestCaseInput struct {
Event ParserTestEventInput `json:"event"`
OutputAssertions []ParserTestCaseAssertionsForOutputInput `json:"outputAssertions"`
}

type ParserTestEvent struct {
RawString graphql.String `graphql:"rawString"`
}

type FieldHasValue struct {
FieldName graphql.String `graphql:"fieldName"`
ExpectedValue graphql.String `graphql:"expectedValue"`
}

type ParserTestCaseOutputAssertions struct {
FieldsNotPresent []string `graphql:"fieldsNotPresent"`
FieldsHaveValues []FieldHasValue `graphql:"fieldsHaveValues"`
}

type ParserTestCaseAssertionsForOutput struct {
OutputEventIndex graphql.Int `graphql:"outputEventIndex"`
Assertions ParserTestCaseOutputAssertions `graphql:"assertions"`
}

type ParserTestCase struct {
Event ParserTestEvent `graphql:"event"` // can we move this from api pkg?
OutputAssertions []ParserTestCaseAssertionsForOutput `graphql:"outputAssertions"`
}

type Parser struct {
ID graphql.String `graphql:"id"`
Name graphql.String `graphql:"name"`
DisplayName graphql.String `graphql:"displayName"`
Description graphql.String `graphql:"description""`
IsBuiltIn graphql.Boolean `graphql:"isBuiltIn"`
Script graphql.String `graphql:"script"`
FieldsToTag []graphql.String `graphql:"fieldsToTag"`
FieldsToBeRemovedBeforeParsing []graphql.String `graphql:"fieldsToBeRemovedBeforeParsing"`
TestCases []ParserTestCase `graphql:"testCases"`
}

type CreateParserInputV2 struct {
Name graphql.String `json:"name"`
Script graphql.String `json:"script""`
TestCases []ParserTestCaseInput `json:"testCases"`
RepositoryName RepoOrViewName `json:"repositoryName"`
FieldsToTag []graphql.String `json:"fieldsToTag"`
FieldsToBeRemovedBeforeParsing []graphql.String `json:"fieldsToBeRemovedBeforeParsing"`
AllowOverwritingExistingParser graphql.Boolean `json:"allowOverwritingExistingParser"`
}
Loading

0 comments on commit c2df0e5

Please sign in to comment.