import { PrimitiveValue } from './common'; import { SchedulerInterval } from './scheduler'; import { Query } from './question'; import { ResultRecordOutput, InternalRawDataDescriptor } from './reporting'; import { AlertInterval, AlertLevel } from './alert'; import { AWSRegion, S3BucketTagSet } from './aws'; export declare type PrimitiveCondition = string | boolean | number; export declare type Condition = PrimitiveCondition | ConditionArray; export declare type ConditionArray = Array; export interface WhenCondition { type: ConditionType; } export interface FilterWhenCondition extends WhenCondition { specVersion?: number; condition: Condition; } export declare enum RuleType { QUESTION = "QUESTION", REPORT = "REPORT" } export declare enum ConditionType { FILTER = "FILTER" } export interface WhenCondition { type: ConditionType; } export declare enum RuleActionType { CREATE_ALERT = "CREATE_ALERT", CUMULATIVE_ALERTS_EMAIL_REPORT = "CUMULATIVE_ALERTS_EMAIL_REPORT", SET_PROPERTY = "SET_PROPERTY", SEND_EMAIL = "SEND_EMAIL", CREATE_JIRA_TICKET = "CREATE_JIRA_TICKET", SEND_SLACK_MESSAGE = "SEND_SLACK_MESSAGE", CREATE_SERVICE_NOW_INCIDENT = "CREATE_SERVICE_NOW_INCIDENT", WEBHOOK = "WEBHOOK", PUBLISH_SNS_MESSAGE = "PUBLISH_SNS_MESSAGE", SEND_SQS_MESSAGE = "SEND_SQS_MESSAGE", REFLEX_SEND_SQS_MESSAGE = "REFLEX_SEND_SQS_MESSAGE", FOR_EACH_ITEM = "FOR_EACH_ITEM", JUPITERONE_QUERY = "JUPITERONE_QUERY", ADD_S3_BUCKET_TAG = "ADD_S3_BUCKET_TAG", DAILY_ALERT_EMAIL_REPORT = "DAILY_ALERT_EMAIL_REPORT" } export interface RuleAction { /** * Unique identifier of this action. This is auto-assigned at creation time * of the rule. */ id: string; type: RuleActionType; } export interface IntegrationRuleAction extends RuleAction { integrationInstanceId: string; } export interface SetPropertyRuleAction extends RuleAction { targetProperty: string; targetValue: PrimitiveValue; } /** * Deprecated - Use CumulativeAlertsEmailReportRuleAction */ export interface DailyAlertEmailReportRuleAction extends RuleAction { recipients: string[]; minAlertLevelThreshold?: AlertLevel; } export interface CumulativeAlertsEmailRecipient { alertInterval: AlertInterval; emailAddress: string; } export interface CumulativeAlertsEmailReportRuleAction extends RuleAction { recipients: string[]; minAlertLevelThreshold?: AlertLevel; } export interface SendEmailAction extends RuleAction { recipients: string[]; /** * Extra body information after the core header bits of the email has been constructed. */ body?: string; } export interface CreateJiraTicketAction extends IntegrationRuleAction { entityClass: string; project: string; summary: string; issueType: string; additionalFields?: object; } export interface CreateServiceNowIncidentAction extends IntegrationRuleAction { requestBody: object; } export interface CreateAlertAction extends RuleAction { } export interface BaseSendSlackMessageAction extends RuleAction { severity?: AlertLevel; /** * Extra body information after the core Slack message blocks have been * constructed. */ body?: string; } export interface SendSlackMessageWebhookAction extends BaseSendSlackMessageAction { webhookUrl: string; } export interface SendSlackMessageIntegrationInstanceAction extends BaseSendSlackMessageAction { integrationInstanceId: string; channels: string[]; } export declare type SendSlackMessageAction = SendSlackMessageWebhookAction & SendSlackMessageIntegrationInstanceAction; export declare enum WebhookRuleActionMethod { POST = "POST", PUT = "PUT", GET = "GET", HEAD = "HEAD", PATCH = "PATCH", DELETE = "DELETE" } export interface WebhookRuleAction extends RuleAction { endpoint: string; method: WebhookRuleActionMethod; body?: object; headers?: object; } export interface PublishSnsMesssageAction extends IntegrationRuleAction { topicArn: string; data: object; } export declare enum SqsMessageAttributeValueDataType { STRING = "String", NUMBER = "Number" } export interface SqsMessageAttributeValue { /** * Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters. */ StringValue?: string; /** * Amazon SQS supports the following logical data types: String, Number, and Binary. For the Number data type, you must use StringValue. You can also append custom labels. For more information, see Amazon SQS Message Attributes in the Amazon Simple Queue Service Developer Guide. */ DataType: SqsMessageAttributeValueDataType; } export declare type SqsMessageBodyAttributeMap = { [key: string]: SqsMessageAttributeValue; }; export interface SendSqsMesssageAction extends IntegrationRuleAction { queueUrl: string; messageAttributes?: SqsMessageBodyAttributeMap; /** * Data that gets included in `MessageBody` after stringified */ data: object; } export interface ForEachItemRuleAction extends RuleAction { items: string | any[]; /** * Used for scoping local data so that subsequent nested rule actions do not * necessarily overwrite each other's data. */ itemRef: string; actions: RuleAction[]; } export interface JupiterOneQueryAction extends RuleAction { name: string; query: string; version?: string; } export interface AddTagToS3BucketAction extends IntegrationRuleAction { bucket: string; region: AWSRegion; tags: S3BucketTagSet; } export declare type RuleActionProperties = RuleAction & CreateAlertAction & DailyAlertEmailReportRuleAction & CumulativeAlertsEmailReportRuleAction & SetPropertyRuleAction & SendEmailAction & CreateJiraTicketAction & CreateServiceNowIncidentAction & SendSlackMessageAction & WebhookRuleAction & PublishSnsMesssageAction & SendSlackMessageAction & ForEachItemRuleAction & JupiterOneQueryAction & AddTagToS3BucketAction; export interface RuleOperation { when?: WhenCondition | WhenCondition[]; actions: RuleAction[]; } export declare enum ActionRuleStateType { JIRA = "JIRA" } export interface ActionRuleState { type: ActionRuleStateType; } export interface JiraActionRuleState extends ActionRuleState { type: ActionRuleStateType.JIRA; /** * Jira host e.g. lifeomic.atlassian.net */ host: string; /** * Jira ticket id e.g. 12345 */ id: string; /** * Jira ticket key e.g. JPT-123 */ key: string; } export interface ActionRuleStateMap { /** * Map of actionId to the state that the action has created */ [key: string]: ActionRuleState; } export interface RuleState { actions?: ActionRuleStateMap; } export interface BaseRuleInstance { name: string; description?: string | undefined; /** * The revision of this rule instance. When updating a Rule, the version is * bumped. */ version: number; /** * This is the version of the rule schema. If we ever update the schema of * rules and how rules are evaluated, this will be used to determine it */ specVersion: number; /** * Is this the latest version of the rule instance? */ latest: boolean; /** * Marks whether this rule has been deleted or not */ deleted: boolean; /** * Id of the latest alert created by this rule */ latestAlertId?: string; /** * Whether the latest alert is active or not. This is used to determine which * rule instances should be fetched. */ latestAlertIsActive?: boolean; /** * Key/value pairs of template name to template string. These templates * can be used inside of different operation values. For example: * * { * "body": "Hello {{itemCount}} {{itemIndex}} {{{itemIndex+1}} {item.firstName}} {{item.lastName}}" * } */ templates?: Record; state?: RuleState; type: RuleType; outputs: string[]; operations: RuleOperation[]; pollingInterval?: SchedulerInterval; } export interface RuleInstance extends BaseRuleInstance { id: string; accountId?: string; } export declare enum RuleEvaluationOrigin { MANUAL = "MANUAL", SCHEDULED = "SCHEDULED", STREAMED = "STREAMED" } export interface RuleInstanceEvaluationQueuePayload { ruleInstanceId: string; ruleInstanceVersion: number; accountId: string; ruleEvaluationOrigin: RuleEvaluationOrigin; /** * The total number of attempts that this payload has been retried. If the * value of `attempts` is `undefined`, it's assumed that this is the first * evaluation. */ attempts?: number; } export interface RuleQuestionDetails { queries: Query[]; version?: string; } export interface QuestionRuleInstance extends RuleInstance { question: RuleQuestionDetails; } export declare type RuleEvaluationOutput = ResultRecordOutput; export interface RuleEvaluationResult { answerText?: string; /** * Whether there was a difference between the raw data of the current rule * evaluation and the last rule evaluation */ rawDataDiff: boolean; /** * Whether a raw data diff was even performed. This will happen in the case * where the previous raw data could not be fetched inside the `jupiter-questions-service` * or if there was not `previousQueryMetaData` passed to the `jupiter-questions-service` * because this is the first time this has been run. */ rawDataDiffOccurred: boolean; outputs: RuleEvaluationOutput[] | undefined; rawDataDescriptors: InternalRawDataDescriptor[] | undefined; evaluationBeginOn: number; evaluationEndOn: number; }