bloodhound-1.0.0.0: src/Database/Bloodhound/OpenSearch1/Client.hs
{-# LANGUAGE RankNTypes #-}
-- |
-- Module : Database.Bloodhound.OpenSearch1.Client
-- Description : OpenSearch 1 client (re-exports Common + OpenSearch 1 plugins)
--
-- The OpenSearch 1 client. Re-exports the version-agnostic "Database.Bloodhound.Common.Client"
-- surface and adds OpenSearch 1 plugins: Index State Management (ISM), ML commons
-- models, neural/kNN cache warmup, asynchronous search, SQL and PPL, and the
-- alerting/monitors framework with destinations and notification email
-- accounts/groups.
module Database.Bloodhound.OpenSearch1.Client
( module Reexport,
deleteISMPolicy,
addISMPolicy,
getMLTask,
putISMPolicy,
putISMPolicyWith,
removeISMPolicy,
changeISMPolicy,
retryISMIndex,
explainISMIndex,
explainISMIndexWith,
getISMPolicy,
getISMPolicies,
getMLStats,
getModel,
searchModels,
listModels,
deleteModel,
predict,
warmupKnnIndex,
warmupKnnIndices,
getKnnStats,
getKnnModel,
trainKnnModel,
trainKnnModelWith,
deleteKnnModel,
searchKnnModels,
submitOSAsyncSearch,
submitOSAsyncSearchWith,
getOSAsyncSearch,
deleteOSAsyncSearch,
getOSAsyncSearchStats,
sqlQuery,
sqlQueryNextPage,
closeSqlCursor,
explainSQL,
pplQuery,
explainPPL,
getSQLStats,
createMonitor,
getMonitor,
updateMonitor,
updateMonitorWith,
deleteMonitor,
searchMonitors,
executeMonitor,
getDestinations,
getDestinationsWith,
createDestination,
updateDestination,
deleteDestination,
getAlertsWith,
getAlerts,
acknowledgeAlert,
getMonitorStats,
createEmailAccount,
getEmailAccount,
updateEmailAccount,
updateEmailAccountWith,
deleteEmailAccount,
createEmailGroup,
getEmailGroup,
updateEmailGroup,
updateEmailGroupWith,
deleteEmailGroup,
getDestination,
searchEmailAccounts,
searchEmailGroups,
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,
)
where
import Data.Aeson (FromJSON, Value)
import Data.Text (Text)
import Data.Word (Word64)
import Database.Bloodhound.Client.Cluster as Cluster
import Database.Bloodhound.Common.Client as Reexport hiding
( PreviewTransformResponse,
TransformId,
TransformStats,
deleteTransform,
explainTransform,
getTransforms,
previewTransform,
startTransform,
stopTransform,
unTransformId,
updateTransform,
updateTransformWith,
)
import Database.Bloodhound.OpenSearch1.Requests qualified as Requests
import Database.Bloodhound.OpenSearch1.Types
-- | 'putISMPolicy' creates or updates an ISM policy.
-- See <https://docs.opensearch.org/1.3/im-plugin/ism/api/#create-policy>
putISMPolicy ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/ism/api/#create-policy>
putISMPolicyWith ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/ism/api/#add-policy>
addISMPolicy ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/ism/api/#remove-policy>
removeISMPolicy ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/ism/api/#change-policy>
changeISMPolicy ::
(MonadBH m, WithBackend OpenSearch1 m) =>
IndexName ->
ChangePolicyRequest ->
m (ParsedEsResponse ISMUpdatedIndicesResponse)
changeISMPolicy indexName req = performBHRequest $ Requests.changeISMPolicy indexName req
-- | 'retryISMIndex' retries the failed ISM action for an index. Pass
-- @Just state@ to retry into a specific state, or 'Nothing' for the current one.
-- See <https://docs.opensearch.org/1.3/im-plugin/ism/api/#retry-failed-index>
retryISMIndex ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/ism/api/#explain-index>
explainISMIndex ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/ism/api/#explain-index>
explainISMIndexWith ::
(MonadBH m, WithBackend OpenSearch1 m) =>
IndexName ->
ISMExplainOptions ->
m (ParsedEsResponse ISMExplanation)
explainISMIndexWith indexName opts =
performBHRequest $ Requests.explainISMIndexWith indexName opts
-- | 'getISMPolicy' fetches a single policy by id.
-- See <https://docs.opensearch.org/1.3/im-plugin/ism/api/#get-policy>
getISMPolicy ::
(MonadBH m, WithBackend OpenSearch1 m) =>
PolicyId ->
m (ParsedEsResponse ISMPolicyInfo)
getISMPolicy policyId = performBHRequest $ Requests.getISMPolicy policyId
-- | 'getISMPolicies' lists policies, optionally filtered / paginated.
-- See <https://docs.opensearch.org/1.3/im-plugin/ism/api/#get-policies>
getISMPolicies ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/ism/api/#delete-policy>
deleteISMPolicy ::
(MonadBH m, WithBackend OpenSearch1 m) =>
PolicyId ->
m (ParsedEsResponse IndexedDocument)
deleteISMPolicy policyId = performBHRequest $ Requests.deleteISMPolicy policyId
-- | '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).
--
-- For more information see
-- <https://docs.opensearch.org/1.3/ml-commons-plugin/api/stats/>.
getMLStats ::
(MonadBH m, WithBackend OpenSearch1 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'.
--
-- For more information see
-- <https://docs.opensearch.org/1.3/ml-commons-plugin/api/model-apis/get-model/>.
getModel ::
(MonadBH m, WithBackend OpenSearch1 m) =>
ModelId ->
m (ParsedEsResponse ModelInfo)
getModel modelId = performBHRequest $ Requests.getModel modelId
-- | 'searchModels' searches the model index.
-- See <https://docs.opensearch.org/1.3/ml-commons-plugin/api/model-apis/search-model/>
searchModels ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Maybe Value ->
m (ParsedEsResponse ModelSearchResponse)
searchModels = performBHRequest . Requests.searchModels
-- | 'listModels' lists models via @POST /_plugins/_ml/models/_search@.
-- Shape-identical to 'searchModels'.
-- See <https://docs.opensearch.org/1.3/ml-commons-plugin/api/model-apis/search-model/>
listModels ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/ml-commons-plugin/api/model-apis/delete-model/>
deleteModel ::
(MonadBH m, WithBackend OpenSearch1 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.
--
-- For more information see
-- <https://docs.opensearch.org/1.3/ml-commons-plugin/api/train-predict/predict/>.
predict ::
(MonadBH m, WithBackend OpenSearch1 m) =>
AlgorithmName ->
ModelId ->
Value ->
m (ParsedEsResponse Value)
predict algo modelId body = performBHRequest $ Requests.predict algo modelId body
-- | '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.
--
-- For more information see
-- <https://docs.opensearch.org/1.3/search-plugins/knn/api/#warmup>.
warmupKnnIndices ::
(MonadBH m, WithBackend OpenSearch1 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 OpenSearch1 m) =>
IndexName ->
m ShardsResult
warmupKnnIndex indexName = warmupKnnIndices [indexName]
-- | 'getKnnStats' fetches k-NN plugin statistics (Stats API introduced in
-- OpenSearch 1.0). 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/1.3/search-plugins/knn/api/#stats>.
getKnnStats ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Maybe KnnNodeId ->
Maybe KnnStatName ->
m (ParsedEsResponse KnnStats)
getKnnStats mNodeId mStatName = performBHRequest $ Requests.getKnnStats mNodeId mStatName
-- | 'getKnnModel' fetches metadata for a trained k-NN model by its
-- 'ModelId' (model APIs introduced in OpenSearch 1.2). 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/1.3/search-plugins/knn/api/#get-model>.
getKnnModel ::
(MonadBH m, WithBackend OpenSearch1 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 (model APIs introduced in OpenSearch 1.2). 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/1.3/search-plugins/knn/api/#train-model>.
trainKnnModel ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/search-plugins/knn/api/#train-model>.
trainKnnModelWith ::
(MonadBH m, WithBackend OpenSearch1 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' (model
-- APIs introduced in OpenSearch 1.2). 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/1.3/search-plugins/knn/api/#delete-model>.
deleteKnnModel ::
(MonadBH m, WithBackend OpenSearch1 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@ (model APIs introduced in
-- OpenSearch 1.2). 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@.
--
-- For more information see
-- <https://docs.opensearch.org/1.3/search-plugins/knn/api/#search-model>.
searchKnnModels ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Search ->
m (SearchResult KnnModel)
searchKnnModels search = performBHRequest $ Requests.searchKnnModels 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/1.3/ml-commons-plugin/api/model-apis/get-task/>.
getMLTask ::
(MonadBH m, WithBackend OpenSearch1 m) =>
MLTaskId ->
m (ParsedEsResponse MLTaskInfo)
getMLTask mlTaskId = performBHRequest $ Requests.getMLTask mlTaskId
-- | '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/1.3/search-plugins/async/index/#submit>.
submitOSAsyncSearch ::
(FromJSON a, MonadBH m, WithBackend OpenSearch1 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/1.3/search-plugins/async/index/#submit>.
submitOSAsyncSearchWith ::
(FromJSON a, MonadBH m, WithBackend OpenSearch1 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/1.3/search-plugins/async/index/#get>.
getOSAsyncSearch ::
(FromJSON a, MonadBH m, WithBackend OpenSearch1 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/1.3/search-plugins/async/index/#delete>.
deleteOSAsyncSearch ::
(MonadBH m, WithBackend OpenSearch1 m) =>
AsyncSearchId ->
m Acknowledged
deleteOSAsyncSearch = performBHRequest . Requests.deleteOSAsyncSearch
-- | 'getOSAsyncSearchStats' fetches cluster-wide async-search statistics.
-- See 'Database.Bloodhound.OpenSearch1.Requests.getOSAsyncSearchStats'.
getOSAsyncSearchStats ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/sql-and-ppl/sql-and-ppl-api/index/>.
sqlQuery ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/sql-and-ppl/sql-and-ppl-api/index/#cursor-and-paginating-results>.
sqlQueryNextPage ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/sql-and-ppl/sql-and-ppl-api/index/#cursor-and-paginating-results>.
closeSqlCursor ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/sql-and-ppl/sql-and-ppl-api/index/#explain-api>.
explainSQL ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/sql-and-ppl/sql-and-ppl-api/index/>.
pplQuery ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/sql-and-ppl/sql-and-ppl-api/index/#explain-api>.
explainPPL ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/sql-and-ppl/sql-and-ppl-api/index/>.
getSQLStats ::
(MonadBH m, WithBackend OpenSearch1 m) =>
m (ParsedEsResponse SQLPluginStats)
getSQLStats = performBHRequest Requests.getSQLStats
-- =========================================================================
-- Alerting plugin
-- =========================================================================
-- | 'createMonitor' creates an alerting monitor. See
-- 'Database.Bloodhound.OpenSearch1.Requests.createMonitor' for the
-- underlying request and the wire-shape details.
createMonitor ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Monitor ->
m MonitorResponse
createMonitor monitor = performBHRequest $ Requests.createMonitor monitor
-- | 'getMonitor' fetches a monitor by id. See
-- 'Database.Bloodhound.OpenSearch1.Requests.getMonitor'.
getMonitor ::
(MonadBH m, WithBackend OpenSearch1 m) =>
MonitorId ->
m Monitor
getMonitor monitorId = performBHRequest $ Requests.getMonitor monitorId
-- | 'updateMonitor' replaces a monitor. See
-- 'Database.Bloodhound.OpenSearch1.Requests.updateMonitor'.
updateMonitor ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.updateMonitorWith'.
updateMonitorWith ::
(MonadBH m, WithBackend OpenSearch1 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 OpenSearch1 m) =>
MonitorId ->
m DeleteMonitorResponse
deleteMonitor monitorId = performBHRequest $ Requests.deleteMonitor monitorId
-- | 'searchMonitors' searches the monitor store. See
-- 'Database.Bloodhound.OpenSearch1.Requests.searchMonitors'.
searchMonitors ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Maybe MonitorsSearchQuery ->
m (ParsedEsResponse SearchMonitorsResponse)
searchMonitors = performBHRequest . Requests.searchMonitors
-- | 'executeMonitor' runs a monitor immediately (out of schedule). See
-- 'Database.Bloodhound.OpenSearch1.Requests.executeMonitor'.
executeMonitor ::
(MonadBH m, WithBackend OpenSearch1 m) =>
MonitorId ->
Maybe ExecuteMonitorRequest ->
m (ParsedEsResponse ExecuteMonitorResponse)
executeMonitor monitorId mRequest =
performBHRequest $ Requests.executeMonitor monitorId mRequest
-- | 'getDestinations' lists every configured alerting destination.
-- Returns the bare 'Destination' list (the paging envelope is
-- discarded). See
-- 'Database.Bloodhound.OpenSearch1.Requests.getDestinations' for the
-- underlying request and the wire-shape details.
getDestinations ::
(MonadBH m, WithBackend OpenSearch1 m) =>
m [Destination]
getDestinations = performBHRequest Requests.getDestinations
-- | 'getDestinationsWith' is the parameterized variant of
-- 'getDestinations'. Returns the full 'GetDestinationsResponse'
-- envelope (including @totalDestinations@). See
-- 'Database.Bloodhound.OpenSearch1.Requests.getDestinationsWith'.
getDestinationsWith ::
(MonadBH m, WithBackend OpenSearch1 m) =>
DestinationListOptions ->
m GetDestinationsResponse
getDestinationsWith opts =
performBHRequest $ Requests.getDestinationsWith opts
-- | 'createDestination' creates an alerting destination. See
-- 'Database.Bloodhound.OpenSearch1.Requests.createDestination' for the
-- underlying request and the wire-shape details.
createDestination ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Destination ->
m DestinationResponse
createDestination destination =
performBHRequest $ Requests.createDestination destination
-- | 'updateDestination' replaces a destination. See
-- 'Database.Bloodhound.OpenSearch1.Requests.updateDestination'.
updateDestination ::
(MonadBH m, WithBackend OpenSearch1 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 OpenSearch1 m) =>
DestinationId ->
m DeleteDestinationResponse
deleteDestination destId =
performBHRequest $ Requests.deleteDestination destId
-- | 'getAlertsWith' lists alert documents, returning the full
-- 'GetAlertsResponse' envelope (including @totalAlerts@). See
-- 'Database.Bloodhound.OpenSearch1.Requests.getAlertsWith'.
getAlertsWith ::
(MonadBH m, WithBackend OpenSearch1 m) =>
GetAlertsOptions ->
m GetAlertsResponse
getAlertsWith opts = performBHRequest $ Requests.getAlertsWith opts
-- | 'getAlerts' lists every active alert, projecting out the bare
-- @['Alert']@ list. See
-- 'Database.Bloodhound.OpenSearch1.Requests.getAlerts'.
getAlerts ::
(MonadBH m, WithBackend OpenSearch1 m) =>
m [Alert]
getAlerts = performBHRequest Requests.getAlerts
-- | 'acknowledgeAlert' acknowledges one or more active alerts of a
-- monitor. See
-- 'Database.Bloodhound.OpenSearch1.Requests.acknowledgeAlert'.
acknowledgeAlert ::
(MonadBH m, WithBackend OpenSearch1 m) =>
MonitorId ->
[Text] ->
m AcknowledgeAlertResponse
acknowledgeAlert monitorId alertIds =
performBHRequest $ Requests.acknowledgeAlert monitorId alertIds
-- | 'getMonitorStats' fetches alerting scheduler statistics. See
-- 'Database.Bloodhound.OpenSearch1.Requests.getMonitorStats'.
getMonitorStats ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.createEmailAccount'.
createEmailAccount ::
(MonadBH m, WithBackend OpenSearch1 m) =>
EmailAccount ->
m EmailAccountResponse
createEmailAccount account =
performBHRequest $ Requests.createEmailAccount account
-- | 'getEmailAccount' fetches an email account by id. See
-- 'Database.Bloodhound.OpenSearch1.Requests.getEmailAccount'.
getEmailAccount ::
(MonadBH m, WithBackend OpenSearch1 m) =>
EmailAccountId ->
m EmailAccount
getEmailAccount emailAccountId =
performBHRequest $ Requests.getEmailAccount emailAccountId
-- | 'updateEmailAccount' replaces an email account. See
-- 'Database.Bloodhound.OpenSearch1.Requests.updateEmailAccount'.
updateEmailAccount ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.updateEmailAccountWith'.
updateEmailAccountWith ::
(MonadBH m, WithBackend OpenSearch1 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 OpenSearch1 m) =>
EmailAccountId ->
m DeleteEmailAccountResponse
deleteEmailAccount emailAccountId =
performBHRequest $ Requests.deleteEmailAccount emailAccountId
-- | 'createEmailGroup' creates a legacy alerting email group. See
-- 'Database.Bloodhound.OpenSearch1.Requests.createEmailGroup'.
createEmailGroup ::
(MonadBH m, WithBackend OpenSearch1 m) =>
EmailGroup ->
m EmailGroupResponse
createEmailGroup group =
performBHRequest $ Requests.createEmailGroup group
-- | 'getEmailGroup' fetches an email group by id. See
-- 'Database.Bloodhound.OpenSearch1.Requests.getEmailGroup'.
getEmailGroup ::
(MonadBH m, WithBackend OpenSearch1 m) =>
EmailGroupId ->
m EmailGroup
getEmailGroup emailGroupId =
performBHRequest $ Requests.getEmailGroup emailGroupId
-- | 'updateEmailGroup' replaces an email group. See
-- 'Database.Bloodhound.OpenSearch1.Requests.updateEmailGroup'.
updateEmailGroup ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.updateEmailGroupWith'.
updateEmailGroupWith ::
(MonadBH m, WithBackend OpenSearch1 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 OpenSearch1 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 OpenSearch1 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 OpenSearch1 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 OpenSearch1 m) =>
Maybe EmailGroupSearchQuery ->
m (ParsedEsResponse SearchEmailGroupsResponse)
searchEmailGroups mQuery =
performBHRequest $ Requests.searchEmailGroups mQuery
-- =========================================================================
-- Anomaly Detection plugin
-- =========================================================================
-- | 'createDetector' creates an anomaly detector. See
-- 'Requests.createDetector' for semantics.
-- See <https://docs.opensearch.org/1.3/observing-your-data/ad/api/#create-anomaly-detector>
createDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#get-detector>
getDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#preview-detector>
previewDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#preview-detector>
previewDetectorInline ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#start-detector-job>
startDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#stop-detector-job>
stopDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#update-detector>
updateDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#update-detector>
updateDetectorWith ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#delete-detector>
deleteDetector ::
(MonadBH m, WithBackend OpenSearch1 m) =>
DetectorId ->
m (ParsedEsResponse DeleteDetectorResponse)
deleteDetector detectorId =
performBHRequest $ Requests.deleteDetector detectorId
-- | 'validateDetector' validates a detector configuration. See
-- 'Requests.validateDetector'.
-- See <https://docs.opensearch.org/1.3/observing-your-data/ad/api/#validate-detector>
validateDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#search-detector>
searchDetectors ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Maybe Value ->
m (ParsedEsResponse SearchDetectorsResponse)
searchDetectors mQuery =
performBHRequest $ Requests.searchDetectors mQuery
-- | 'profileDetector' profiles a detector. See 'Requests.profileDetector'.
-- See <https://docs.opensearch.org/1.3/observing-your-data/ad/api/#profile-detector>
profileDetector ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#get-stats>
getDetectorStats ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#search-results>
searchDetectorResults ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#delete-results>
deleteDetectorResults ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#search-task>
searchDetectorTasks ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/observing-your-data/ad/api/#get-top-anomaly-results>
topAnomalies ::
(MonadBH m, WithBackend OpenSearch1 m) =>
DetectorId ->
Bool ->
TopAnomaliesRequest ->
m (ParsedEsResponse TopAnomaliesResponse)
topAnomalies detectorId historical req =
performBHRequest $ Requests.topAnomalies detectorId historical req
-- ----------------------------------------------------------------------------
-- Index Rollups plugin
-- <https://docs.opensearch.org/1.3/im-plugin/index-rollups/rollup-api/>
-- ----------------------------------------------------------------------------
-- | 'createRollup' creates or replaces an index rollup job. See
-- 'Requests.createRollup'.
-- See <https://docs.opensearch.org/1.3/im-plugin/index-rollups/rollup-api/#create-or-update-an-index-rollup-job>
createRollup ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-rollups/rollup-api/#create-or-update-an-index-rollup-job>
createRollupWith ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-rollups/rollup-api/#get-an-index-rollup-job>
getRollup ::
(MonadBH m, WithBackend OpenSearch1 m) =>
RollupId ->
m (ParsedEsResponse RollupResponse)
getRollup rollupId =
performBHRequest $ Requests.getRollup rollupId
-- | 'getAllRollups' lists every rollup job. See 'Requests.getAllRollups'.
-- See <https://docs.opensearch.org/1.3/im-plugin/index-rollups/rollup-api/>
getAllRollups ::
(MonadBH m, WithBackend OpenSearch1 m) =>
m (ParsedEsResponse Value)
getAllRollups =
performBHRequest $ Requests.getAllRollups
-- | 'deleteRollup' deletes a rollup job by id. See 'Requests.deleteRollup'.
-- See <https://docs.opensearch.org/1.3/im-plugin/index-rollups/rollup-api/#delete-an-index-rollup-job>
deleteRollup ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job>
startRollup ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job>
stopRollup ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-rollups/rollup-api/#explain-an-index-rollup-job>
explainRollup ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.startReplication'.
startReplication ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.stopReplication'.
stopReplication ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Text ->
m (ParsedEsResponse Acknowledged)
stopReplication = performBHRequest . Requests.stopReplication
-- | 'pauseReplication' pauses replication of the leader index. See
-- 'Database.Bloodhound.OpenSearch1.Requests.pauseReplication'.
pauseReplication ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Text ->
m (ParsedEsResponse Acknowledged)
pauseReplication = performBHRequest . Requests.pauseReplication
-- | 'resumeReplication' resumes replication after a pause. See
-- 'Database.Bloodhound.OpenSearch1.Requests.resumeReplication'.
resumeReplication ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Text ->
m (ParsedEsResponse Acknowledged)
resumeReplication = performBHRequest . Requests.resumeReplication
-- | 'updateReplicationSettings' applies index-level settings to the
-- follower index. See
-- 'Database.Bloodhound.OpenSearch1.Requests.updateReplicationSettings'.
updateReplicationSettings ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.getReplicationStatus'.
getReplicationStatus ::
(MonadBH m, WithBackend OpenSearch1 m) =>
Text ->
m (ParsedEsResponse ReplicationStatusResponse)
getReplicationStatus = performBHRequest . Requests.getReplicationStatus
-- | 'getReplicationStatusWith' is the parameterized variant of
-- 'getReplicationStatus'. See
-- 'Database.Bloodhound.OpenSearch1.Requests.getReplicationStatusWith'.
getReplicationStatusWith ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.getLeaderStats'.
getLeaderStats ::
(MonadBH m, WithBackend OpenSearch1 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.OpenSearch1.Requests.getFollowerStats'.
getFollowerStats ::
(MonadBH m, WithBackend OpenSearch1 m) =>
m (ParsedEsResponse FollowerStatsResponse)
getFollowerStats = performBHRequest Requests.getFollowerStats
-- | 'getAutoFollowStats' fetches auto-follow activity and the configured
-- replication rules. See
-- 'Database.Bloodhound.OpenSearch1.Requests.getAutoFollowStats'.
getAutoFollowStats ::
(MonadBH m, WithBackend OpenSearch1 m) =>
m (ParsedEsResponse AutoFollowStatsResponse)
getAutoFollowStats = performBHRequest Requests.getAutoFollowStats
-- | 'createAutoFollowPattern' creates or updates an auto-follow rule.
-- See
-- 'Database.Bloodhound.OpenSearch1.Requests.createAutoFollowPattern'.
createAutoFollowPattern ::
(MonadBH m, WithBackend OpenSearch1 m) =>
CreateAutoFollowPatternRequest ->
m (ParsedEsResponse Acknowledged)
createAutoFollowPattern =
performBHRequest . Requests.createAutoFollowPattern
-- | 'deleteAutoFollowPattern' deletes an auto-follow rule. See
-- 'Database.Bloodhound.OpenSearch1.Requests.deleteAutoFollowPattern'.
deleteAutoFollowPattern ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
createTransform ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
updateTransform ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
updateTransformWith ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
getTransform ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
getTransforms ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
startTransform ::
(MonadBH m, WithBackend OpenSearch1 m) =>
TransformId ->
m (ParsedEsResponse Acknowledged)
startTransform transformId =
performBHRequest $ Requests.startTransform transformId
-- | 'stopTransform' stops a transform job. See 'Requests.stopTransform'.
-- See <https://docs.opensearch.org/1.3/im-plugin/index-transforms/transforms-apis/>
stopTransform ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
explainTransform ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
previewTransform ::
(MonadBH m, WithBackend OpenSearch1 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/1.3/im-plugin/index-transforms/transforms-apis/>
deleteTransform ::
(MonadBH m, WithBackend OpenSearch1 m) =>
TransformId ->
m (ParsedEsResponse BulkResponse)
deleteTransform transformId =
performBHRequest $ Requests.deleteTransform transformId