{
    "swagger": "2.0",
    "info": {
        "version": "4.0.1",
        "title": "Jobs Management",
        "description": "Jobs Management Module API Specification"
    },
    "host": "admin.alertsense.com",
    "basePath": "/api",
    "schemes": [
        "http",
        "https"
    ],
    "consumes": [
        "application/json"
    ],
    "produces": [
        "application/json"
    ],
    "paths": {
        "/v4/{tenantId}/jobs/{jobId}": {
            "get": {
                "operationId": "getJobById",
                "description": "Get a job by ID for the tenant.",
                "tags": [
                    "jobs"
                ],
                "parameters": [
                    {
                        "name": "tenantId",
                        "in": "path",
                        "description": "Id of the tenant",
                        "required": true,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "jobId",
                        "in": "path",
                        "description": "Id of the job",
                        "required": true,
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success. Returns the job for the tenant.",
                        "schema": {
                            "$ref": "#/definitions/SingleJobStatusResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    }
                },
                "security": [
                    {
                        "JwtBearerTokenScheme": [],
                        "Oauth2Scheme": []
                    }
                ]
            }
        },
        "/v4/{tenantId}/jobs/{jobId}/stages": {
            "get": {
                "operationId": "getJobStages",
                "description": "Get the stages for a specified job.",
                "tags": [
                    "jobs"
                ],
                "parameters": [
                    {
                        "name": "tenantId",
                        "in": "path",
                        "description": "Id of the tenant",
                        "required": true,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "jobId",
                        "in": "path",
                        "description": "Id of the job",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "name": "parentId",
                        "in": "query",
                        "description": "Parent stage to get child stage ids for",
                        "required": false,
                        "type": "string"
                    },
                    {
                        "name": "ids",
                        "in": "query",
                        "description": "the stage ids to return",
                        "required": false,
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "the page number of jobs to return. (1 by default)",
                        "required": false,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "pageSize",
                        "in": "query",
                        "description": "the desired number of jobs per page. (25 by default)",
                        "required": false,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "description": "the field to sort by",
                        "required": false,
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success. Returns a paged list of the jobs for the tenant.",
                        "schema": {
                            "$ref": "#/definitions/PagedJobStagesResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    }
                },
                "security": [
                    {
                        "JwtBearerTokenScheme": [],
                        "Oauth2Scheme": []
                    }
                ]
            }
        },
        "/v4/{tenantId}/jobs/{jobId}/events": {
            "get": {
                "operationId": "getJobEvents",
                "description": "Get the events for a specified job.",
                "tags": [
                    "jobs"
                ],
                "parameters": [
                    {
                        "name": "tenantId",
                        "in": "path",
                        "description": "Id of the tenant",
                        "required": true,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "jobId",
                        "in": "path",
                        "description": "Id of the job",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "name": "stageId",
                        "in": "query",
                        "description": "Job stage to get the events for",
                        "required": false,
                        "type": "string"
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "the page number of jobs to return. (1 by default)",
                        "required": false,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "pageSize",
                        "in": "query",
                        "description": "the desired number of jobs per page. (25 by default)",
                        "required": false,
                        "type": "integer",
                        "format": "int32"
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "description": "the field to sort by",
                        "required": false,
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success. Returns a paged list of the jobs for the tenant.",
                        "schema": {
                            "$ref": "#/definitions/PagedJobEventsResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/ApiResponse"
                        }
                    }
                },
                "security": [
                    {
                        "JwtBearerTokenScheme": [],
                        "Oauth2Scheme": []
                    }
                ]
            }
        }
    },
    "parameters": {
        "endDate": {
            "name": "endDate",
            "in": "query",
            "description": "The ending date for the date range.",
            "required": false,
            "type": "string",
            "format": "date-time"
        },
        "integrationsCategory": {
            "name": "category",
            "in": "query",
            "description": "The category of integration history items.",
            "required": false,
            "type": "string",
            "enum": [
                "None",
                "Event",
                "Trigger",
                "Action",
                "Status"
            ]
        },
        "level": {
            "name": "level",
            "in": "query",
            "description": "The level of history items.",
            "required": false,
            "type": "string",
            "enum": [
                "Debug",
                "Information",
                "Warning",
                "Error"
            ]
        },
        "page": {
            "name": "page",
            "in": "query",
            "description": "The page number of items to return. (1 by default)",
            "required": false,
            "default": 1,
            "type": "integer",
            "format": "int32"
        },
        "pageSize": {
            "name": "pageSize",
            "in": "query",
            "description": "The desired number of items per page. (25 by default)",
            "default": 25,
            "required": false,
            "type": "integer",
            "format": "int32"
        },
        "search": {
            "name": "search",
            "in": "query",
            "description": "A value matched against one or more resource properties.",
            "required": false,
            "type": "string"
        },
        "sort": {
            "name": "sort",
            "in": "query",
            "description": "A comma seperated list of properties to order by. Properties preceded by a '-' will be ordered descending. (e.g.  ?sort=lastName,firstName,-responseTime). Property names are case insensitive.",
            "required": false,
            "type": "string"
        },
        "startDate": {
            "name": "startDate",
            "in": "query",
            "description": "The starting date for the date range.",
            "required": false,
            "type": "string",
            "format": "date-time"
        }
    },
    "responses": {
        "204": {
            "description": "Success. No Content."
        },
        "400": {
            "description": "Bad request.",
            "schema": {
                "$ref": "#/definitions/ErrorResponse"
            },
            "examples": {
                "application/json": {
                    "error": "Bad request."
                }
            }
        },
        "401": {
            "description": "Unauthorized.",
            "schema": {
                "$ref": "#/definitions/ErrorResponse"
            },
            "examples": {
                "application/json": {
                    "error": "Unauthorized."
                }
            }
        },
        "403": {
            "description": "Forbidden.",
            "schema": {
                "$ref": "#/definitions/ErrorResponse"
            },
            "examples": {
                "application/json": {
                    "error": "Forbidden."
                }
            }
        },
        "404": {
            "description": "Not Found.",
            "schema": {
                "$ref": "#/definitions/ErrorResponse"
            },
            "examples": {
                "application/json": {
                    "error": "Not Found."
                }
            }
        },
        "500": {
            "description": "Internal server error.",
            "schema": {
                "$ref": "#/definitions/ErrorResponse"
            },
            "examples": {
                "application/json": {
                    "error": "Unexpected server error."
                }
            }
        }
    },
    "definitions": {
        "ApiResponse": {
            "discriminator": "type",
            "properties": {
                "status": {
                    "$ref": "#/definitions/ResponseStatus"
                },
                "hasErrors": {
                    "description": "Set true when status.isSuccess is false.",
                    "type": "boolean"
                },
                "isValid": {
                    "description": "Set false on API parameter validation failures.",
                    "type": "boolean"
                }
            },
            "type": "object"
        },
        "ErrorResponse": {
            "properties": {
                "error": {
                    "type": "string"
                }
            },
            "type": "object"
        },
        "JobEvent": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "jobId": {
                    "type": "string"
                },
                "stage": {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string"
                        },
                        "id": {
                            "type": "string"
                        }
                    }
                },
                "messages": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/JobMessage"
                    }
                },
                "metadata": {
                    "description": "Additional metadata about the job event",
                    "$ref": "#/definitions/Metadata"
                },
                "timestamp": {
                    "type": "string",
                    "format": "date-time"
                }
            }
        },
        "JobMessage": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "description": {
                    "type": "string"
                }
            }
        },
        "JobStage": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "jobId": {
                    "type": "string"
                },
                "parentId": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "timestamp": {
                    "type": "string",
                    "format": "date-time"
                }
            }
        },
        "JobState": {
            "type": "string",
            "enum": [
                "Queued",
                "Running",
                "Success",
                "Failure"
            ]
        },
        "JobStatus": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "tenantId": {
                    "type": "string"
                },
                "timestamp": {
                    "type": "string",
                    "format": "date-time"
                },
                "type": {
                    "$ref": "#/definitions/JobType"
                },
                "state": {
                    "$ref": "#/definitions/JobState"
                },
                "isSuccess": {
                    "type": "boolean"
                },
                "metadata": {
                    "description": "Additional metadata about the job",
                    "$ref": "#/definitions/Metadata"
                }
            }
        },
        "JobType": {
            "type": "string",
            "enum": [
                "Geocoding",
                "Sftp",
                "TaskListReminder",
                "AlertPreview",
                "SendAlert",
                "ExtractUsageData",
                "Installer",
                "TeamsDiscovery",
                "LargeScaleIncident",
                "BulkAlert",
                "BulkTaskListActivation",
                "ContactUploadPreview",
                "ContactUploadImport"
            ]
        },
        "Metadata": {
            "type": "object",
            "properties": {
                "tags": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "statistics": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "number",
                        "format": "float"
                    }
                },
                "attributes": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                },
                "tenantId": {
                    "type": "string"
                },
                "ownerId": {
                    "type": "string"
                },
                "featuresInUse": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "PagedApiResponse": {
            "discriminator": "type",
            "properties": {
                "page": {
                    "format": "int32",
                    "type": "integer"
                },
                "pageCount": {
                    "format": "int32",
                    "type": "integer"
                },
                "pageSize": {
                    "format": "int32",
                    "type": "integer"
                },
                "totalItemCount": {
                    "format": "int32",
                    "type": "integer"
                },
                "status": {
                    "$ref": "#/definitions/ResponseStatus"
                },
                "hasErrors": {
                    "description": "Set true when status.isSuccess is false.",
                    "type": "boolean"
                },
                "isValid": {
                    "description": "Set false on API parameter validation failures.",
                    "type": "boolean"
                }
            },
            "type": "object"
        },
        "PagedJobEventsResponse": {
            "allOf": [
                {
                    "$ref": "#/definitions/PagedApiResponse"
                },
                {
                    "properties": {
                        "items": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/JobEvent"
                            }
                        }
                    }
                }
            ]
        },
        "PagedJobStagesResponse": {
            "allOf": [
                {
                    "$ref": "#/definitions/PagedApiResponse"
                },
                {
                    "properties": {
                        "items": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/JobStage"
                            }
                        }
                    }
                }
            ]
        },
        "ResponseMessage": {
            "type": "object",
            "properties": {
                "severity": {
                    "type": "string"
                },
                "message": {
                    "type": "string"
                },
                "resourceKey": {
                    "type": "string"
                }
            },
            "example": {
                "severity": "Warning",
                "message": "My custom message",
                "resourceKey": "warnings.customMessage"
            }
        },
        "ResponseStatus": {
            "type": "object",
            "properties": {
                "resourceKey": {
                    "type": "string"
                },
                "isSuccess": {
                    "description": "False when errorCode is not None or there is an errorMessage or validationFailures.",
                    "type": "boolean"
                },
                "errorCode": {
                    "type": "string"
                },
                "errorMessage": {
                    "type": "string"
                },
                "validationFailures": {
                    "description": "API parameter validation failures.",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/ValidationFailure"
                    }
                },
                "messages": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/ResponseMessage"
                    }
                }
            },
            "example": {
                "resourceKey": "error.notFound",
                "isSuccess": false,
                "errorCode": "NotFound",
                "errorMessage": "The item cannot be found.",
                "validationFailures": [
                    {
                        "propertyName": "email",
                        "errorMessage": "Value is required",
                        "errorCode": "Required",
                        "attemptedValue": "chester.tester@mailinator.com"
                    }
                ],
                "messages": [
                    {
                        "severity": "Warning",
                        "message": "My custom message"
                    }
                ]
            }
        },
        "SingleJobStatusResponse": {
            "type": "object",
            "allOf": [
                {
                    "$ref": "#/definitions/ApiResponse"
                },
                {
                    "properties": {
                        "item": {
                            "$ref": "#/definitions/JobStatus"
                        }
                    }
                }
            ]
        },
        "ValidationFailure": {
            "type": "object",
            "properties": {
                "propertyName": {
                    "type": "string"
                },
                "errorMessage": {
                    "type": "string"
                },
                "errorCode": {
                    "type": "string"
                },
                "attemptedValue": {
                    "type": "object"
                },
                "resourceKey": {
                    "type": "string"
                }
            },
            "example": {
                "propertyName": "email",
                "errorMessage": "Value is required",
                "errorCode": "Required",
                "attemptedValue": "chester.tester@mailinator.com",
                "resourceKey": "validation.required"
            }
        }
    },
    "securityDefinitions": {
        "Oauth2Scheme": {
            "type": "oauth2",
            "flow": "accessCode",
            "tokenUrl": "https://auth.alertsense.com/connect/token",
            "authorizationUrl": "https://auth.alertsense.com/account/login",
            "scopes": {
                "tamarack": "Hickory",
                "content": "ExternalID",
                "elm": "GIS"
            }
        },
        "JwtBearerTokenScheme": {
            "type": "apiKey",
            "description": "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"",
            "name": "Authorization",
            "in": "header"
        }
    }
}