Skip to content

Commit

Permalink
feature: update monitorv2 to allow inline actions (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
obs-gh-catherman authored Dec 3, 2024
1 parent e0b8aa4 commit 526a97b
Show file tree
Hide file tree
Showing 13 changed files with 1,395 additions and 122 deletions.
17 changes: 17 additions & 0 deletions client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,23 @@ func (c *Client) GetMonitor(ctx context.Context, id string) (*meta.Monitor, erro
return c.Meta.GetMonitor(ctx, id)
}

func (c *Client) SaveMonitorV2WithActions(
ctx context.Context,
workspaceId string,
monitorId *string,
input *meta.MonitorV2Input,
actions []meta.MonitorV2ActionAndRelationInput,
) (*meta.MonitorV2, error) {
if !c.Flags[flagObs2110] {
c.obs2110.Lock()
defer c.obs2110.Unlock()
}
if c.Config.ManagingObjectID != nil {
input.ManagedById = c.Config.ManagingObjectID
}
return c.Meta.SaveMonitorV2WithActions(ctx, workspaceId, monitorId, input, actions)
}

func (c *Client) CreateMonitorV2(ctx context.Context, workspaceId string, input *meta.MonitorV2Input) (*meta.MonitorV2, error) {
if !c.Flags[flagObs2110] {
c.obs2110.Lock()
Expand Down
90 changes: 90 additions & 0 deletions client/internal/meta/operation/monitorv2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ fragment MonitorV2Definition on MonitorV2Definition{
}
lookbackTime
dataStabilizationDelay
maxAlertsPerHour
# @genqlient(flatten: true)
groupings {
...MonitorV2Column
Expand Down Expand Up @@ -155,13 +156,31 @@ fragment MonitorV2ActionRule on MonitorV2ActionRule {
levels
sendEndNotifications
sendRemindersInterval
# @genqlient(flatten: true)
definition {
...MonitorV2ActionDefinition
}
}

fragment MonitorV2ActionDefinition on MonitorV2ActionDefinition {
inline
type
# @genqlient(flatten: true)
email {
...MonitorV2EmailAction
}
# @genqlient(flatten: true)
webhook {
...MonitorV2WebhookAction
}
}

# @genqlient(for: "MonitorV2Input.iconUrl", omitempty: true)
# @genqlient(for: "MonitorV2Input.description", omitempty: true)
# @genqlient(for: "MonitorV2Input.managedById", omitempty: true)
# @genqlient(for: "MonitorV2Input.folderId", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.dataStabilizationDelay", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.maxAlertsPerHour", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.count", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.threshold", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.promote", omitempty: true)
Expand All @@ -180,6 +199,7 @@ fragment MonitorV2ActionRule on MonitorV2ActionRule {
# @genqlient(for: "PrimitiveValueInput.string", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.timestamp", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.duration", omitempty: true)
# @genclient(for: "MonitorV2ComparisonExpressionInput.conditions", omitempty: true)
fragment MonitorV2 on MonitorV2 {
id
workspaceId
Expand Down Expand Up @@ -209,6 +229,7 @@ fragment MonitorV2 on MonitorV2 {
# @genqlient(for: "MonitorV2Input.managedById", omitempty: true)
# @genqlient(for: "MonitorV2Input.folderId", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.dataStabilizationDelay", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.maxAlertsPerHour", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.count", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.threshold", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.promote", omitempty: true)
Expand All @@ -227,6 +248,7 @@ fragment MonitorV2 on MonitorV2 {
# @genqlient(for: "PrimitiveValueInput.string", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.timestamp", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.duration", omitempty: true)
# @genclient(for: "MonitorV2ComparisonExpressionInput.conditions", omitempty: true)
mutation createMonitorV2(
$workspaceId: ObjectId!,
$input: MonitorV2Input!
Expand All @@ -242,6 +264,7 @@ mutation createMonitorV2(
# @genqlient(for: "MonitorV2Input.managedById", omitempty: true)
# @genqlient(for: "MonitorV2Input.folderId", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.dataStabilizationDelay", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.maxAlertsPerHour", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.count", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.threshold", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.promote", omitempty: true)
Expand All @@ -260,6 +283,7 @@ mutation createMonitorV2(
# @genqlient(for: "PrimitiveValueInput.string", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.timestamp", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.duration", omitempty: true)
# @genclient(for: "MonitorV2ComparisonExpressionInput.conditions", omitempty: true)
mutation updateMonitorV2(
$id: ObjectId!,
$input: MonitorV2Input!
Expand Down Expand Up @@ -291,6 +315,8 @@ query lookupMonitorV2($workspaceId: ObjectId, $folderId: ObjectId, $nameExact: S
}
}

# @genqlient(for: "MonitorV2ActionRuleInput.levels", omitempty: true)
# @genqlient(for: "MonitorV2ActionRuleInput.conditions", omitempty: true)
# @genqlient(for: "MonitorV2ActionRuleInput.sendEndNotifications", omitempty: true)
# @genqlient(for: "MonitorV2ActionRuleInput.sendRemindersInterval", omitempty: true)
mutation saveMonitorV2Relations(
Expand All @@ -302,3 +328,67 @@ mutation saveMonitorV2Relations(
...MonitorV2
}
}

# @genqlient(for: "MonitorV2Input.iconUrl", omitempty: true)
# @genqlient(for: "MonitorV2Input.description", omitempty: true)
# @genqlient(for: "MonitorV2Input.managedById", omitempty: true)
# @genqlient(for: "MonitorV2Input.folderId", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.groupings", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.dataStabilizationDelay", omitempty: true)
# @genqlient(for: "MonitorV2DefinitionInput.maxAlertsPerHour", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.count", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.threshold", omitempty: true)
# @genqlient(for: "MonitorV2RuleInput.promote", omitempty: true)
# @genqlient(for: "MonitorV2ColumnInput.linkColumn", omitempty: true)
# @genqlient(for: "MonitorV2ColumnInput.columnPath", omitempty: true)
# @genqlient(for: "MonitorV2LinkColumnInput.meta", omitempty: true)
# @genqlient(for: "MonitorV2ColumnPathInput.path", omitempty: true)
# @genqlient(for: "InputDefinitionInput.stageID", omitempty: true)
# @genqlient(for: "InputDefinitionInput.stageId", omitempty: true)
# @genqlient(for: "StageQueryInput.stageID", omitempty: true)
# @genqlient(for: "StageQueryInput.stageId", omitempty: true)
# @genqlient(for: "StageQueryInput.id", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.bool", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.float64", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.int64", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.string", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.timestamp", omitempty: true)
# @genqlient(for: "PrimitiveValueInput.duration", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.inline", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.email", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.webhook", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.iconUrl", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.description", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.managedById", omitempty: true)
# @genqlient(for: "MonitorV2ActionInput.folderId", omitempty: true)
# @genqlient(for: "MonitorV2EmailActionInput.fragments", omitempty: true)
# @genqlient(for: "MonitorV2WebhookActionInput.headers", omitempty: true)
# @genqlient(for: "MonitorV2WebhookActionInput.fragments", omitempty: true)
# @genqlient(for: "MonitorV2ActionAndRelationInput.action", omitempty: true)
# @genqlient(for: "MonitorV2ActionAndRelationInput.actionID", omitempty: true)
# @genqlient(for: "MonitorV2ActionAndRelationInput.levels", omitempty: true)
# @genqlient(for: "MonitorV2ActionAndRelationInput.conditions", omitempty: true)
# @genqlient(for: "MonitorV2ActionAndRelationInput.sendEndNotifications", omitempty: true)
# @genqlient(for: "MonitorV2ActionAndRelationInput.sendRemindersInterval", omitempty: true)
# @genqlient(for: "MonitorV2ComparisonExpressionInput.compareTerms", omitempty: true)
# @genqlient(for: "MonitorV2ComparisonExpressionInput.subExpressions", omitempty: true)
# @genqlient(for: "MonitorV2CountRuleInput.compareGroups", omitempty: true)
# @genqlient(for: "MonitorV2ThresholdRuleInput.compareGroups", omitempty: true)
# @genqlient(for: "MonitorV2PromoteRuleInput.compareColumns", omitempty: true)
mutation saveMonitorV2WithActions(
$workspaceId: ObjectId!,
$monitorId: ObjectId,
$input: MonitorV2Input!,
$actions: [MonitorV2ActionAndRelationInput!],
) {
# @genqlient(flatten: true)
monitorV2: saveMonitorV2WithActions(
workspaceId: $workspaceId,
monitorId: $monitorId,
input: $input,
actions: $actions,
) {
...MonitorV2
}
}

Loading

0 comments on commit 526a97b

Please sign in to comment.