bloodhound-1.0.0.0: src/Database/Bloodhound/OpenSearch3/Client.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- |
-- Module : Database.Bloodhound.OpenSearch3.Client
-- Description : OpenSearch 3 client (re-exports Common + OpenSearch 3 plugins)
--
-- The OpenSearch 3 client. Re-exports the version-agnostic "Database.Bloodhound.Common.Client"
-- surface and adds OpenSearch 3 plugins: neural and k-NN search/stats (incl. k-NN
-- model training), Index State Management (ISM), ML commons models and agents,
-- point in time (PIT), asynchronous search, SQL and PPL, the notifications
-- framework, and the alerting/monitors framework.
module Database.Bloodhound.OpenSearch3.Client
( module Reexport,
pitSearch,
pitSearchWith,
openPointInTime,
openPointInTimeWith,
closePointInTime,
listAllPITs,
deleteAllPITs,
neuralSearchByIndices,
neuralSearchByIndex,
getNeuralStats,
getNeuralStatsWith,
warmupNeuralIndex,
warmupNeuralIndices,
clearNeuralCache,
clearNeuralCaches,
getKnnStats,
warmupKnnIndex,
warmupKnnIndices,
clearKnnCache,
clearKnnCaches,
getKnnModel,
trainKnnModel,
trainKnnModelWith,
deleteKnnModel,
searchKnnModels,
getMLStats,
getModel,
registerModel,
registerModelWith,
deployModel,
undeployModel,
updateModel,
searchModels,
listModels,
deleteModel,
predict,
registerAgent,
getAgent,
deleteAgent,
searchAgents,
updateAgent,
executeAgent,
executeAgentAsync,
executeStreamAgent,
executeStreamAgentAGUI,
knnSearch,
getMLTask,
deleteISMPolicy,
addISMPolicy,
putISMPolicy,
putISMPolicyWith,
removeISMPolicy,
changeISMPolicy,
retryISMIndex,
explainISMIndex,
explainISMIndexWith,
explainISMIndexFiltered,
simulateISMPolicy,
getISMPolicy,
getISMPolicies,
postSMPolicy,
putSMPolicyWith,
getSMPolicy,
getSMPolicies,
deleteSMPolicy,
startSMPolicy,
stopSMPolicy,
explainSMPolicies,
submitOSAsyncSearch,
submitOSAsyncSearchWith,
getOSAsyncSearch,
deleteOSAsyncSearch,
getOSAsyncSearchStats,
sqlQuery,
sqlQueryNextPage,
closeSqlCursor,
explainSQL,
pplQuery,
explainPPL,
getSQLStats,
createNotificationConfig,
createNotificationConfigWith,
deleteNotificationConfig,
deleteNotificationConfigs,
getNotificationConfig,
getNotificationConfigs,
getNotificationConfigsWith,
getNotificationFeatures,
getNotificationChannels,
getNotificationChannelsWith,
updateNotificationConfig,
sendTestNotification,
createMonitor,
getMonitor,
updateMonitor,
updateMonitorWith,
deleteMonitor,
searchMonitors,
executeMonitor,
createSADetector,
getSADetector,
updateSADetector,
deleteSADetector,
searchSADetectors,
searchSAPrePackagedRules,
searchSACustomRules,
createSACustomRule,
updateSACustomRule,
deleteSACustomRule,
getSAMappingsView,
createSAMappings,
getSAMappings,
updateSAMappings,
getSAAlertsWith,
getSAAlerts,
acknowledgeSADetectorAlerts,
searchSAFindings,
createSACorrelationRule,
getSACorrelations,
findSACorrelation,
searchSACorrelationAlerts,
acknowledgeSACorrelationAlerts,
createSALogType,
searchSALogTypes,
updateSALogType,
deleteSALogType,
getDestinations,
getDestinationsWith,
createDestination,
updateDestination,
deleteDestination,
getAlertsWith,
getAlerts,
acknowledgeAlert,
getMonitorStats,
createEmailAccount,
getEmailAccount,
updateEmailAccount,
updateEmailAccountWith,
deleteEmailAccount,
createEmailGroup,
getEmailGroup,
updateEmailGroup,
updateEmailGroupWith,
deleteEmailGroup,
getDestination,
searchEmailAccounts,
searchEmailGroups,
searchFindings,
createComment,
updateComment,
searchComments,
deleteComment,
createWorkflow,
createWorkflowWith,
getWorkflow,
provisionWorkflow,
provisionWorkflowWith,
deleteWorkflow,
deleteWorkflowWith,
searchWorkflows,
updateWorkflow,
updateWorkflowWith,
deprovisionWorkflow,
deprovisionWorkflowWith,
getWorkflowState,
getWorkflowStateWith,
getWorkflowSteps,
getWorkflowStepsWith,
searchWorkflowState,
createDetector,
getDetector,
previewDetector,
previewDetectorInline,
startDetector,
stopDetector,
updateDetector,
updateDetectorWith,
deleteDetector,
validateDetector,
searchDetectors,
profileDetector,
getDetectorStats,
searchDetectorResults,
deleteDetectorResults,
searchDetectorTasks,
topAnomalies,
createRollup,
createRollupWith,
getRollup,
getAllRollups,
deleteRollup,
startRollup,
stopRollup,
explainRollup,
startReplication,
stopReplication,
pauseReplication,
resumeReplication,
updateReplicationSettings,
getReplicationStatus,
getReplicationStatusWith,
getLeaderStats,
getFollowerStats,
getAutoFollowStats,
createAutoFollowPattern,
deleteAutoFollowPattern,
createTransform,
updateTransform,
updateTransformWith,
getTransform,
getTransforms,
startTransform,
stopTransform,
explainTransform,
previewTransform,
deleteTransform,
getJobSchedulerJobs,
getJobSchedulerLocks,
getJobSchedulerLock,
)
where
import Control.Monad
import Control.Monad.IO.Class (MonadIO)
import Data.Aeson
import Data.Aeson.KeyMap qualified as KM
import Data.ByteString.Lazy qualified as BL
import Data.List.NonEmpty (NonEmpty)
import Data.Maybe (fromMaybe)
import Data.Monoid
import Data.Text (Text)
import Data.Text.Encoding qualified as TE
import Data.Word (Word64)
import Database.Bloodhound.Client.Cluster
import Database.Bloodhound.Common.Client as Reexport hiding
( PreviewTransformResponse,
TransformId,
TransformStats,
deleteTransform,
explainTransform,
getTransforms,
previewTransform,
startTransform,
stopTransform,
unTransformId,
updateTransform,
updateTransformWith,
)
import Database.Bloodhound.Internal.Utils.SSE (newSSEState, readSSEEvent, sseData)
import Database.Bloodhound.Internal.Versions.Common.Types.Knn
import Database.Bloodhound.Internal.Versions.Common.Types.Search
import Database.Bloodhound.OpenSearch3.Requests qualified as Requests
import Database.Bloodhound.OpenSearch3.Types
import Network.HTTP.Client qualified as HTTP (responseBody)
import Prelude hiding (filter, head)
-- | 'pitSearch' uses the point in time (PIT) API of OpenSearch, for a given
-- 'IndexName'. The supplied 'KeepAlive' duration is forwarded to every PIT
-- open\/extend call. Note that this will consume the entire search result set
-- and will be doing O(n) list appends so this may not be suitable for large
-- result sets. In that case, the point in time API should be used directly
-- with `openPointInTime` and `closePointInTime`.
--
-- This is a convenience wrapper around 'pitSearchWith' that lifts the
-- single 'IndexName' into an 'IndexPattern'. To search across multiple
-- comma-joined indices or a wildcard pattern, use 'pitSearchWith'
-- directly with an 'IndexPattern'.
--
-- Note that 'pitSearch' utilizes the 'search_after' parameter under the hood,
-- which requires a non-empty 'sortBody' field in the provided 'Search' value.
-- Otherwise, 'pitSearch' will fail to return all matching documents.
--
-- Closing the PIT (via 'closePointInTime') is best-effort cleanup: if it
-- fails, the accumulated hits are still returned rather than discarded. The
-- PIT will expire on its own once the @keep_alive@ elapses.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/api-reference/search-apis/point-in-time-api/>.
pitSearch ::
forall a m.
(FromJSON a, MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
KeepAlive ->
Search ->
m [Hit a]
pitSearch indexName = pitSearchWith (IndexPattern (unIndexName indexName))
-- | 'pitSearchWith' is the parameterized variant of 'pitSearch': it
-- takes an 'IndexPattern' as the target (@target_indexes@ on the wire),
-- which may be a single index name, a comma-separated list of indices,
-- or a wildcard pattern (e.g. @\"logs-*\"@, @\"logs-2024,logs-2025\"@).
-- Otherwise behaves exactly like 'pitSearch'. See
-- 'openPointInTimeWith' for the target rendering.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/api-reference/search-apis/point-in-time-api/>.
pitSearchWith ::
forall a m.
(FromJSON a, MonadBH m, WithBackend OpenSearch3 m) =>
IndexPattern ->
KeepAlive ->
Search ->
m [Hit a]
pitSearchWith indexPattern keepAlive search = do
openResp <- openPointInTimeWith indexPattern keepAlive defaultPITOptions
case openResp of
Left e -> throwEsError e
Right OpenPointInTimeResponse {..} -> do
let searchPIT = search {pointInTime = Just (PointInTime oos3PitId (Just keepAlive))}
hits <- pitAccumulator searchPIT []
closeResp <- closePointInTime (ClosePointInTime [oos3PitId])
case closeResp of
Left _ -> return hits
Right resp
| not (null (closePITs resp)) && all cpitSuccessful (closePITs resp) -> return hits
| otherwise -> error "failed to close point in time (PIT)"
where
pitAccumulator :: Search -> [Hit a] -> m [Hit a]
pitAccumulator search' oldHits = do
resp <- tryPerformBHRequest $ Requests.searchAll search'
case resp of
Left _ -> return []
Right searchResult -> case hits (searchHits searchResult) of
[] -> return oldHits
newHits -> case (hitSort $ last newHits, pitId searchResult) of
(Nothing, Nothing) ->
error "no point in time (PIT) ID or last sort value"
(Just _, Nothing) -> error "no point in time (PIT) ID"
(Nothing, _) -> return (oldHits <> newHits)
(Just lastSort, Just pitId') -> do
let newSearch =
search'
{ pointInTime = Just (PointInTime pitId' (Just keepAlive)),
searchAfterKey = Just lastSort
}
pitAccumulator newSearch (oldHits <> newHits)
-- | 'openPointInTime' opens a point in time for an index given an 'IndexName'
-- and a 'KeepAlive' duration (e.g. @keepAliveMinutes 1@). Note that the point
-- in time should be closed with 'closePointInTime' as soon as it is no longer
-- needed.
--
-- Equivalent to 'openPointInTimeWith' with
-- 'Database.Bloodhound.Internal.Versions.Common.Types.PointInTime.defaultPITOptions'
-- (no optional URI parameters).
--
-- For more information see
-- <https://docs.opensearch.org/3.7/api-reference/search-apis/point-in-time-api/>.
openPointInTime ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
KeepAlive ->
m (ParsedEsResponse OpenPointInTimeResponse)
openPointInTime indexName keepAlive = performBHRequest $ Requests.openPointInTime indexName keepAlive
-- | 'openPointInTimeWith' is the parameterized variant of
-- 'openPointInTime': it takes an 'IndexPattern' target (single name,
-- comma-list, or wildcard) and forwards the supplied 'PITOptions' as
-- query-string parameters in addition to the mandatory @keep_alive@.
-- See 'Database.Bloodhound.OpenSearch3.Requests.openPointInTimeWith'
-- for which parameters are emitted.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/api-reference/search-apis/point-in-time-api/#create-a-pit>.
openPointInTimeWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexPattern ->
KeepAlive ->
PITOptions ->
m (ParsedEsResponse OpenPointInTimeResponse)
openPointInTimeWith indexPattern keepAlive opts =
performBHRequest $ Requests.openPointInTimeWith indexPattern keepAlive opts
-- | 'closePointInTime' closes a point in time given a 'ClosePointInTime'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/api-reference/search-apis/point-in-time-api/>.
closePointInTime ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ClosePointInTime ->
m (ParsedEsResponse ClosePointInTimeResponse)
closePointInTime q = performBHRequest $ Requests.closePointInTime q
-- | 'listAllPITs' returns every currently-open point in time on the
-- cluster via @GET /_search/point_in_time/_all@. Each 'PITInfo' carries
-- the pit id, the @creation_time@ and the remaining @keep_alive@ (a bare
-- millisecond count on the wire); the @_shards@ summary is absent from
-- list entries (it appears only in the @POST@ create-PIT response, see
-- 'OpenPointInTimeResponse').
--
-- For more information see
-- <https://docs.opensearch.org/3.7/api-reference/search-apis/point-in-time-api/#list-all-pits>.
listAllPITs ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m [PITInfo]
listAllPITs = performBHRequest Requests.listAllPITs
-- | 'deleteAllPITs' deletes every currently-open point in time on the
-- cluster via @DELETE /_search/point_in_time/_all@ (no request body).
-- The server returns one 'ClosePointInTimeResult' per deleted PIT, so
-- the response reuses the 'ClosePointInTimeResponse' envelope; partial
-- failures are reported as failures. Deletes only local and mixed PITs,
-- not fully remote (cross-cluster) ones.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/api-reference/search-apis/point-in-time-api/#delete-pits>.
deleteAllPITs ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse ClosePointInTimeResponse)
deleteAllPITs = performBHRequest Requests.deleteAllPITs
-- | 'neuralSearchByIndices' executes a neural search against a list of
-- indices via the standard @POST \/{indices}\/_search@ endpoint; the
-- neural behaviour comes from a @neural@ clause in the 'Search' body.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/ai-search/index/>.
neuralSearchByIndices ::
(MonadBH m, WithBackend OpenSearch3 m, FromJSON a) =>
[IndexName] ->
Search ->
m (ParsedEsResponse (SearchResult a))
neuralSearchByIndices indices search = performBHRequest $ Requests.neuralSearch indices search
-- | 'neuralSearchByIndex' executes a neural search against a single
-- index (a 'neural' clause in the 'Search' body against
-- @POST \/{index}\/_search@).
neuralSearchByIndex ::
(MonadBH m, WithBackend OpenSearch3 m, FromJSON a) =>
IndexName ->
Search ->
m (ParsedEsResponse (SearchResult a))
neuralSearchByIndex indexName = neuralSearchByIndices [indexName]
-- | 'getNeuralStats' fetches Neural Search plugin statistics. Both arguments
-- are optional: 'Nothing' for the node ID queries every node; 'Nothing' for
-- the stat name returns every stat. The endpoint is disabled by default and
-- must be enabled with the @plugins.neural_search.stats_enabled@ cluster
-- setting before it will respond (else HTTP 403). See
-- "Database.Bloodhound.OpenSearch3.Requests" for the live-verified wire
-- shape.
--
-- Equivalent to 'getNeuralStatsWith' with 'defaultNeuralStatsOptions'; see
-- 'getNeuralStatsWith' to toggle individual response sections via the
-- @include_*@ query parameters.
--
-- For more information see
-- <https://github.com/opensearch-project/neural-search>.
getNeuralStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe NeuralNodeId ->
Maybe NeuralStatName ->
m (ParsedEsResponse NeuralStats)
getNeuralStats mNodeId mStatName = performBHRequest $ Requests.getNeuralStats mNodeId mStatName
-- | 'getNeuralStatsWith' is the parameterized variant of 'getNeuralStats':
-- it forwards the supplied 'NeuralStatsOptions' as the three documented
-- @include_*@ query parameters (@include_info@, @include_all_nodes@,
-- @include_individual_nodes@), each toggling whether the server emits the
-- corresponding top-level section of the 'NeuralStats' response. Fields set
-- to 'Nothing' are omitted; with 'defaultNeuralStatsOptions' this yields no
-- query string, reproducing the wire shape of 'getNeuralStats'. Pass
-- 'defaultNeuralStatsOptions' to reproduce the wire shape of 'getNeuralStats'.
--
-- For more information see
-- <https://github.com/opensearch-project/neural-search>.
getNeuralStatsWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe NeuralNodeId ->
Maybe NeuralStatName ->
NeuralStatsOptions ->
m (ParsedEsResponse NeuralStats)
getNeuralStatsWith mNodeId mStatName opts =
performBHRequest $ Requests.getNeuralStatsWith mNodeId mStatName opts
-- | 'warmupNeuralIndices' preloads the neural sparse data for the given
-- indices into JVM memory on the data nodes, so the first neural sparse
-- search against each index does not pay the cache-load latency. Maps to
-- @POST /_plugins/_neural/warmup/{index}@ (the index segment is rendered
-- as a comma-separated list, matching the OpenSearch multi-target syntax)
-- and returns 'ShardsResult' (the @{\"_shards\":{...}}@ envelope) on
-- success. The warmup is asynchronous — the response is returned as soon
-- as the load is scheduled; 'getNeuralStats' reports plugin cache
-- statistics.
--
-- Wire shape live-verified against OS 3.7.0 (bead bloodhound-at5); see
-- 'Database.Bloodhound.OpenSearch3.Requests.warmupNeuralIndex' for
-- details.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/neural/#warm-up-sparse-indexes>.
warmupNeuralIndices ::
(MonadBH m, WithBackend OpenSearch3 m) =>
[IndexName] ->
m ShardsResult
warmupNeuralIndices indexNames = performBHRequest $ Requests.warmupNeuralIndex indexNames
-- | 'warmupNeuralIndex' is a convenience wrapper around
-- 'warmupNeuralIndices' for the common single-index case. See
-- 'warmupNeuralIndices' for the multi-index variant.
warmupNeuralIndex ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
m ShardsResult
warmupNeuralIndex indexName = warmupNeuralIndices [indexName]
-- | 'clearNeuralCaches' drops the neural search cache entries that the
-- plugin maintains for the given indices, freeing the associated
-- native-memory reservations. Maps to
-- @POST /_plugins/_neural/clear_cache/{index}@ (the index segment is
-- rendered as a comma-separated list, matching the OpenSearch
-- multi-target syntax) and returns 'ShardsResult' (the
-- @{\"_shards\":{...}}@ envelope) on success.
--
-- Wire shape live-verified against OS 3.7.0 (bead bloodhound-at5); see
-- 'Database.Bloodhound.OpenSearch3.Requests.clearNeuralCache' for
-- details.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/neural/#clear-cache>.
clearNeuralCaches ::
(MonadBH m, WithBackend OpenSearch3 m) =>
[IndexName] ->
m ShardsResult
clearNeuralCaches indexNames = performBHRequest $ Requests.clearNeuralCache indexNames
-- | 'clearNeuralCache' is a convenience wrapper around 'clearNeuralCaches'
-- for the common single-index case. See 'clearNeuralCaches' for the
-- multi-index variant.
clearNeuralCache ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
m ShardsResult
clearNeuralCache indexName = clearNeuralCaches [indexName]
-- | 'getKnnStats' fetches k-NN plugin statistics. Both arguments are
-- optional: 'Nothing' for the node ID queries every node; 'Nothing' for the
-- stat name returns every stat. The response is a flat 'KnnStats' envelope
-- (cluster-level scalars plus a @nodes@ per-node map); navigate it via
-- 'knnStatsEntries'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#stats>.
getKnnStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe KnnNodeId ->
Maybe KnnStatName ->
m (ParsedEsResponse KnnStats)
getKnnStats mNodeId mStatName = performBHRequest $ Requests.getKnnStats mNodeId mStatName
-- | 'warmupKnnIndices' loads the k-NN native library indices for the given
-- indices into memory on the data nodes, so the first k-NN search against
-- each index does not pay the native-engine load latency. Maps to
-- @GET /_plugins/_knn/warmup/{index}@ (the index segment is rendered as a
-- comma-separated list, matching the OpenSearch multi-target syntax) and
-- returns 'ShardsResult' (the @{\"_shards\":{...}}@ envelope,
-- live-verified against OS 2.19.5 and 3.7.0) on success. The warmup is
-- asynchronous — the response is returned as soon as the load is
-- scheduled; poll 'getKnnStats' to observe progress.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#warmup-operation>.
warmupKnnIndices ::
(MonadBH m, WithBackend OpenSearch3 m) =>
[IndexName] ->
m ShardsResult
warmupKnnIndices indexNames = performBHRequest $ Requests.warmupKnnIndex indexNames
-- | 'warmupKnnIndex' is a convenience wrapper around 'warmupKnnIndices'
-- for the common single-index case. See 'warmupKnnIndices' for the
-- multi-index variant.
warmupKnnIndex ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
m ShardsResult
warmupKnnIndex indexName = warmupKnnIndices [indexName]
-- | 'clearKnnCaches' drops the native cache entries that the k-NN plugin
-- maintains for the given indices (the @faiss@ \/ @nmslib@ native library
-- index handles), freeing the associated native-memory reservations. Has
-- no effect on @lucene@ indexes. Maps to
-- @POST /_plugins/_knn/clear_cache/{index}@ (the index segment is rendered
-- as a comma-separated list, matching the OpenSearch multi-target syntax;
-- available since OpenSearch 2.14) and returns 'ShardsResult' (the
-- @{\"_shards\":{...}}@ envelope, live-verified against OS 2.19.5 and
-- 3.7.0) on success. The resulting cache-size drop is visible immediately
-- in 'getKnnStats'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#k-nn-clear-cache>.
clearKnnCaches ::
(MonadBH m, WithBackend OpenSearch3 m) =>
[IndexName] ->
m ShardsResult
clearKnnCaches indexNames = performBHRequest $ Requests.clearKnnCache indexNames
-- | 'clearKnnCache' is a convenience wrapper around 'clearKnnCaches' for
-- the common single-index case. See 'clearKnnCaches' for the multi-index
-- variant.
clearKnnCache ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
m ShardsResult
clearKnnCache indexName = clearKnnCaches [indexName]
-- | 'getKnnModel' fetches metadata for a trained k-NN model by its
-- 'ModelId'. Maps to @GET /_plugins/_knn/models/{model_id}@. The response is
-- a bare object (no envelope), decoded into 'KnnModel'; the
-- 'knnModelModelBlob' field is large and may be absent when the caller has
-- excluded it via @?filter_path@.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#get-a-model>.
getKnnModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
m (ParsedEsResponse KnnModel)
getKnnModel modelId = performBHRequest $ Requests.getKnnModel modelId
-- | 'trainKnnModel' schedules asynchronous training of a k-NN native library
-- model (e.g. FAISS IVF) from the vectors in a training index's
-- @knn_vector@ field. Maps to @POST /_plugins/_knn/models/{model_id}/_train@.
-- The request returns as soon as training is scheduled; the
-- 'KnnTrainResponse' echoes the @model_id@ under which training was
-- scheduled. To observe progress, poll 'getKnnModel' and watch
-- 'knnModelState' transition from @training@ to @created@ (success) or
-- @failed@ (consult 'knnModelError' for the cause).
--
-- Equivalent to 'trainKnnModelWith' with @Nothing@ (no node preference).
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#train-a-model>.
trainKnnModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
KnnTrainingRequest ->
m (ParsedEsResponse KnnTrainResponse)
trainKnnModel = trainKnnModelWith Nothing
-- | 'trainKnnModelWith' extends 'trainKnnModel' with an optional
-- @?preference@ query parameter. Supplying 'Just' a 'KnnNodeId' pins the
-- asynchronous training task to the specified data node, sent on the wire
-- as @?preference={node_id}@; 'Nothing' lets OpenSearch choose the training
-- node. The pinned node must already host a shard of the training index,
-- otherwise OpenSearch rejects the request.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#train-a-model>.
trainKnnModelWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe KnnNodeId ->
ModelId ->
KnnTrainingRequest ->
m (ParsedEsResponse KnnTrainResponse)
trainKnnModelWith mNodeId modelId req =
performBHRequest $ Requests.trainKnnModelWith mNodeId modelId req
-- | 'deleteKnnModel' removes a trained k-NN model by its 'ModelId'.
-- Maps to @DELETE /_plugins/_knn/models/{model_id}@ and returns a
-- 'KnnDeleteModelResponse' echoing the @model_id@ and reporting
-- @result = "deleted"@. Note this is NOT the standard 'Acknowledged'
-- envelope (the k-NN plugin returns a richer response than the typical
-- cluster-level ack). A missing model id surfaces as an 'EsError' via
-- 'StatusDependant', matching 'getKnnModel' and the ML Commons
-- 'deleteModel' precedent.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#delete-a-model>.
deleteKnnModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
m (ParsedEsResponse KnnDeleteModelResponse)
deleteKnnModel modelId = performBHRequest $ Requests.deleteKnnModel modelId
-- | 'searchKnnModels' searches the @.opensearch-knn-models@ system index
-- via @POST /_plugins/_knn/models/_search@. The caller drives the query
-- through the standard 'Search' DSL (paginate with @from@\/@size@, filter
-- with 'queryBody', and exclude the large 'knnModelModelBlob' via the
-- 'source' projection). Returns the standard search envelope as a
-- 'SearchResult' whose hits carry a 'KnnModel' in each @_source@.
--
-- Mirrors 'knnSearch' in shape; see
-- 'Database.Bloodhound.OpenSearch3.Requests.searchKnnModels' for the
-- request-level details.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/vector-search/api/knn/#search-for-a-model>.
searchKnnModels ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Search ->
m (SearchResult KnnModel)
searchKnnModels search = performBHRequest $ Requests.searchKnnModels search
-- | 'getMLStats' fetches ML Commons plugin statistics. Both arguments are
-- optional: 'Nothing' for the node ID queries every node; 'Nothing' for the
-- stat name returns every stat. The endpoint is available whenever the ML
-- Commons plugin is installed (no cluster setting needs to be enabled,
-- unlike 'getNeuralStats').
--
-- For more information see
-- <https://docs.opensearch.org/3.7/ml-commons-plugin/api/stats/>.
getMLStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe MLNodeId ->
Maybe MLStatName ->
m (ParsedEsResponse MLStats)
getMLStats mNodeId mStatName = performBHRequest $ Requests.getMLStats mNodeId mStatName
-- | 'getModel' fetches full metadata for a registered model by its
-- 'ModelId'. The response is a bare object (no envelope), decoded into
-- 'ModelInfo'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/get-model/>.
getModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
m (ParsedEsResponse ModelInfo)
getModel modelId = performBHRequest $ Requests.getModel modelId
-- | 'registerModel' registers a model. Registration is asynchronous; poll
-- the returned @task_id@ via the Get ML Task API. Equivalent to
-- 'registerModelWith' with @deploy = False@.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/register-model/>
registerModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RegisterModelRequest ->
m (ParsedEsResponse MLTaskAck)
registerModel = performBHRequest . Requests.registerModel
-- | 'registerModelWith' registers a model with an optional @?deploy=true@
-- query flag that chains a deploy after successful registration.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/register-model/>
registerModelWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Bool ->
RegisterModelRequest ->
m (ParsedEsResponse MLTaskAck)
registerModelWith deploy req = performBHRequest $ Requests.registerModelWith deploy req
-- | 'deployModel' loads a registered model into memory on ML worker nodes.
-- Pass 'Nothing' to let OpenSearch pick eligible nodes; pass a
-- 'DeployModelRequest' to restrict to a node list. Deployment is
-- asynchronous; poll the returned @task_id@ via the Get ML Task API.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/deploy-model/>
deployModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
Maybe DeployModelRequest ->
m (ParsedEsResponse MLTaskAck)
deployModel modelId mReq = performBHRequest $ Requests.deployModel modelId mReq
-- | 'undeployModel' unloads a deployed model from ML worker nodes
-- (the inverse of 'deployModel'). Unlike deploy, undeploy is
-- synchronous: the response is a node-keyed stats map
-- ('UndeployModelResponse'), not a task ack.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/undeploy-model/>
undeployModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
m (ParsedEsResponse UndeployModelResponse)
undeployModel modelId = performBHRequest $ Requests.undeployModel modelId
-- | 'updateModel' updates a subset of a registered model's metadata
-- via @PUT /_plugins/_ml/models/{model_id}@. The body is an
-- 'UpdateModelRequest' whose every field is 'Maybe'; only the
-- supplied fields are written. The response is the standard
-- document-update envelope ('IndexedDocument' with
-- @result = "updated"@).
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/update-model/>
updateModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
UpdateModelRequest ->
m (ParsedEsResponse IndexedDocument)
updateModel modelId req = performBHRequest $ Requests.updateModel modelId req
-- | 'searchModels' searches the model index via
-- @POST /_plugins/_ml/models/_search@. Pass 'Nothing' for the plain
-- empty-body @{}@ POST that returns the first page of all models;
-- pass @'Just' query@ to filter, paginate, or sort using the
-- standard OpenSearch query DSL carried opaquely as a 'Value'.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/search-model/>
searchModels ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Value ->
m (ParsedEsResponse ModelSearchResponse)
searchModels = performBHRequest . Requests.searchModels
-- | 'listModels' lists models. Historically this hit the
-- @POST /_plugins/_ml/models/_list@ endpoint, but OS 3.x removed POST
-- from @_list@ (it now returns 405). The modern, supported endpoint
-- for listing is @POST /_plugins/_ml/models/_search@ — the same one
-- 'searchModels' uses. Kept as a separate function rather than aliased
-- to 'searchModels' so callers and telemetry can distinguish the two
-- call sites.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/search-model/>
listModels ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Value ->
m (ParsedEsResponse ModelSearchResponse)
listModels = performBHRequest . Requests.listModels
-- | 'deleteModel' deletes a registered model by id. OpenSearch stores
-- models as documents in @.plugins-ml-model@, so the response is the
-- standard document-delete envelope (parsed here as 'IndexedDocument'),
-- not an 'Acknowledged' ack — identical to 'deleteISMPolicy'. A
-- deployed model must be undeployed before it can be deleted, otherwise
-- the server returns an error which surfaces as an 'EsError'.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/delete-model/>
deleteModel ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ModelId ->
m (ParsedEsResponse IndexedDocument)
deleteModel modelId = performBHRequest $ Requests.deleteModel modelId
-- | 'predict' invokes a deployed model. The request body and response are
-- model-specific, so both are opaque 'Value's; the caller decodes the
-- payload with a model-specific parser.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/ml-commons-plugin/api/train-predict/predict/>.
predict ::
(MonadBH m, WithBackend OpenSearch3 m) =>
AlgorithmName ->
ModelId ->
Value ->
m (ParsedEsResponse Value)
predict algo modelId body = performBHRequest $ Requests.predict algo modelId body
-- | 'registerAgent' registers an ML Commons agent (OS 2.12+) — a named
-- configuration binding an LLM (or a routed population of sub-agents and
-- tools) behind a server-assigned 'AgentId'. Unlike 'registerModel',
-- registration is synchronous: the response carries the @agent_id@
-- directly, with no @task_id@ to poll.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/register-agent/>
registerAgent ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RegisterAgentRequest ->
m (ParsedEsResponse RegisterAgentResponse)
registerAgent = performBHRequest . Requests.registerAgent
-- | 'getAgent' fetches a registered agent by id. The body is the bare
-- stored agent document, decoded as 'AgentInfo'.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/get-agent/>
getAgent ::
(MonadBH m, WithBackend OpenSearch3 m) =>
AgentId ->
m (ParsedEsResponse AgentInfo)
getAgent agentId = performBHRequest $ Requests.getAgent agentId
-- | 'deleteAgent' deletes a registered agent by id. The response is
-- the standard document-delete envelope ('IndexedDocument'),
-- identical to 'deleteModel'.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/delete-agent/>
deleteAgent ::
(MonadBH m, WithBackend OpenSearch3 m) =>
AgentId ->
m (ParsedEsResponse IndexedDocument)
deleteAgent agentId = performBHRequest $ Requests.deleteAgent agentId
-- | 'searchAgents' searches the agent index via
-- @POST /_plugins/_ml/agents/_search@. Pass 'Nothing' for the plain
-- empty-body @{}@ POST; pass @'Just' query@ to filter, paginate, or
-- sort using the standard OpenSearch query DSL carried opaquely as a
-- 'Value'.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/search-agent/>
searchAgents ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Value ->
m (ParsedEsResponse AgentSearchResponse)
searchAgents = performBHRequest . Requests.searchAgents
-- | 'updateAgent' updates a subset of a registered agent's
-- configuration via @PUT /_plugins/_ml/agents/{agent_id}@. The body is
-- a partial update ('UpdateAgentRequest'); the response is the
-- standard document-update envelope ('IndexedDocument' with
-- @result = "updated"@).
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/update-agent/>
updateAgent ::
(MonadBH m, WithBackend OpenSearch3 m) =>
AgentId ->
UpdateAgentRequest ->
m (ParsedEsResponse IndexedDocument)
updateAgent agentId = performBHRequest . Requests.updateAgent agentId
-- | 'executeAgent' runs a registered agent synchronously, returning
-- its 'ExecuteAgentResponse'. For the asynchronous variant (3.0+) use
-- 'executeAgentAsync'.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/execute-agent/>
executeAgent ::
(MonadBH m, WithBackend OpenSearch3 m) =>
AgentId ->
ExecuteAgentRequest ->
m (ParsedEsResponse ExecuteAgentResponse)
executeAgent agentId = performBHRequest . Requests.executeAgent agentId
-- | 'executeAgentAsync' runs a registered agent asynchronously
-- (OpenSearch 3.0+), returning an 'MLTaskAck' carrying a @task_id@ to
-- poll via 'getMLTask'. Sets @?async=true@.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/execute-agent/>
executeAgentAsync ::
(MonadBH m, WithBackend OpenSearch3 m) =>
AgentId ->
ExecuteAgentRequest ->
m (ParsedEsResponse MLTaskAck)
executeAgentAsync agentId = performBHRequest . Requests.executeAgentAsync agentId
-- | 'executeStreamAgent' runs a conversational agent against the
-- streaming Execute Stream Agent API
-- (@POST /_plugins/_ml/agents/{agent_id}/_execute/stream@, OS 3.3+)
-- and invokes the supplied callback once per Server-Sent Event chunk
-- as it arrives — the response body is /not/ buffered, so partial
-- results (token-by-token LLM output) are visible immediately.
--
-- Each chunk is decoded into an 'ExecuteStreamChunk' pairing the
-- 'ExecuteAgentResponse' payload with its per-chunk @is_last@ flag.
-- The stream terminates after yielding the chunk whose
-- 'isStreamChunkLast' is 'True' (an empty-content chunk the server
-- emits to signal completion); the callback is /not/ invoked for that
-- final terminator unless you wish to handle it — it is yielded like
-- any other chunk. If the body ends without a terminator (network
-- error, server crash), parsing simply stops.
--
-- The callback runs in 'IO' (not the underlying monad @m@): lift into
-- your monad inside the callback if needed
-- (e.g. @liftIO . writeTBQueue chunk@). To collect chunks into a
-- conduit, pipes, or an 'IO' list, adapt the callback accordingly —
-- the raw conduit source 'Database.Bloodhound.Internal.Utils.SSE.sseSource'
-- is also available for callers who want to drive framing themselves.
--
-- /Status errors are not parsed:/ unlike 'performBHRequest', a non-2xx
-- response does not surface as an 'EsError' here — the body of a 4xx
-- is not SSE-framed, so the decoder would yield nothing. Inspect the
-- cluster settings if the callback is never invoked
-- (@plugins.ml_commons.stream_enabled@, the @transport-reactor-netty4@
-- and @arrow-flight-rpc@ plugins; see the endpoint docs).
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/execute-stream-agent/>
executeStreamAgent ::
(MonadIO m) =>
AgentId ->
ExecuteAgentRequest ->
(ExecuteStreamChunk -> IO ()) ->
BH m ()
executeStreamAgent agentId req callback =
withStreamingResponse (Requests.executeStreamAgentRequest agentId req) $
\resp -> do
st <- newSSEState (HTTP.responseBody resp)
chunkLoop st
where
chunkLoop st = do
next <- readSSEEvent st
case next of
Nothing -> pure ()
Just ev ->
case decodeTextAsJson (sseData ev) of
Just payload -> do
let chunk = ExecuteStreamChunk payload (detectIsLast payload)
callback chunk
if executeStreamChunkIsLast chunk
then pure ()
else chunkLoop st
Nothing -> chunkLoop st
-- | 'executeStreamAgentAGUI' is the AG-UI-protocol variant of
-- 'executeStreamAgent' (OS 3.5+). The request body uses the AG-UI
-- request format (@threadId@\/@runId@\/@messages@; passed opaquely as
-- a 'Value' because the schema is defined by the AG-UI spec and
-- varies across agent configurations), and the stream emits
-- 'AgUIEvent's discriminated by @type@. The stream terminates after
-- yielding an 'AgUIRunFinished'; an unknown event type decodes to
-- 'AgUIOther' rather than throwing, so future plugin releases adding
-- event kinds round-trip.
-- See <https://docs.opensearch.org/3.7/ml-commons-plugin/api/agent-apis/execute-stream-agent/>
executeStreamAgentAGUI ::
(MonadIO m) =>
AgentId ->
Value ->
(AgUIEvent -> IO ()) ->
BH m ()
executeStreamAgentAGUI agentId body callback =
withStreamingResponse (Requests.executeStreamAgentAGUIRequest agentId body) $
\resp -> do
st <- newSSEState (HTTP.responseBody resp)
eventLoop st
where
eventLoop st = do
next <- readSSEEvent st
case next of
Nothing -> pure ()
Just ev ->
case decodeTextAsJson (sseData ev) of
Just agEv -> do
callback agEv
case agEv of
AgUIRunFinished {} -> pure ()
_ -> eventLoop st
Nothing -> eventLoop st
-- | Decode a 'Text' (an SSE @data:@ payload, which is itself a JSON
-- fragment) to a value via a strict UTF-8 encode + aeson 'decode'.
decodeTextAsJson :: (FromJSON a) => Text -> Maybe a
decodeTextAsJson = decode . BL.fromStrict . TE.encodeUtf8
-- | Examine a decoded chunk's @response@ output for the @is_last@
-- flag in its @dataAsMap@. The conversational agent emits
-- @{\"content\": ..., \"is_last\": <bool>}@ under the @response@ name;
-- the terminal chunk has empty @content@ and @is_last: true@. Returns
-- 'False' if the flag is absent or not a boolean.
detectIsLast :: ExecuteAgentResponse -> Bool
detectIsLast resp =
any (any checkOutput . inferenceResultOutput) (executeAgentInferenceResults resp)
where
checkOutput out =
executeOutputName out == Just "response"
&& fromMaybe False (executeOutputDataAsMap out >>= boolField "is_last")
boolField k value =
case value of
Object o ->
case KM.lookup k o of
Just (Bool b) -> Just b
_ -> Nothing
_ -> Nothing
-- | 'knnSearch' executes a k-NN vector search request against a single index for OpenSearch 3+.
--
-- OpenSearch kNN uses the standard @POST \/{index}\/_search@ body with a knn
-- clause nested inside @query@ (different shape from ES8+ which uses a
-- top-level knn array). See 'OpenSearchKnnQuery' for the body shape and
-- <https://docs.opensearch.org/3.7/query-dsl/specialized/k-nn/index/> for the spec.
knnSearch ::
(MonadBH m, WithBackend OpenSearch3 m, FromJSON a) =>
IndexName ->
OpenSearchKnnQuery ->
Search ->
m (SearchResult a)
knnSearch indexName osknnQuery search = performBHRequest $ Requests.knnSearch indexName osknnQuery search
-- | 'getMLTask' fetches the current state of an ML Commons asynchronous task
-- (model registration, deployment, training, ...). Poll this with the
-- @task_id@ returned by the submit endpoint until 'mlTaskInfoState' reaches
-- 'MLTaskStateCompleted' or 'MLTaskStateFailed'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/ml-commons-plugin/api/model-apis/get-task/>.
getMLTask ::
(MonadBH m, WithBackend OpenSearch3 m) =>
MLTaskId ->
m (ParsedEsResponse MLTaskInfo)
getMLTask mlTaskId = performBHRequest $ Requests.getMLTask mlTaskId
-- | 'putISMPolicy' creates or updates an ISM policy.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#create-policy>
putISMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PolicyId ->
ISMPolicyRequest ->
m (ParsedEsResponse PutISMPolicyResponse)
putISMPolicy policyId policy = performBHRequest $ Requests.putISMPolicy policyId policy
-- | 'putISMPolicyWith' creates or updates an ISM policy with an optional
-- optimistic-concurrency guard (@if_seq_no@ / @if_primary_term@). See
-- 'Requests.putISMPolicyWith' for semantics.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#create-policy>
putISMPolicyWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PolicyId ->
ISMPolicyRequest ->
Maybe (Word64, Word64) ->
m (ParsedEsResponse PutISMPolicyResponse)
putISMPolicyWith policyId policy mOcc =
performBHRequest $ Requests.putISMPolicyWith policyId policy mOcc
-- | 'addISMPolicy' applies an existing ISM policy to an index.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#add-policy>
addISMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PolicyId ->
IndexName ->
m (ParsedEsResponse ISMUpdatedIndicesResponse)
addISMPolicy policyId indexName = performBHRequest $ Requests.addISMPolicy policyId indexName
-- | 'removeISMPolicy' detaches any ISM policy from the given index.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#remove-policy>
removeISMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
m (ParsedEsResponse ISMUpdatedIndicesResponse)
removeISMPolicy indexName = performBHRequest $ Requests.removeISMPolicy indexName
-- | 'changeISMPolicy' updates the managed-index policy attached to an index.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#change-policy>
changeISMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
ChangePolicyRequest ->
m (ParsedEsResponse ISMUpdatedIndicesResponse)
changeISMPolicy indexName req = performBHRequest $ Requests.changeISMPolicy indexName req
-- | 'retryISMIndex' retries the failed ISM action for an index.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#retry-failed-index>
retryISMIndex ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
Maybe Text ->
m (ParsedEsResponse ISMUpdatedIndicesResponse)
retryISMIndex indexName mState = performBHRequest $ Requests.retryISMIndex indexName mState
-- | 'explainISMIndex' returns the ISM state of an index.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#explain-index>
explainISMIndex ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
m (ParsedEsResponse ISMExplanation)
explainISMIndex indexName = performBHRequest $ Requests.explainISMIndex indexName
-- | 'explainISMIndexWith' returns the ISM state of an index with optional
-- @show_policy@, @validate_action@, @local@ and @expand_wildcards@ query
-- parameters.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#explain-index>
explainISMIndexWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
ISMExplainOptions ->
m (ParsedEsResponse ISMExplanation)
explainISMIndexWith indexName opts =
performBHRequest $ Requests.explainISMIndexWith indexName opts
-- | 'explainISMIndexFiltered' returns the ISM state of an index via the
-- @POST /_plugins/_ism/explain/{index}@ "Explain index with filtering" form,
-- sending an 'ISMExplainFilter' as the request body.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#explain-index-with-filtering>
explainISMIndexFiltered ::
(MonadBH m, WithBackend OpenSearch3 m) =>
IndexName ->
ISMExplainFilter ->
m (ParsedEsResponse ISMExplanation)
explainISMIndexFiltered indexName filt =
performBHRequest $ Requests.explainISMIndexFiltered indexName filt
-- | 'simulateISMPolicy' previews how a policy would apply to indexes (OS 3.7+).
-- See 'Database.Bloodhound.OpenSearch3.Requests.simulateISMPolicy'.
simulateISMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SimulateISMPolicyRequest ->
m SimulateISMPolicyResponse
simulateISMPolicy = performBHRequest . Requests.simulateISMPolicy
-- | 'getISMPolicy' fetches a single policy by id.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#get-policy>
getISMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PolicyId ->
m (ParsedEsResponse ISMPolicyInfo)
getISMPolicy policyId = performBHRequest $ Requests.getISMPolicy policyId
-- | 'getISMPolicies' lists policies, optionally filtered / paginated.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#get-policies>
getISMPolicies ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe ISMPoliciesQuery ->
m (ParsedEsResponse GetISMPoliciesResponse)
getISMPolicies mQuery = performBHRequest $ Requests.getISMPolicies mQuery
-- | 'deleteISMPolicy' deletes an ISM policy by id.
-- OpenSearch stores policies as documents in @.opendistro-ism-config@, so the
-- response is the standard document-delete envelope (parsed here as
-- 'IndexedDocument'), not an 'Acknowledged' ack.
-- See <https://docs.opensearch.org/3.7/im-plugin/ism/api/#delete-policy>
deleteISMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PolicyId ->
m (ParsedEsResponse IndexedDocument)
deleteISMPolicy policyId = performBHRequest $ Requests.deleteISMPolicy policyId
-- =========================================================================
-- Snapshot Management plugin
-- =========================================================================
-- | 'postSMPolicy' creates a new SM policy.
postSMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SMPolicyName ->
SMPolicyBody ->
m (ParsedEsResponse SMPolicyResponse)
postSMPolicy policyName body = performBHRequest $ Requests.postSMPolicy policyName body
-- | 'putSMPolicyWith' updates an existing SM policy with the @if_seq_no@
-- / @if_primary_term@ optimistic-concurrency guard.
putSMPolicyWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SMPolicyName ->
SMPolicyBody ->
Word64 ->
Word64 ->
m (ParsedEsResponse SMPolicyResponse)
putSMPolicyWith policyName body seqNo primaryTerm =
performBHRequest $ Requests.putSMPolicyWith policyName body seqNo primaryTerm
-- | 'getSMPolicy' fetches a single SM policy by name.
getSMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SMPolicyName ->
m (ParsedEsResponse SMPolicyResponse)
getSMPolicy policyName = performBHRequest $ Requests.getSMPolicy policyName
-- | 'getSMPolicies' lists SM policies, optionally filtered / paginated.
getSMPolicies ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe GetSMPoliciesQuery ->
m (ParsedEsResponse GetSMPoliciesResponse)
getSMPolicies mQuery = performBHRequest $ Requests.getSMPolicies mQuery
-- | 'deleteSMPolicy' deletes an SM policy by name.
deleteSMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SMPolicyName ->
m (ParsedEsResponse DeleteSMPolicyResponse)
deleteSMPolicy policyName = performBHRequest $ Requests.deleteSMPolicy policyName
-- | 'startSMPolicy' enables an SM policy (sets @enabled=true@).
startSMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SMPolicyName ->
m (ParsedEsResponse Acknowledged)
startSMPolicy policyName = performBHRequest $ Requests.startSMPolicy policyName
-- | 'stopSMPolicy' disables an SM policy (sets @enabled=false@).
stopSMPolicy ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SMPolicyName ->
m (ParsedEsResponse Acknowledged)
stopSMPolicy policyName = performBHRequest $ Requests.stopSMPolicy policyName
-- | 'explainSMPolicies' returns the running state of policies matching a
-- name expression (comma list / wildcard).
explainSMPolicies ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse SMExplainResponse)
explainSMPolicies policyNames = performBHRequest $ Requests.explainSMPolicies policyNames
-- | 'submitOSAsyncSearch' submits a 'Search' for asynchronous execution via
-- the OpenSearch async search plugin (@POST /_plugins/_asynchronous_search@),
-- returning immediately with an id and partial results. This is the
-- OpenSearch-plugin-path analogue of the Elasticsearch 'submitAsyncSearch';
-- poll the returned id with 'getOSAsyncSearch' until 'asyncSearchIsRunning'
-- is @False@.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/search-plugins/async/index/#submit>.
submitOSAsyncSearch ::
(FromJSON a, MonadBH m, WithBackend OpenSearch3 m) =>
Search ->
m (AsyncSearchResult a)
submitOSAsyncSearch = performBHRequest . Requests.submitOSAsyncSearch
-- | Like 'submitOSAsyncSearch' but accepts 'AsyncSearchSubmitOptions'
-- carrying the URI parameters documented for
-- @POST /_plugins/_asynchronous_search@ (@wait_for_completion@,
-- @keep_on_completion@, @keep_alive@). The Elasticsearch-only
-- 'assoBatchedReduceSize' and 'assoCcsMinimizeRoundtrips' are silently
-- dropped. 'defaultAsyncSearchSubmitOptions' makes this byte-for-byte
-- equivalent to 'submitOSAsyncSearch'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/search-plugins/async/index/#submit>.
submitOSAsyncSearchWith ::
(FromJSON a, MonadBH m, WithBackend OpenSearch3 m) =>
AsyncSearchSubmitOptions ->
Search ->
m (AsyncSearchResult a)
submitOSAsyncSearchWith opts = performBHRequest . Requests.submitOSAsyncSearchWith opts
-- | 'getOSAsyncSearch' polls an OpenSearch async search by id, returning its
-- current state and (partial or final) results. Maps to
-- @GET /_plugins/_asynchronous_search/{id}@.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/search-plugins/async/index/#get>.
getOSAsyncSearch ::
(FromJSON a, MonadBH m, WithBackend OpenSearch3 m) =>
AsyncSearchId ->
m (AsyncSearchResult a)
getOSAsyncSearch = performBHRequest . Requests.getOSAsyncSearch
-- | 'deleteOSAsyncSearch' deletes an OpenSearch async search result and its
-- context by id. Maps to @DELETE /_plugins/_asynchronous_search/{id}@ and returns
-- 'Acknowledged' on success.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/search-plugins/async/index/#delete>.
deleteOSAsyncSearch ::
(MonadBH m, WithBackend OpenSearch3 m) =>
AsyncSearchId ->
m Acknowledged
deleteOSAsyncSearch = performBHRequest . Requests.deleteOSAsyncSearch
-- | 'getOSAsyncSearchStats' fetches cluster-wide async-search statistics.
-- See 'Database.Bloodhound.OpenSearch3.Requests.getOSAsyncSearchStats'.
getOSAsyncSearchStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m AsyncSearchStatsResponse
getOSAsyncSearchStats = performBHRequest Requests.getOSAsyncSearchStats
-- | 'sqlQuery' executes a SQL query via the OpenSearch SQL plugin
-- (@POST /_plugins/_sql@). Returns a JDBC-style rowset ('SQLResult'). Use
-- 'sqlRequestFetchSize' to opt into cursor pagination, then walk subsequent
-- pages with 'sqlQueryNextPage' and release an unfinished cursor with
-- 'closeSqlCursor'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/sql-and-ppl/sql-and-ppl-api/index/>.
sqlQuery ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SQLRequest ->
m (ParsedEsResponse SQLResult)
sqlQuery = performBHRequest . Requests.sqlQuery
-- | 'sqlQueryNextPage' fetches the next page of a paginated SQL result by
-- POSTing the opaque 'SQLCursor' returned by a previous 'sqlQuery' or
-- 'sqlQueryNextPage' call. The server drops @schema@, @total@, @size@ and
-- @status@ from continuation responses, so every 'SQLResult' field except
-- 'sqlResultDatarows' is 'Maybe'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/sql-and-ppl/sql-and-ppl-api/index/#cursor-and-paginating-results>.
sqlQueryNextPage ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SQLCursor ->
m (ParsedEsResponse SQLResult)
sqlQueryNextPage = performBHRequest . Requests.sqlQueryNextPage
-- | 'closeSqlCursor' releases the server-side context held by a SQL
-- pagination cursor (@POST /_plugins/_sql/close@). Call this when you stop
-- reading before the cursor is naturally exhausted.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/sql-and-ppl/sql-and-ppl-api/index/#cursor-and-paginating-results>.
closeSqlCursor ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SQLCursor ->
m (ParsedEsResponse SQLCloseResult)
closeSqlCursor = performBHRequest . Requests.closeSqlCursor
-- | 'explainSQL' translates a SQL query into the underlying query DSL without
-- executing it (@POST /_plugins/_sql/_explain@). The response shape varies by
-- query and plugin version, so it is returned as an opaque 'Value'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/sql-and-ppl/sql-and-ppl-api/index/#explain-api>.
explainSQL ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SQLRequest ->
m (ParsedEsResponse Value)
explainSQL = performBHRequest . Requests.explainSQL
-- | 'pplQuery' executes a PPL (Piped Processing Language) query via the
-- OpenSearch SQL plugin's PPL endpoint (@POST /_plugins/_ppl@). Returns the
-- same JDBC-style rowset shape as 'sqlQuery' (typed as 'PPLResult'). PPL
-- does not support cursor pagination.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/sql-and-ppl/sql-and-ppl-api/index/>.
pplQuery ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PPLRequest ->
m (ParsedEsResponse PPLResult)
pplQuery = performBHRequest . Requests.pplQuery
-- | 'explainPPL' translates a PPL query into the underlying query DSL without
-- executing it (@POST /_plugins/_ppl/_explain@). The response shape varies by
-- query and plugin version, so it is returned as an opaque 'Value'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/sql-and-ppl/sql-and-ppl-api/index/#explain-api>.
explainPPL ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PPLRequest ->
m (ParsedEsResponse Value)
explainPPL = performBHRequest . Requests.explainPPL
-- | 'getSQLStats' fetches SQL plugin statistics
-- (@GET /_plugins/_sql/stats@). The endpoint is node-level only (the
-- plugin documents that cluster-level stats are not implemented), so the
-- response describes only the node you hit; there is no @nodes@ sub-key
-- to navigate. The body is decoded as a flat 'SQLPluginStats' map keyed
-- by metric name because the metric-name set grows across OpenSearch
-- releases.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/sql-and-ppl/sql-and-ppl-api/index/>.
getSQLStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse SQLPluginStats)
getSQLStats = performBHRequest Requests.getSQLStats
-- =========================================================================
-- Notifications plugin
-- =========================================================================
-- | 'createNotificationConfig' creates a notification channel
-- configuration via the Notifications plugin
-- (@POST /_plugins/_notifications/configs@). The server assigns the
-- @config_id@ and echoes it in the 'CreateNotificationConfigResponse'.
-- Equivalent to 'createNotificationConfigWith' with 'Nothing'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/observing-your-data/notifications/api/#create-notification-config>.
createNotificationConfig ::
(MonadBH m, WithBackend OpenSearch3 m) =>
NotificationConfig ->
m (ParsedEsResponse CreateNotificationConfigResponse)
createNotificationConfig = performBHRequest . Requests.createNotificationConfig
-- | 'createNotificationConfigWith' is the parameterized variant of
-- 'createNotificationConfig': the optional 'Text' is forwarded as the
-- request's @config_id@. Pass 'Nothing' for a server-assigned id; pass
-- @'Just' id@ for a stable identifier (a duplicate surfaces as HTTP
-- 409, decoded as an 'EsError' via 'StatusDependant').
-- See <https://docs.opensearch.org/3.7/observing-your-data/notifications/api/#create-notification-config>.
createNotificationConfigWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Text ->
NotificationConfig ->
m (ParsedEsResponse CreateNotificationConfigResponse)
createNotificationConfigWith mConfigId config =
performBHRequest $ Requests.createNotificationConfigWith mConfigId config
-- | 'deleteNotificationConfig' removes a notification channel
-- configuration by @config_id@ via the Notifications plugin
-- (@DELETE /_plugins/_notifications/configs/{config_id}@). The result
-- is a 'DeleteNotificationConfigResponse' mapping the id to its
-- per-id deletion status; use 'deleteResponseAllOK' for a quick
-- success check or 'deleteResponseStatus' for the raw status string.
-- A 404 (unknown @config_id@) surfaces as 'Left' 'EsError'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/observing-your-data/notifications/api/#delete-channel-configuration>.
deleteNotificationConfig ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse DeleteNotificationConfigResponse)
deleteNotificationConfig =
performBHRequest . Requests.deleteNotificationConfig
-- | 'getNotificationConfigs' lists every notification channel
-- configuration (@GET /_plugins/_notifications/configs@), returning
-- each as a 'NotificationConfigEntry'. Equivalent to
-- 'getNotificationConfigsWith' with 'defaultNotificationListOptions'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/observing-your-data/notifications/api/#get-notification-config>.
getNotificationConfigs ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse [NotificationConfigEntry])
getNotificationConfigs = performBHRequest Requests.getNotificationConfigs
-- | 'getNotificationConfigsWith' is the parameterized variant of
-- 'getNotificationConfigs': the supplied 'NotificationListOptions' are
-- forwarded as query-string parameters. Pass
-- 'defaultNotificationListOptions' for the plain no-arg GET.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/observing-your-data/notifications/api/#get-notification-config>.
getNotificationConfigsWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
NotificationListOptions ->
m (ParsedEsResponse [NotificationConfigEntry])
getNotificationConfigsWith opts =
performBHRequest $ Requests.getNotificationConfigsWith opts
-- | 'getNotificationChannels' lists every notification channel
-- (@GET /_plugins/_notifications/channels@) as a lightweight 'Channel'
-- summary view (no transport details). Equivalent to
-- 'getNotificationChannelsWith' with 'defaultNotificationListOptions'.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/observing-your-data/notifications/api/#list-all-notification-channels>.
getNotificationChannels ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse [Channel])
getNotificationChannels = performBHRequest Requests.getNotificationChannels
-- | 'getNotificationChannelsWith' is the parameterized variant of
-- 'getNotificationChannels': the supplied 'NotificationListOptions' are
-- forwarded as query-string parameters. Pass
-- 'defaultNotificationListOptions' for the plain no-arg GET.
--
-- For more information see
-- <https://docs.opensearch.org/3.7/observing-your-data/notifications/api/#list-all-notification-channels>.
getNotificationChannelsWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
NotificationListOptions ->
m (ParsedEsResponse [Channel])
getNotificationChannelsWith opts =
performBHRequest $ Requests.getNotificationChannelsWith opts
-- | 'getNotificationConfig' fetches a single notification channel
-- configuration by id. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getNotificationConfig'.
getNotificationConfig ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse (Maybe NotificationConfigEntry))
getNotificationConfig = performBHRequest . Requests.getNotificationConfig
-- | 'updateNotificationConfig' replaces a notification channel
-- configuration by id. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateNotificationConfig'.
updateNotificationConfig ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
NotificationConfig ->
m (ParsedEsResponse CreateNotificationConfigResponse)
updateNotificationConfig configId config =
performBHRequest $ Requests.updateNotificationConfig configId config
-- | 'deleteNotificationConfigs' is the batch variant of
-- 'deleteNotificationConfig'. See
-- 'Database.Bloodhound.OpenSearch3.Requests.deleteNotificationConfigs'.
deleteNotificationConfigs ::
(MonadBH m, WithBackend OpenSearch3 m) =>
NonEmpty Text ->
m (ParsedEsResponse DeleteNotificationConfigResponse)
deleteNotificationConfigs =
performBHRequest . Requests.deleteNotificationConfigs
-- | 'getNotificationFeatures' lists supported channel configuration
-- types. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getNotificationFeatures'.
getNotificationFeatures ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse NotificationFeaturesResponse)
getNotificationFeatures = performBHRequest Requests.getNotificationFeatures
-- | 'sendTestNotification' triggers a one-shot probe delivery to a
-- channel. See
-- 'Database.Bloodhound.OpenSearch3.Requests.sendTestNotification'.
sendTestNotification ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse TestNotificationResponse)
sendTestNotification =
performBHRequest . Requests.sendTestNotification
-- =========================================================================
-- Alerting plugin
-- =========================================================================
-- | 'createMonitor' creates an alerting monitor. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createMonitor' for the
-- underlying request and the wire-shape details.
createMonitor ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Monitor ->
m MonitorResponse
createMonitor monitor = performBHRequest $ Requests.createMonitor monitor
-- | 'getMonitor' fetches a monitor by id. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getMonitor'.
getMonitor ::
(MonadBH m, WithBackend OpenSearch3 m) =>
MonitorId ->
m Monitor
getMonitor monitorId = performBHRequest $ Requests.getMonitor monitorId
-- | 'updateMonitor' replaces a monitor. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateMonitor'.
updateMonitor ::
(MonadBH m, WithBackend OpenSearch3 m) =>
MonitorId ->
Monitor ->
m MonitorResponse
updateMonitor monitorId monitor = performBHRequest $ Requests.updateMonitor monitorId monitor
-- | 'updateMonitorWith' replaces a monitor with an optional
-- optimistic-concurrency guard (@if_seq_no@ \/ @if_primary_term@). See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateMonitorWith'.
updateMonitorWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
MonitorId ->
Monitor ->
Maybe (Word64, Word64) ->
m MonitorResponse
updateMonitorWith monitorId monitor mOcc =
performBHRequest $ Requests.updateMonitorWith monitorId monitor mOcc
-- | 'deleteMonitor' deletes a monitor by id. Returns the bare
-- Elasticsearch delete-document response (see 'DeleteMonitorResponse' for
-- why this deviates from @m 'Acknowledged'@).
deleteMonitor ::
(MonadBH m, WithBackend OpenSearch3 m) =>
MonitorId ->
m DeleteMonitorResponse
deleteMonitor monitorId = performBHRequest $ Requests.deleteMonitor monitorId
-- | 'searchMonitors' searches the monitor store. See
-- 'Database.Bloodhound.OpenSearch3.Requests.searchMonitors'.
searchMonitors ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe MonitorsSearchQuery ->
m (ParsedEsResponse SearchMonitorsResponse)
searchMonitors = performBHRequest . Requests.searchMonitors
-- | 'executeMonitor' runs a monitor immediately (out of schedule). See
-- 'Database.Bloodhound.OpenSearch3.Requests.executeMonitor'.
executeMonitor ::
(MonadBH m, WithBackend OpenSearch3 m) =>
MonitorId ->
Maybe ExecuteMonitorRequest ->
m (ParsedEsResponse ExecuteMonitorResponse)
executeMonitor monitorId mRequest =
performBHRequest $ Requests.executeMonitor monitorId mRequest
-- =========================================================================
-- Security Analytics plugin
-- =========================================================================
-- | 'createSADetector' creates a Security Analytics detector. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createSADetector' for the
-- underlying request and the wire-shape details.
createSADetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SADetector ->
m SADetectorResponse
createSADetector detector = performBHRequest $ Requests.createSADetector detector
-- | 'getSADetector' fetches a detector by id. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getSADetector'.
getSADetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
m SADetector
getSADetector detectorId = performBHRequest $ Requests.getSADetector detectorId
-- | 'updateSADetector' replaces a detector. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateSADetector'.
updateSADetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
SADetector ->
m SADetectorResponse
updateSADetector detectorId detector = performBHRequest $ Requests.updateSADetector detectorId detector
-- | 'deleteSADetector' deletes a detector by id. See
-- 'Database.Bloodhound.OpenSearch3.Requests.deleteSADetector'.
deleteSADetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
m DeleteSADetectorResponse
deleteSADetector detectorId = performBHRequest $ Requests.deleteSADetector detectorId
-- | 'searchSAPrePackagedRules' searches the pre-packaged Sigma rules
-- index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.searchSAPrePackagedRules'
-- for the underlying request and the bead-acceptance deviation note.
searchSAPrePackagedRules ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe SARulesQuery ->
m (ParsedEsResponse SARulesSearchResponse)
searchSAPrePackagedRules = performBHRequest . Requests.searchSAPrePackagedRules
-- | 'searchSACustomRules' searches the custom Sigma rules index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.searchSACustomRules'.
searchSACustomRules ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe SARulesQuery ->
m (ParsedEsResponse SARulesSearchResponse)
searchSACustomRules = performBHRequest . Requests.searchSACustomRules
-- | 'createSACustomRule' creates a custom Sigma rule. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createSACustomRule' for the
-- underlying request and the raw-YAML-body detail.
createSACustomRule ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SADetectorType ->
Text ->
m SARuleResponse
createSACustomRule category sigmaYaml =
performBHRequest $ Requests.createSACustomRule category sigmaYaml
-- | 'updateSACustomRule' replaces a custom Sigma rule. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateSACustomRule'.
updateSACustomRule ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RuleId ->
SADetectorType ->
Bool ->
Text ->
m SARuleResponse
updateSACustomRule ruleId category forced sigmaYaml =
performBHRequest $ Requests.updateSACustomRule ruleId category forced sigmaYaml
-- | 'deleteSACustomRule' deletes a custom Sigma rule. See
-- 'Database.Bloodhound.OpenSearch3.Requests.deleteSACustomRule'.
deleteSACustomRule ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RuleId ->
Bool ->
m DeleteSARuleResponse
deleteSACustomRule ruleId forced =
performBHRequest $ Requests.deleteSACustomRule ruleId forced
-- | 'searchSADetectors' searches the detector store. See
-- 'Database.Bloodhound.OpenSearch3.Requests.searchSADetectors'.
searchSADetectors ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe SADetectorsSearchQuery ->
m (ParsedEsResponse SADetectorsSearchResponse)
searchSADetectors = performBHRequest . Requests.searchSADetectors
-- | 'getSAMappingsView' returns a mappings view for an index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getSAMappingsView'.
getSAMappingsView ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SAMappingsViewRequest ->
m SAMappingsViewResponse
getSAMappingsView = performBHRequest . Requests.getSAMappingsView
-- | 'createSAMappings' creates the field-to-alias mappings for an
-- index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createSAMappings'.
createSAMappings ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SACreateMappingsRequest ->
m Acknowledged
createSAMappings = performBHRequest . Requests.createSAMappings
-- | 'getSAMappings' fetches the persisted mappings for an index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getSAMappings'.
getSAMappings ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m SAGetMappingsResponse
getSAMappings = performBHRequest . Requests.getSAMappings
-- | 'updateSAMappings' updates a single field mapping for an index.
-- See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateSAMappings'.
updateSAMappings ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SAUpdateMappingsRequest ->
m Acknowledged
updateSAMappings = performBHRequest . Requests.updateSAMappings
-- | 'getSAAlertsWith' lists Security Analytics alert documents with the
-- supplied options. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getSAAlertsWith'.
getSAAlertsWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SAGetAlertsOptions ->
m SAGetAlertsResponse
getSAAlertsWith = performBHRequest . Requests.getSAAlertsWith
-- | 'getSAAlerts' lists the alert documents of a single detector. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getSAAlerts'.
getSAAlerts ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
m [SAAlert]
getSAAlerts = performBHRequest . Requests.getSAAlerts
-- | 'acknowledgeSADetectorAlerts' acknowledges one or more active
-- alerts of a detector. See
-- 'Database.Bloodhound.OpenSearch3.Requests.acknowledgeSADetectorAlerts'.
acknowledgeSADetectorAlerts ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
[Text] ->
m AcknowledgeSADetectorAlertsResponse
acknowledgeSADetectorAlerts = (performBHRequest .) . Requests.acknowledgeSADetectorAlerts
-- | 'searchSAFindings' lists Security Analytics finding documents. See
-- 'Database.Bloodhound.OpenSearch3.Requests.searchSAFindings'.
searchSAFindings ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SASearchFindingsOptions ->
m (ParsedEsResponse SASearchFindingsResponse)
searchSAFindings = performBHRequest . Requests.searchSAFindings
-- | 'createSACorrelationRule' creates a correlation rule. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createSACorrelationRule'.
createSACorrelationRule ::
(MonadBH m, WithBackend OpenSearch3 m) =>
CreateSACorrelationRuleRequest ->
m CreateSACorrelationRuleResponse
createSACorrelationRule = performBHRequest . Requests.createSACorrelationRule
-- | 'getSACorrelations' lists pairwise finding correlations within a
-- time window. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getSACorrelations'.
getSACorrelations ::
(MonadBH m, WithBackend OpenSearch3 m) =>
GetSACorrelationsOptions ->
m GetSACorrelationsResponse
getSACorrelations = performBHRequest . Requests.getSACorrelations
-- | 'findSACorrelation' lists correlated findings for a given finding.
-- See
-- 'Database.Bloodhound.OpenSearch3.Requests.findSACorrelation'.
findSACorrelation ::
(MonadBH m, WithBackend OpenSearch3 m) =>
FindSACorrelationOptions ->
m FindSACorrelationResponse
findSACorrelation = performBHRequest . Requests.findSACorrelation
-- | 'searchSACorrelationAlerts' lists correlation alerts. See
-- 'Database.Bloodhound.OpenSearch3.Requests.searchSACorrelationAlerts'.
searchSACorrelationAlerts ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SearchSACorrelationAlertsOptions ->
m SearchSACorrelationAlertsResponse
searchSACorrelationAlerts = performBHRequest . Requests.searchSACorrelationAlerts
-- | 'acknowledgeSACorrelationAlerts' acknowledges one or more
-- correlation alerts. See
-- 'Database.Bloodhound.OpenSearch3.Requests.acknowledgeSACorrelationAlerts'.
acknowledgeSACorrelationAlerts ::
(MonadBH m, WithBackend OpenSearch3 m) =>
[Text] ->
m AcknowledgeSACorrelationAlertsResponse
acknowledgeSACorrelationAlerts = performBHRequest . Requests.acknowledgeSACorrelationAlerts
-- | 'createSALogType' creates a custom log type. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createSALogType'.
createSALogType ::
(MonadBH m, WithBackend OpenSearch3 m) =>
SALogType ->
m SALogTypeResponse
createSALogType = performBHRequest . Requests.createSALogType
-- | 'searchSALogTypes' searches the log type store. See
-- 'Database.Bloodhound.OpenSearch3.Requests.searchSALogTypes'.
searchSALogTypes ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe SALogTypeSearchQuery ->
m (ParsedEsResponse SALogTypesSearchResponse)
searchSALogTypes = performBHRequest . Requests.searchSALogTypes
-- | 'updateSALogType' replaces a custom log type. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateSALogType'.
updateSALogType ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
SALogType ->
m SALogTypeResponse
updateSALogType = (performBHRequest .) . Requests.updateSALogType
-- | 'deleteSALogType' deletes a custom log type. See
-- 'Database.Bloodhound.OpenSearch3.Requests.deleteSALogType'.
deleteSALogType ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m DeleteSALogTypeResponse
deleteSALogType = performBHRequest . Requests.deleteSALogType
-- | 'getDestinations' lists every configured alerting destination.
-- Returns the bare 'Destination' list (the paging envelope is
-- discarded). See
-- 'Database.Bloodhound.OpenSearch3.Requests.getDestinations' for the
-- underlying request and the wire-shape details.
getDestinations ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m [Destination]
getDestinations = performBHRequest Requests.getDestinations
-- | 'getDestinationsWith' is the parameterized variant of
-- 'getDestinations'. Returns the full 'GetDestinationsResponse'
-- envelope (including @totalDestinations@). See
-- 'Database.Bloodhound.OpenSearch3.Requests.getDestinationsWith'.
getDestinationsWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DestinationListOptions ->
m GetDestinationsResponse
getDestinationsWith opts =
performBHRequest $ Requests.getDestinationsWith opts
-- | 'createDestination' creates an alerting destination. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createDestination' for the
-- underlying request and the wire-shape details.
createDestination ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Destination ->
m DestinationResponse
createDestination destination =
performBHRequest $ Requests.createDestination destination
-- | 'updateDestination' replaces a destination. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateDestination'.
updateDestination ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DestinationId ->
Destination ->
m DestinationResponse
updateDestination destId destination =
performBHRequest $ Requests.updateDestination destId destination
-- | 'deleteDestination' deletes a destination by id. Returns the bare
-- Elasticsearch delete-document response (see 'DeleteDestinationResponse'
-- for why this deviates from @m 'Acknowledged'@).
deleteDestination ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DestinationId ->
m DeleteDestinationResponse
deleteDestination destId =
performBHRequest $ Requests.deleteDestination destId
-- | 'getAlertsWith' lists alert documents, returning the full
-- 'GetAlertsResponse' envelope (including @totalAlerts@). See
-- 'Database.Bloodhound.OpenSearch3.Requests.getAlertsWith'.
getAlertsWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
GetAlertsOptions ->
m GetAlertsResponse
getAlertsWith opts = performBHRequest $ Requests.getAlertsWith opts
-- | 'getAlerts' lists every active alert, projecting out the bare
-- @['Alert']@ list. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getAlerts'.
getAlerts ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m [Alert]
getAlerts = performBHRequest Requests.getAlerts
-- | 'acknowledgeAlert' acknowledges one or more active alerts of a
-- monitor. See
-- 'Database.Bloodhound.OpenSearch3.Requests.acknowledgeAlert'.
acknowledgeAlert ::
(MonadBH m, WithBackend OpenSearch3 m) =>
MonitorId ->
[Text] ->
m AcknowledgeAlertResponse
acknowledgeAlert monitorId alertIds =
performBHRequest $ Requests.acknowledgeAlert monitorId alertIds
-- | 'getMonitorStats' fetches alerting scheduler statistics. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getMonitorStats'.
getMonitorStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Text ->
Maybe Text ->
m (ParsedEsResponse MonitorStats)
getMonitorStats mNodeId mMetric =
performBHRequest $ Requests.getMonitorStats mNodeId mMetric
-- | 'createEmailAccount' creates a legacy alerting email account. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createEmailAccount'.
createEmailAccount ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailAccount ->
m EmailAccountResponse
createEmailAccount account =
performBHRequest $ Requests.createEmailAccount account
-- | 'getEmailAccount' fetches an email account by id. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getEmailAccount'.
getEmailAccount ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailAccountId ->
m EmailAccount
getEmailAccount emailAccountId =
performBHRequest $ Requests.getEmailAccount emailAccountId
-- | 'updateEmailAccount' replaces an email account. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateEmailAccount'.
updateEmailAccount ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailAccountId ->
EmailAccount ->
m EmailAccountResponse
updateEmailAccount emailAccountId account =
performBHRequest $ Requests.updateEmailAccount emailAccountId account
-- | 'updateEmailAccountWith' replaces an email account with an optional
-- optimistic-concurrency guard. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateEmailAccountWith'.
updateEmailAccountWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailAccountId ->
EmailAccount ->
Maybe (Word64, Word64) ->
m EmailAccountResponse
updateEmailAccountWith emailAccountId account mOcc =
performBHRequest $ Requests.updateEmailAccountWith emailAccountId account mOcc
-- | 'deleteEmailAccount' deletes an email account by id. Returns the
-- bare Elasticsearch delete-document response (see
-- 'DeleteEmailAccountResponse').
deleteEmailAccount ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailAccountId ->
m DeleteEmailAccountResponse
deleteEmailAccount emailAccountId =
performBHRequest $ Requests.deleteEmailAccount emailAccountId
-- | 'createEmailGroup' creates a legacy alerting email group. See
-- 'Database.Bloodhound.OpenSearch3.Requests.createEmailGroup'.
createEmailGroup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailGroup ->
m EmailGroupResponse
createEmailGroup group =
performBHRequest $ Requests.createEmailGroup group
-- | 'getEmailGroup' fetches an email group by id. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getEmailGroup'.
getEmailGroup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailGroupId ->
m EmailGroup
getEmailGroup emailGroupId =
performBHRequest $ Requests.getEmailGroup emailGroupId
-- | 'updateEmailGroup' replaces an email group. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateEmailGroup'.
updateEmailGroup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailGroupId ->
EmailGroup ->
m EmailGroupResponse
updateEmailGroup emailGroupId group =
performBHRequest $ Requests.updateEmailGroup emailGroupId group
-- | 'updateEmailGroupWith' replaces an email group with an optional
-- optimistic-concurrency guard. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateEmailGroupWith'.
updateEmailGroupWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailGroupId ->
EmailGroup ->
Maybe (Word64, Word64) ->
m EmailGroupResponse
updateEmailGroupWith emailGroupId group mOcc =
performBHRequest $ Requests.updateEmailGroupWith emailGroupId group mOcc
-- | 'deleteEmailGroup' deletes an email group by id. Returns the bare
-- Elasticsearch delete-document response (see 'DeleteEmailGroupResponse').
deleteEmailGroup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
EmailGroupId ->
m DeleteEmailGroupResponse
deleteEmailGroup emailGroupId =
performBHRequest $ Requests.deleteEmailGroup emailGroupId
-- | 'getDestination' fetches a single destination by id. See
-- 'Database.Bloodhound.OpenSearch2.Requests.getDestination'.
getDestination ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DestinationId ->
m GetDestinationsResponse
getDestination destId =
performBHRequest $ Requests.getDestination destId
-- | 'searchEmailAccounts' searches the email account store. See
-- 'Database.Bloodhound.OpenSearch2.Requests.searchEmailAccounts'.
searchEmailAccounts ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe EmailAccountSearchQuery ->
m (ParsedEsResponse SearchEmailAccountsResponse)
searchEmailAccounts mQuery =
performBHRequest $ Requests.searchEmailAccounts mQuery
-- | 'searchEmailGroups' searches the email group store. See
-- 'Database.Bloodhound.OpenSearch2.Requests.searchEmailGroups'.
searchEmailGroups ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe EmailGroupSearchQuery ->
m (ParsedEsResponse SearchEmailGroupsResponse)
searchEmailGroups mQuery =
performBHRequest $ Requests.searchEmailGroups mQuery
-- | 'searchFindings' searches the findings index. See
-- 'Database.Bloodhound.OpenSearch2.Requests.searchFindings'.
searchFindings ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe FindingsSearchOptions ->
m (ParsedEsResponse SearchFindingsResponse)
searchFindings mOpts =
performBHRequest $ Requests.searchFindings mOpts
-- | 'createComment' adds a comment to an alert. See
-- 'Database.Bloodhound.OpenSearch2.Requests.createComment'.
createComment ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
CreateCommentRequest ->
m CommentResponse
createComment alertId req =
performBHRequest $ Requests.createComment alertId req
-- | 'updateComment' modifies a comment. See
-- 'Database.Bloodhound.OpenSearch2.Requests.updateComment'.
updateComment ::
(MonadBH m, WithBackend OpenSearch3 m) =>
CommentId ->
UpdateCommentRequest ->
m CommentResponse
updateComment commentId req =
performBHRequest $ Requests.updateComment commentId req
-- | 'searchComments' searches comments. See
-- 'Database.Bloodhound.OpenSearch2.Requests.searchComments'.
searchComments ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe CommentSearchQuery ->
m (ParsedEsResponse SearchCommentsResponse)
searchComments mQuery =
performBHRequest $ Requests.searchComments mQuery
-- | 'deleteComment' removes a comment. See
-- 'Database.Bloodhound.OpenSearch2.Requests.deleteComment'.
deleteComment ::
(MonadBH m, WithBackend OpenSearch3 m) =>
CommentId ->
m DeleteCommentResponse
deleteComment commentId =
performBHRequest $ Requests.deleteComment commentId
-- =========================================================================
-- Anomaly Detection plugin
-- =========================================================================
-- | 'createDetector' creates an anomaly detector. See
-- 'Requests.createDetector' for semantics.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#create-anomaly-detector>
createDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Detector ->
m (ParsedEsResponse CreateDetectorResponse)
createDetector = performBHRequest . Requests.createDetector
-- | 'getDetector' fetches a detector by id. See 'Requests.getDetector' for
-- semantics.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#get-detector>
getDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
GetDetectorParams ->
m (ParsedEsResponse GetDetectorResponse)
getDetector detectorId params =
performBHRequest $ Requests.getDetector detectorId params
-- | 'previewDetector' previews a detector on historical data. See
-- 'Requests.previewDetector' for semantics.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#preview-detector>
previewDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
PreviewRequest ->
m (ParsedEsResponse PreviewResponse)
previewDetector detectorId req =
performBHRequest $ Requests.previewDetector detectorId req
-- | 'previewDetectorInline' previews an unpersisted or body-referenced
-- detector. See 'Requests.previewDetectorInline' for semantics.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#preview-detector>
previewDetectorInline ::
(MonadBH m, WithBackend OpenSearch3 m) =>
PreviewRequest ->
m (ParsedEsResponse PreviewResponse)
previewDetectorInline req =
performBHRequest $ Requests.previewDetectorInline req
-- | 'startDetector' starts a detector job. See
-- 'Requests.startDetector' for semantics.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#start-detector-job>
startDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
Maybe StartDetectorJobRequest ->
m (ParsedEsResponse DetectorJobAcknowledgment)
startDetector detectorId mReq =
performBHRequest $ Requests.startDetector detectorId mReq
-- | 'stopDetector' stops a detector job. See 'Requests.stopDetector'
-- for semantics.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#stop-detector-job>
stopDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
Bool ->
m (ParsedEsResponse DetectorJobAcknowledgment)
stopDetector detectorId historical =
performBHRequest $ Requests.stopDetector detectorId historical
-- | 'updateDetector' replaces a detector. See
-- 'Requests.updateDetector' for semantics.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#update-detector>
updateDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
Detector ->
m (ParsedEsResponse CreateDetectorResponse)
updateDetector detectorId detector =
performBHRequest $ Requests.updateDetector detectorId detector
-- | 'updateDetectorWith' replaces a detector with an optional
-- optimistic-concurrency guard. See 'Requests.updateDetectorWith'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#update-detector>
updateDetectorWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
Detector ->
Maybe (Word64, Word64) ->
m (ParsedEsResponse CreateDetectorResponse)
updateDetectorWith detectorId detector mOcc =
performBHRequest $ Requests.updateDetectorWith detectorId detector mOcc
-- | 'deleteDetector' deletes a detector by id. See 'Requests.deleteDetector'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#delete-detector>
deleteDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
m (ParsedEsResponse DeleteDetectorResponse)
deleteDetector detectorId =
performBHRequest $ Requests.deleteDetector detectorId
-- | 'validateDetector' validates a detector configuration. See
-- 'Requests.validateDetector'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#validate-detector>
validateDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ValidateDetectorMode ->
Detector ->
m (ParsedEsResponse ValidateDetectorResponse)
validateDetector mode detector =
performBHRequest $ Requests.validateDetector mode detector
-- | 'searchDetectors' searches the detector-config index. See
-- 'Requests.searchDetectors'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#search-detector>
searchDetectors ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Value ->
m (ParsedEsResponse SearchDetectorsResponse)
searchDetectors mQuery =
performBHRequest $ Requests.searchDetectors mQuery
-- | 'profileDetector' profiles a detector. See 'Requests.profileDetector'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#profile-detector>
profileDetector ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
[Text] ->
Bool ->
Maybe [Entity] ->
m (ParsedEsResponse DetectorProfileResponse)
profileDetector detectorId types allFlag mEntities =
performBHRequest $ Requests.profileDetector detectorId types allFlag mEntities
-- | 'getDetectorStats' fetches plugin statistics. See
-- 'Requests.getDetectorStats'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#get-stats>
getDetectorStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Text ->
Maybe Text ->
m (ParsedEsResponse DetectorStatsResponse)
getDetectorStats mNodeId mStat =
performBHRequest $ Requests.getDetectorStats mNodeId mStat
-- | 'searchDetectorResults' searches the anomaly-result index. See
-- 'Requests.searchDetectorResults'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#search-results>
searchDetectorResults ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Text ->
Maybe Bool ->
Maybe Value ->
m (ParsedEsResponse SearchDetectorResultsResponse)
searchDetectorResults mCustomResultIndex mOnlyCustom mQuery =
performBHRequest $ Requests.searchDetectorResults mCustomResultIndex mOnlyCustom mQuery
-- | 'deleteDetectorResults' deletes anomaly-result documents by query.
-- See 'Requests.deleteDetectorResults'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#delete-results>
deleteDetectorResults ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Value ->
m (ParsedEsResponse DeleteDetectorResultsResponse)
deleteDetectorResults query =
performBHRequest $ Requests.deleteDetectorResults query
-- | 'searchDetectorTasks' searches the detection-state index. See
-- 'Requests.searchDetectorTasks'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#search-task>
searchDetectorTasks ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe Value ->
m (ParsedEsResponse SearchDetectorTasksResponse)
searchDetectorTasks mQuery =
performBHRequest $ Requests.searchDetectorTasks mQuery
-- | 'topAnomalies' returns the top anomaly results for a
-- high-cardinality detector. See 'Requests.topAnomalies'.
-- See <https://docs.opensearch.org/3.7/observing-your-data/ad/api/#get-top-anomaly-results>
topAnomalies ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DetectorId ->
Bool ->
TopAnomaliesRequest ->
m (ParsedEsResponse TopAnomaliesResponse)
topAnomalies detectorId historical req =
performBHRequest $ Requests.topAnomalies detectorId historical req
-- =========================================================================
-- Flow Framework plugin
-- =========================================================================
-- | 'createWorkflow' persists a 'WorkflowTemplate'. See
-- 'Requests.createWorkflow' for semantics.
-- See <https://docs.opensearch.org/3.7/automating-configurations/api/create-workflow/>.
createWorkflow ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowTemplate ->
m (ParsedEsResponse CreateWorkflowResponse)
createWorkflow = performBHRequest . Requests.createWorkflow
-- | 'createWorkflowWith' is the parameterized variant of 'createWorkflow'.
-- See 'Requests.createWorkflowWith'.
createWorkflowWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
CreateWorkflowOptions ->
WorkflowTemplate ->
m (ParsedEsResponse CreateWorkflowResponse)
createWorkflowWith opts = performBHRequest . Requests.createWorkflowWith opts
-- | 'getWorkflow' fetches a stored 'WorkflowTemplate' by id. See
-- 'Requests.getWorkflow'.
getWorkflow ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
m (ParsedEsResponse WorkflowTemplate)
getWorkflow = performBHRequest . Requests.getWorkflow
-- | 'provisionWorkflow' provisions a workflow. See
-- 'Requests.provisionWorkflow'.
provisionWorkflow ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
m (ParsedEsResponse CreateWorkflowResponse)
provisionWorkflow = performBHRequest . Requests.provisionWorkflow
-- | 'provisionWorkflowWith' is the parameterized variant of
-- 'provisionWorkflow'. See 'Requests.provisionWorkflowWith'.
provisionWorkflowWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
ProvisionOptions ->
m (ParsedEsResponse CreateWorkflowResponse)
provisionWorkflowWith workflowId opts =
performBHRequest $ Requests.provisionWorkflowWith workflowId opts
-- | 'deleteWorkflow' removes a stored template. See
-- 'Requests.deleteWorkflow'.
deleteWorkflow ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
m (ParsedEsResponse IndexedDocument)
deleteWorkflow = performBHRequest . Requests.deleteWorkflow
-- | 'deleteWorkflowWith' is the parameterized variant of
-- 'deleteWorkflow'. See 'Requests.deleteWorkflowWith'.
deleteWorkflowWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
DeleteWorkflowOptions ->
m (ParsedEsResponse IndexedDocument)
deleteWorkflowWith workflowId opts =
performBHRequest $ Requests.deleteWorkflowWith workflowId opts
-- | 'searchWorkflows' searches the stored 'WorkflowTemplate' documents.
-- See 'Requests.searchWorkflows'.
searchWorkflows ::
forall a m.
(MonadBH m, WithBackend OpenSearch3 m, FromJSON a) =>
Search ->
m (ParsedEsResponse (SearchResult a))
searchWorkflows = performBHRequest . Requests.searchWorkflows
-- | 'updateWorkflow' replaces a stored template (PUT). See
-- 'Requests.updateWorkflow'.
updateWorkflow ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
WorkflowTemplate ->
m (ParsedEsResponse CreateWorkflowResponse)
updateWorkflow workflowId tmpl =
performBHRequest $ Requests.updateWorkflow workflowId tmpl
-- | 'updateWorkflowWith' is the parameterized variant of
-- 'updateWorkflow'. See 'Requests.updateWorkflowWith'.
updateWorkflowWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
CreateWorkflowOptions ->
WorkflowTemplate ->
m (ParsedEsResponse CreateWorkflowResponse)
updateWorkflowWith workflowId opts tmpl =
performBHRequest $ Requests.updateWorkflowWith workflowId opts tmpl
-- | 'deprovisionWorkflow' tears down a workflow's resources. See
-- 'Requests.deprovisionWorkflow'.
deprovisionWorkflow ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
m (ParsedEsResponse DeprovisionWorkflowResponse)
deprovisionWorkflow = performBHRequest . Requests.deprovisionWorkflow
-- | 'deprovisionWorkflowWith' is the parameterized variant of
-- 'deprovisionWorkflow'. See 'Requests.deprovisionWorkflowWith'.
deprovisionWorkflowWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
DeprovisionWorkflowOptions ->
m (ParsedEsResponse DeprovisionWorkflowResponse)
deprovisionWorkflowWith workflowId opts =
performBHRequest $ Requests.deprovisionWorkflowWith workflowId opts
-- | 'getWorkflowState' fetches a workflow's provisioning state. See
-- 'Requests.getWorkflowState'.
getWorkflowState ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
m (ParsedEsResponse WorkflowStateResponse)
getWorkflowState = performBHRequest . Requests.getWorkflowState
-- | 'getWorkflowStateWith' is the parameterized variant of
-- 'getWorkflowState'. See 'Requests.getWorkflowStateWith'.
getWorkflowStateWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowId ->
WorkflowStateOptions ->
m (ParsedEsResponse WorkflowStateResponse)
getWorkflowStateWith workflowId opts =
performBHRequest $ Requests.getWorkflowStateWith workflowId opts
-- | 'getWorkflowSteps' lists the registered workflow step types. See
-- 'Requests.getWorkflowSteps'.
getWorkflowSteps ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse WorkflowStepsResponse)
getWorkflowSteps = performBHRequest Requests.getWorkflowSteps
-- | 'getWorkflowStepsWith' is the parameterized variant of
-- 'getWorkflowSteps'. See 'Requests.getWorkflowStepsWith'.
getWorkflowStepsWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
WorkflowStepsOptions ->
m (ParsedEsResponse WorkflowStepsResponse)
getWorkflowStepsWith opts =
performBHRequest $ Requests.getWorkflowStepsWith opts
-- | 'searchWorkflowState' searches the stored workflow-state documents.
-- See 'Requests.searchWorkflowState'.
searchWorkflowState ::
forall a m.
(MonadBH m, WithBackend OpenSearch3 m, FromJSON a) =>
Search ->
m (ParsedEsResponse (SearchResult a))
searchWorkflowState = performBHRequest . Requests.searchWorkflowState
-- Index Rollups plugin
-- <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/>
-- ----------------------------------------------------------------------------
-- | 'createRollup' creates or replaces an index rollup job. See
-- 'Requests.createRollup'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/#create-or-update-an-index-rollup-job>
createRollup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RollupId ->
Rollup ->
m (ParsedEsResponse RollupResponse)
createRollup rollupId rollup =
performBHRequest $ Requests.createRollup rollupId rollup
-- | 'createRollupWith' creates or replaces an index rollup job with an
-- optional optimistic-concurrency guard. See 'Requests.createRollupWith'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/#create-or-update-an-index-rollup-job>
createRollupWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RollupId ->
Rollup ->
Maybe (Word64, Word64) ->
m (ParsedEsResponse RollupResponse)
createRollupWith rollupId rollup mOcc =
performBHRequest $ Requests.createRollupWith rollupId rollup mOcc
-- | 'getRollup' fetches a rollup job by id. See 'Requests.getRollup'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/#get-an-index-rollup-job>
getRollup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RollupId ->
m (ParsedEsResponse RollupResponse)
getRollup rollupId =
performBHRequest $ Requests.getRollup rollupId
-- | 'getAllRollups' lists every rollup job. See 'Requests.getAllRollups'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/>
getAllRollups ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse Value)
getAllRollups =
performBHRequest $ Requests.getAllRollups
-- | 'deleteRollup' deletes a rollup job by id. See 'Requests.deleteRollup'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/#delete-an-index-rollup-job>
deleteRollup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RollupId ->
m (ParsedEsResponse Value)
deleteRollup rollupId =
performBHRequest $ Requests.deleteRollup rollupId
-- | 'startRollup' starts a rollup job by id. See 'Requests.startRollup'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job>
startRollup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RollupId ->
m (ParsedEsResponse Acknowledged)
startRollup rollupId =
performBHRequest $ Requests.startRollup rollupId
-- | 'stopRollup' stops a rollup job by id. See 'Requests.stopRollup'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job>
stopRollup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RollupId ->
m (ParsedEsResponse Acknowledged)
stopRollup rollupId =
performBHRequest $ Requests.stopRollup rollupId
-- | 'explainRollup' returns execution metadata for a rollup job by id.
-- See 'Requests.explainRollup'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-rollups/rollup-api/#explain-an-index-rollup-job>
explainRollup ::
(MonadBH m, WithBackend OpenSearch3 m) =>
RollupId ->
m (ParsedEsResponse ExplainRollupResponse)
explainRollup rollupId =
performBHRequest $ Requests.explainRollup rollupId
-- =========================================================================
-- Cross-Cluster Replication (CCR) plugin
-- =========================================================================
-- | 'startReplication' begins replicating a leader index into a follower
-- index on the /follower/ cluster. See
-- 'Database.Bloodhound.OpenSearch3.Requests.startReplication'.
startReplication ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
StartReplicationRequest ->
m (ParsedEsResponse Acknowledged)
startReplication followerIndex req =
performBHRequest $ Requests.startReplication followerIndex req
-- | 'stopReplication' terminates replication and converts the follower
-- index into a standard writable index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.stopReplication'.
stopReplication ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse Acknowledged)
stopReplication = performBHRequest . Requests.stopReplication
-- | 'pauseReplication' pauses replication of the leader index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.pauseReplication'.
pauseReplication ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse Acknowledged)
pauseReplication = performBHRequest . Requests.pauseReplication
-- | 'resumeReplication' resumes replication after a pause. See
-- 'Database.Bloodhound.OpenSearch3.Requests.resumeReplication'.
resumeReplication ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse Acknowledged)
resumeReplication = performBHRequest . Requests.resumeReplication
-- | 'updateReplicationSettings' applies index-level settings to the
-- follower index. See
-- 'Database.Bloodhound.OpenSearch3.Requests.updateReplicationSettings'.
updateReplicationSettings ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
UpdateReplicationSettingsRequest ->
m (ParsedEsResponse Acknowledged)
updateReplicationSettings followerIndex req =
performBHRequest $ Requests.updateReplicationSettings followerIndex req
-- | 'getReplicationStatus' fetches the replication state of a follower
-- index without the @verbose@ flag. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getReplicationStatus'.
getReplicationStatus ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Text ->
m (ParsedEsResponse ReplicationStatusResponse)
getReplicationStatus = performBHRequest . Requests.getReplicationStatus
-- | 'getReplicationStatusWith' is the parameterized variant of
-- 'getReplicationStatus'. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getReplicationStatusWith'.
getReplicationStatusWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
ReplicationStatusOptions ->
Text ->
m (ParsedEsResponse ReplicationStatusResponse)
getReplicationStatusWith opts followerIndex =
performBHRequest $ Requests.getReplicationStatusWith opts followerIndex
-- | 'getLeaderStats' fetches aggregate and per-index read-side counters
-- from the /leader/ cluster. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getLeaderStats'.
getLeaderStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse LeaderStatsResponse)
getLeaderStats = performBHRequest Requests.getLeaderStats
-- | 'getFollowerStats' fetches follower index state counts and write-side
-- throughput from the /follower/ cluster. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getFollowerStats'.
getFollowerStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse FollowerStatsResponse)
getFollowerStats = performBHRequest Requests.getFollowerStats
-- | 'getAutoFollowStats' fetches auto-follow activity and the configured
-- replication rules. See
-- 'Database.Bloodhound.OpenSearch3.Requests.getAutoFollowStats'.
getAutoFollowStats ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse AutoFollowStatsResponse)
getAutoFollowStats = performBHRequest Requests.getAutoFollowStats
-- | 'createAutoFollowPattern' creates or updates an auto-follow rule.
-- See
-- 'Database.Bloodhound.OpenSearch3.Requests.createAutoFollowPattern'.
createAutoFollowPattern ::
(MonadBH m, WithBackend OpenSearch3 m) =>
CreateAutoFollowPatternRequest ->
m (ParsedEsResponse Acknowledged)
createAutoFollowPattern =
performBHRequest . Requests.createAutoFollowPattern
-- | 'deleteAutoFollowPattern' deletes an auto-follow rule. See
-- 'Database.Bloodhound.OpenSearch3.Requests.deleteAutoFollowPattern'.
deleteAutoFollowPattern ::
(MonadBH m, WithBackend OpenSearch3 m) =>
DeleteAutoFollowPatternRequest ->
m (ParsedEsResponse Acknowledged)
deleteAutoFollowPattern =
performBHRequest . Requests.deleteAutoFollowPattern
-- =========================================================================
-- Index Transforms plugin
-- =========================================================================
-- | 'createTransform' creates or replaces a transform job. See
-- 'Requests.createTransform' for semantics.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
createTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
Transform ->
m (ParsedEsResponse TransformDocumentResponse)
createTransform transformId transform =
performBHRequest $ Requests.createTransform transformId transform
-- | 'updateTransform' replaces a transform job (unconditional). See
-- 'Requests.updateTransform' for semantics.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
updateTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
Transform ->
m (ParsedEsResponse TransformDocumentResponse)
updateTransform transformId transform =
performBHRequest $ Requests.updateTransform transformId transform
-- | 'updateTransformWith' replaces a transform job with an optional
-- optimistic-concurrency guard. See 'Requests.updateTransformWith'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
updateTransformWith ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
Transform ->
Maybe (Word64, Word64) ->
m (ParsedEsResponse TransformDocumentResponse)
updateTransformWith transformId transform mOcc =
performBHRequest $ Requests.updateTransformWith transformId transform mOcc
-- | 'getTransform' fetches a single transform job by id. See
-- 'Requests.getTransform'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
getTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
m (ParsedEsResponse TransformDocumentResponse)
getTransform transformId =
performBHRequest $ Requests.getTransform transformId
-- | 'getTransforms' lists transform jobs, optionally filtered /
-- paginated. See 'Requests.getTransforms'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
getTransforms ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Maybe TransformsListOptions ->
m (ParsedEsResponse GetTransformsResponse)
getTransforms mOpts =
performBHRequest $ Requests.getTransforms mOpts
-- | 'startTransform' starts a transform job. See
-- 'Requests.startTransform'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
startTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
m (ParsedEsResponse Acknowledged)
startTransform transformId =
performBHRequest $ Requests.startTransform transformId
-- | 'stopTransform' stops a transform job. See 'Requests.stopTransform'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
stopTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
m (ParsedEsResponse Acknowledged)
stopTransform transformId =
performBHRequest $ Requests.stopTransform transformId
-- | 'explainTransform' returns the runtime status and statistics of a
-- transform job. See 'Requests.explainTransform'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
explainTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
m (ParsedEsResponse (Maybe TransformExplain))
explainTransform transformId =
performBHRequest $ Requests.explainTransform transformId
-- | 'previewTransform' previews what the transformed target index would
-- look like. See 'Requests.previewTransform'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
previewTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
Transform ->
m (ParsedEsResponse PreviewTransformResponse)
previewTransform transform =
performBHRequest $ Requests.previewTransform transform
-- | 'deleteTransform' deletes a transform job by id. See
-- 'Requests.deleteTransform'.
-- See <https://docs.opensearch.org/3.7/im-plugin/index-transforms/transforms-apis/>
deleteTransform ::
(MonadBH m, WithBackend OpenSearch3 m) =>
TransformId ->
m (ParsedEsResponse BulkResponse)
deleteTransform transformId =
performBHRequest $ Requests.deleteTransform transformId
-- =========================================================================
-- Job Scheduler plugin
-- <https://docs.opensearch.org/3.7/monitoring-your-cluster/job-scheduler/>
-- =========================================================================
-- | 'getJobSchedulerJobs' lists every scheduled job. See
-- 'Requests.getJobSchedulerJobs'.
-- See <https://docs.opensearch.org/3.7/monitoring-your-cluster/job-scheduler/>
getJobSchedulerJobs ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse JobsResponse)
getJobSchedulerJobs =
performBHRequest $ Requests.getJobSchedulerJobs
-- | 'getJobSchedulerLocks' lists every distributed lock. See
-- 'Requests.getJobSchedulerLocks'.
-- See <https://docs.opensearch.org/3.7/monitoring-your-cluster/job-scheduler/>
getJobSchedulerLocks ::
(MonadBH m, WithBackend OpenSearch3 m) =>
m (ParsedEsResponse LocksResponse)
getJobSchedulerLocks =
performBHRequest $ Requests.getJobSchedulerLocks
-- | 'getJobSchedulerLock' looks up a single lock by id. See
-- 'Requests.getJobSchedulerLock'.
-- See <https://docs.opensearch.org/3.7/monitoring-your-cluster/job-scheduler/>
getJobSchedulerLock ::
(MonadBH m, WithBackend OpenSearch3 m) =>
LockId ->
m (ParsedEsResponse LocksResponse)
getJobSchedulerLock lockId =
performBHRequest $ Requests.getJobSchedulerLock lockId