Skip to content

Commit e84e461

Browse files
committed
feat: implement all conditions
1 parent 28b307d commit e84e461

File tree

9 files changed

+1563
-402
lines changed

9 files changed

+1563
-402
lines changed

internal/acctest/regexp.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package acctest
2+
3+
import (
4+
"regexp"
5+
"strings"
6+
7+
"github.com/jianyuan/go-utils/sliceutils"
8+
)
9+
10+
func ExpectLiteralError(lines ...string) *regexp.Regexp {
11+
return regexp.MustCompile(strings.Join(sliceutils.Map(func(v string) string {
12+
return regexp.QuoteMeta(v)
13+
}, lines), `\n`))
14+
}

internal/apiclient/api.yaml

Lines changed: 200 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -369,52 +369,46 @@ paths:
369369
type: object
370370
required:
371371
- name
372+
- actionMatch
373+
- filterMatch
374+
- frequency
375+
- projects
376+
- conditions
377+
- filters
378+
- actions
372379
properties:
373380
name:
374381
type: string
382+
actionMatch:
383+
type: string
384+
filterMatch:
385+
type: string
386+
frequency:
387+
type: integer
388+
format: int64
389+
owner:
390+
type: string
375391
environment:
376392
type: string
393+
projects:
394+
type: array
395+
items:
396+
type: string
377397
conditions:
398+
type: array
399+
items:
400+
$ref: "#/components/schemas/ProjectRuleCondition"
401+
filters:
378402
type: array
379403
items:
380404
type: object
381-
required:
382-
- id
383-
- category
384-
- type
385-
properties:
386-
id:
387-
type: string
388-
category:
389-
type: string
390-
type:
391-
type: string
392-
values:
393-
type: array
394-
items:
395-
type: string
396405
actions:
397406
type: array
398407
items:
399408
type: object
400-
required:
401-
- id
402-
- category
403-
- type
404-
properties:
405-
id:
406-
type: string
407-
category:
408-
type: string
409-
type:
410-
type: string
411-
values:
412-
type: array
413-
items:
414-
type: string
415409
responses:
416-
"201":
417-
description: Created
410+
"200":
411+
description: OK
418412
content:
419413
application/json:
420414
schema:
@@ -470,49 +464,45 @@ paths:
470464
application/json:
471465
schema:
472466
type: object
467+
required:
468+
- name
469+
- actionMatch
470+
- filterMatch
471+
- frequency
472+
- projects
473+
- conditions
474+
- filters
475+
- actions
473476
properties:
474477
name:
475478
type: string
479+
actionMatch:
480+
type: string
481+
filterMatch:
482+
type: string
483+
frequency:
484+
type: integer
485+
format: int64
486+
owner:
487+
type: string
476488
environment:
477489
type: string
490+
projects:
491+
type: array
492+
items:
493+
type: string
478494
conditions:
495+
type: array
496+
items:
497+
$ref: "#/components/schemas/ProjectRuleCondition"
498+
filters:
479499
type: array
480500
items:
481501
type: object
482-
required:
483-
- id
484-
- category
485-
- type
486-
properties:
487-
id:
488-
type: string
489-
category:
490-
type: string
491-
type:
492-
type: string
493-
values:
494-
type: array
495-
items:
496-
type: string
497502
actions:
498503
type: array
499504
items:
500505
type: object
501-
required:
502-
- id
503-
- category
504-
- type
505-
properties:
506-
id:
507-
type: string
508-
category:
509-
type: string
510-
type:
511-
type: string
512-
values:
513-
type: array
514-
items:
515-
type: string
516506
responses:
517507
"200":
518508
description: OK
@@ -530,8 +520,8 @@ paths:
530520
summary: Delete a Rule
531521
operationId: deleteProjectRule
532522
responses:
533-
"204":
534-
description: No Content
523+
"202":
524+
description: Accepted
535525
"401":
536526
description: Unauthorized
537527
"403":
@@ -768,7 +758,7 @@ components:
768758
conditions:
769759
type: array
770760
items:
771-
type: object
761+
$ref: "#/components/schemas/ProjectRuleCondition"
772762
filters:
773763
type: array
774764
items:
@@ -777,6 +767,151 @@ components:
777767
type: array
778768
items:
779769
type: object
770+
ProjectRuleCondition:
771+
oneOf:
772+
- $ref: "#/components/schemas/ProjectRuleConditionFirstSeenEvent"
773+
- $ref: "#/components/schemas/ProjectRuleConditionRegressionEvent"
774+
- $ref: "#/components/schemas/ProjectRuleConditionReappearedEvent"
775+
- $ref: "#/components/schemas/ProjectRuleConditionNewHighPriorityIssue"
776+
- $ref: "#/components/schemas/ProjectRuleConditionExistingHighPriorityIssue"
777+
- $ref: "#/components/schemas/ProjectRuleConditionEventFrequency"
778+
- $ref: "#/components/schemas/ProjectRuleConditionEventUniqueUserFrequency"
779+
- $ref: "#/components/schemas/ProjectRuleConditionEventFrequencyPercent"
780+
discriminator:
781+
propertyName: id
782+
mapping:
783+
"sentry.rules.conditions.first_seen_event.FirstSeenEventCondition": "#/components/schemas/ProjectRuleConditionFirstSeenEvent"
784+
"sentry.rules.conditions.regression_event.RegressionEventCondition": "#/components/schemas/ProjectRuleConditionRegressionEvent"
785+
"sentry.rules.conditions.reappeared_event.ReappearedEventCondition": "#/components/schemas/ProjectRuleConditionReappearedEvent"
786+
"sentry.rules.conditions.high_priority_issue.NewHighPriorityIssueCondition": "#/components/schemas/ProjectRuleConditionNewHighPriorityIssue"
787+
"sentry.rules.conditions.high_priority_issue.ExistingHighPriorityIssueCondition": "#/components/schemas/ProjectRuleConditionExistingHighPriorityIssue"
788+
"sentry.rules.conditions.event_frequency.EventFrequencyCondition": "#/components/schemas/ProjectRuleConditionEventFrequency"
789+
"sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition": "#/components/schemas/ProjectRuleConditionEventUniqueUserFrequency"
790+
"sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition": "#/components/schemas/ProjectRuleConditionEventFrequencyPercent"
791+
ProjectRuleConditionFirstSeenEvent:
792+
type: object
793+
required:
794+
- id
795+
properties:
796+
id:
797+
type: string
798+
enum:
799+
- "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
800+
name:
801+
type: string
802+
ProjectRuleConditionRegressionEvent:
803+
type: object
804+
required:
805+
- id
806+
properties:
807+
id:
808+
type: string
809+
enum:
810+
- "sentry.rules.conditions.regression_event.RegressionEventCondition"
811+
name:
812+
type: string
813+
ProjectRuleConditionReappearedEvent:
814+
type: object
815+
required:
816+
- id
817+
properties:
818+
id:
819+
type: string
820+
enum:
821+
- "sentry.rules.conditions.reappeared_event.ReappearedEventCondition"
822+
name:
823+
type: string
824+
ProjectRuleConditionNewHighPriorityIssue:
825+
type: object
826+
required:
827+
- id
828+
properties:
829+
id:
830+
type: string
831+
enum:
832+
- "sentry.rules.conditions.high_priority_issue.NewHighPriorityIssueCondition"
833+
name:
834+
type: string
835+
ProjectRuleConditionExistingHighPriorityIssue:
836+
type: object
837+
required:
838+
- id
839+
properties:
840+
id:
841+
type: string
842+
enum:
843+
- "sentry.rules.conditions.high_priority_issue.ExistingHighPriorityIssueCondition"
844+
name:
845+
type: string
846+
ProjectRuleConditionEventFrequency:
847+
type: object
848+
required:
849+
- id
850+
- comparisonType
851+
- value
852+
- interval
853+
properties:
854+
id:
855+
type: string
856+
enum:
857+
- "sentry.rules.conditions.event_frequency.EventFrequencyCondition"
858+
name:
859+
type: string
860+
comparisonType:
861+
type: string
862+
comparisonInterval:
863+
type: string
864+
value:
865+
type: integer
866+
format: int64
867+
interval:
868+
type: string
869+
ProjectRuleConditionEventUniqueUserFrequency:
870+
type: object
871+
required:
872+
- id
873+
- comparisonType
874+
- value
875+
- interval
876+
properties:
877+
id:
878+
type: string
879+
enum:
880+
- "sentry.rules.conditions.event_frequency.EventUniqueUserFrequencyCondition"
881+
name:
882+
type: string
883+
comparisonType:
884+
type: string
885+
comparisonInterval:
886+
type: string
887+
value:
888+
type: integer
889+
format: int64
890+
interval:
891+
type: string
892+
ProjectRuleConditionEventFrequencyPercent:
893+
type: object
894+
required:
895+
- id
896+
- comparisonType
897+
- value
898+
- interval
899+
properties:
900+
id:
901+
type: string
902+
enum:
903+
- "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition"
904+
name:
905+
type: string
906+
comparisonType:
907+
type: string
908+
comparisonInterval:
909+
type: string
910+
value:
911+
type: number
912+
format: double
913+
interval:
914+
type: string
780915
Team:
781916
type: object
782917
required:

0 commit comments

Comments
 (0)