bloodhound-1.0.0.0: src/Database/Bloodhound/Common/Client.hs
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wno-warnings-deprecations #-}
-- |
-- Module : Database.Bloodhound.Client
-- Copyright : (C) 2014, 2018 Chris Allen
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Chris Allen <cma@bitemyapp.com>
-- Stability : provisional
-- Portability : GHC
--
-- Client side functions for talking to Elasticsearch servers.
module Database.Bloodhound.Common.Client
( -- * Bloodhound client functions
-- | The examples in this module assume the following code has been run.
-- The :{ and :} will only work in GHCi. You'll only need the data types
-- and typeclass instances for the functions that make use of them.
-- $setup
withBH,
-- ** Indices
createIndex,
createIndexOptions,
CreateIndexOptions (..),
ActiveShardCount (..),
defaultCreateIndexOptions,
createIndexWith,
flushIndex,
flushIndexWith,
FlushIndexOptions (..),
defaultFlushIndexOptions,
clearIndexCache,
reloadSearchAnalyzers,
reloadSearchAnalyzersWith,
ReloadSearchAnalyzersResponse (..),
ReloadDetail (..),
ReloadSearchAnalyzersOptions (..),
defaultReloadSearchAnalyzersOptions,
reloadSearchAnalyzersOptionsParams,
diskUsage,
diskUsageWith,
DiskUsageResponse (..),
DiskUsageIndex (..),
DiskUsageFieldBreakdown (..),
DiskUsageInvertedIndex (..),
DiskUsageOptions (..),
defaultDiskUsageOptions,
diskUsageOptionsParams,
fieldUsageStats,
fieldUsageStatsWith,
FieldUsageStatsResponse (..),
FieldUsageStatsIndex (..),
FieldUsageShard (..),
FieldUsageRouting (..),
FieldUsageStats (..),
FieldUsageBreakdown (..),
FieldUsageInvertedIndex (..),
FieldUsageStatsOptions (..),
defaultFieldUsageStatsOptions,
fieldUsageStatsOptionsParams,
getScriptContexts,
ScriptContextsResponse (..),
ScriptContextInfo (..),
ScriptContextMethod (..),
ScriptContextParam (..),
getScriptLanguages,
ScriptLanguagesResponse (..),
ScriptLanguageContext (..),
deleteIndex,
updateIndexSettings,
updateIndexSettingsWith,
UpdateIndexSettingsOptions (..),
defaultUpdateIndexSettingsOptions,
getIndexSettings,
getIndexSettingsWith,
GetIndexSettingsOptions (..),
defaultGetIndexSettingsOptions,
getIndex,
getIndexStats,
getIndexRecovery,
getIndexSegments,
getShardStores,
getShardStoresWith,
ShardStoresOptions (..),
defaultShardStoresOptions,
IndexInfo (..),
IndexStats (..),
IndexStatEntry (..),
IndexStatAggregate (..),
IndexStatMetrics (..),
IndexStatDocs (..),
IndexStatStore (..),
IndexRecovery (..),
IndexSegments (..),
ShardStores (..),
ShardStoresShard (..),
ShardStore (..),
ShardStoreNode (..),
ShardStoreAllocation (..),
ShardStoreException (..),
ShardRecovery (..),
ShardRecoveryIndex (..),
ShardRecoveryFiles (..),
forceMergeIndex,
indexExists,
openIndex,
openIndexWith,
closeIndex,
closeIndexWith,
OpenCloseIndexOptions (..),
defaultOpenCloseIndexOptions,
listIndices,
catIndices,
catIndicesWith,
catAliases,
catAliasesWith,
catAllocation,
catAllocationWith,
catCount,
catCountWith,
catMaster,
catMasterWith,
catHealth,
catHealthWith,
catPendingTasks,
catPendingTasksWith,
catPlugins,
catPluginsWith,
catTemplates,
catTemplatesWith,
catThreadPool,
catThreadPoolWith,
catFielddata,
catFielddataWith,
catNodeattrs,
catNodeattrsWith,
catRepositories,
catRepositoriesWith,
catShards,
catShardsWith,
catTasks,
catTasksWith,
catSnapshots,
catSnapshotsWith,
catNodes,
catNodesWith,
catSegments,
catSegmentsWith,
catRecovery,
catRecoveryWith,
catComponentTemplates,
catComponentTemplatesWith,
catCircuitBreakers,
catCircuitBreakersWith,
catMlJobs,
catMlJobsWith,
catMlDataFrameAnalytics,
catMlDataFrameAnalyticsWith,
catMlDatafeeds,
catMlDatafeedsWith,
catMlTrainedModels,
catMlTrainedModelsWith,
catTransforms,
catTransformsWith,
catHelp,
addIndexBlock,
removeIndexBlock,
IndexBlock (..),
indexBlockText,
waitForYellowIndex,
rolloverIndex,
RolloverConditions (..),
RolloverResponse (..),
defaultRolloverConditions,
shrinkIndex,
ShrinkSettings (..),
defaultShrinkSettings,
splitIndex,
SplitSettings (..),
defaultSplitSettings,
cloneIndex,
CloneSettings (..),
defaultCloneSettings,
Requests.HealthStatus (..),
resolveIndex,
resolveIndexWith,
ResolveIndexOptions (..),
defaultResolveIndexOptions,
ResolvedIndices (..),
ResolvedIndex (..),
ResolvedAlias (..),
ResolvedDataStream (..),
-- *** Dangling indices
listDanglingIndices,
importDanglingIndex,
importDanglingIndexWith,
deleteDanglingIndex,
deleteDanglingIndexWith,
DanglingIndexUuid (..),
unDanglingIndexUuid,
DanglingIndex (..),
DanglingIndicesResponse (..),
ImportDanglingIndexOptions (..),
defaultImportDanglingIndexOptions,
DeleteDanglingIndexOptions (..),
defaultDeleteDanglingIndexOptions,
-- *** Index Aliases
updateIndexAliases,
updateIndexAliasesWith,
UpdateAliasesOptions (..),
defaultUpdateAliasesOptions,
updateAliasesOptionsParams,
createIndexAlias,
getIndexAliases,
getIndexAlias,
deleteIndexAlias,
deleteIndexAliasFrom,
aliasExists,
defaultIndexAliasCreate,
-- *** Index Templates
putTemplate,
templateExists,
getTemplate,
deleteTemplate,
ComponentTemplate (..),
ComposableTemplate (..),
ComposableTemplateContent (..),
ComposableTemplateOptions (..),
defaultComposableTemplateOptions,
composableTemplateOptionsParams,
putIndexTemplate,
putIndexTemplateWith,
getIndexTemplate,
deleteIndexTemplate,
putComponentTemplate,
deleteComponentTemplate,
IndexTemplateInfo (..),
GetIndexTemplatesResponse (..),
TemplateInfo (..),
GetTemplatesResponse (..),
getComponentTemplate,
ComponentTemplateInfo (..),
GetComponentTemplatesResponse (..),
TemplateNamePattern (..),
SimulatedTemplate (..),
SimulatedTemplateOverlap (..),
simulateIndexTemplate,
simulateIndexTemplateWith,
simulateIndex,
simulateIndexWith,
-- ** Mapping
putMapping,
putMappingWith,
getMapping,
getFieldMapping,
FieldMappingResponse (..),
FieldMappingIndexEntry (..),
FieldMappingDetail (..),
-- ** Documents
indexDocument,
updateDocument,
updateDocumentWith,
UpdateBody (..),
mkUpdateDoc,
mkUpdateScript,
updateByQuery,
updateByQueryWith,
rethrottleUpdateByQuery,
getDocument,
getDocumentWith,
getDocumentSource,
getDocumentSourceWith,
getDocuments,
getDocumentsWith,
getDocumentsMulti,
getDocumentsMultiWith,
TermVectors (..),
FieldTermVectors (..),
FieldStatistics (..),
TermVectorStats (..),
TermVectorToken (..),
TermVectorsRequest (..),
TermVectorsFilter (..),
defaultTermVectorsRequest,
defaultTermVectorsFilter,
TermVectorsOptions (..),
defaultTermVectorsOptions,
termVectorsOptionsParams,
getTermVectors,
getTermVectorsWith,
MultiTermVectorsDoc (..),
mkMultiTermVectorsDoc,
MultiTermVectors (..),
MultiTermVectorsResponse (..),
getMultiTermVectors,
getMultiTermVectorsWith,
getMultiTermVectorsByIndex,
getMultiTermVectorsByIndexWith,
GetDocumentOptions (..),
defaultGetDocumentOptions,
GetDocumentSourceOptions (..),
defaultGetDocumentSourceOptions,
MultiGetOptions (..),
defaultMultiGetOptions,
DeleteDocumentOptions (..),
defaultDeleteDocumentOptions,
DocumentExistsOptions (..),
defaultDocumentExistsOptions,
DocumentSourceExistsOptions (..),
defaultDocumentSourceExistsOptions,
ByQueryOptions (..),
ConflictsPolicy (..),
Slices (..),
defaultByQueryOptions,
documentExists,
documentExistsWith,
documentSourceExists,
documentSourceExistsWith,
deleteDocument,
deleteDocumentWith,
deleteByQuery,
deleteByQueryWith,
rethrottleDeleteByQuery,
Requests.IndexedDocument (..),
Requests.DeletedDocuments (..),
Requests.DeletedDocumentsRetries (..),
-- ** Searching
searchAll,
searchAllWith,
multiSearch,
multiSearchWith,
multiSearchByIndex,
multiSearchByIndexWith,
Requests.MultiSearchTemplateItem (..),
multiSearchTemplate,
multiSearchTemplateWith,
multiSearchTemplateByIndex,
multiSearchTemplateByIndexWith,
searchByIndex,
searchByIndexWith,
searchByIndices,
searchByIndicesWith,
explainDocument,
explainDocumentWith,
ExplainOptions (..),
defaultExplainOptions,
explainOptionsParams,
searchByIndexTemplate,
searchByIndicesTemplate,
scanSearch,
getInitialScroll,
getInitialSortedScroll,
advanceScroll,
advanceScrollWith,
AdvanceScrollOptions (..),
defaultAdvanceScrollOptions,
advanceScrollOptionsParams,
clearScroll,
refreshIndex,
refreshIndexWith,
RefreshIndexOptions (..),
defaultRefreshIndexOptions,
Requests.mkSearch,
SearchOptions (..),
defaultSearchOptions,
Requests.mkAggregateSearch,
Requests.mkHighlightSearch,
Requests.mkSearchTemplate,
bulk,
bulkWith,
Requests.pageSearch,
Requests.mkShardCount,
Requests.mkReplicaCount,
getStatus,
-- ** Templates
storeSearchTemplate,
getSearchTemplate,
deleteSearchTemplate,
renderTemplate,
-- ** Snapshot/Restore
-- *** Snapshot Repos
getSnapshotRepos,
getSnapshotReposWith,
updateSnapshotRepo,
verifySnapshotRepo,
verifySnapshotRepoWith,
cleanupSnapshotRepo,
cleanupSnapshotRepoWith,
deleteSnapshotRepo,
deleteSnapshotRepoWith,
SnapshotMasterTimeoutOptions (..),
defaultSnapshotMasterTimeoutOptions,
SnapshotRepoGetOptions (..),
defaultSnapshotRepoGetOptions,
SnapshotRepoTimeoutOptions (..),
defaultSnapshotRepoTimeoutOptions,
-- *** Snapshots
createSnapshot,
cloneSnapshot,
getSnapshots,
getSnapshotsWith,
SnapshotSelectionOptions (..),
SnapshotSortField (..),
SnapshotSortOrder (..),
defaultSnapshotSelectionOptions,
getSnapshotStatus,
getSnapshotStatusWith,
SnapshotStatusOptions (..),
defaultSnapshotStatusOptions,
deleteSnapshot,
deleteSnapshotWith,
-- *** Restoring Snapshots
restoreSnapshot,
-- *** Reindex
reindex,
reindexWith,
reindexAsync,
reindexAsyncWith,
rethrottleReindex,
ReindexOptions (..),
defaultReindexOptions,
reindexOptionsParams,
-- *** Task
getTask,
getTaskWith,
cancelTask,
listTasks,
TaskInfo (..),
TaskListNode (..),
TaskListResponse (..),
taskListFlat,
TaskListOptions (..),
TaskListGroupBy (..),
defaultTaskListOptions,
TaskGetOptions (..),
defaultTaskGetOptions,
-- ** Async Search
getAsyncSearch,
getAsyncSearchStatus,
-- ** Nodes
getNodesInfo,
getNodesInfoWith,
getNodesStats,
getNodesStatsWith,
getNodesUsage,
getNodesUsageWith,
getNodesHotThreads,
getNodesHotThreadsWith,
reloadSecureSettings,
NodeInfoMetric (..),
renderNodeInfoMetric,
NodeStatsMetric (..),
renderNodeStatsMetric,
NodeStatsLevel (..),
renderNodeStatsLevel,
NodeUsageMetric (..),
renderNodeUsageMetric,
-- ** Cluster
getClusterHealth,
getClusterHealthWith,
getClusterHealthForIndex,
getClusterHealthForIndexWith,
ClusterHealthOptions (..),
ClusterHealthLevel (..),
ClusterHealthStatus (..),
defaultClusterHealthOptions,
getClusterSettings,
getClusterSettingsWith,
ClusterSettings (..),
ClusterSettingsOptions (..),
defaultClusterSettingsOptions,
updateClusterSettings,
updateClusterSettingsWith,
ClusterSettingsUpdate (..),
defaultClusterSettingsUpdate,
ClusterSettingsUpdateOptions (..),
defaultClusterSettingsUpdateOptions,
getClusterState,
getClusterStateWith,
ClusterStateOptions (..),
ClusterStateMetric (..),
renderClusterStateMetric,
defaultClusterStateOptions,
getClusterStats,
getPendingTasks,
PendingTask (..),
PendingTaskPriority (..),
explainAllocation,
AllocationExplainRequest (..),
AllocationExplanation (..),
defaultAllocationExplainRequest,
mkAllocationExplainRequest,
getRemoteClusterInfo,
RemoteClustersInfo (..),
RemoteClusterInfo (..),
RemoteClusterMode (..),
updateVotingConfigExclusions,
clearVotingConfigExclusions,
VotingConfigExclusionOptions (..),
defaultVotingConfigExclusionOptions,
votingConfigExclusionOptionsParams,
rerouteCluster,
rerouteClusterWith,
RerouteCommand (..),
RerouteOptions (..),
defaultRerouteOptions,
rerouteOptionsParams,
RerouteResponse (..),
-- ** Index Lifecycle Management (ILM)
getILMPolicy,
putILMPolicy,
deleteILMPolicy,
explainILM,
explainILMWith,
startILM,
stopILM,
getILMStatus,
moveILMStep,
retryILMStep,
removeILM,
migrateDataTiers,
migrateDataTiersWith,
ILMPolicyId (..),
ILMPolicy (..),
ILMPolicyInfo (..),
ILMInUseBy (..),
ILMExplanation (..),
ILMExplanations (..),
ILMExplainOptions (..),
defaultILMExplainOptions,
ILMStepKey (..),
MoveStepRequest (..),
ILMOperationMode (..),
ILMStatus (..),
MigrateDataTiersRequest (..),
defaultMigrateDataTiersRequest,
MigrateDataTiersOptions (..),
defaultMigrateDataTiersOptions,
MigrateDataTiersResponse (..),
-- ** Snapshot Lifecycle Management (SLM)
putSLMPolicy,
getSLMPolicy,
deleteSLMPolicy,
executeSLMPolicy,
getSLMStatus,
stopSLM,
startSLM,
-- ** Enrich
putEnrichPolicy,
getEnrichPolicy,
deleteEnrichPolicy,
executeEnrichPolicy,
executeEnrichPolicyWith,
getEnrichExecuteStats,
getEnrichPolicyExecuteStats,
EnrichPolicyId (..),
EnrichPolicyType (..),
EnrichPolicyConfig (..),
EnrichPolicy (..),
EnrichPolicyInfo (..),
EnrichPoliciesResponse (..),
EnrichPolicyPhase (..),
EnrichExecuteStatsEntry (..),
EnrichExecuteStatsResponse (..),
EnrichExecuteOptions (..),
defaultEnrichExecuteOptions,
-- ** Autoscaling
putAutoscalingPolicy,
getAutoscalingPolicy,
deleteAutoscalingPolicy,
getAutoscalingCapacity,
AutoscalingPolicyName (..),
AutoscalingPolicy (..),
defaultAutoscalingPolicy,
AutoscalingCapacity (..),
AutoscalingCapacityPolicy (..),
CapacitySize (..),
AutoscalingResource (..),
AutoscalingCurrentNode (..),
AutoscalingDeciderResult (..),
-- ** Security — shared privilege vocabulary
ClusterPrivilege (..),
IndexPrivilegeName (..),
ApplicationName (..),
ApplicationPrivilegeName (..),
ResourceName (..),
FieldSecurity (..),
defaultFieldSecurity,
IndexPrivilege (..),
defaultIndexPrivilege,
ApplicationPrivilege (..),
defaultApplicationPrivilege,
-- ** Security — roles (/_security/role/*)
putRole,
getRole,
getRoles,
deleteRole,
clearRoleCache,
RoleName (..),
Role (..),
defaultRole,
RoleCreatedResponse (..),
RoleDeletedResponse (..),
RolesListResponse (..),
ClearRoleCacheResponse (..),
-- ** Security — role mappings (/_security/role_mapping/*)
putRoleMapping,
getRoleMapping,
getRoleMappings,
deleteRoleMapping,
RoleMappingName (..),
RoleMapping (..),
defaultRoleMapping,
RoleMappingRule (..),
RoleMappingsListResponse (..),
-- ** Security — users (/_security/user/*)
putUser,
getUser,
getUsers,
deleteUser,
enableUser,
disableUser,
changeUserPassword,
userHasPrivileges,
selfHasPrivileges,
getUserPrivileges,
UserName (..),
User (..),
UserCreateBody (..),
defaultUserCreateBody,
UserCreatedResponse (..),
UserDeletedResponse (..),
UsersListResponse (..),
ChangePasswordBody (..),
HasPrivilegesRequest (..),
defaultHasPrivilegesRequest,
HasPrivilegesResponse (..),
HasPrivilegesIndexResult (..),
HasPrivilegesApplicationResult (..),
UserPrivileges (..),
UserIndexPrivileges (..),
UserApplicationPrivileges (..),
-- ** Security — API keys (/_security/api_key)
createApiKey,
grantApiKey,
getApiKey,
invalidateApiKey,
updateApiKey,
queryApiKey,
queryApiKeyWith,
-- ** Security — authentication (/_security/_authenticate, _whoami, _logout)
authenticate,
whoami,
logout,
ApiKeyId (..),
ApiKeyName (..),
CreateApiKeyRequest (..),
defaultCreateApiKeyRequest,
ApiKeyCreatedResponse (..),
GrantApiKeyRequest (..),
GrantType (..),
ApiKeySpec (..),
defaultApiKeySpec,
RetrieveApiKeyRequest (..),
defaultRetrieveApiKeyRequest,
ApiKeyInfo (..),
apiKeyInfoExtrasLens,
ApiKeyRetrievalResponse (..),
InvalidateApiKeyRequest (..),
defaultInvalidateApiKeyRequest,
InvalidateApiKeyResponse (..),
InvalidateApiKeyError (..),
UpdateApiKeyRequest (..),
QueryApiKeyRequest (..),
defaultQueryApiKeyRequest,
QueryApiKeyResponse (..),
Requests.QueryApiKeyOptions (..),
Requests.defaultQueryApiKeyOptions,
AuthenticateResponse (..),
SecurityRealm (..),
WhoAmIResponse (..),
whoAmIResponseExtrasLens,
LogoutRequest (..),
defaultLogoutRequest,
LogoutResponse (..),
-- ** Security — service accounts (/_security/service/*)
getServiceAccounts,
getServiceAccountsInNamespace,
getServiceAccount,
createServiceToken,
getServiceCredentials,
deleteServiceToken,
ServiceAccountNamespace (..),
ServiceAccountService (..),
ServiceTokenName (..),
ServiceAccount (..),
defaultServiceAccount,
ServiceAccountsListResponse (..),
ServiceTokenSecret (..),
CreateServiceTokenResponse (..),
GetServiceCredentialsResponse (..),
ServiceTokenDeletedResponse (..),
-- ** Security — SSO / token (/_security/oauth2, /_security/oidc, /_security/saml)
getToken,
invalidateToken,
prepareSamlAuthentication,
authenticateSaml,
logoutSaml,
prepareOidcAuthentication,
authenticateOidc,
logoutOidc,
SsoToken (..),
SsoRefreshToken (..),
OAuth2GrantType (..),
oAuth2GrantTypeText,
GetTokenRequest (..),
defaultGetTokenRequest,
GetTokenResponse (..),
TokenAuthentication (..),
SsoRealmInfo (..),
tokenAuthenticationExtrasLens,
InvalidateTokenRequest (..),
defaultInvalidateTokenRequest,
InvalidateTokenResponse (..),
InvalidateTokenError (..),
SsoTokenResponse (..),
SsoRedirectResponse (..),
SamlPrepareRequest (..),
defaultSamlPrepareRequest,
SamlPrepareResponse (..),
SamlAuthenticateRequest (..),
SamlLogoutRequest (..),
OidcPrepareRequest (..),
defaultOidcPrepareRequest,
OidcPrepareResponse (..),
OidcAuthenticateRequest (..),
OidcLogoutRequest (..),
-- ** Security — application privileges (/_security/privilege/*)
putPrivilege,
getPrivileges,
getPrivilegesInApplication,
getPrivilege,
deletePrivilege,
clearPrivilegeCache,
ActionName (..),
ApplicationPrivilegeDefinition (..),
defaultApplicationPrivilegeDefinition,
ApplicationPrivilegeInfo (..),
PrivilegesListResponse (..),
PrivilegeCreatedResponse (..),
PrivilegeDeletedResponse (..),
ClearPrivilegeCacheResponse (..),
-- ** Fleet
getFleetGlobalCheckpoints,
getFleetGlobalCheckpointsWith,
fleetSearch,
fleetSearchWith,
fleetMultiSearch,
fleetMultiSearchWith,
GlobalCheckpoint (..),
FleetGlobalCheckpointsResponse (..),
FleetGlobalCheckpointsOptions (..),
defaultFleetGlobalCheckpointsOptions,
FleetSearchOptions (..),
defaultFleetSearchOptions,
SLMPolicyId (..),
SLMPolicy (..),
SLMPolicyInfo (..),
SLMExecutionResult (..),
SLMOperationMode (..),
SLMStatus (..),
-- ** Repositories Metering
getRepositoriesMetering,
deleteRepositoriesMetering,
RepositoriesMeteringResponse (..),
NodeRepositoriesMetering (..),
RepositoryMeteringInfo (..),
RepositoriesMeteringNodesSummary (..),
-- ** Rollup
putRollupJob,
getRollupJob,
deleteRollupJob,
startRollupJob,
stopRollupJob,
stopRollupJobWith,
getRollupJobStats,
getRollupCapabilities,
getRollupIndexCapabilities,
rollupSearchByIndex,
rollupSearchByIndexWith,
RollupJobId (..),
RollupJobConfig (..),
defaultRollupJobConfig,
RollupGroups (..),
defaultRollupGroups,
RollupDateHistogramGroup (..),
defaultRollupDateHistogramGroup,
RollupTermsGroup (..),
RollupHistogramGroup (..),
RollupJobMetric (..),
RollupJobMetricAgg (..),
rollupJobMetricAggText,
GetRollupJobsResponse (..),
RollupJob (..),
RollupJobStatus (..),
RollupJobState (..),
rollupJobStateText,
RollupJobStats (..),
GetRollupJobStatsResponse (..),
RollupJobStatsEntry (..),
RollupCapabilitiesResponse (..),
RollupIndexCapabilities (..),
RollupJobCapability (..),
RollupFieldCapability (..),
RollupCapabilityAgg (..),
rollupCapabilityAggText,
StopRollupJobOptions (..),
defaultStopRollupJobOptions,
RollupJobStarted (..),
RollupJobStopped (..),
-- ** Searchable Snapshots
mountSearchableSnapshot,
mountSearchableSnapshotWith,
getSearchableSnapshotsStats,
getSearchableSnapshotsCacheStats,
clearSearchableSnapshotsCache,
SearchableSnapshotMount (..),
defaultSearchableSnapshotMount,
SearchableSnapshotStorage (..),
SearchableSnapshotMountOptions (..),
defaultSearchableSnapshotMountOptions,
SearchableSnapshotMountResponse (..),
SearchableSnapshotsStatsResponse (..),
SearchableSnapshotsCacheStatsResponse (..),
-- ** Watcher
putWatch,
getWatch,
deleteWatch,
executeWatch,
executeWatchWith,
ackWatch,
activateWatch,
deactivateWatch,
watcherStats,
watcherStatsWith,
getWatcherSettings,
updateWatcherSettings,
startWatcher,
stopWatcher,
WatchId (..),
WatchBody (..),
Watch (..),
WatchStatus (..),
WatchState (..),
ExecuteWatchRequest (..),
ExecuteWatchResponse (..),
ExecuteWatchOptions (..),
defaultExecuteWatchOptions,
AckWatchResponse (..),
WatchStateResponse (..),
AckState (..),
WatchExecutionState (..),
WatcherStatsResponse (..),
WatcherStatsSummary (..),
WatcherStatsMetric (..),
WatcherSettings (..),
-- ** Text structure
findStructure,
findStructureWith,
findMessageStructure,
findMessageStructureWith,
findFieldStructure,
findFieldStructureWith,
testGrokPattern,
testGrokPatternWith,
FindStructureResponse (..),
FindStructureFieldStats (..),
FindStructureTopHit (..),
FindStructureOptions (..),
defaultFindStructureOptions,
findStructureOptionsParams,
FindMessageStructureRequest (..),
FindMessageStructureOptions (..),
defaultFindMessageStructureOptions,
findMessageStructureOptionsParams,
FindFieldStructureOptions (..),
defaultFindFieldStructureOptions,
findFieldStructureOptionsParams,
TestGrokPatternRequest (..),
TestGrokPatternResponse (..),
TestGrokPatternOptions (..),
defaultTestGrokPatternOptions,
testGrokPatternOptionsParams,
-- ** Transform
putTransform,
putTransformWith,
updateTransform,
updateTransformWith,
getTransforms,
getTransformsWith,
deleteTransform,
deleteTransformWith,
startTransform,
startTransformWith,
stopTransform,
stopTransformWith,
previewTransform,
previewTransformWith,
getTransformStats,
getTransformStatsWith,
explainTransform,
TransformId (..),
TransformState (..),
TransformHealth (..),
TransformSource (..),
TransformDestination (..),
TransformLatest (..),
TransformSync (..),
TransformSyncTime (..),
TransformSettings (..),
TransformConfig (..),
PutTransformResponse (..),
TransformsResponse (..),
DeleteTransformResponse (..),
StopTransformResponse (..),
PreviewTransformResponse (..),
TransformStatsResponse (..),
TransformStats (..),
TransformExplainResponse (..),
TransformExplainEntry (..),
PutTransformOptions (..),
defaultPutTransformOptions,
UpdateTransformOptions (..),
defaultUpdateTransformOptions,
GetTransformsOptions (..),
defaultGetTransformsOptions,
DeleteTransformOptions (..),
defaultDeleteTransformOptions,
StartTransformOptions (..),
defaultStartTransformOptions,
StopTransformOptions (..),
defaultStopTransformOptions,
PreviewTransformOptions (..),
defaultPreviewTransformOptions,
GetTransformStatsOptions (..),
defaultGetTransformStatsOptions,
-- ** Migration
getMigrationDeprecations,
getSystemFeatures,
upgradeSystemFeatures,
DeprecationLevel (..),
Deprecation (..),
MigrationDeprecations (..),
FeatureMigrationStatus (..),
FeatureUpgradeIndex (..),
FeatureUpgradeInfo (..),
FeatureUpgradeStatus (..),
-- ** Ingest Pipelines
putIngestPipeline,
getIngestPipeline,
deleteIngestPipeline,
simulateIngestPipeline,
getGrokPatterns,
GrokPatterns (..),
PipelineId (..),
IngestPipeline (..),
IngestPipelineInfo (..),
SimulateResult (..),
-- ** Async Search
deleteAsyncSearch,
submitAsyncSearch,
submitAsyncSearchWith,
AsyncSearchId (..),
AsyncSearchResult (..),
AsyncSearchStatus (..),
AsyncSearchSubmitOptions (..),
defaultAsyncSearchSubmitOptions,
assoWaitForCompletionLens,
assoKeepOnCompletionLens,
assoKeepAliveLens,
assoBatchedReduceSizeLens,
assoCcsMinimizeRoundtripsLens,
-- ** Request Utilities
Requests.encodeBulkOperations,
Requests.encodeBulkOperation,
-- * Authentication
basicAuthHook,
-- * Count
countByIndex,
countByIndexWith,
countAll,
CountOptions (..),
defaultCountOptions,
countOptionsParams,
-- * Validate
validateQuery,
validateQueryWith,
validateAll,
ValidateOptions (..),
defaultValidateOptions,
validateOptionsParams,
-- * Rank Evaluation
evaluateRank,
evaluateRankByIndex,
evaluateRankWith,
RankEvalOptions (..),
defaultRankEvalOptions,
rankEvalOptionsParams,
-- * Analyze
analyzeText,
-- * Field Capabilities
getFieldCaps,
getFieldCapsWith,
FieldPattern (..),
FieldCapsRequest (..),
defaultFieldCapsRequest,
FieldCapsOptions (..),
defaultFieldCapsOptions,
fieldCapsOptionsParams,
FieldCapsResponse (..),
FieldCapability (..),
-- * Search Shards
getSearchShards,
getSearchShardsWith,
SearchShardsResponse (..),
SearchShardsNode (..),
SearchShardsShard (..),
SearchShardsState (..),
SearchShardsOptions (..),
defaultSearchShardsOptions,
searchShardsOptionsParams,
-- * Generic
Acknowledged (..),
Accepted (..),
IgnoredBody (..),
)
where
import Control.Monad
import Control.Monad.Catch
import Data.Aeson
import Data.ByteString.Lazy qualified as L
import Data.List.NonEmpty (NonEmpty (..))
import Data.Text (Text)
import Data.Text.Encoding qualified as T
import Data.Time.Clock
import Data.Vector qualified as V
import Database.Bloodhound.Client.Cluster
import Database.Bloodhound.Common.Requests qualified as Requests
import Database.Bloodhound.Common.Types
import Network.HTTP.Client hiding (Proxy)
import Prelude hiding (filter, head)
-- $setup
-- >>> :set -XOverloadedStrings
-- >>> :set -XDeriveGeneric
-- >>> import Database.Bloodhound
-- >>> import Network.HTTP.Client
-- >>> let testServer = (Server "http://localhost:9200")
-- >>> let runBH' = withBH defaultManagerSettings testServer
-- >>> let testIndex = IndexName "twitter"
-- >>> let defaultIndexSettings = IndexSettings (ShardCount 1) (ReplicaCount 0)
-- >>> data TweetMapping = TweetMapping deriving stock (Eq, Show)
-- >>> _ <- runBH' $ deleteIndex testIndex
-- >>> _ <- runBH' $ deleteIndex (IndexName "didimakeanindex")
-- >>> import GHC.Generics
-- >>> import Data.Time.Calendar (Day (..))
-- >>> import Data.Time.Clock (UTCTime (..), secondsToDiffTime)
-- >>> :{
-- instance ToJSON TweetMapping where
-- toJSON TweetMapping =
-- object ["properties" .=
-- object ["location" .=
-- object ["type" .= ("geo_point" :: Text)]]]
-- data Location = Location { lat :: Double
-- , lon :: Double } deriving stock (Eq, Generic, Show)
-- data Tweet = Tweet { user :: Text
-- , postDate :: UTCTime
-- , message :: Text
-- , age :: Int
-- , location :: Location } deriving stock (Eq, Generic, Show)
-- exampleTweet = Tweet { user = "bitemyapp"
-- , postDate = UTCTime
-- (ModifiedJulianDay 55000)
-- (secondsToDiffTime 10)
-- , message = "Use haskell!"
-- , age = 10000
-- , location = Location 40.12 (-71.34) }
-- instance ToJSON Tweet where
-- toJSON = genericToJSON defaultOptions
-- instance FromJSON Tweet where
-- parseJSON = genericParseJSON defaultOptions
-- instance ToJSON Location where
-- toJSON = genericToJSON defaultOptions
-- instance FromJSON Location where
-- parseJSON = genericParseJSON defaultOptions
-- data BulkTest = BulkTest { name :: Text } deriving stock (Eq, Generic, Show)
-- instance FromJSON BulkTest where
-- parseJSON = genericParseJSON defaultOptions
-- instance ToJSON BulkTest where
-- toJSON = genericToJSON defaultOptions
-- :}
-- | Convenience function that sets up a manager and BHEnv and runs
-- the given set of bloodhound operations. Connections will be
-- pipelined automatically in accordance with the given manager
-- settings in IO. If you've got your own monad transformer stack, you
-- should use 'runBH' directly.
withBH :: ManagerSettings -> Server -> BH IO a -> IO a
withBH ms s f = do
mgr <- newManager ms
let env = mkBHEnv s mgr
runBH env f >>= either throwM return
-- | 'getStatus' fetches the 'Status' of a 'Server'
--
-- >>> serverStatus <- runBH' getStatus
-- >>> fmap tagline (serverStatus)
-- Just "You Know, for Search"
getStatus :: (MonadBH m) => m Status
getStatus = performBHRequest $ Requests.getStatus
-- | 'getSnapshotRepos' gets the definitions of a subset of the
-- defined snapshot repos.
getSnapshotRepos :: (MonadBH m) => SnapshotRepoSelection -> m [GenericSnapshotRepo]
getSnapshotRepos sel = performBHRequest $ Requests.getSnapshotRepos sel
-- | Variant of 'getSnapshotRepos' that accepts
-- 'SnapshotRepoGetOptions' for the @master_timeout@ and @local@ URI
-- parameters.
getSnapshotReposWith ::
(MonadBH m) =>
SnapshotRepoSelection ->
SnapshotRepoGetOptions ->
m [GenericSnapshotRepo]
getSnapshotReposWith sel opts = performBHRequest $ Requests.getSnapshotReposWith sel opts
-- | Create or update a snapshot repo
updateSnapshotRepo ::
(MonadBH m) =>
(SnapshotRepo repo) =>
-- | Use 'defaultSnapshotRepoUpdateSettings' if unsure
SnapshotRepoUpdateSettings ->
repo ->
m Acknowledged
updateSnapshotRepo settings repo = performBHRequest $ Requests.updateSnapshotRepo settings repo
-- | Verify if a snapshot repo is working. __NOTE:__ this API did not
-- make it into Elasticsearch until 1.4. If you use an older version,
-- you will get an error here.
verifySnapshotRepo :: (MonadBH m) => SnapshotRepoName -> m SnapshotVerification
verifySnapshotRepo repoName = performBHRequest $ Requests.verifySnapshotRepo repoName
-- | Variant of 'verifySnapshotRepo' that accepts
-- 'SnapshotRepoTimeoutOptions' for the @master_timeout@ and
-- @timeout@ URI parameters.
verifySnapshotRepoWith ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotRepoTimeoutOptions ->
m SnapshotVerification
verifySnapshotRepoWith repoName opts = performBHRequest $ Requests.verifySnapshotRepoWith repoName opts
-- | Removes stale data from a snapshot repository (segments not
-- referenced by any snapshot). Returns a 'SnapshotCleanupResult'
-- reporting the bytes and blobs deleted. A missing repository
-- surfaces as an 'EsError'.
cleanupSnapshotRepo ::
(MonadBH m) =>
SnapshotRepoName ->
m SnapshotCleanupResult
cleanupSnapshotRepo repoName = performBHRequest $ Requests.cleanupSnapshotRepo repoName
-- | Variant of 'cleanupSnapshotRepo' that accepts
-- 'SnapshotMasterTimeoutOptions' for the @master_timeout@ URI
-- parameter.
cleanupSnapshotRepoWith ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotMasterTimeoutOptions ->
m SnapshotCleanupResult
cleanupSnapshotRepoWith repoName opts = performBHRequest $ Requests.cleanupSnapshotRepoWith repoName opts
deleteSnapshotRepo :: (MonadBH m) => SnapshotRepoName -> m Acknowledged
deleteSnapshotRepo repoName = performBHRequest $ Requests.deleteSnapshotRepo repoName
-- | Variant of 'deleteSnapshotRepo' that accepts
-- 'SnapshotRepoTimeoutOptions' for the @master_timeout@ and
-- @timeout@ URI parameters.
deleteSnapshotRepoWith ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotRepoTimeoutOptions ->
m Acknowledged
deleteSnapshotRepoWith repoName opts = performBHRequest $ Requests.deleteSnapshotRepoWith repoName opts
-- | Create and start a snapshot. Returns 'CreateSnapshotResponse',
-- a sum type whose two arms decode the two response shapes the
-- server emits: 'CreateSnapshotAcknowledged' for the default
-- @wait_for_completion=false@ path (@{"acknowledged": <bool>}@) and
-- 'CreateSnapshotCompleted' for @wait_for_completion=true@
-- (@{"snapshot": {…}}@). See 'Requests.createSnapshot' for details.
createSnapshot ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotName ->
SnapshotCreateSettings ->
m CreateSnapshotResponse
createSnapshot repoName snapName settings = performBHRequest $ Requests.createSnapshot repoName snapName settings
-- | Clone a snapshot within the same repository, copying a (partial or
-- full) selection of indices from the source snapshot to a new target
-- snapshot. A missing repository\/source snapshot (404) or an
-- already-existing target (409) surfaces as an 'EsError'.
cloneSnapshot ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotName ->
SnapshotName ->
SnapshotCloneSettings ->
m Acknowledged
cloneSnapshot repoName src target settings =
performBHRequest $ Requests.cloneSnapshot repoName src target settings
-- | Get info about known snapshots given a pattern and repo name.
getSnapshots :: (MonadBH m) => SnapshotRepoName -> SnapshotSelection -> m [SnapshotInfo]
getSnapshots repoName sel = performBHRequest $ Requests.getSnapshots repoName sel
-- | Variant of 'getSnapshots' that accepts 'SnapshotSelectionOptions'
-- for the @master_timeout@, @verbose@, @index_details@,
-- @include_repository@, @sort@, @order@, @size@, @offset@, @after@,
-- @from_sort_value@, @ignore_unavailable@, @index_names@ and
-- @slm_policy_filter@ URI parameters. Calling with
-- 'defaultSnapshotSelectionOptions' is byte-for-byte identical to
-- 'getSnapshots'.
getSnapshotsWith ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotSelection ->
SnapshotSelectionOptions ->
m [SnapshotInfo]
getSnapshotsWith repoName sel opts = performBHRequest $ Requests.getSnapshotsWith repoName sel opts
-- | Get detailed shard-level status of a snapshot. Use this rather than
-- 'getSnapshots' to monitor in-progress snapshots.
getSnapshotStatus :: (MonadBH m) => SnapshotRepoName -> SnapshotName -> m [SnapshotStatus]
getSnapshotStatus repoName snapName = performBHRequest $ Requests.getSnapshotStatus repoName snapName
-- | Variant of 'getSnapshotStatus' that accepts
-- 'SnapshotStatusOptions' for the @master_timeout@ and
-- @ignore_unavailable@ URI parameters.
getSnapshotStatusWith ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotName ->
SnapshotStatusOptions ->
m [SnapshotStatus]
getSnapshotStatusWith repoName snapName opts = performBHRequest $ Requests.getSnapshotStatusWith repoName snapName opts
-- | Delete a snapshot. Cancels if it is running.
deleteSnapshot :: (MonadBH m) => SnapshotRepoName -> SnapshotName -> m Acknowledged
deleteSnapshot repoName snapName = performBHRequest $ Requests.deleteSnapshot repoName snapName
-- | Variant of 'deleteSnapshot' that accepts
-- 'SnapshotMasterTimeoutOptions' for the @master_timeout@ URI
-- parameter.
deleteSnapshotWith ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotName ->
SnapshotMasterTimeoutOptions ->
m Acknowledged
deleteSnapshotWith repoName snapName opts = performBHRequest $ Requests.deleteSnapshotWith repoName snapName opts
-- | Restore a snapshot to the cluster See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-snapshots.html#_restore>
-- for more details.
restoreSnapshot ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotName ->
-- | Start with 'defaultSnapshotRestoreSettings' and customize
-- from there for reasonable defaults.
SnapshotRestoreSettings ->
m Accepted
restoreSnapshot repoName snapName settings = performBHRequest $ Requests.restoreSnapshot repoName snapName settings
getNodesInfo :: (MonadBH m) => NodeSelection -> m NodesInfo
getNodesInfo sel = performBHRequest $ Requests.getNodesInfo sel
-- | 'getNodesInfoWith' is the fully-parameterised form of
-- 'getNodesInfo'. See 'Requests.getNodesInfoWith' and
-- 'NodeInfoOptions' for the available parameters.
getNodesInfoWith :: (MonadBH m) => NodeSelection -> NodeInfoOptions -> m NodesInfo
getNodesInfoWith sel opts = performBHRequest $ Requests.getNodesInfoWith sel opts
getNodesStats :: (MonadBH m) => NodeSelection -> m NodesStats
getNodesStats sel = performBHRequest $ Requests.getNodesStats sel
-- | 'getNodesStatsWith' is the fully-parameterised form of
-- 'getNodesStats'. See 'Requests.getNodesStatsWith' and
-- 'NodeStatsOptions' for the available parameters.
getNodesStatsWith :: (MonadBH m) => NodeSelection -> NodeStatsOptions -> m NodesStats
getNodesStatsWith sel opts = performBHRequest $ Requests.getNodesStatsWith sel opts
getNodesUsage :: (MonadBH m) => NodeSelection -> m NodesUsage
getNodesUsage sel = performBHRequest $ Requests.getNodesUsage sel
-- | 'getNodesUsageWith' is the fully-parameterised form of
-- 'getNodesUsage'. See 'Requests.getNodesUsageWith' and
-- 'NodeUsageOptions' for the available parameters.
getNodesUsageWith :: (MonadBH m) => NodeSelection -> NodeUsageOptions -> m NodesUsage
getNodesUsageWith sel opts = performBHRequest $ Requests.getNodesUsageWith sel opts
-- | 'getNodesHotThreads' fetches the @GET /_nodes/hot_threads@ report
-- (high-CPU diagnostic). See 'Requests.getNodesHotThreads' for the
-- semantics of the @Maybe 'NodeSelector'@ and @Maybe 'ThreadCount'@
-- parameters.
getNodesHotThreads :: (MonadBH m) => Maybe NodeSelector -> Maybe ThreadCount -> m Text
getNodesHotThreads mSel mThreadCount = performBHRequest $ Requests.getNodesHotThreads mSel mThreadCount
-- | 'getNodesHotThreadsWith' is the fully-parameterised form of
-- 'getNodesHotThreads'. See 'Requests.getNodesHotThreadsWith' and
-- 'HotThreadsOptions' for the available parameters.
getNodesHotThreadsWith :: (MonadBH m) => Maybe NodeSelector -> HotThreadsOptions -> m Text
getNodesHotThreadsWith mSel opts = performBHRequest $ Requests.getNodesHotThreadsWith mSel opts
-- | 'reloadSecureSettings' reloads keystore-backed secure settings on
-- the selected nodes without a restart. Pass @Nothing@ for cluster-wide
-- reload, or @Just sel@ to scope to a 'NodeSelection'. See
-- 'Requests.reloadSecureSettings' for the URL rendering of each
-- selection form.
reloadSecureSettings :: (MonadBH m) => Maybe NodeSelection -> m Acknowledged
reloadSecureSettings mSel = performBHRequest $ Requests.reloadSecureSettings mSel
getClusterHealth :: (MonadBH m) => m ClusterHealth
getClusterHealth = performBHRequest Requests.getClusterHealth
-- | Fully-parameterised cluster health query ('ClusterHealthOptions' for
-- every URI parameter). See 'Requests.getClusterHealthWith'.
getClusterHealthWith :: (MonadBH m) => ClusterHealthOptions -> m ClusterHealth
getClusterHealthWith opts = performBHRequest $ Requests.getClusterHealthWith opts
-- | Per-index cluster health (@GET /_cluster/health/{index}@).
getClusterHealthForIndex :: (MonadBH m) => IndexName -> m ClusterHealth
getClusterHealthForIndex indexName = performBHRequest $ Requests.getClusterHealthForIndex indexName
-- | Per-index cluster health with the full 'ClusterHealthOptions'
-- parameter set. This is the most general cluster-health query.
getClusterHealthForIndexWith ::
(MonadBH m) =>
ClusterHealthOptions ->
IndexName ->
m ClusterHealth
getClusterHealthForIndexWith opts indexName =
performBHRequest $ Requests.getClusterHealthForIndexWith opts indexName
getClusterState :: (MonadBH m) => m ClusterState
getClusterState = performBHRequest Requests.getClusterState
-- | Explain why a shard is (or is not) allocated —
-- @/_cluster/allocation/explain@. See 'Requests.explainAllocation'.
explainAllocation ::
(MonadBH m) =>
Maybe AllocationExplainRequest ->
m AllocationExplanation
explainAllocation = performBHRequest . Requests.explainAllocation
-- | Fetch connection state for every configured remote cluster
-- (@GET /_remote/info@). Returns an alias-keyed
-- 'RemoteClustersInfo'; an empty object on a cluster with no remotes
-- configured. Elasticsearch-only — OpenSearch does not expose this
-- endpoint. See 'Requests.getRemoteClusterInfo'.
getRemoteClusterInfo :: (MonadBH m) => m RemoteClustersInfo
getRemoteClusterInfo = performBHRequest Requests.getRemoteClusterInfo
-- | Manually add voting config exclusions for departed nodes
-- (@POST /_cluster/voting_config_exclusions@). The server requires at
-- least one node id or name across the two option lists.
-- Elasticsearch-only — OpenSearch does not expose this endpoint. See
-- 'Requests.updateVotingConfigExclusions'.
updateVotingConfigExclusions ::
(MonadBH m) =>
VotingConfigExclusionOptions ->
m Acknowledged
updateVotingConfigExclusions opts =
performBHRequest $ Requests.updateVotingConfigExclusions opts
-- | Clear all voting config exclusions the cluster is currently
-- holding (@DELETE /_cluster/voting_config_exclusions@).
-- Elasticsearch-only — OpenSearch does not expose this endpoint. See
-- 'Requests.clearVotingConfigExclusions'.
clearVotingConfigExclusions :: (MonadBH m) => m Acknowledged
clearVotingConfigExclusions =
performBHRequest Requests.clearVotingConfigExclusions
-- | Fully-parameterised cluster state query
-- (@GET /_cluster/state/{metric}/{index}@). See
-- 'Requests.getClusterStateWith' and 'ClusterStateOptions' for the
-- available URI parameters. Passing 'defaultClusterStateOptions'
-- reproduces 'getClusterState' byte-for-byte.
getClusterStateWith ::
(MonadBH m) =>
ClusterStateOptions ->
m ClusterState
getClusterStateWith opts =
performBHRequest $ Requests.getClusterStateWith opts
-- | Fetch cluster-level statistics (@GET /_cluster/stats@): indices
-- counts, shards, docs, store size, versions and per-node aggregates
-- (count by role, JVM, FS, OS, plugins, ingest, ...). See
-- 'Requests.getClusterStats'.
getClusterStats :: (MonadBH m) => m ClusterStats
getClusterStats = performBHRequest Requests.getClusterStats
-- | Fetch the cluster-level changes not yet executed by the master
-- (@GET /_cluster/pending_tasks@): pending index creations, mapping
-- updates, shard starts, reroutes and the like. Returns the plain
-- list of 'PendingTask' values (empty when the cluster is idle). See
-- 'Requests.getPendingTasks'.
getPendingTasks :: (MonadBH m) => m [PendingTask]
getPendingTasks = performBHRequest Requests.getPendingTasks
-- | Fetch cluster-wide settings (@GET /_cluster/settings@). Returns the
-- persistent and transient layers; the defaults layer is omitted unless
-- the request is issued via 'getClusterSettingsWith' with
-- 'csoIncludeDefaults' set.
getClusterSettings :: (MonadBH m) => m ClusterSettings
getClusterSettings = performBHRequest Requests.getClusterSettings
-- | Fully-parameterised cluster settings query
-- ('ClusterSettingsOptions' for every URI parameter). See
-- 'Requests.getClusterSettingsWith'.
getClusterSettingsWith :: (MonadBH m) => ClusterSettingsOptions -> m ClusterSettings
getClusterSettingsWith opts = performBHRequest $ Requests.getClusterSettingsWith opts
-- | Update cluster-wide settings (@PUT /_cluster/settings@). Applies the
-- persistent and\/or transient settings carried by the
-- 'ClusterSettingsUpdate' body; assign 'Null' to a key to clear it. See
-- 'Requests.updateClusterSettings'.
updateClusterSettings :: (MonadBH m) => ClusterSettingsUpdate -> m Acknowledged
updateClusterSettings update = performBHRequest $ Requests.updateClusterSettings update
-- | Fully-parameterised cluster settings update
-- ('ClusterSettingsUpdateOptions' for every URI parameter). See
-- 'Requests.updateClusterSettingsWith'.
updateClusterSettingsWith ::
(MonadBH m) =>
ClusterSettingsUpdateOptions ->
ClusterSettingsUpdate ->
m Acknowledged
updateClusterSettingsWith opts update =
performBHRequest $ Requests.updateClusterSettingsWith opts update
-- | Manually execute shard reroute commands (@POST /_cluster/reroute@).
-- Each 'RerouteCommand' (move, cancel, allocate_replica, ...) is applied
-- immediately; the cluster acknowledges the operation. See
-- 'Requests.rerouteCluster' and 'rerouteClusterWith' for the non-mutating
-- @dry_run@ form.
rerouteCluster :: (MonadBH m) => [RerouteCommand] -> m Acknowledged
rerouteCluster cmds = performBHRequest $ Requests.rerouteCluster cmds
-- | Fully-parameterised cluster reroute
-- ('RerouteOptions' for every URI parameter). Returns the rich
-- 'RerouteResponse' so that @dry_run\@true@ surfaces the simulated
-- cluster state and @explain@ surfaces the allocation-decision
-- explanations. See 'Requests.rerouteClusterWith'.
rerouteClusterWith ::
(MonadBH m) =>
RerouteOptions ->
[RerouteCommand] ->
m RerouteResponse
rerouteClusterWith opts cmds =
performBHRequest $ Requests.rerouteClusterWith opts cmds
createIndex :: (MonadBH m) => IndexSettings -> IndexName -> m Acknowledged
createIndex indexSettings indexName = performBHRequest $ Requests.createIndex indexSettings indexName
-- | Create an index, providing it with any number of settings. This
-- is more expressive than 'createIndex' but makes is more verbose
-- for the common case of configuring only the shard count and
-- replica count.
createIndexWith ::
(MonadBH m) =>
[UpdatableIndexSetting] ->
-- | shard count
Int ->
IndexName ->
m Acknowledged
createIndexWith updates shards indexName = performBHRequest $ Requests.createIndexWith updates shards indexName
-- | Create an index with the full set of body fields (@settings@,
-- @mappings@, @aliases@) and URI parameters (@wait_for_active_shards@,
-- @master_timeout@, @timeout@) accepted by the create-index endpoint.
-- This is a superset of 'createIndex' \/ 'createIndexWith' for callers
-- that need more than just @settings@. See 'CreateIndexOptions' for the
-- shape and 'defaultCreateIndexOptions' for an empty starting point.
--
-- @since 0.26.0.0
createIndexOptions ::
(MonadBH m) =>
CreateIndexOptions ->
IndexName ->
m Acknowledged
createIndexOptions opts indexName = performBHRequest $ Requests.createIndexOptions opts indexName
-- | 'flushIndex' will flush an index given a 'Server' and an 'IndexName'.
-- Returns 'ShardsResult' (the @{\"_shards\": {...}}@ envelope); reach the
-- inner counts via 'srShards'.
flushIndex :: (MonadBH m) => IndexName -> m ShardsResult
flushIndex indexName = performBHRequest $ Requests.flushIndex indexName
-- | 'flushIndexWith' is the fully-parameterised form of 'flushIndex'.
-- Pass 'defaultFlushIndexOptions' to reproduce the legacy behaviour.
flushIndexWith :: (MonadBH m) => FlushIndexOptions -> IndexName -> m ShardsResult
flushIndexWith opts indexName = performBHRequest $ Requests.flushIndexWith opts indexName
-- | 'clearIndexCache' clears the caches (query, fielddata, request)
-- for a single index. Wraps @POST \/\<index\>\/_cache\/clear@.
--
-- Returns 'ShardsResult' (the @{\"_shards\": {...}}@ envelope), like the
-- neighbouring 'flushIndex' and 'refreshIndex', because the ES\/OS
-- response wraps the shard stats in a top-level @_shards@ key. Only
-- @?fielddata@, @?query@, @?request@ for selective clearing are not yet
-- exposed.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-clearcache.html>
-- and
-- <https://docs.opensearch.org/latest/api-reference/index-apis/clear-cache/>.
--
-- @since 0.26.0.0
clearIndexCache :: (MonadBH m) => IndexName -> m ShardsResult
clearIndexCache indexName = performBHRequest $ Requests.clearIndexCache indexName
-- | 'reloadSearchAnalyzers' reloads an index's updateable search
-- analyzers (e.g. @updateable@ @synonym@\/@synonym_graph@ filters),
-- picking up changes to the underlying synonym files. Maps to
-- @POST \/{index}/_reload_search_analyzers@.
--
-- Equivalent to
-- @'reloadSearchAnalyzersWith' 'defaultReloadSearchAnalyzersOptions'@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-reload-analyzers.html>
-- and
-- <https://docs.opensearch.org/latest/api-reference/index-apis/reload-search-analyzers/>.
--
-- @since 0.26.0.0
reloadSearchAnalyzers ::
(MonadBH m) =>
IndexName ->
m ReloadSearchAnalyzersResponse
reloadSearchAnalyzers = reloadSearchAnalyzersWith defaultReloadSearchAnalyzersOptions
-- | 'reloadSearchAnalyzersWith' is the fully-parameterised form of
-- 'reloadSearchAnalyzers'.
reloadSearchAnalyzersWith ::
(MonadBH m) =>
ReloadSearchAnalyzersOptions ->
IndexName ->
m ReloadSearchAnalyzersResponse
reloadSearchAnalyzersWith opts indexName =
performBHRequest $ Requests.reloadSearchAnalyzersWith opts indexName
-- | 'diskUsage' analyses the disk usage of each field of an index. Maps
-- to @POST \/{index}/_disk_usage@. ES-only feature (technical preview)
-- and resource-intensive; 'defaultDiskUsageOptions' sets the required
-- @run_expensive_tasks=true@.
--
-- Equivalent to @'diskUsageWith' 'defaultDiskUsageOptions'@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-disk-usage.html>.
--
-- @since 0.26.0.0
diskUsage ::
(MonadBH m) =>
IndexName ->
m DiskUsageResponse
diskUsage = diskUsageWith defaultDiskUsageOptions
-- | 'diskUsageWith' is the fully-parameterised form of 'diskUsage'.
diskUsageWith ::
(MonadBH m) =>
DiskUsageOptions ->
IndexName ->
m DiskUsageResponse
diskUsageWith opts indexName =
performBHRequest $ Requests.diskUsageWith opts indexName
-- | 'fieldUsageStats' reports per-shard, per-field access counts. Maps
-- to @GET \/{index}/_field_usage_stats@. ES-only feature (technical
-- preview).
--
-- Equivalent to
-- @'fieldUsageStatsWith' 'defaultFieldUsageStatsOptions'@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/field-usage-stats.html>.
--
-- @since 0.26.0.0
fieldUsageStats ::
(MonadBH m) =>
IndexName ->
m FieldUsageStatsResponse
fieldUsageStats = fieldUsageStatsWith defaultFieldUsageStatsOptions
-- | 'fieldUsageStatsWith' is the fully-parameterised form of
-- 'fieldUsageStats'.
fieldUsageStatsWith ::
(MonadBH m) =>
FieldUsageStatsOptions ->
IndexName ->
m FieldUsageStatsResponse
fieldUsageStatsWith opts indexName =
performBHRequest $ Requests.fieldUsageStatsWith opts indexName
-- | 'getScriptContexts' lists every Painless \/ expression execution
-- context the cluster knows about, with each context's method
-- catalogue. Maps to @GET /_script_context@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/painless-api-reference.html>.
--
-- @since 0.26.0.0
getScriptContexts ::
(MonadBH m) =>
m ScriptContextsResponse
getScriptContexts = performBHRequest $ Requests.getScriptContexts
-- | 'getScriptLanguages' lists the script languages the cluster
-- supports and, per language, the execution contexts in which each may
-- run. Maps to @GET /_script_language@.
--
-- Note: on OpenSearch 1.3 this endpoint returns HTTP 500 (a server
-- bug); calls against a 1.3 cluster will fail.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/painless-api-reference.html>.
--
-- @since 0.26.0.0
getScriptLanguages ::
(MonadBH m) =>
m ScriptLanguagesResponse
getScriptLanguages = performBHRequest $ Requests.getScriptLanguages
-- | 'deleteIndex' will delete an index given a 'Server' and an 'IndexName'.
--
-- >>> _ <- runBH' $ createIndex defaultIndexSettings (IndexName "didimakeanindex")
-- >>> response <- runBH' $ deleteIndex (IndexName "didimakeanindex")
-- >>> isSuccess response
-- True
-- >>> runBH' $ indexExists (IndexName "didimakeanindex")
-- False
deleteIndex :: (MonadBH m) => IndexName -> m Acknowledged
deleteIndex indexName = performBHRequest $ Requests.deleteIndex indexName
-- | 'updateIndexSettings' will apply a non-empty list of setting updates to an index
--
-- >>> _ <- runBH' $ createIndex defaultIndexSettings (IndexName "unconfiguredindex")
-- >>> response <- runBH' $ updateIndexSettings (BlocksWrite False :| []) (IndexName "unconfiguredindex")
-- >>> isSuccess response
-- True
--
-- Equivalent to @'updateIndexSettingsWith' updates 'defaultUpdateIndexSettingsOptions'@.
updateIndexSettings ::
(MonadBH m) =>
NonEmpty UpdatableIndexSetting ->
IndexName ->
m Acknowledged
updateIndexSettings updates indexName = performBHRequest $ Requests.updateIndexSettings updates indexName
-- | 'updateIndexSettingsWith' is the fully-parameterised form of
-- 'updateIndexSettings'. Pass 'defaultUpdateIndexSettingsOptions' to
-- reproduce the legacy behaviour.
updateIndexSettingsWith ::
(MonadBH m) =>
NonEmpty UpdatableIndexSetting ->
IndexName ->
UpdateIndexSettingsOptions ->
m Acknowledged
updateIndexSettingsWith updates indexName opts =
performBHRequest $ Requests.updateIndexSettingsWith updates indexName opts
-- | 'getIndexSettings' retrieves the live settings of a single index.
-- Equivalent to @'getIndexSettingsWith' name 'defaultGetIndexSettingsOptions'@.
getIndexSettings :: (MonadBH m) => IndexName -> m IndexSettingsSummary
getIndexSettings indexName = performBHRequest $ Requests.getIndexSettings indexName
-- | 'getIndexSettingsWith' is the fully-parameterised form of
-- 'getIndexSettings'. Pass 'defaultGetIndexSettingsOptions' to reproduce
-- the legacy behaviour.
getIndexSettingsWith ::
(MonadBH m) =>
IndexName ->
GetIndexSettingsOptions ->
m IndexSettingsSummary
getIndexSettingsWith indexName opts =
performBHRequest $ Requests.getIndexSettingsWith indexName opts
-- | 'getIndex' fetches the full definition of a single index — its
-- @aliases@, @mappings@ and @settings@ — in one request. Wraps the
-- @GET \/\<index\>@ endpoint
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-get-index.html>).
getIndex :: (MonadBH m) => IndexName -> m IndexInfo
getIndex indexName = performBHRequest $ Requests.getIndex indexName
-- | 'getIndexStats' returns statistics for a single index — the
-- @GET \/\<index\>\/_stats@ endpoint
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-stats.html>).
getIndexStats :: (MonadBH m) => IndexName -> m IndexStats
getIndexStats indexName = performBHRequest $ Requests.getIndexStats indexName
-- | 'getIndexRecovery' returns information about ongoing and completed
-- shard recoveries for the given index (e.g. after snapshot restore,
-- replica allocation or peer recovery on node restart). Wraps the
-- @GET \/\<index\>\/_recovery@ endpoint
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-recovery.html>).
getIndexRecovery :: (MonadBH m) => IndexName -> m IndexRecovery
getIndexRecovery indexName = performBHRequest $ Requests.getIndexRecovery indexName
-- | 'getIndexSegments' returns low-level Lucene segment information
-- for the given index, one entry per shard copy (primary and each
-- replica). Wraps the @GET \/\<index\>\/_segments@ endpoint
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-segments.html>;
-- also implemented by OpenSearch — see
-- <https://docs.opensearch.org/latest/api-reference/index-apis/segments/>).
getIndexSegments :: (MonadBH m) => IndexName -> m IndexSegments
getIndexSegments indexName = performBHRequest $ Requests.getIndexSegments indexName
-- | 'getShardStores' returns store information for every shard copy
-- (primary and each replica) of the given index, one entry per copy
-- describing where it is allocated and its allocation state. Wraps the
-- @GET \/\<index\>\/_shard_stores@ endpoint
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-shards-stores.html>;
-- also implemented by OpenSearch — see
-- <https://docs.opensearch.org/latest/api-reference/index-apis/shard-stores/>).
--
-- Equivalent to @'getShardStoresWith' 'defaultShardStoresOptions'@. Use
-- the @With@ variant to pass URI parameters such as @status@
-- (cluster-health filter). Surfaced as 'StatusDependant' so genuine
-- server-side errors (auth, missing index, 5xx, ...) decode as an
-- 'EsError'.
getShardStores :: (MonadBH m) => IndexName -> m ShardStores
getShardStores indexName = performBHRequest $ Requests.getShardStores indexName
-- | Like 'getShardStores' but additionally accepts 'ShardStoresOptions'
-- rendered as URI parameters. 'defaultShardStoresOptions' makes this
-- byte-for-byte identical to 'getShardStores'.
getShardStoresWith ::
(MonadBH m) =>
IndexName ->
ShardStoresOptions ->
m ShardStores
getShardStoresWith indexName opts =
performBHRequest $ Requests.getShardStoresWith indexName opts
-- | 'resolveIndex' resolves indices, aliases and data streams matching
-- the given patterns. Wraps @GET /_resolve/index\/{name}@
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-resolve-index-api.html>;
-- also implemented by OpenSearch — see
-- <https://docs.opensearch.org/latest/api-reference/index-apis/resolve-index/>).
--
-- Patterns are comma-joined into a single path segment; an empty list
-- is treated as the wildcard @*@. Use 'resolveIndexWith' to pass URI
-- parameters such as @expand_wildcards@. Surfaced as 'StatusDependant'
-- so genuine server-side errors (auth, malformed pattern, ...) decode
-- as an 'EsError'. A missing concrete target usually returns 200 with
-- empty result arrays rather than a 404 — see 'ResolveIndexOptions'
-- for the @ignore_unavailable@ knob (documented on ES 8.x+, silently
-- accepted by OpenSearch).
resolveIndex :: (MonadBH m) => [IndexPattern] -> m ResolvedIndices
resolveIndex patterns = performBHRequest $ Requests.resolveIndex patterns
-- | Like 'resolveIndex' but additionally accepts 'ResolveIndexOptions'
-- rendered as URI parameters. 'defaultResolveIndexOptions' makes this
-- byte-for-byte identical to 'resolveIndex'.
resolveIndexWith ::
(MonadBH m) =>
ResolveIndexOptions ->
[IndexPattern] ->
m ResolvedIndices
resolveIndexWith opts patterns =
performBHRequest $ Requests.resolveIndexWith opts patterns
-- | 'listDanglingIndices' returns every dangling index currently
-- known to the cluster. See 'Requests.listDanglingIndices' for the
-- underlying builder and wire-shape details. Not implemented by
-- OpenSearch — a request against an OS backend surfaces as an
-- 'EsError'.
--
-- @since 0.26.0.0
listDanglingIndices :: (MonadBH m) => m [DanglingIndex]
listDanglingIndices = performBHRequest Requests.listDanglingIndices
-- | 'importDanglingIndex' re-attaches a dangling index to the cluster
-- metadata via @POST /_dangling/{uuid}@. The
-- @accept_data_loss=true@ flag is set by
-- 'defaultImportDanglingIndexOptions'. See 'Requests.importDanglingIndex'.
--
-- @since 0.26.0.0
importDanglingIndex ::
(MonadBH m) =>
DanglingIndexUuid ->
m Acknowledged
importDanglingIndex uuid =
performBHRequest $ Requests.importDanglingIndex uuid
-- | Fully-parameterised form of 'importDanglingIndex'. Pass
-- 'defaultImportDanglingIndexOptions' to reproduce the bare behaviour.
-- See 'Requests.importDanglingIndexWith'.
--
-- @since 0.26.0.0
importDanglingIndexWith ::
(MonadBH m) =>
DanglingIndexUuid ->
ImportDanglingIndexOptions ->
m Acknowledged
importDanglingIndexWith uuid opts =
performBHRequest $ Requests.importDanglingIndexWith uuid opts
-- | 'deleteDanglingIndex' permanently removes a dangling index's
-- on-disk data via @DELETE /_dangling/{uuid}@. See
-- 'Requests.deleteDanglingIndex'.
--
-- @since 0.26.0.0
deleteDanglingIndex ::
(MonadBH m) =>
DanglingIndexUuid ->
m Acknowledged
deleteDanglingIndex uuid =
performBHRequest $ Requests.deleteDanglingIndex uuid
-- | Fully-parameterised form of 'deleteDanglingIndex'. Pass
-- 'defaultDeleteDanglingIndexOptions' to send no parameters at all.
-- See 'Requests.deleteDanglingIndexWith'.
--
-- @since 0.26.0.0
deleteDanglingIndexWith ::
(MonadBH m) =>
DanglingIndexUuid ->
DeleteDanglingIndexOptions ->
m Acknowledged
deleteDanglingIndexWith uuid opts =
performBHRequest $ Requests.deleteDanglingIndexWith uuid opts
-- | 'forceMergeIndex'
--
-- The force merge API allows to force merging of one or more indices through
-- an API. The merge relates to the number of segments a Lucene index holds
-- within each shard. The force merge operation allows to reduce the number of
-- segments by merging them.
--
-- This call will block until the merge is complete. If the http connection is
-- lost, the request will continue in the background, and any new requests will
-- block until the previous force merge is complete.
-- For more information see
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-forcemerge.html#indices-forcemerge>.
-- Nothing
-- worthwhile comes back in the response body, so matching on the status
-- should suffice.
--
-- 'forceMergeIndex' with a maxNumSegments of 1 and onlyExpungeDeletes
-- to True is the main way to release disk space back to the OS being
-- held by deleted documents.
--
-- >>> let ixn = IndexName "unoptimizedindex"
-- >>> _ <- runBH' $ deleteIndex ixn >> createIndex defaultIndexSettings ixn
-- >>> response <- runBH' $ forceMergeIndex (IndexList (ixn :| [])) (defaultIndexOptimizationSettings { maxNumSegments = Just 1, onlyExpungeDeletes = True })
-- >>> isSuccess response
-- True
forceMergeIndex :: (MonadBH m) => IndexSelection -> ForceMergeIndexSettings -> m ShardsResult
forceMergeIndex ixs settings = performBHRequest $ Requests.forceMergeIndex ixs settings
-- | 'indexExists' enables you to check if an index exists. Returns 'Bool'
-- in IO
--
-- >>> exists <- runBH' $ indexExists testIndex
indexExists :: (MonadBH m) => IndexName -> m Bool
indexExists indexName = performBHRequest $ Requests.indexExists indexName
-- | 'refreshIndex' will force a refresh on an index. You must
-- do this if you want to read what you wrote.
--
-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
-- >>> _ <- runBH' $ refreshIndex testIndex
--
-- Returns 'ShardsResult' (the @{\"_shards\": {...}}@ envelope); reach the
-- inner counts via 'srShards'.
refreshIndex :: (MonadBH m) => IndexName -> m ShardsResult
refreshIndex indexName = performBHRequest $ Requests.refreshIndex indexName
-- | 'refreshIndexWith' is the fully-parameterised form of 'refreshIndex'.
-- Pass 'defaultRefreshIndexOptions' to reproduce the legacy behaviour.
refreshIndexWith :: (MonadBH m) => RefreshIndexOptions -> IndexName -> m ShardsResult
refreshIndexWith opts indexName = performBHRequest $ Requests.refreshIndexWith opts indexName
-- | Block until the index becomes available for indexing
-- documents. This is useful for integration tests in which
-- indices are rapidly created and deleted.
waitForYellowIndex :: (MonadBH m) => IndexName -> m Requests.HealthStatus
waitForYellowIndex indexName = performBHRequest $ Requests.waitForYellowIndex indexName
-- | 'rolloverIndex' rolls an alias over to a new index when the
-- supplied conditions are met on the alias's current write index. The
-- alias must point at exactly one write index whose name matches the
-- rollover naming convention (e.g. @logs-000001@ -> @logs-000002@).
-- Wraps @POST /\<alias\>/_rollover@.
--
-- Pass @'Just' conditions@ to set thresholds (any subset of
-- 'rolloverConditionsMaxAge' \/ 'rolloverConditionsMaxDocs' \/
-- 'rolloverConditionsMaxSize' \/ 'rolloverConditionsMaxPrimaryShardSize';
-- at least one should be 'Just'). Pass 'Nothing' to roll over
-- unconditionally. See 'RolloverResponse' for the result.
--
-- @since 0.26.0.0
rolloverIndex ::
(MonadBH m) =>
IndexAliasName ->
Maybe RolloverConditions ->
m RolloverResponse
rolloverIndex alias mConditions = performBHRequest $ Requests.rolloverIndex alias mConditions
-- | Shrink an existing index into a new index with fewer primary shards.
-- Wraps @POST /\<source\>/_shrink/\<target\>@. The source must be
-- read-only (@index.blocks.write: true@) and all primary shards must be
-- co-located on one node; the target's @number_of_shards@ must be a
-- divisor of the source's. Override 'shrinkSettingsOptions' to set the
-- target shard count, aliases and the other body fields and URI
-- parameters (@wait_for_active_shards@, @master_timeout@, @timeout@).
--
-- @since 0.26.0.0
shrinkIndex ::
(MonadBH m) =>
IndexName ->
IndexName ->
ShrinkSettings ->
m Acknowledged
shrinkIndex source target settings =
performBHRequest $ Requests.shrinkIndex source target settings
-- | Split an existing index into a new index with more primary shards.
-- Wraps @POST /\<source\>/_split/\<target\>@. The source must be
-- read-only (@index.blocks.write: true@); the target's
-- @number_of_shards@ must be a multiple of the source's, and the
-- source's @index.number_of_routing_shards@ must be a multiple of the
-- target's. See 'shrinkSettingsOptions' for the body and URI parameter
-- surface.
--
-- @since 0.26.0.0
splitIndex ::
(MonadBH m) =>
IndexName ->
IndexName ->
SplitSettings ->
m Acknowledged
splitIndex source target settings =
performBHRequest $ Requests.splitIndex source target settings
-- | Clone an existing index into a new index with the same mappings and
-- settings. Wraps @POST /\<source\>/_clone/\<target\>@. The source must
-- be read-only (@index.blocks.write: true@); the target inherits the
-- source's @number_of_shards@. See 'shrinkSettingsOptions' for the
-- body and URI parameter surface (the record is wrapped under
-- 'cloneSettingsOptions' here).
--
-- @since 0.26.0.0
cloneIndex ::
(MonadBH m) =>
IndexName ->
IndexName ->
CloneSettings ->
m Acknowledged
cloneIndex source target settings =
performBHRequest $ Requests.cloneIndex source target settings
-- | 'openIndex' opens an index given a 'Server' and an 'IndexName'. Explained in further detail at
-- <http://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-open-close.html>
--
-- >>> response <- runBH' $ openIndex testIndex
openIndex :: (MonadBH m) => IndexName -> m Acknowledged
openIndex indexName = performBHRequest $ Requests.openIndex indexName
-- | 'openIndexWith' is the fully-parameterised form of 'openIndex'. Pass
-- 'defaultOpenCloseIndexOptions' to reproduce the legacy behaviour.
openIndexWith :: (MonadBH m) => OpenCloseIndexOptions -> IndexName -> m Acknowledged
openIndexWith opts indexName = performBHRequest $ Requests.openIndexWith opts indexName
-- | 'closeIndex' closes an index given a 'Server' and an 'IndexName'. Explained in further detail at
-- <http://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-open-close.html>
--
-- >>> response <- runBH' $ closeIndex testIndex
closeIndex :: (MonadBH m) => IndexName -> m Acknowledged
closeIndex indexName = performBHRequest $ Requests.closeIndex indexName
-- | 'closeIndexWith' is the fully-parameterised form of 'closeIndex'. Pass
-- 'defaultOpenCloseIndexOptions' to reproduce the legacy behaviour.
closeIndexWith :: (MonadBH m) => OpenCloseIndexOptions -> IndexName -> m Acknowledged
closeIndexWith opts indexName = performBHRequest $ Requests.closeIndexWith opts indexName
-- | 'listIndices' returns a list of all index names on a given 'Server'
listIndices :: (MonadBH m) => m [IndexName]
listIndices = performBHRequest $ Requests.listIndices
-- | 'catIndices' returns a list of all index names on a given 'Server' as well as their doc counts
catIndices :: (MonadBH m) => m [(IndexName, Int)]
catIndices = performBHRequest $ Requests.catIndices
-- | 'catIndicesWith' is the fully-parameterised form of 'catIndices'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatIndicesOptions'
-- for the available parameters.
catIndicesWith :: (MonadBH m) => CatIndicesOptions -> m [CatIndicesRow]
catIndicesWith = performBHRequest . Requests.catIndicesWith
-- | 'catAliases' lists every index alias on the cluster via
-- @GET /_cat\/aliases?format=json@. Equivalent to
-- @'catAliasesWith' 'Nothing' 'defaultCatAliasesOptions'@.
catAliases :: (MonadBH m) => m [CatAliasesRow]
catAliases = performBHRequest $ Requests.catAliases
-- | 'catAliasesWith' is the fully-parameterised form of 'catAliases'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatAliasesOptions'
-- for the available parameters.
catAliasesWith ::
(MonadBH m) =>
Maybe AliasName ->
CatAliasesOptions ->
m [CatAliasesRow]
catAliasesWith mAlias opts =
performBHRequest $ Requests.catAliasesWith mAlias opts
-- | 'catAllocation' lists the allocation of disk space for indexes and
-- the number of shards on each data node via
-- @GET /_cat\/allocation?format=json@. Equivalent to
-- @'catAllocationWith' 'Nothing' 'defaultCatAllocationOptions'@.
catAllocation :: (MonadBH m) => m [CatAllocationRow]
catAllocation = performBHRequest $ Requests.catAllocation
-- | 'catAllocationWith' is the fully-parameterised form of
-- 'catAllocation'. See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatAllocationOptions'
-- for the available parameters.
catAllocationWith ::
(MonadBH m) =>
Maybe NodeName ->
CatAllocationOptions ->
m [CatAllocationRow]
catAllocationWith mNode opts =
performBHRequest $ Requests.catAllocationWith mNode opts
-- | 'catCount' reports the document count for the whole cluster via
-- @GET /_cat\/count?format=json@. Equivalent to
-- @'catCountWith' 'Nothing' 'defaultCatCountOptions'@.
catCount :: (MonadBH m) => m [CatCountRow]
catCount = performBHRequest $ Requests.catCount
-- | 'catCountWith' is the fully-parameterised form of 'catCount'. See
-- "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatCountOptions'
-- for the available parameters.
catCountWith ::
(MonadBH m) =>
Maybe IndexName ->
CatCountOptions ->
m [CatCountRow]
catCountWith mIndex opts =
performBHRequest $ Requests.catCountWith mIndex opts
-- | 'catMaster' reports the identity of the elected master node via
-- @GET /_cat\/master?format=json@. Equivalent to
-- @'catMasterWith' 'defaultCatMasterOptions'@.
catMaster :: (MonadBH m) => m [CatMasterRow]
catMaster = performBHRequest $ Requests.catMaster
-- | 'catMasterWith' is the fully-parameterised form of 'catMaster'. See
-- "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatMasterOptions'
-- for the available parameters.
catMasterWith ::
(MonadBH m) =>
CatMasterOptions ->
m [CatMasterRow]
catMasterWith opts =
performBHRequest $ Requests.catMasterWith opts
-- | 'catHealth' reports a one-row-per-snapshot summary of cluster
-- health via @GET /_cat\/health?format=json@. Equivalent to
-- @'catHealthWith' 'defaultCatHealthOptions'@.
catHealth :: (MonadBH m) => m [CatHealthRow]
catHealth = performBHRequest $ Requests.catHealth
-- | 'catHealthWith' is the fully-parameterised form of 'catHealth'. See
-- "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatHealthOptions'
-- for the available parameters.
catHealthWith ::
(MonadBH m) =>
CatHealthOptions ->
m [CatHealthRow]
catHealthWith opts =
performBHRequest $ Requests.catHealthWith opts
-- | 'catPendingTasks' lists the cluster-level tasks waiting to be
-- executed via @GET /_cat\/pending_tasks?format=json@. Equivalent to
-- @'catPendingTasksWith' 'defaultCatPendingTasksOptions'@.
catPendingTasks :: (MonadBH m) => m [CatPendingTasksRow]
catPendingTasks = performBHRequest $ Requests.catPendingTasks
-- | 'catPendingTasksWith' is the fully-parameterised form of
-- 'catPendingTasks'. See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatPendingTasksOptions'
-- for the available parameters.
catPendingTasksWith ::
(MonadBH m) =>
CatPendingTasksOptions ->
m [CatPendingTasksRow]
catPendingTasksWith opts =
performBHRequest $ Requests.catPendingTasksWith opts
-- | 'catPlugins' lists the plugins installed on each node via
-- @GET /_cat\/plugins?format=json@. Equivalent to
-- @'catPluginsWith' 'defaultCatPluginsOptions'@.
catPlugins :: (MonadBH m) => m [CatPluginsRow]
catPlugins = performBHRequest $ Requests.catPlugins
-- | 'catPluginsWith' is the fully-parameterised form of 'catPlugins'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatPluginsOptions'
-- for the available parameters.
catPluginsWith ::
(MonadBH m) =>
CatPluginsOptions ->
m [CatPluginsRow]
catPluginsWith opts =
performBHRequest $ Requests.catPluginsWith opts
-- | 'catTemplates' lists the cluster's index templates via
-- @GET /_cat\/templates?format=json@. Equivalent to
-- @'catTemplatesWith' 'Nothing' 'defaultCatTemplatesOptions'@.
catTemplates :: (MonadBH m) => m [CatTemplatesRow]
catTemplates = performBHRequest $ Requests.catTemplates
-- | 'catTemplatesWith' is the fully-parameterised form of 'catTemplates'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatTemplatesOptions'
-- for the available parameters.
catTemplatesWith ::
(MonadBH m) =>
Maybe TemplateName ->
CatTemplatesOptions ->
m [CatTemplatesRow]
catTemplatesWith mName opts =
performBHRequest $ Requests.catTemplatesWith mName opts
-- | 'catThreadPool' lists the thread pools of each node via
-- @GET /_cat\/thread_pool?format=json@. Equivalent to
-- @'catThreadPoolWith' 'Nothing' 'defaultCatThreadPoolOptions'@.
catThreadPool :: (MonadBH m) => m [CatThreadPoolRow]
catThreadPool = performBHRequest $ Requests.catThreadPool
-- | 'catThreadPoolWith' is the fully-parameterised form of
-- 'catThreadPool'. See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatThreadPoolOptions'
-- for the available parameters.
catThreadPoolWith ::
(MonadBH m) =>
Maybe IndexName ->
CatThreadPoolOptions ->
m [CatThreadPoolRow]
catThreadPoolWith mPool opts =
performBHRequest $ Requests.catThreadPoolWith mPool opts
-- | 'catFielddata' lists the amount of heap memory currently used by
-- the field data cache, per field per node, via
-- @GET /_cat\/fielddata?format=json@. Equivalent to
-- @'catFielddataWith' 'Nothing' 'defaultCatFielddataOptions'@.
catFielddata :: (MonadBH m) => m [CatFielddataRow]
catFielddata = performBHRequest $ Requests.catFielddata
-- | 'catFielddataWith' is the fully-parameterised form of
-- 'catFielddata'. See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatFielddataOptions'
-- for the available parameters.
catFielddataWith ::
(MonadBH m) =>
Maybe FieldName ->
CatFielddataOptions ->
m [CatFielddataRow]
catFielddataWith mField opts =
performBHRequest $ Requests.catFielddataWith mField opts
-- | 'catNodeattrs' lists custom node attributes via
-- @GET /_cat\/nodeattrs?format=json@. Equivalent to
-- @'catNodeattrsWith' 'defaultCatNodeattrsOptions'@.
catNodeattrs :: (MonadBH m) => m [CatNodeattrsRow]
catNodeattrs = performBHRequest $ Requests.catNodeattrs
-- | 'catNodeattrsWith' is the fully-parameterised form of
-- 'catNodeattrs'. See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatNodeattrsOptions'
-- for the available parameters.
catNodeattrsWith ::
(MonadBH m) =>
CatNodeattrsOptions ->
m [CatNodeattrsRow]
catNodeattrsWith opts =
performBHRequest $ Requests.catNodeattrsWith opts
-- | 'catRepositories' lists snapshot repositories registered on the
-- cluster via @GET /_cat\/repositories?format=json@. Equivalent to
-- @'catRepositoriesWith' 'defaultCatRepositoriesOptions'@.
catRepositories :: (MonadBH m) => m [CatRepositoriesRow]
catRepositories = performBHRequest $ Requests.catRepositories
-- | 'catRepositoriesWith' is the fully-parameterised form of
-- 'catRepositories'. See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatRepositoriesOptions'
-- for the available parameters.
catRepositoriesWith ::
(MonadBH m) =>
CatRepositoriesOptions ->
m [CatRepositoriesRow]
catRepositoriesWith opts =
performBHRequest $ Requests.catRepositoriesWith opts
-- | 'catShards' lists the state of every primary and replica shard in
-- the cluster via @GET /_cat\/shards?format=json@. Equivalent to
-- @'catShardsWith' 'Nothing' 'defaultCatShardsOptions'@.
catShards :: (MonadBH m) => m [CatShardsRow]
catShards = performBHRequest $ Requests.catShards
-- | 'catShardsWith' is the fully-parameterised form of 'catShards'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatShardsOptions'
-- for the available parameters.
catShardsWith ::
(MonadBH m) =>
Maybe IndexName ->
CatShardsOptions ->
m [CatShardsRow]
catShardsWith mIndex opts =
performBHRequest $ Requests.catShardsWith mIndex opts
-- | 'catTasks' lists the tasks currently executing on the cluster via
-- @GET /_cat\/tasks?format=json@. Equivalent to
-- @'catTasksWith' 'defaultCatTasksOptions'@.
catTasks :: (MonadBH m) => m [CatTasksRow]
catTasks = performBHRequest $ Requests.catTasks
-- | 'catTasksWith' is the fully-parameterised form of 'catTasks'. See
-- "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatTasksOptions'
-- for the available parameters.
catTasksWith ::
(MonadBH m) =>
CatTasksOptions ->
m [CatTasksRow]
catTasksWith opts =
performBHRequest $ Requests.catTasksWith opts
-- | 'catSnapshots' lists the snapshots stored in every snapshot
-- repository registered on the cluster via
-- @GET /_cat\/snapshots?format=json@. Equivalent to
-- @'catSnapshotsWith' 'Nothing' 'defaultCatSnapshotsOptions'@.
catSnapshots :: (MonadBH m) => m [CatSnapshotsRow]
catSnapshots = performBHRequest $ Requests.catSnapshots
-- | 'catSnapshotsWith' is the fully-parameterised form of
-- 'catSnapshots'. See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatSnapshotsOptions'
-- for the available parameters.
catSnapshotsWith ::
(MonadBH m) =>
Maybe SnapshotRepoName ->
CatSnapshotsOptions ->
m [CatSnapshotsRow]
catSnapshotsWith mRepo opts =
performBHRequest $ Requests.catSnapshotsWith mRepo opts
-- | 'catNodes' lists the cluster topology — one row per node with its
-- identity, resource usage, and elected-master flag — via
-- @GET /_cat\/nodes?format=json@. Equivalent to
-- @'catNodesWith' 'defaultCatNodesOptions'@.
catNodes :: (MonadBH m) => m [CatNodesRow]
catNodes = performBHRequest $ Requests.catNodes
-- | 'catNodesWith' is the fully-parameterised form of 'catNodes'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatNodesOptions'
-- for the available parameters.
catNodesWith ::
(MonadBH m) =>
CatNodesOptions ->
m [CatNodesRow]
catNodesWith opts =
performBHRequest $ Requests.catNodesWith opts
-- | 'catSegments' lists the low-level Lucene segments of each shard of
-- each index via @GET /_cat\/segments?format=json@. Equivalent to
-- @'catSegmentsWith' 'Nothing' 'defaultCatSegmentsOptions'@.
catSegments :: (MonadBH m) => m [CatSegmentsRow]
catSegments = performBHRequest $ Requests.catSegments
-- | 'catSegmentsWith' is the fully-parameterised form of 'catSegments'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatSegmentsOptions'
-- for the available parameters.
catSegmentsWith ::
(MonadBH m) =>
Maybe IndexName ->
CatSegmentsOptions ->
m [CatSegmentsRow]
catSegmentsWith mIndex opts =
performBHRequest $ Requests.catSegmentsWith mIndex opts
-- | 'catRecovery' lists shard recovery progress for each shard of each
-- index via @GET /_cat\/recovery?format=json@. Equivalent to
-- @'catRecoveryWith' 'Nothing' 'defaultCatRecoveryOptions'@.
catRecovery :: (MonadBH m) => m [CatRecoveryRow]
catRecovery = performBHRequest $ Requests.catRecovery
-- | 'catRecoveryWith' is the fully-parameterised form of 'catRecovery'.
-- See "Database.Bloodhound.Common.Requests" and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatRecoveryOptions'
-- for the available parameters.
catRecoveryWith ::
(MonadBH m) =>
Maybe IndexName ->
CatRecoveryOptions ->
m [CatRecoveryRow]
catRecoveryWith mIndex opts =
performBHRequest $ Requests.catRecoveryWith mIndex opts
-- | 'catComponentTemplates' lists the component templates.
-- See 'Database.Bloodhound.Common.Requests.catComponentTemplates' and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatComponentTemplatesRow'.
--
-- @since 0.26.0.0
catComponentTemplates :: (MonadBH m) => m [CatComponentTemplatesRow]
catComponentTemplates = performBHRequest $ Requests.catComponentTemplates
-- | 'catComponentTemplatesWith' is the fully-parameterised form of
-- 'catComponentTemplates'.
--
-- @since 0.26.0.0
catComponentTemplatesWith ::
(MonadBH m) =>
Maybe Text ->
CatComponentTemplatesOptions ->
m [CatComponentTemplatesRow]
catComponentTemplatesWith mName opts =
performBHRequest $ Requests.catComponentTemplatesWith mName opts
-- | 'catCircuitBreakers' lists the JVM circuit breakers.
-- See 'Database.Bloodhound.Common.Requests.catCircuitBreakers' and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatCircuitBreakersRow'.
--
-- @since 0.26.0.0
catCircuitBreakers :: (MonadBH m) => m [CatCircuitBreakersRow]
catCircuitBreakers = performBHRequest $ Requests.catCircuitBreakers
-- | 'catCircuitBreakersWith' is the fully-parameterised form of
-- 'catCircuitBreakers'.
--
-- @since 0.26.0.0
catCircuitBreakersWith ::
(MonadBH m) =>
Maybe Text ->
CatCircuitBreakersOptions ->
m [CatCircuitBreakersRow]
catCircuitBreakersWith mPatterns opts =
performBHRequest $ Requests.catCircuitBreakersWith mPatterns opts
-- | 'catMlJobs' lists the ML anomaly-detection jobs.
-- See 'Database.Bloodhound.Common.Requests.catMlJobs' and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatMlJobsRow'.
--
-- @since 0.26.0.0
catMlJobs :: (MonadBH m) => m [CatMlJobsRow]
catMlJobs = performBHRequest $ Requests.catMlJobs
-- | 'catMlJobsWith' is the fully-parameterised form of 'catMlJobs'.
--
-- @since 0.26.0.0
catMlJobsWith ::
(MonadBH m) =>
Maybe Text ->
CatMlJobsOptions ->
m [CatMlJobsRow]
catMlJobsWith mJobId opts =
performBHRequest $ Requests.catMlJobsWith mJobId opts
-- | 'catMlDataFrameAnalytics' lists the ML data frame analytics jobs.
-- See 'Database.Bloodhound.Common.Requests.catMlDataFrameAnalytics' and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatMlDataFrameAnalyticsRow'.
--
-- @since 0.26.0.0
catMlDataFrameAnalytics :: (MonadBH m) => m [CatMlDataFrameAnalyticsRow]
catMlDataFrameAnalytics =
performBHRequest $ Requests.catMlDataFrameAnalytics
-- | 'catMlDataFrameAnalyticsWith' is the fully-parameterised form of
-- 'catMlDataFrameAnalytics'.
--
-- @since 0.26.0.0
catMlDataFrameAnalyticsWith ::
(MonadBH m) =>
Maybe Text ->
CatMlDataFrameAnalyticsOptions ->
m [CatMlDataFrameAnalyticsRow]
catMlDataFrameAnalyticsWith mId opts =
performBHRequest $ Requests.catMlDataFrameAnalyticsWith mId opts
-- | 'catMlDatafeeds' lists the ML datafeeds.
-- See 'Database.Bloodhound.Common.Requests.catMlDatafeeds' and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatMlDatafeedsRow'.
--
-- @since 0.26.0.0
catMlDatafeeds :: (MonadBH m) => m [CatMlDatafeedsRow]
catMlDatafeeds = performBHRequest $ Requests.catMlDatafeeds
-- | 'catMlDatafeedsWith' is the fully-parameterised form of
-- 'catMlDatafeeds'.
--
-- @since 0.26.0.0
catMlDatafeedsWith ::
(MonadBH m) =>
Maybe Text ->
CatMlDatafeedsOptions ->
m [CatMlDatafeedsRow]
catMlDatafeedsWith mDatafeedId opts =
performBHRequest $ Requests.catMlDatafeedsWith mDatafeedId opts
-- | 'catMlTrainedModels' lists the ML trained models.
-- See 'Database.Bloodhound.Common.Requests.catMlTrainedModels' and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatMlTrainedModelsRow'.
--
-- @since 0.26.0.0
catMlTrainedModels :: (MonadBH m) => m [CatMlTrainedModelsRow]
catMlTrainedModels = performBHRequest $ Requests.catMlTrainedModels
-- | 'catMlTrainedModelsWith' is the fully-parameterised form of
-- 'catMlTrainedModels'.
--
-- @since 0.26.0.0
catMlTrainedModelsWith ::
(MonadBH m) =>
Maybe Text ->
CatMlTrainedModelsOptions ->
m [CatMlTrainedModelsRow]
catMlTrainedModelsWith mModelId opts =
performBHRequest $ Requests.catMlTrainedModelsWith mModelId opts
-- | 'catTransforms' lists the transforms.
-- See 'Database.Bloodhound.Common.Requests.catTransforms' and
-- 'Database.Bloodhound.Internal.Versions.Common.Types.Cat.CatTransformsRow'.
--
-- @since 0.26.0.0
catTransforms :: (MonadBH m) => m [CatTransformsRow]
catTransforms = performBHRequest $ Requests.catTransforms
-- | 'catTransformsWith' is the fully-parameterised form of 'catTransforms'.
--
-- @since 0.26.0.0
catTransformsWith ::
(MonadBH m) =>
Maybe Text ->
CatTransformsOptions ->
m [CatTransformsRow]
catTransformsWith mTransformId opts =
performBHRequest $ Requests.catTransformsWith mTransformId opts
-- | 'catHelp' fetches the @GET /_cat@ report, which lists the
-- available cat commands as plain text. See
-- 'Database.Bloodhound.Common.Requests.catHelp'.
--
-- @since 0.26.0.0
catHelp :: (MonadBH m) => m Text
catHelp = performBHRequest $ Requests.catHelp
-- | 'addIndexBlock' applies an 'IndexBlock' to an index via
-- @PUT /\<index\>/_block/\<block\>@, returning 'Acknowledged' on
-- success. Useful for cluster maintenance: temporarily disabling
-- writes, reads, or metadata operations without closing the index.
--
-- See 'Database.Bloodhound.Common.Requests.addIndexBlock' for the
-- underlying request builder, and
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-blocks.html>
-- for the upstream documentation.
--
-- @since 0.26.0.0
addIndexBlock :: (MonadBH m) => IndexName -> IndexBlock -> m Acknowledged
addIndexBlock indexName block = performBHRequest $ Requests.addIndexBlock indexName block
-- | 'removeIndexBlock' releases an 'IndexBlock' from an index.
-- Counterpart to 'addIndexBlock'. Because the dedicated
-- @PUT /\<index\>/_block/\<block\>@ endpoint is add-only on every
-- supported backend (ES7+ and OS1+), the removal uses
-- @PUT /\<index\>/_settings@ with the matching @BlocksX False@
-- 'UpdatableIndexSetting'. Surfaced as 'StatusDependant' so a 404
-- for a missing index decodes as a structured 'EsError' (unlike
-- 'updateIndexSettings', which is 'StatusIndependant'). See
-- 'Database.Bloodhound.Common.Requests.removeIndexBlock' for details.
--
-- @since 0.26.0.0
removeIndexBlock :: (MonadBH m) => IndexName -> IndexBlock -> m Acknowledged
removeIndexBlock indexName block = performBHRequest $ Requests.removeIndexBlock indexName block
-- | 'updateIndexAliases' updates the server's index alias
-- table. Operations are atomic. Explained in further detail at
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-aliases.html>
--
-- >>> let src = IndexName "a-real-index"
-- >>> let aliasName = IndexName "an-alias"
-- >>> let iAlias = IndexAlias src (IndexAliasName aliasName)
-- >>> let aliasCreate = defaultIndexAliasCreate
-- >>> _ <- runBH' $ deleteIndex src
-- >>> isSuccess <$> runBH' (createIndex defaultIndexSettings src)
-- True
-- >>> runBH' $ indexExists src
-- True
-- >>> isSuccess <$> runBH' (updateIndexAliases (AddAlias iAlias aliasCreate :| []))
-- True
-- >>> runBH' $ indexExists aliasName
-- True
updateIndexAliases :: (MonadBH m) => NonEmpty IndexAliasAction -> m Acknowledged
updateIndexAliases actions = performBHRequest $ Requests.updateIndexAliases actions
-- | 'updateIndexAliasesWith' is the fully-parameterised form of
-- 'updateIndexAliases'. See "Database.Bloodhound.Common.Requests" for
-- the underlying builder and 'UpdateAliasesOptions' for the available
-- URI parameters.
updateIndexAliasesWith ::
(MonadBH m) =>
UpdateAliasesOptions ->
NonEmpty IndexAliasAction ->
m Acknowledged
updateIndexAliasesWith opts actions =
performBHRequest $ Requests.updateIndexAliasesWith opts actions
-- | Get all aliases configured on the server.
getIndexAliases :: (MonadBH m) => m IndexAliasesSummary
getIndexAliases = performBHRequest $ Requests.getIndexAliases
-- | Get aliases for a single source index, optionally narrowed to one
-- alias name (@GET /{index}/_alias[\/{name}]@). See
-- "Database.Bloodhound.Common.Requests" for the underlying builder and
-- the wire-shape details. A missing index or named alias surfaces as
-- an 'EsError' (404); wrap with 'tryEsError' for a miss-tolerant
-- variant.
--
-- >>> IndexAliasesInfo _ <- runBH' $ getIndexAlias (IndexName "my-index") (Just (AliasName (IndexName "my-alias")))
getIndexAlias ::
(MonadBH m) =>
IndexName ->
Maybe AliasName ->
m IndexAliasesInfo
getIndexAlias srcIndex mAlias =
performBHRequest $ Requests.getIndexAlias srcIndex mAlias
-- | Delete a single alias name, removing it from /every/ index it is
-- currently associated with (the underlying request uses the @_all@
-- wildcard). See 'deleteIndexAliasFrom' for a per-source-index variant.
deleteIndexAlias :: (MonadBH m) => IndexAliasName -> m Acknowledged
deleteIndexAlias indexAliasName = performBHRequest $ Requests.deleteIndexAlias indexAliasName
-- | Remove an alias from a single source index, hitting
-- @DELETE /{index}/_alias/{name}@. Leaves any other index publishing
-- the same alias name untouched.
deleteIndexAliasFrom ::
(MonadBH m) =>
IndexName ->
IndexAliasName ->
m Acknowledged
deleteIndexAliasFrom srcIndex aliasName =
performBHRequest $ Requests.deleteIndexAliasFrom srcIndex aliasName
-- | Add an alias to a single index via @PUT /{index}/_alias/{name}@ —
-- the non-atomic, single-action variant of 'updateIndexAliases'. Pass
-- 'defaultIndexAliasCreate' for an empty body. Returns the server's
-- 'Acknowledged' flag.
--
-- >>> _ <- runBH' $ createIndexAlias (IndexName "my-index") (IndexAliasName (IndexName "my-alias")) defaultIndexAliasCreate
createIndexAlias ::
(MonadBH m) =>
IndexName ->
IndexAliasName ->
IndexAliasCreate ->
m Acknowledged
createIndexAlias srcIndex aliasName body =
performBHRequest $ Requests.createIndexAlias srcIndex aliasName body
-- | Check whether an alias name exists anywhere in the cluster, hitting
-- @HEAD /_alias/{name}@. Returns 'False' when the alias is absent (404)
-- rather than throwing.
--
-- >>> present <- runBH' $ aliasExists (IndexAliasName (IndexName "my-alias"))
aliasExists :: (MonadBH m) => IndexAliasName -> m Bool
aliasExists aliasName = performBHRequest $ Requests.aliasExists aliasName
-- | 'putTemplate' creates a template given an 'IndexTemplate' and a 'TemplateName'.
-- Explained in further detail at
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html>
--
-- >>> let idxTpl = IndexTemplate [IndexPattern "tweet-*"] (Just (IndexSettings (ShardCount 1) (ReplicaCount 1))) [toJSON TweetMapping]
-- >>> resp <- runBH' $ putTemplate idxTpl (TemplateName "tweet-tpl")
putTemplate :: (MonadBH m) => IndexTemplate -> TemplateName -> m Acknowledged
putTemplate indexTemplate templateName = performBHRequest $ Requests.putTemplate indexTemplate templateName
-- | 'templateExists' checks to see if a template exists.
--
-- >>> exists <- runBH' $ templateExists (TemplateName "tweet-tpl")
templateExists :: (MonadBH m) => TemplateName -> m Bool
templateExists templateName = performBHRequest $ Requests.templateExists templateName
-- | 'getTemplate' fetches /legacy/ templates (the @GET /_template@
-- endpoint). Read-side counterpart of 'putTemplate'. See
-- 'Database.Bloodhound.Common.Requests.getTemplate' for the wire
-- envelope details and the 'TemplateInfo' body shape.
--
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-get-template.html>)
getTemplate :: (MonadBH m) => Maybe TemplateNamePattern -> m [TemplateInfo]
getTemplate = performBHRequest . Requests.getTemplate
-- | 'deleteTemplate' is an HTTP DELETE and deletes a template.
--
-- >>> let idxTpl = IndexTemplate [IndexPattern "tweet-*"] (Just (IndexSettings (ShardCount 1) (ReplicaCount 1))) [toJSON TweetMapping]
-- >>> _ <- runBH' $ putTemplate idxTpl (TemplateName "tweet-tpl")
-- >>> resp <- runBH' $ deleteTemplate (TemplateName "tweet-tpl")
deleteTemplate :: (MonadBH m) => TemplateName -> m Acknowledged
deleteTemplate templateName = performBHRequest $ Requests.deleteTemplate templateName
-- | 'putIndexTemplate' creates or updates a /composable/ index template
-- (the @PUT /_index_template/{name}@ endpoint, available since
-- Elasticsearch 7.8 and in OpenSearch 2.x). This is the modern
-- replacement for the legacy 'putTemplate' (which targets
-- @PUT /_template@): composable templates can be assembled from
-- reusable component templates and carry an explicit priority for
-- deterministic conflict resolution.
--
-- Unlike the legacy 'putTemplate' this surfaces 4xx responses as
-- 'EsError's. To fail when a template with the given name already
-- exists, use 'putIndexTemplateWith' with @'ctoCreate' = 'Just' True@.
--
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-put-index-template.html>)
putIndexTemplate :: (MonadBH m) => TemplateName -> ComposableTemplate -> m Acknowledged
putIndexTemplate templateName template = performBHRequest $ Requests.putIndexTemplate templateName template
-- | Like 'putIndexTemplate' but additionally accepts
-- 'ComposableTemplateOptions' rendered as URI parameters. Use
-- 'defaultComposableTemplateOptions' to send no parameters at all.
putIndexTemplateWith :: (MonadBH m) => TemplateName -> ComposableTemplate -> ComposableTemplateOptions -> m Acknowledged
putIndexTemplateWith templateName template opts = performBHRequest $ Requests.putIndexTemplateWith templateName template opts
-- | 'getIndexTemplate' fetches /composable/ index templates (the
-- @GET /_index_template@ endpoint). Read-side counterpart of
-- 'putIndexTemplate'.
--
-- * @'Nothing'@ → list every composable template
-- on the cluster.
-- * @'Just' ('TemplateNamePattern' p)@ → list the templates whose
-- names match @p@ (a literal name or a glob such as @"logs-*"@; the
-- server does the matching). A pattern that matches no template
-- surfaces as an 'EsError' (HTTP 404); wrap with
-- 'tryPerformBHRequest' if you need miss-tolerant lookup.
--
-- The body of each returned 'IndexTemplateInfo' is decoded into a
-- 'ComposableTemplate'.
--
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-get-template.html>)
getIndexTemplate :: (MonadBH m) => Maybe TemplateNamePattern -> m [IndexTemplateInfo]
getIndexTemplate = performBHRequest . Requests.getIndexTemplate
-- | 'deleteIndexTemplate' deletes a /composable/ index template
-- (@DELETE /_index_template/{name}@). It is the write-side counterpart
-- of 'putIndexTemplate'. Like 'getIndexTemplate', a @404@ for a missing
-- template is surfaced as an 'EsError'; wrap with
-- 'tryPerformBHRequest' for miss-tolerant deletion.
deleteIndexTemplate :: (MonadBH m) => TemplateName -> m Acknowledged
deleteIndexTemplate templateName = performBHRequest $ Requests.deleteIndexTemplate templateName
-- | 'simulateIndexTemplate' resolves a hypothetical 'ComposableTemplate'
-- against the templates already registered on the cluster (the
-- @POST /_index_template/_simulate@ endpoint, available since
-- Elasticsearch 7.8 and in OpenSearch 2.x). The server returns the
-- merged @settings@\/@mappings@\/@aliases@ that would be applied to a
-- new matching index, plus the list of /existing/ composable templates
-- whose @index_patterns@ overlap the supplied template's patterns.
--
-- Like 'putIndexTemplate', this surfaces 4xx responses as 'EsError's.
--
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-simulate-template.html>)
simulateIndexTemplate :: (MonadBH m) => ComposableTemplate -> m SimulatedTemplate
simulateIndexTemplate = performBHRequest . Requests.simulateIndexTemplate
-- | Like 'simulateIndexTemplate' but additionally accepts
-- 'ComposableTemplateOptions' rendered as URI parameters. Use
-- 'defaultComposableTemplateOptions' to send no parameters at all.
simulateIndexTemplateWith :: (MonadBH m) => ComposableTemplate -> ComposableTemplateOptions -> m SimulatedTemplate
simulateIndexTemplateWith template opts = performBHRequest $ Requests.simulateIndexTemplateWith template opts
-- | 'simulateIndex' resolves the composable index template(s) that
-- Elasticsearch /would/ apply to a hypothetical new index with the given
-- name (@POST /_index_template/_simulate_index/{name}@, available since
-- Elasticsearch 7.8 and in OpenSearch 2.x). Returns the merged
-- @settings@\/@mappings@\/@aliases@ and any lower-priority templates that
-- also matched. Read-only — safe to call without side effects.
--
-- This is the index-name-driven counterpart of 'simulateIndexTemplate'
-- (which takes a 'ComposableTemplate' body).
simulateIndex :: (MonadBH m) => IndexName -> m SimulatedTemplate
simulateIndex = performBHRequest . Requests.simulateIndex
-- | Like 'simulateIndex' but additionally accepts 'ComposableTemplateOptions'
-- rendered as URI parameters. Use 'defaultComposableTemplateOptions' to
-- send no parameters at all, in which case the emitted request is
-- byte-for-byte identical to 'simulateIndex'. See 'simulateIndexWith' in
-- the Requests module for the wire-shape details.
simulateIndexWith :: (MonadBH m) => IndexName -> ComposableTemplateOptions -> m SimulatedTemplate
simulateIndexWith indexName opts = performBHRequest $ Requests.simulateIndexWith indexName opts
-- | 'putComponentTemplate' creates or updates a reusable /component/
-- template (@PUT /_component_template/{name}@, available since
-- Elasticsearch 7.8 and in OpenSearch 2.x). Component templates are
-- building blocks composed into composable index templates (see
-- 'ComposableTemplate'\'s @composed_of@ field); they have no
-- @index_patterns@ of their own.
--
-- Like 'putIndexTemplate', this surfaces 4xx responses as 'EsError's.
--
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-component-template.html>)
putComponentTemplate :: (MonadBH m) => TemplateName -> ComponentTemplate -> m Acknowledged
putComponentTemplate templateName template = performBHRequest $ Requests.putComponentTemplate templateName template
-- | 'deleteComponentTemplate' deletes a reusable /component/ template
-- (@DELETE /_component_template/{name}@). It is the write-side counterpart
-- of 'putComponentTemplate'. Like 'deleteIndexTemplate', a @404@ for a
-- missing template is surfaced as an 'EsError'; wrap with
-- 'tryPerformBHRequest' for miss-tolerant deletion.
deleteComponentTemplate :: (MonadBH m) => TemplateName -> m Acknowledged
deleteComponentTemplate templateName = performBHRequest $ Requests.deleteComponentTemplate templateName
-- | 'getComponentTemplate' fetches reusable /component/ templates (the
-- @GET /_component_template@ endpoint, available since Elasticsearch
-- 7.8 and in OpenSearch 2.x). Read-side counterpart of
-- 'putComponentTemplate'. See 'Requests.getComponentTemplate' for the
-- shape of the @Maybe TemplateNamePattern@ argument.
--
-- Like 'getIndexTemplate', this is 'StatusDependant': a 4xx (in
-- particular a @404@ when no component template matches the pattern)
-- is surfaced as an 'EsError'. Callers that want miss-tolerant lookup
-- should use 'tryPerformBHRequest'.
--
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/getting-component-templates.html>)
getComponentTemplate :: (MonadBH m) => Maybe TemplateNamePattern -> m [ComponentTemplateInfo]
getComponentTemplate = performBHRequest . Requests.getComponentTemplate
-- | 'putMapping' is an HTTP PUT and has upsert semantics. Mappings are schemas
-- for documents in indexes.
--
-- >>> _ <- runBH' $ createIndex defaultIndexSettings testIndex
-- >>> resp <- runBH' $ putMapping testIndex TweetMapping
-- >>> print resp
-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("content-type","application/json; charset=UTF-8"),("content-encoding","gzip"),("transfer-encoding","chunked")], responseBody = "{\"acknowledged\":true}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
putMapping :: forall r a m. (MonadBH m, FromJSON r, ToJSON a) => IndexName -> a -> m r
putMapping indexName mapping = performBHRequest $ Requests.putMapping indexName mapping
-- | 'putMappingWith' is the fully-parameterised form of 'putMapping'.
-- Every URI parameter accepted by @PUT /{index}/_mapping@ is exposed via
-- 'PutMappingOptions'. 'defaultPutMappingOptions' makes this
-- byte-for-byte identical to 'putMapping'. See 'Requests.putMappingWith'
-- for details.
putMappingWith ::
forall r a m.
(MonadBH m, FromJSON r, ToJSON a) =>
IndexName ->
a ->
PutMappingOptions ->
m r
putMappingWith indexName mapping opts =
performBHRequest $ Requests.putMappingWith indexName mapping opts
-- | 'getMapping' fetches the mapping for a given index. Wraps the
-- @GET \/\<index\>\/_mapping@ endpoint
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-get-mapping.html>).
--
-- The response is generic over any 'FromJSON' @r@, mirroring
-- 'putMapping'. Decode into a 'Value' for an untyped view of the mapping
-- (the response is shaped @{\<index\>: {mappings: {...}}}@), or into a
-- custom type. Use 'getIndex' to fetch aliases and settings alongside
-- the mappings in a single request.
getMapping :: forall r m. (MonadBH m, FromJSON r) => IndexName -> m r
getMapping indexName = performBHRequest $ Requests.getMapping indexName
-- | 'getFieldMapping' fetches the mapping for specific fields of a given
-- index. Wraps the @GET \/\<index\>\/_mapping\/field\/\<fields\>@ endpoint
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-get-field-mapping.html>).
--
-- The response is generic over any 'FromJSON' @r', mirroring 'getMapping'.
-- Decode into a 'Value' for an untyped view, or into
-- 'FieldMappingResponse' for a structured one.
getFieldMapping ::
forall r m.
(MonadBH m, FromJSON r) =>
IndexName ->
[FieldName] ->
m r
getFieldMapping indexName fields =
performBHRequest $ Requests.getFieldMapping indexName fields
-- | 'indexDocument' is the primary way to save a single document in
-- Elasticsearch. The document itself is simply something we can
-- convert into a JSON 'Value'. The 'DocId' will function as the
-- primary key for the document. You are encouraged to generate
-- your own id's and not rely on Elasticsearch's automatic id
-- generation. Read more about it here:
-- https://github.com/bitemyapp/bloodhound/issues/107
--
-- >>> resp <- runBH' $ indexDocument testIndex defaultIndexDocumentSettings exampleTweet (DocId "1")
-- >>> print resp
-- Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("content-type","application/json; charset=UTF-8"),("content-encoding","gzip"),("content-length","152")], responseBody = "{\"_index\":\"twitter\",\"_type\":\"_doc\",\"_id\":\"1\",\"_version\":2,\"result\":\"updated\",\"_shards\":{\"total\":1,\"successful\":1,\"failed\":0},\"_seq_no\":1,\"_primary_term\":1}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}
indexDocument ::
forall doc m.
(MonadBH m, ToJSON doc) =>
IndexName ->
IndexDocumentSettings ->
doc ->
DocId ->
m Requests.IndexedDocument
indexDocument indexName cfg document docId = performBHRequest $ Requests.indexDocument indexName cfg document docId
-- | 'updateDocument' provides a way to perform an partial update of a
-- an already indexed document.
updateDocument ::
forall patch m.
(MonadBH m, ToJSON patch) =>
IndexName ->
IndexDocumentSettings ->
patch ->
DocId ->
m Requests.IndexedDocument
updateDocument indexName cfg patch docId = performBHRequest $ Requests.updateDocument indexName cfg patch docId
-- | Like 'updateDocument' but accepts the full 'UpdateBody' union,
-- supporting script-driven updates, upserts, @doc_as_upsert@ and
-- @scripted_upsert@. The 'IndexDocumentSettings' argument still supplies
-- the URI-level parameters shared with the Index API.
updateDocumentWith ::
forall m.
(MonadBH m) =>
IndexName ->
IndexDocumentSettings ->
UpdateBody ->
DocId ->
m Requests.IndexedDocument
updateDocumentWith indexName cfg body docId = performBHRequest $ Requests.updateDocumentWith indexName cfg body docId
updateByQuery :: (MonadBH m, FromJSON a) => IndexName -> Query -> Maybe Script -> m a
updateByQuery indexName q mScript = performBHRequest $ Requests.updateByQuery indexName q mScript
-- | Like 'updateByQuery' but accepts 'ByQueryOptions' for URI-level
-- parameters (@conflicts@, @wait_for_completion@, @slices@, @max_docs@,
-- @routing@, @scroll_size@, @refresh@, @timeout@, @scroll@,
-- @request_cache@, @pipeline@).
updateByQueryWith ::
forall a m.
(MonadBH m, FromJSON a) =>
ByQueryOptions ->
IndexName ->
Query ->
Maybe Script ->
m a
updateByQueryWith opts indexName q mScript = performBHRequest $ Requests.updateByQueryWith opts indexName q mScript
-- | 'rethrottleUpdateByQuery' changes the maximum documents-per-second
-- rate of an in-progress asynchronous @update_by_query@ task. Maps to
-- @POST /_update_by_query/{task_id}/_rethrottle?requests_per_second=<n>@.
-- Returns a 'TaskListResponse' (same shape as 'cancelTask') listing
-- the task(s) whose rate was changed — an empty node list means the
-- task had already finished. Pass the 'TaskNodeId' returned by an
-- asynchronous 'updateByQueryWith' (called with
-- @bqoWaitForCompletion = Just False@). Use 'RethrottleUnlimited' to
-- disable throttling, or @'RethrottlePerSecond' n@ for any non-negative
-- decimal rate.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-update-by-query.html#docs-update-by-query-rethrottle-api>.
rethrottleUpdateByQuery :: (MonadBH m) => TaskNodeId -> RethrottleRate -> m TaskListResponse
rethrottleUpdateByQuery tid = performBHRequest . Requests.rethrottleUpdateByQuery tid
-- | 'deleteDocument' is the primary way to delete a single document.
--
-- >>> _ <- runBH' $ deleteDocument testIndex (DocId "1")
deleteDocument :: (MonadBH m) => IndexName -> DocId -> m Requests.IndexedDocument
deleteDocument indexName docId = performBHRequest $ Requests.deleteDocument indexName docId
-- | Like 'deleteDocument' but accepts 'DeleteDocumentOptions' for
-- URI-level parameters (@wait_for_active_shards@, @refresh@,
-- @routing@, @timeout@, @version@, @version_type@, @if_seq_no@,
-- @if_primary_term@).
deleteDocumentWith ::
(MonadBH m) =>
DeleteDocumentOptions ->
IndexName ->
DocId ->
m Requests.IndexedDocument
deleteDocumentWith opts indexName docId =
performBHRequest $ Requests.deleteDocumentWith opts indexName docId
-- | 'deleteByQuery' performs a deletion on every document that matches a query.
--
-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
-- >>> _ <- runBH' $ deleteByQuery testIndex query
deleteByQuery :: (MonadBH m, FromJSON a) => IndexName -> Query -> m a
deleteByQuery indexName query = performBHRequest $ Requests.deleteByQuery indexName query
-- | Like 'deleteByQuery' but accepts 'ByQueryOptions' for URI-level
-- parameters (same set as 'updateByQueryWith'). The response type is
-- polymorphic: instantiate at 'TaskNodeId' when called with
-- @bqoWaitForCompletion = Just False@ to get the async task id.
deleteByQueryWith ::
forall a m.
(MonadBH m, FromJSON a) =>
ByQueryOptions ->
IndexName ->
Query ->
m a
deleteByQueryWith opts indexName query = performBHRequest $ Requests.deleteByQueryWith opts indexName query
-- | 'rethrottleDeleteByQuery' changes the maximum documents-per-second
-- rate of an in-progress asynchronous @delete_by_query@ task. Maps to
-- @POST /_delete_by_query/{task_id}/_rethrottle?requests_per_second=<n>@.
-- Returns a 'TaskListResponse' (same shape as 'cancelTask') listing
-- the task(s) whose rate was changed — an empty node list means the
-- task had already finished. Pass the 'TaskNodeId' returned by an
-- asynchronous 'deleteByQueryWith' (called with
-- @bqoWaitForCompletion = Just False@). Use 'RethrottleUnlimited' to
-- disable throttling, or @'RethrottlePerSecond' n@ for any non-negative
-- decimal rate.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-delete-by-query.html#docs-delete-by-query-rethrottle-api>.
rethrottleDeleteByQuery :: (MonadBH m) => TaskNodeId -> RethrottleRate -> m TaskListResponse
rethrottleDeleteByQuery tid = performBHRequest . Requests.rethrottleDeleteByQuery tid
-- | 'bulk' uses
-- <http://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-bulk.html Elasticsearch's bulk API>
-- to perform bulk operations. The 'BulkOperation' data type encodes the
-- index\/update\/delete\/create operations. You pass a 'V.Vector' of 'BulkOperation's
-- and a 'Server' to 'bulk' in order to send those operations up to your Elasticsearch
-- server to be performed. I changed from [BulkOperation] to a Vector due to memory overhead.
--
-- Uses 'defaultBulkSettings' (no URI parameters). For control over the
-- @refresh@, @routing@, @pipeline@, @wait_for_active_shards@, etc.
-- parameters, use 'bulkWith'.
--
-- >>> let stream = V.fromList [BulkIndex testIndex (DocId "2") (toJSON (BulkTest "blah")) []]
-- >>> _ <- runBH' $ bulk stream
-- >>> _ <- runBH' $ refreshIndex testIndex
bulk ::
forall m.
(MonadBH m) =>
V.Vector BulkOperation ->
m BulkResponse
bulk ops = performBHRequest $ Requests.bulk @StatusDependant ops
-- | Like 'bulk' but accepts a 'BulkSettings' record carrying the URI-level
-- parameters of the @POST /_bulk@ endpoint. 'defaultBulkSettings' makes
-- this byte-for-byte equivalent to 'bulk'.
bulkWith ::
forall m.
(MonadBH m) =>
BulkSettings ->
V.Vector BulkOperation ->
m BulkResponse
bulkWith opts ops = performBHRequest $ Requests.bulkWith @StatusDependant opts ops
-- | 'getDocument' is a straight-forward way to fetch a single document from
-- Elasticsearch using a 'Server', 'IndexName', and a 'DocId'.
-- The 'DocId' is the primary key for your Elasticsearch document.
--
-- >>> yourDoc <- runBH' $ getDocument testIndex (DocId "1")
getDocument :: (MonadBH m, FromJSON a) => IndexName -> DocId -> m (EsResult a)
getDocument indexName docId = performBHRequest $ Requests.getDocument indexName docId
-- | Like 'getDocument' but accepts 'GetDocumentOptions' for URI-level
-- parameters (@_source@, @_source_includes@\/@_source_excludes@,
-- @stored_fields@, @preference@, @realtime@, @refresh@, @routing@,
-- @version@, @version_type@).
getDocumentWith ::
forall a m.
(MonadBH m, FromJSON a) =>
GetDocumentOptions ->
IndexName ->
DocId ->
m (EsResult a)
getDocumentWith opts indexName docId = performBHRequest $ Requests.getDocumentWith opts indexName docId
-- | 'getDocumentSource' fetches only the @_source@ of a document (no
-- metadata envelope). Maps to
-- @GET \/{index}\/_doc\/{id}\/_source@. Returns 'Nothing' when the
-- document does not exist (HTTP 404); other non-2xx responses throw
-- 'EsError' (use
-- 'Database.Bloodhound.Client.Cluster.tryPerformBHRequest' to
-- surface them as @'Either' 'EsError' ('Maybe' a)@ instead).
getDocumentSource ::
forall a m.
(MonadBH m, FromJSON a) =>
IndexName ->
DocId ->
m (Maybe a)
getDocumentSource indexName docId = performBHRequest $ Requests.getDocumentSource indexName docId
-- | Like 'getDocumentSource' but accepts 'GetDocumentSourceOptions'
-- carrying the source-filtering and routing parameters that apply to
-- the source-only endpoint.
getDocumentSourceWith ::
forall a m.
(MonadBH m, FromJSON a) =>
GetDocumentSourceOptions ->
IndexName ->
DocId ->
m (Maybe a)
getDocumentSourceWith opts indexName docId = performBHRequest $ Requests.getDocumentSourceWith opts indexName docId
getDocuments ::
(MonadBH m, FromJSON a) =>
IndexName ->
[DocId] ->
m (MultiGetResponse a)
getDocuments indexName docIds = performBHRequest $ Requests.getDocuments indexName docIds
-- | Like 'getDocuments' but accepts 'MultiGetOptions' applied at the
-- URI level.
getDocumentsWith ::
forall a m.
(MonadBH m, FromJSON a) =>
MultiGetOptions ->
IndexName ->
[DocId] ->
m (MultiGetResponse a)
getDocumentsWith opts indexName docIds = performBHRequest $ Requests.getDocumentsWith opts indexName docIds
getDocumentsMulti ::
(MonadBH m, FromJSON a) =>
MultiGet ->
m (MultiGetResponse a)
getDocumentsMulti body = performBHRequest $ Requests.getDocumentsMulti body
-- | Like 'getDocumentsMulti' but accepts 'MultiGetOptions' applied at
-- the URI level. Per-document filtering is carried by the 'MultiGet' body.
getDocumentsMultiWith ::
forall a m.
(MonadBH m, FromJSON a) =>
MultiGetOptions ->
MultiGet ->
m (MultiGetResponse a)
getDocumentsMultiWith opts body = performBHRequest $ Requests.getDocumentsMultiWith opts body
-- | 'getTermVectors' returns information and statistics about the
-- terms in the fields of a particular document. Maps to
-- @POST \/{index}\/_termvectors\/{id}@. Pass
-- 'defaultTermVectorsRequest' to reproduce the parameterless form;
-- populate 'TermVectorsRequest' fields to request @fields@,
-- @offsets@, @positions@, @term_statistics@, @field_statistics@,
-- @payload@, or apply a 'TermVectorsFilter'.
getTermVectors ::
(MonadBH m) =>
IndexName ->
DocId ->
TermVectorsRequest ->
m TermVectors
getTermVectors indexName docId body = performBHRequest $ Requests.getTermVectors indexName docId body
-- | Like 'getTermVectors' but accepts 'TermVectorsOptions' carrying
-- the URI-level parameters (@preference@, @realtime@, @routing@,
-- @version@, @version_type@). 'defaultTermVectorsOptions' makes the
-- wire output byte-identical to 'getTermVectors'.
getTermVectorsWith ::
(MonadBH m) =>
TermVectorsOptions ->
IndexName ->
DocId ->
TermVectorsRequest ->
m TermVectors
getTermVectorsWith opts indexName docId body =
performBHRequest $ Requests.getTermVectorsWith opts indexName docId body
-- | 'getMultiTermVectors' returns term vectors for multiple documents
-- in a single request. Maps to @POST \/_mtermvectors@ (no index in
-- the URL). Each 'MultiTermVectorsDoc' must carry its own @_index@.
-- For the single-index form, see 'getMultiTermVectorsByIndex'.
getMultiTermVectors ::
(MonadBH m) =>
MultiTermVectors ->
m MultiTermVectorsResponse
getMultiTermVectors body = performBHRequest $ Requests.getMultiTermVectors body
-- | Like 'getMultiTermVectors' but accepts 'TermVectorsOptions'
-- carrying the URI-level parameters (@preference@, @realtime@,
-- @routing@, @version@, @version_type@). 'defaultTermVectorsOptions'
-- makes the wire output byte-identical to 'getMultiTermVectors'.
getMultiTermVectorsWith ::
(MonadBH m) =>
TermVectorsOptions ->
MultiTermVectors ->
m MultiTermVectorsResponse
getMultiTermVectorsWith opts body =
performBHRequest $ Requests.getMultiTermVectorsWith opts body
-- | 'getMultiTermVectorsByIndex' is the single-index form of
-- 'getMultiTermVectors'. Maps to
-- @POST \/{index}\/_mtermvectors@. Each 'DocId' is wrapped with
-- 'mkMultiTermVectorsDoc' (no per-doc @_index@, no parameter
-- overrides); for per-document overrides, build the
-- 'MultiTermVectors' body directly and use 'getMultiTermVectors'.
getMultiTermVectorsByIndex ::
(MonadBH m) =>
IndexName ->
[DocId] ->
m MultiTermVectorsResponse
getMultiTermVectorsByIndex indexName docIds =
performBHRequest $ Requests.getMultiTermVectorsByIndex indexName docIds
-- | Like 'getMultiTermVectorsByIndex' but accepts 'TermVectorsOptions'
-- carrying the URI-level parameters (@preference@, @realtime@,
-- @routing@, @version@, @version_type@). 'defaultTermVectorsOptions'
-- makes the wire output byte-identical to 'getMultiTermVectorsByIndex'.
getMultiTermVectorsByIndexWith ::
(MonadBH m) =>
TermVectorsOptions ->
IndexName ->
[DocId] ->
m MultiTermVectorsResponse
getMultiTermVectorsByIndexWith opts indexName docIds =
performBHRequest $ Requests.getMultiTermVectorsByIndexWith opts indexName docIds
documentExists :: (MonadBH m) => IndexName -> DocId -> m Bool
documentExists indexName docId = performBHRequest $ Requests.documentExists indexName docId
-- | Like 'documentExists' but accepts 'DocumentExistsOptions' for the
-- URI-level parameters (@stored_fields@, @preference@, @realtime@,
-- @refresh@, @routing@, @version@, @version_type@). See
-- 'Requests.documentExistsWith' for the wire-level details.
documentExistsWith ::
(MonadBH m) =>
DocumentExistsOptions ->
IndexName ->
DocId ->
m Bool
documentExistsWith opts indexName docId =
performBHRequest $ Requests.documentExistsWith opts indexName docId
-- | 'documentSourceExists' checks whether @_source@ is present for the
-- given document, hitting @HEAD \/{index}\/_doc\/{id}\/_source@.
-- Returns 'False' on any non-2xx status (including 404); see
-- 'Requests.documentSourceExists' for the wire-level details.
documentSourceExists :: (MonadBH m) => IndexName -> DocId -> m Bool
documentSourceExists indexName docId =
performBHRequest $ Requests.documentSourceExists indexName docId
-- | Like 'documentSourceExists' but accepts
-- 'DocumentSourceExistsOptions' for the URI-level parameters
-- (@preference@, @realtime@, @refresh@, @routing@, @version@,
-- @version_type@). See 'Requests.documentSourceExistsWith' for the
-- wire-level details.
documentSourceExistsWith ::
(MonadBH m) =>
DocumentSourceExistsOptions ->
IndexName ->
DocId ->
m Bool
documentSourceExistsWith opts indexName docId =
performBHRequest $ Requests.documentSourceExistsWith opts indexName docId
-- | 'searchAll', given a 'Search', will perform that search against all indexes
-- on an Elasticsearch server. Try to avoid doing this if it can be helped.
--
-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
-- >>> let search = mkSearch (Just query) Nothing
-- >>> response <- runBH' $ searchAll search
searchAll :: forall a m. (MonadBH m, FromJSON a) => Search -> m (SearchResult a)
searchAll search = performBHRequest $ Requests.searchAll search
-- | 'searchAllWith' is a variant of 'searchAll' that accepts a
-- 'SearchOptions' record for URI-level parameters such as @preference@,
-- @routing@, and @request_cache@. See 'SearchOptions' for the full set.
searchAllWith ::
forall a m.
(MonadBH m, FromJSON a) =>
SearchOptions ->
Search ->
m (SearchResult a)
searchAllWith opts search = performBHRequest $ Requests.searchAllWith opts search
-- | 'searchByIndex', given a 'Search' and an 'IndexName', will perform that search
-- within an index on an Elasticsearch server.
--
-- >>> let query = TermQuery (Term "user" "bitemyapp") Nothing
-- >>> let search = mkSearch (Just query) Nothing
-- >>> response <- runBH' $ searchByIndex testIndex search
searchByIndex :: forall a m. (MonadBH m, FromJSON a) => IndexName -> Search -> m (SearchResult a)
searchByIndex indexName search = performBHRequest $ Requests.searchByIndex indexName search
-- | 'searchByIndexWith' is a variant of 'searchByIndex' that accepts a
-- 'SearchOptions' record for URI-level parameters such as @preference@,
-- @routing@, and @request_cache@. See 'SearchOptions' for the full set.
--
-- >>> let opts = defaultSearchOptions { soPreference = Just "_local", soRequestCache = Just True }
-- >>> response <- runBH' $ searchByIndexWith testIndex opts search
searchByIndexWith ::
forall a m.
(MonadBH m, FromJSON a) =>
IndexName ->
SearchOptions ->
Search ->
m (SearchResult a)
searchByIndexWith indexName opts search = performBHRequest $ Requests.searchByIndexWith indexName opts search
-- | 'searchByIndices' is a variant of 'searchByIndex' that executes a
-- 'Search' over many indices. This is much faster than using
-- 'mapM' to 'searchByIndex' over a collection since it only
-- causes a single HTTP request to be emitted.
searchByIndices :: forall a m. (MonadBH m, FromJSON a) => NonEmpty IndexName -> Search -> m (SearchResult a)
searchByIndices ixs search = performBHRequest $ Requests.searchByIndices ixs search
-- | 'searchByIndicesWith' is a variant of 'searchByIndices' that accepts a
-- 'SearchOptions' record for URI-level parameters. See 'SearchOptions' for
-- the full set.
searchByIndicesWith ::
forall a m.
(MonadBH m, FromJSON a) =>
NonEmpty IndexName ->
SearchOptions ->
Search ->
m (SearchResult a)
searchByIndicesWith ixs opts search = performBHRequest $ Requests.searchByIndicesWith ixs opts search
-- | 'explainDocument' computes a score explanation for a single
-- document under a given 'Query' (see
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-explain.html ES docs>,
-- <https://docs.opensearch.org/latest/api-reference/search-apis/explain/ OpenSearch docs>).
--
-- See 'Requests.explainDocument' for the full semantics, in
-- particular the three distinguishable outcomes: matched; doc exists
-- but query does not match (explanation is @Just (Explanation 0.0
-- ...)@); and missing document (explanation is 'Nothing'). A missing
-- document /does not/ surface as an 'EsError' — its HTTP-404 body is
-- shaped like an 'ExplainResponse' and decodes cleanly as
-- @ExplainResponse { explainResponseMatched = False, explainResponseExplanation = Nothing }@.
explainDocument ::
forall m.
(MonadBH m) =>
IndexName ->
DocId ->
Query ->
m ExplainResponse
explainDocument indexName docId query =
performBHRequest $ Requests.explainDocument indexName docId query
-- | Like 'explainDocument' but accepts an 'ExplainOptions' record
-- carrying the URI-level @_explain@ parameters (@routing@,
-- @preference@, @stored_fields@, @_source@ filtering, and the
-- query-parsing @default_operator@\/@analyzer@\/@df@\/
-- @analyze_wildcard@\/@lenient@). 'defaultExplainOptions' makes this
-- byte-for-byte equivalent to 'explainDocument'. See
-- 'Requests.explainDocumentWith' for the full semantics.
explainDocumentWith ::
forall m.
(MonadBH m) =>
ExplainOptions ->
IndexName ->
DocId ->
Query ->
m ExplainResponse
explainDocumentWith opts indexName docId query =
performBHRequest $ Requests.explainDocumentWith opts indexName docId query
multiSearch ::
forall a m.
(MonadBH m, FromJSON a) =>
NonEmpty MultiSearchItem ->
m (MultiSearchResponse a)
multiSearch items = performBHRequest $ Requests.multiSearch items
-- | 'multiSearchWith' is a variant of 'multiSearch' that accepts a
-- 'SearchOptions' record for URI-level parameters
-- (@max_concurrent_searches@, @typed_keys@, ...). Per-header fields ride
-- on each 'MultiSearchItem'.
multiSearchWith ::
forall a m.
(MonadBH m, FromJSON a) =>
SearchOptions ->
NonEmpty MultiSearchItem ->
m (MultiSearchResponse a)
multiSearchWith opts items = performBHRequest $ Requests.multiSearchWith opts items
multiSearchByIndex ::
forall a m.
(MonadBH m, FromJSON a) =>
IndexName ->
NonEmpty Search ->
m (MultiSearchResponse a)
multiSearchByIndex indexName searches = performBHRequest $ Requests.multiSearchByIndex indexName searches
-- | 'multiSearchByIndexWith' is a variant of 'multiSearchByIndex' that
-- accepts a 'SearchOptions' record.
multiSearchByIndexWith ::
forall a m.
(MonadBH m, FromJSON a) =>
SearchOptions ->
IndexName ->
NonEmpty Search ->
m (MultiSearchResponse a)
multiSearchByIndexWith opts indexName searches =
performBHRequest $ Requests.multiSearchByIndexWith opts indexName searches
-- | 'multiSearchTemplate' performs a multi-search template request
-- against @_msearch/template@. Each 'MultiSearchTemplateItem' pairs a
-- per-sub-request header with a 'SearchTemplate' body. See
-- 'Database.Bloodhound.Common.Requests.multiSearchTemplate'.
multiSearchTemplate ::
forall a m.
(MonadBH m, FromJSON a) =>
NonEmpty MultiSearchTemplateItem ->
m (MultiSearchResponse a)
multiSearchTemplate items = performBHRequest $ Requests.multiSearchTemplate items
-- | 'multiSearchTemplateWith' is a variant of 'multiSearchTemplate' that
-- accepts a 'SearchOptions' record.
multiSearchTemplateWith ::
forall a m.
(MonadBH m, FromJSON a) =>
SearchOptions ->
NonEmpty MultiSearchTemplateItem ->
m (MultiSearchResponse a)
multiSearchTemplateWith opts items =
performBHRequest $ Requests.multiSearchTemplateWith opts items
-- | 'multiSearchTemplateByIndex' runs an @_msearch/template@ scoped to a
-- single index.
multiSearchTemplateByIndex ::
forall a m.
(MonadBH m, FromJSON a) =>
IndexName ->
NonEmpty SearchTemplate ->
m (MultiSearchResponse a)
multiSearchTemplateByIndex indexName templates =
performBHRequest $ Requests.multiSearchTemplateByIndex indexName templates
-- | 'multiSearchTemplateByIndexWith' is a variant of
-- 'multiSearchTemplateByIndex' that accepts a 'SearchOptions' record.
multiSearchTemplateByIndexWith ::
forall a m.
(MonadBH m, FromJSON a) =>
SearchOptions ->
IndexName ->
NonEmpty SearchTemplate ->
m (MultiSearchResponse a)
multiSearchTemplateByIndexWith opts indexName templates =
performBHRequest $ Requests.multiSearchTemplateByIndexWith opts indexName templates
searchByIndexTemplate ::
forall a m.
(MonadBH m, FromJSON a) =>
IndexName ->
SearchTemplate ->
m (SearchResult a)
searchByIndexTemplate indexName search = performBHRequest $ Requests.searchByIndexTemplate indexName search
-- | 'searchByIndicesTemplate' is a variant of 'searchByIndexTemplate' that executes a
-- 'SearchTemplate' over many indices. This is much faster than using
-- 'mapM' to 'searchByIndexTemplate' over a collection since it only
-- causes a single HTTP request to be emitted.
searchByIndicesTemplate ::
forall a m.
(MonadBH m, FromJSON a) =>
NonEmpty IndexName ->
SearchTemplate ->
m (SearchResult a)
searchByIndicesTemplate ixs search = performBHRequest $ Requests.searchByIndicesTemplate ixs search
-- | 'storeSearchTemplate', saves a 'SearchTemplateSource' to be used later.
storeSearchTemplate :: (MonadBH m) => SearchTemplateId -> SearchTemplateSource -> m Acknowledged
storeSearchTemplate tid ts = performBHRequest $ Requests.storeSearchTemplate tid ts
-- | 'getSearchTemplate', get info of an stored 'SearchTemplateSource'.
getSearchTemplate :: (MonadBH m) => SearchTemplateId -> m GetTemplateScript
getSearchTemplate tid = performBHRequest $ Requests.getSearchTemplate tid
-- | 'storeSearchTemplate',
deleteSearchTemplate :: (MonadBH m) => SearchTemplateId -> m Acknowledged
deleteSearchTemplate tid = performBHRequest $ Requests.deleteSearchTemplate tid
-- | 'renderTemplate' renders a 'SearchTemplate' as a search request
-- body without executing the search. See
-- 'Database.Bloodhound.Common.Requests.renderTemplate' for the
-- endpoint shape (GET-with-body, path derived from the
-- 'searchTemplate' field) and the raw-'Value' return contract.
renderTemplate :: (MonadBH m) => SearchTemplate -> m (ParsedEsResponse Value)
renderTemplate = performBHRequest . Requests.renderTemplate
-- | For a given search, request a scroll for efficient streaming of
-- search results. Note that the search is put into 'SearchTypeScan'
-- mode and thus results will not be sorted. Combine this with
-- 'advanceScroll' to efficiently stream through the full result set
getInitialScroll ::
forall a m.
(MonadBH m, FromJSON a) =>
IndexName ->
Search ->
m (ParsedEsResponse (SearchResult a))
getInitialScroll indexName search' = performBHRequest $ Requests.getInitialScroll indexName search'
-- | For a given search, request a scroll for efficient streaming of
-- search results. Combine this with 'advanceScroll' to efficiently
-- stream through the full result set. Note that this search respects
-- sorting and may be less efficient than 'getInitialScroll'.
getInitialSortedScroll ::
forall a m.
(MonadBH m, FromJSON a) =>
IndexName ->
Search ->
m (SearchResult a)
getInitialSortedScroll indexName search = performBHRequest $ Requests.getInitialSortedScroll indexName search
-- | Use the given scroll to fetch the next page of documents. If there are no
-- further pages, 'SearchResult.searchHits.hits' will be '[]'.
--
-- Equivalent to @'advanceScrollWith' 'defaultAdvanceScrollOptions'@. Use
-- the @With@ variant to send @?rest_total_hits_as_int=true@.
advanceScroll ::
forall a m.
(MonadBH m, FromJSON a) =>
ScrollId ->
-- | How long should the snapshot of data be kept around? This timeout is updated every time 'advanceScroll' is used, so don't feel the need to set it to the entire duration of your search processing. Note that durations < 1s will be rounded up. Also note that 'NominalDiffTime' is an instance of Num so literals like 60 will be interpreted as seconds. 60s is a reasonable default.
NominalDiffTime ->
m (SearchResult a)
advanceScroll sid scroll = performBHRequest $ Requests.advanceScroll sid scroll
-- | Like 'advanceScroll' but accepts an 'AdvanceScrollOptions' record
-- carrying URI-level parameters for @POST /_search/scroll@ (currently
-- only @rest_total_hits_as_int@).
--
-- @'advanceScrollWith' 'defaultAdvanceScrollOptions'@ is byte-for-byte
-- identical to 'advanceScroll'.
advanceScrollWith ::
forall a m.
(MonadBH m, FromJSON a) =>
AdvanceScrollOptions ->
ScrollId ->
-- | How long should the snapshot of data be kept around? See
-- 'advanceScroll' for details.
NominalDiffTime ->
m (SearchResult a)
advanceScrollWith opts sid scroll =
performBHRequest $ Requests.advanceScrollWith opts sid scroll
-- | Release a scroll context immediately rather than waiting for its
-- @keep_alive@ to expire. Use this after finishing (or abandoning) a
-- scan-scroll stream so the server can free the associated snapshot before
-- the @search.max_open_scroll_context@ limit is reached.
clearScroll :: (MonadBH m) => ScrollId -> m ClearScrollResponse
clearScroll sid = performBHRequest $ Requests.clearScroll sid
-- | 'scanSearch' uses the 'scroll' API of elastic,
-- for a given 'IndexName'. 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, 'getInitialScroll' and 'advanceScroll' are good low level
-- tools. You should be able to hook them up trivially to conduit,
-- pipes, or your favorite streaming IO abstraction of choice. Note
-- that ordering on the search would destroy performance and thus is
-- ignored.
scanSearch :: forall a m. (FromJSON a, MonadBH m) => IndexName -> Search -> m [Hit a]
scanSearch indexName search = do
initialSearchResult <- getInitialScroll indexName search
let (hits', josh) = case initialSearchResult of
Right SearchResult {..} -> (hits searchHits, scrollId)
Left _ -> ([], Nothing)
(totalHits, _) <- scanAccumulator [] (hits', josh)
return totalHits
where
scanAccumulator :: [Hit a] -> ([Hit a], Maybe ScrollId) -> m ([Hit a], Maybe ScrollId)
scanAccumulator oldHits (newHits, Nothing) = return (oldHits ++ newHits, Nothing)
scanAccumulator oldHits ([], _) = return (oldHits, Nothing)
scanAccumulator oldHits (newHits, msid) = do
(newHits', msid') <- scroll' msid
scanAccumulator (oldHits ++ newHits) (newHits', msid')
scroll' :: Maybe ScrollId -> m ([Hit a], Maybe ScrollId)
scroll' Nothing = return ([], Nothing)
scroll' (Just sid) = do
res <- tryPerformBHRequest $ Requests.advanceScroll sid 60
case res of
Right SearchResult {..} -> return (hits searchHits, scrollId)
Left _ -> return ([], Nothing)
-- | This is a hook that can be set via the 'bhRequestHook' function
-- that will authenticate all requests using an HTTP Basic
-- Authentication header. Note that it is *strongly* recommended that
-- this option only be used over an SSL connection.
--
-- >> (mkBHEnv myServer myManager) { bhRequestHook = basicAuthHook (EsUsername "myuser") (EsPassword "mypass") }
basicAuthHook :: (Monad m) => EsUsername -> EsPassword -> Request -> m Request
basicAuthHook (EsUsername u) (EsPassword p) = return . applyBasicAuth u' p'
where
u' = T.encodeUtf8 u
p' = T.encodeUtf8 p
countByIndex :: (MonadBH m) => IndexName -> CountQuery -> m CountResponse
countByIndex indexName q = performBHRequest $ Requests.countByIndex indexName q
-- | 'countByIndexWith' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.countByIndexWith'. See that
-- function for the request-shape details.
countByIndexWith ::
(MonadBH m) =>
Maybe [IndexName] ->
CountOptions ->
CountQuery ->
m CountResponse
countByIndexWith mIndices opts q =
performBHRequest $ Requests.countByIndexWith mIndices opts q
-- | 'countAll' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.countAll'.
countAll :: (MonadBH m) => CountQuery -> m CountResponse
countAll q = performBHRequest $ Requests.countAll q
-- | 'validateQuery' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.validateQuery'. See that
-- function for the request-shape details.
validateQuery ::
(MonadBH m) =>
IndexName ->
ValidateQuery ->
m ValidateQueryResponse
validateQuery indexName q =
performBHRequest $ Requests.validateQuery indexName q
-- | 'validateQueryWith' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.validateQueryWith'. See that
-- function for the request-shape details.
validateQueryWith ::
(MonadBH m) =>
Maybe [IndexName] ->
ValidateOptions ->
ValidateQuery ->
m ValidateQueryResponse
validateQueryWith mIndices opts q =
performBHRequest $ Requests.validateQueryWith mIndices opts q
-- | 'validateAll' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.validateAll'.
validateAll ::
(MonadBH m) =>
ValidateQuery ->
m ValidateQueryResponse
validateAll q = performBHRequest $ Requests.validateAll q
-- | 'evaluateRank' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.evaluateRank'. See that
-- function for the request-shape details.
evaluateRank :: (MonadBH m) => RankEvalRequest -> m RankEvalResponse
evaluateRank = performBHRequest . Requests.evaluateRank
-- | 'evaluateRankByIndex' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.evaluateRankByIndex'.
evaluateRankByIndex ::
(MonadBH m) => IndexName -> RankEvalRequest -> m RankEvalResponse
evaluateRankByIndex indexName =
performBHRequest . Requests.evaluateRankByIndex indexName
-- | 'evaluateRankWith' is the 'MonadBH' runner for
-- 'Database.Bloodhound.Common.Requests.evaluateRankWith'.
evaluateRankWith ::
(MonadBH m) =>
Maybe [IndexName] ->
RankEvalOptions ->
RankEvalRequest ->
m RankEvalResponse
evaluateRankWith mIndices opts body =
performBHRequest $ Requests.evaluateRankWith mIndices opts body
-- | 'analyzeText' runs the analysis pipeline on the supplied text
-- without indexing it. Pass 'Nothing' to call @POST /_analyze@ with
-- only built-in or named analyzers, or @'Just' index@ to call
-- @POST \/{index}\/_analyze@ and reference analyzers configured on
-- that index. See "Database.Bloodhound.Common.Requests#analyzeText"
-- for the request-shape details and the supported subset of the API.
analyzeText :: (MonadBH m) => Maybe IndexName -> AnalyzeRequest -> m AnalyzeResponse
analyzeText mIndex req = performBHRequest $ Requests.analyzeText mIndex req
getFieldCaps :: (MonadBH m) => Maybe [IndexName] -> [FieldPattern] -> m FieldCapsResponse
getFieldCaps mIndices fields = performBHRequest $ Requests.getFieldCaps mIndices fields
getFieldCapsWith ::
(MonadBH m) =>
Maybe [IndexName] ->
FieldCapsOptions ->
FieldCapsRequest ->
m FieldCapsResponse
getFieldCapsWith mIndices opts req =
performBHRequest $ Requests.getFieldCapsWith mIndices opts req
-- | 'getSearchShards' returns the shards and nodes that a search
-- request would be executed against, without running the search
-- itself. Wraps @GET \/{indices}\/_search_shards@
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-shards.html>;
-- also implemented by OpenSearch — see
-- <https://docs.opensearch.org/latest/api-reference/search/>). Pass
-- 'Nothing' or @'Just' []@ to target every index; pass a non-empty
-- list to restrict to a comma-joined subset.
--
-- Surfaced as 'StatusDependant' so genuine server-side errors (auth,
-- missing index, 5xx, ...) decode as an 'EsError'.
getSearchShards ::
(MonadBH m) =>
Maybe [IndexName] ->
m SearchShardsResponse
getSearchShards mIndices =
performBHRequest $ Requests.getSearchShards mIndices
-- | Like 'getSearchShards' but additionally accepts 'SearchShardsOptions'
-- rendered as URI parameters (@allow_no_indices@, @expand_wildcards@,
-- @ignore_unavailable@, @local@, @preference@, @routing@).
-- 'defaultSearchShardsOptions' makes this byte-for-byte identical to
-- 'getSearchShards'.
getSearchShardsWith ::
(MonadBH m) =>
Maybe [IndexName] ->
SearchShardsOptions ->
m SearchShardsResponse
getSearchShardsWith mIndices opts =
performBHRequest $ Requests.getSearchShardsWith mIndices opts
reindex :: (MonadBH m) => ReindexRequest -> m ReindexResponse
reindex = performBHRequest . Requests.reindex
-- | Like 'reindex' but accepts 'ReindexOptions' carrying the URI-level
-- parameters documented for @POST /_reindex@
-- (<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-reindex.html#docs-reindex-api-query-params>).
-- Pass 'defaultReindexOptions' to reproduce the legacy behaviour.
reindexWith :: (MonadBH m) => ReindexOptions -> ReindexRequest -> m ReindexResponse
reindexWith opts = performBHRequest . Requests.reindexWith opts
reindexAsync :: (MonadBH m) => ReindexRequest -> m TaskNodeId
reindexAsync = performBHRequest . Requests.reindexAsync
-- | Like 'reindexAsync' but accepts 'ReindexOptions' carrying the
-- URI-level parameters documented for @POST /_reindex@. @wait_for_completion=false@
-- is always appended; pass 'defaultReindexOptions' to reproduce the
-- legacy behaviour.
reindexAsyncWith :: (MonadBH m) => ReindexOptions -> ReindexRequest -> m TaskNodeId
reindexAsyncWith opts = performBHRequest . Requests.reindexAsyncWith opts
-- | 'rethrottleReindex' changes the maximum documents-per-second rate
-- of an in-progress asynchronous reindex. Maps to
-- @POST /_reindex/{task_id}/_rethrottle?requests_per_second=<n>@.
-- Returns a 'TaskListResponse' (same shape as 'cancelTask') listing
-- the task(s) whose rate was changed — an empty node list means the
-- task had already finished. Pass the 'TaskNodeId' returned by
-- 'reindexAsync'. Use 'RethrottleUnlimited' to disable throttling,
-- or @'RethrottlePerSecond' n@ for any non-negative decimal rate.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-reindex.html#docs-reindex-rethrottle-api>.
rethrottleReindex :: (MonadBH m) => TaskNodeId -> RethrottleRate -> m TaskListResponse
rethrottleReindex tid = performBHRequest . Requests.rethrottleReindex tid
-- | Legacy 'getTask'; equivalent to @'getTaskWith' 'defaultTaskGetOptions'@.
getTask :: (MonadBH m, FromJSON a) => TaskNodeId -> m (TaskResponse a)
getTask = performBHRequest . Requests.getTask
-- | Like 'getTask' but accepts 'TaskGetOptions' carrying the URI-level
-- parameters documented for @GET /_tasks/{task_id}@
-- (@wait_for_completion@, @timeout@). Pass 'defaultTaskGetOptions' to
-- reproduce the legacy behaviour.
getTaskWith :: (MonadBH m, FromJSON a) => TaskGetOptions -> TaskNodeId -> m (TaskResponse a)
getTaskWith opts = performBHRequest . Requests.getTaskWith opts
-- | 'cancelTask' cancels a currently running task by id. Maps to
-- @POST /_tasks/{task_id}/_cancel@. The response lists the tasks that
-- were actually cancelled (same nodes-grouped shape as 'listTasks'),
-- returned as a 'TaskListResponse' — empty if the task had already
-- finished. Pass the 'TaskNodeId' returned by 'reindexAsync' or
-- observed via 'listTasks' or 'getTask'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/tasks-cancel.html>.
cancelTask :: (MonadBH m) => TaskNodeId -> m TaskListResponse
cancelTask = performBHRequest . Requests.cancelTask
-- | 'listTasks' lists currently running tasks on the cluster. Maps to
-- @GET /_tasks@. Pass 'Nothing' for the unfiltered endpoint, or a
-- populated 'TaskListOptions' to filter (e.g. by @actions@) or to
-- request @detailed@ task bodies. Flatten the structured
-- 'TaskListResponse' with 'taskListFlat' to obtain a plain
-- @['TaskInfo']@.
listTasks :: (MonadBH m) => Maybe TaskListOptions -> m TaskListResponse
listTasks = performBHRequest . Requests.listTasks
-- | 'getAsyncSearch' polls an async search by id, returning its current
-- running state and any partial or final results. Maps to
-- @GET /_async_search/{id}@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/async-search.html#get-async-search>.
getAsyncSearch :: (MonadBH m, FromJSON a) => AsyncSearchId -> m (AsyncSearchResult a)
getAsyncSearch = performBHRequest . Requests.getAsyncSearch
-- | 'getAsyncSearchStatus' reports only the running\/partial state (and
-- scheduling times) for an async search, without transferring the result
-- set. Maps to @GET /_async_search/status/{id}@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/async-search.html#get-async-search-status>.
getAsyncSearchStatus :: (MonadBH m) => AsyncSearchId -> m AsyncSearchStatus
getAsyncSearchStatus = performBHRequest . Requests.getAsyncSearchStatus
-- | 'getILMPolicy' lists ILM policies.
--
-- * @'Nothing'@ → @GET /_ilm/policy@ returns every policy on the cluster.
-- * @'Just' pid@ → @GET /_ilm/policy/{pid}@ returns just that one (as a
-- singleton list).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-get-lifecycle.html>.
getILMPolicy :: (MonadBH m) => Maybe ILMPolicyId -> m [ILMPolicyInfo]
getILMPolicy = performBHRequest . Requests.getILMPolicy
-- | 'putILMPolicy' creates or updates a single ILM policy by id. Maps to
-- @PUT /_ilm/policy/{id}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-put-lifecycle.html>.
putILMPolicy :: (MonadBH m) => ILMPolicyId -> ILMPolicy -> m Acknowledged
putILMPolicy policyId policy = performBHRequest $ Requests.putILMPolicy policyId policy
-- | 'deleteILMPolicy' deletes a single ILM policy by id. Maps to
-- @DELETE /_ilm/policy/{id}@ and returns 'Acknowledged' on success.
-- Deleting a policy that does not exist surfaces as an 'EsError'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-delete-lifecycle.html>.
deleteILMPolicy :: (MonadBH m) => ILMPolicyId -> m Acknowledged
deleteILMPolicy = performBHRequest . Requests.deleteILMPolicy
-- | 'explainILM' retrieves the ILM state (managed flag, current
-- phase\/action\/step, age, error details, ...) for every index matched
-- by the given 'IndexName', which may be a wildcard (@*@) or a
-- comma-separated list. Maps to @GET /_ilm/explain/{index}@ and returns
-- one 'ILMExplanation' per concrete matched index.
--
-- Equivalent to @'explainILMWith' 'defaultILMExplainOptions'@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-explain-lifecycle.html>.
explainILM :: (MonadBH m) => IndexName -> m ILMExplanations
explainILM indexName = performBHRequest $ Requests.explainILM indexName
-- | Like 'explainILM' but accepts an 'ILMExplainOptions' record for the
-- @only_errors@, @only_managed@ and @master_timeout@ URI parameters.
-- 'defaultILMExplainOptions' makes this byte-for-byte equivalent to
-- 'explainILM'.
explainILMWith ::
(MonadBH m) =>
ILMExplainOptions ->
IndexName ->
m ILMExplanations
explainILMWith opts indexName =
performBHRequest $ Requests.explainILMWith opts indexName
-- | 'startILM' starts the ILM plugin. Maps to @POST /_ilm/start@ and
-- returns 'Acknowledged' on success. ILM runs by default; this is only
-- needed to resume after 'stopILM'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-start.html>.
startILM :: (MonadBH m) => m Acknowledged
startILM = performBHRequest Requests.startILM
-- | 'stopILM' stops the ILM plugin. Maps to @POST /_ilm/stop@ and
-- returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-stop.html>.
stopILM :: (MonadBH m) => m Acknowledged
stopILM = performBHRequest Requests.stopILM
-- | 'getILMStatus' reports the cluster-wide ILM operation mode.
-- Maps to @GET /_ilm/status@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-get-status.html>.
getILMStatus :: (MonadBH m) => m ILMStatus
getILMStatus = performBHRequest Requests.getILMStatus
-- | 'moveILMStep' forces the given index from one lifecycle step into
-- another. Maps to @POST /_ilm/move/{index}@. Returns 'Acknowledged' on
-- success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-move-to-step.html>.
moveILMStep ::
(MonadBH m) =>
IndexName ->
MoveStepRequest ->
m Acknowledged
moveILMStep indexName body =
performBHRequest $ Requests.moveILMStep indexName body
-- | 'retryILMStep' retries the current ILM step for an index in an error
-- state. Maps to @POST /_ilm/retry/{index}@ and returns 'Acknowledged' on
-- success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-retry-policy.html>.
retryILMStep :: (MonadBH m) => IndexName -> m Acknowledged
retryILMStep indexName =
performBHRequest $ Requests.retryILMStep indexName
-- | 'removeILM' detaches the given index from ILM management. Maps to
-- @POST /_ilm/remove/{index}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-remove-policy.html>.
removeILM :: (MonadBH m) => IndexName -> m Acknowledged
removeILM indexName =
performBHRequest $ Requests.removeILM indexName
-- | 'migrateDataTiers' migrates the cluster's allocation routing from the
-- legacy @node.attr.*@ style to the modern data-tier style. Maps to
-- @POST /_ilm/migrate_to_data_tiers@ and returns a
-- 'MigrateDataTiersResponse'.
--
-- Equivalent to
-- @'migrateDataTiersWith' 'defaultMigrateDataTiersOptions' 'defaultMigrateDataTiersRequest'@.
-- Use 'migrateDataTiersWith' to preview (with 'migrateDataTiersOptionsDryRun')
-- or to override the auto-detected legacy template and node attribute.
--
-- See
-- <https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ilm-migrate-to-data-tiers>.
migrateDataTiers :: (MonadBH m) => m MigrateDataTiersResponse
migrateDataTiers = performBHRequest Requests.migrateDataTiers
-- | 'migrateDataTiersWith' is the fully-parameterised form of
-- 'migrateDataTiers'.
migrateDataTiersWith ::
(MonadBH m) =>
MigrateDataTiersOptions ->
MigrateDataTiersRequest ->
m MigrateDataTiersResponse
migrateDataTiersWith opts body =
performBHRequest $ Requests.migrateDataTiersWith opts body
-- | 'putSLMPolicy' creates or updates a single snapshot lifecycle policy
-- by id. Maps to @PUT /_slm/policy/{id}@ and returns 'Acknowledged' on
-- success. The 'SLMPolicy' body is sent as-is at the top level of the
-- request — SLM, unlike ILM, does @not@ wrap the policy under a @policy@
-- key.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-slm-lifecycle-policy.html>.
putSLMPolicy :: (MonadBH m) => SLMPolicyId -> SLMPolicy -> m Acknowledged
putSLMPolicy policyId policy =
performBHRequest $ Requests.putSLMPolicy policyId policy
-- | 'putIngestPipeline' creates or updates a single ingest pipeline by id.
-- Maps to @PUT /_ingest/pipeline/{id}@ and returns 'Acknowledged' on
-- success. The 'IngestPipeline' body is sent as-is at the top level of the
-- request — ingest, unlike ILM, does @not@ wrap the pipeline under a
-- @pipeline@ key.
--
-- Available on Elasticsearch 5.0+ and OpenSearch 1.x\/2.x\/3.x, so the
-- request lives in the Common layer and is re-exported by every client
-- module.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-pipeline-api.html>.
putIngestPipeline ::
(MonadBH m) =>
PipelineId ->
IngestPipeline ->
m Acknowledged
putIngestPipeline pipelineId pipeline =
performBHRequest $ Requests.putIngestPipeline pipelineId pipeline
-- | 'getIngestPipeline' lists one or all ingest pipelines. Maps to
-- @GET /_ingest/pipeline[\/{id}]@. The response is keyed by pipeline id
-- on the wire; the client decoder walks the keys and returns a flat list
-- of 'IngestPipelineInfo' values (the same shape 'getILMPolicy' uses).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-pipeline-api.html>.
getIngestPipeline ::
(MonadBH m) =>
Maybe PipelineId ->
m [IngestPipelineInfo]
getIngestPipeline = performBHRequest . Requests.getIngestPipeline
-- | 'deleteIngestPipeline' deletes a single ingest pipeline by id. Maps to
-- @DELETE /_ingest/pipeline/{id}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-pipeline-api.html>.
deleteIngestPipeline :: (MonadBH m) => PipelineId -> m Acknowledged
deleteIngestPipeline = performBHRequest . Requests.deleteIngestPipeline
-- | 'simulateIngestPipeline' runs the supplied documents through an ingest
-- pipeline without indexing anything, returning the per-document
-- transformed results. The 'PipelineId' argument selects between the
-- stored-pipeline form (@POST /_ingest/pipeline/{id}/_simulate@) and the
-- inline-only form (@POST /_ingest/pipeline/_simulate@).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/simulate-pipeline-api.html>.
simulateIngestPipeline ::
(MonadBH m) =>
Maybe PipelineId ->
IngestPipeline ->
[Value] ->
m SimulateResult
simulateIngestPipeline mPipelineId pipeline docs =
performBHRequest $
Requests.simulateIngestPipeline mPipelineId pipeline docs
-- | 'getGrokPatterns' lists the built-in grok patterns shipped with the
-- grok ingest processor. Maps to @GET /_ingest/processor/grok@ and
-- returns a 'GrokPatterns'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/grok-processor.html#grok-processor-get>.
getGrokPatterns :: (MonadBH m) => m GrokPatterns
getGrokPatterns = performBHRequest Requests.getGrokPatterns
-- | 'getSLMPolicy' lists SLM policies.
--
-- * @'Nothing'@ → @GET /_slm/policy@ returns every policy on the cluster.
-- * @'Just' pid@ → @GET /_slm/policy/{pid}@ returns just that one (as a
-- singleton list).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-slm-lifecycle-policy.html>.
getSLMPolicy :: (MonadBH m) => Maybe SLMPolicyId -> m [SLMPolicyInfo]
getSLMPolicy = performBHRequest . Requests.getSLMPolicy
-- | 'deleteSLMPolicy' deletes a single SLM policy by id. Maps to
-- @DELETE /_slm/policy/{id}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-slm-lifecycle-policy.html>.
deleteSLMPolicy :: (MonadBH m) => SLMPolicyId -> m Acknowledged
deleteSLMPolicy = performBHRequest . Requests.deleteSLMPolicy
-- | 'executeSLMPolicy' triggers a single SLM policy immediately, outside
-- of its schedule. Maps to @POST /_slm/execute/{id}@ and returns the
-- 'SnapshotName' of the newly-created snapshot on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/execute-slm-lifecycle-policy.html>.
executeSLMPolicy :: (MonadBH m) => SLMPolicyId -> m SnapshotName
executeSLMPolicy = performBHRequest . Requests.executeSLMPolicy
-- | 'getSLMStatus' reports the cluster-wide SLM operation mode
-- ('SLMOperationMode') alongside the cumulative snapshot creation and
-- deletion counters. Maps to @GET /_slm/status@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-get-status.html>.
getSLMStatus :: (MonadBH m) => m SLMStatus
getSLMStatus = performBHRequest Requests.getSLMStatus
-- | 'stopSLM' stops all SLM scheduling. Maps to @POST /_slm/stop@ and
-- returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/stop-slm.html>.
stopSLM :: (MonadBH m) => m Acknowledged
stopSLM = performBHRequest Requests.stopSLM
-- | 'startSLM' (re)starts SLM scheduling. Maps to @POST /_slm/start@ and
-- returns 'Acknowledged' on success. Inverse of 'stopSLM'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-start.html>.
--
-- @since 0.26.0.0
startSLM :: (MonadBH m) => m Acknowledged
startSLM = performBHRequest Requests.startSLM
------------------------------------------------------------------------------
-- Enrich policy API
-- | 'putEnrichPolicy' creates or replaces an enrich policy by id. Maps to
-- @PUT /_enrich/policy/{policy_id}@ and returns 'Acknowledged' on
-- success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-enrich-policy-api.html>.
putEnrichPolicy ::
(MonadBH m) =>
EnrichPolicyId ->
EnrichPolicy ->
m Acknowledged
putEnrichPolicy policyId policy =
performBHRequest $ Requests.putEnrichPolicy policyId policy
-- | 'getEnrichPolicy' lists enrich policies. @'Nothing'@ returns every
-- policy on the cluster; @'Just' pid@ returns just that one (as a
-- singleton 'EnrichPoliciesResponse').
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-enrich-policy-api.html>.
getEnrichPolicy ::
(MonadBH m) =>
Maybe EnrichPolicyId ->
m EnrichPoliciesResponse
getEnrichPolicy = performBHRequest . Requests.getEnrichPolicy
-- | 'deleteEnrichPolicy' deletes a single enrich policy by id. Maps to
-- @DELETE /_enrich/policy/{policy_id}@ and returns 'Acknowledged' on
-- success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-enrich-policy-api.html>.
deleteEnrichPolicy :: (MonadBH m) => EnrichPolicyId -> m Acknowledged
deleteEnrichPolicy = performBHRequest . Requests.deleteEnrichPolicy
-- | 'executeEnrichPolicy' triggers a synchronous execution of an enrich
-- policy (creating\/refreshing its follower index). Maps to
-- @POST /_enrich/policy/{policy_id}/_execute@ and returns 'Acknowledged'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/execute-enrich-policy-api.html>.
executeEnrichPolicy :: (MonadBH m) => EnrichPolicyId -> m Acknowledged
executeEnrichPolicy = performBHRequest . Requests.executeEnrichPolicy
-- | Like 'executeEnrichPolicy' but accepts 'EnrichExecuteOptions'
-- carrying the documented URI parameter @wait_for_completion@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/execute-enrich-policy-api.html>.
executeEnrichPolicyWith ::
(MonadBH m) =>
EnrichPolicyId ->
EnrichExecuteOptions ->
m Acknowledged
executeEnrichPolicyWith pid opts =
performBHRequest $ Requests.executeEnrichPolicyWith pid opts
-- | 'getEnrichExecuteStats' reports the executor pool and per-policy
-- execution statistics across the cluster. Maps to
-- @GET /_enrich/_execute_stats@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/enrich-stats-api.html>.
getEnrichExecuteStats :: (MonadBH m) => m EnrichExecuteStatsResponse
getEnrichExecuteStats = performBHRequest Requests.getEnrichExecuteStats
-- | 'getEnrichPolicyExecuteStats' reports execution statistics for a
-- single enrich policy. Maps to
-- @GET /_enrich/policy/{policy_id}/_execute_stats@ (per-policy variant,
-- ES 7.16+).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/enrich-stats-api.html>.
getEnrichPolicyExecuteStats ::
(MonadBH m) =>
EnrichPolicyId ->
m EnrichExecuteStatsResponse
getEnrichPolicyExecuteStats =
performBHRequest . Requests.getEnrichPolicyExecuteStats
------------------------------------------------------------------------------
-- Autoscaling API
-- | 'putAutoscalingPolicy' creates or replaces an autoscaling policy by name.
-- Maps to @PUT /_autoscaling/policy/{name}@ and returns 'Acknowledged' on
-- success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-put-autoscaling-policy.html>.
putAutoscalingPolicy ::
(MonadBH m) =>
AutoscalingPolicyName ->
AutoscalingPolicy ->
m Acknowledged
putAutoscalingPolicy name policy =
performBHRequest $ Requests.putAutoscalingPolicy name policy
-- | 'getAutoscalingPolicy' retrieves a single autoscaling policy by name.
-- Maps to @GET /_autoscaling/policy/{name}@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-get-autoscaling-policy.html>.
getAutoscalingPolicy ::
(MonadBH m) =>
AutoscalingPolicyName ->
m AutoscalingPolicy
getAutoscalingPolicy =
performBHRequest . Requests.getAutoscalingPolicy
-- | 'deleteAutoscalingPolicy' deletes a single autoscaling policy by name.
-- Maps to @DELETE /_autoscaling/policy/{name}@ and returns 'Acknowledged'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-delete-autoscaling-policy.html>.
deleteAutoscalingPolicy ::
(MonadBH m) =>
AutoscalingPolicyName ->
m Acknowledged
deleteAutoscalingPolicy =
performBHRequest . Requests.deleteAutoscalingPolicy
-- | 'getAutoscalingCapacity' reports the current autoscaling capacity for
-- every configured policy. Maps to @GET /_autoscaling/capacity@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-get-autoscaling-capacity.html>.
getAutoscalingCapacity :: (MonadBH m) => m AutoscalingCapacity
getAutoscalingCapacity =
performBHRequest Requests.getAutoscalingCapacity
------------------------------------------------------------------------------
-- Security — roles API (/_security/role/*)
-- | 'putRole' creates or replaces a role by name. Maps to
-- @PUT /_security/role/{name}@; 'RoleCreatedResponse' reports whether
-- the role was newly created (@created=True@) or updated.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-put-role.html>.
putRole :: (MonadBH m) => RoleName -> Role -> m RoleCreatedResponse
putRole name role = performBHRequest $ Requests.putRole name role
-- | 'getRoles' lists every role on the cluster. Maps to
-- @GET /_security/role@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-roles.html>.
getRoles :: (MonadBH m) => m RolesListResponse
getRoles = performBHRequest Requests.getRoles
-- | 'getRole' fetches a single role by name. Maps to
-- @GET /_security/role/{name}@; the result is a singleton
-- 'RolesListResponse' (possibly empty if the role is absent).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-roles.html>.
getRole :: (MonadBH m) => RoleName -> m RolesListResponse
getRole = performBHRequest . Requests.getRole
-- | 'deleteRole' deletes a role by name. Maps to
-- @DELETE /_security/role/{name}@; 'RoleDeletedResponse' reports
-- whether the role existed.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-delete-role.html>.
deleteRole :: (MonadBH m) => RoleName -> m RoleDeletedResponse
deleteRole = performBHRequest . Requests.deleteRole
-- | 'clearRoleCache' evicts a role from the security cache. Maps to
-- @POST /_security/role/{name}/_clear_cache@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-clear-role-cache.html>.
clearRoleCache :: (MonadBH m) => RoleName -> m ClearRoleCacheResponse
clearRoleCache = performBHRequest . Requests.clearRoleCache
------------------------------------------------------------------------------
-- Security — role mappings API (/_security/role_mapping/*)
-- | 'putRoleMapping' creates or replaces a role mapping. Maps to
-- @PUT /_security/role_mapping/{name}@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-create-role-mapping.html>.
putRoleMapping ::
(MonadBH m) =>
RoleMappingName ->
RoleMapping ->
m Acknowledged
putRoleMapping name rm = performBHRequest $ Requests.putRoleMapping name rm
-- | 'getRoleMappings' lists every role mapping. Maps to
-- @GET /_security/role_mapping@.
getRoleMappings :: (MonadBH m) => m RoleMappingsListResponse
getRoleMappings = performBHRequest Requests.getRoleMappings
-- | 'getRoleMapping' fetches a single role mapping by name.
getRoleMapping ::
(MonadBH m) =>
RoleMappingName ->
m RoleMappingsListResponse
getRoleMapping = performBHRequest . Requests.getRoleMapping
-- | 'deleteRoleMapping' deletes a role mapping by name. Maps to
-- @DELETE /_security/role_mapping/{name}@.
deleteRoleMapping :: (MonadBH m) => RoleMappingName -> m Acknowledged
deleteRoleMapping = performBHRequest . Requests.deleteRoleMapping
------------------------------------------------------------------------------
-- Security — users API (/_security/user/*)
-- | 'putUser' creates or updates a user. Maps to
-- @PUT /_security/user/{username}@; 'UserCreatedResponse' reports
-- whether the user was newly created (@created=True@) or updated.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-put-user.html>.
putUser ::
(MonadBH m) =>
UserName ->
UserCreateBody ->
m UserCreatedResponse
putUser username body = performBHRequest $ Requests.putUser username body
-- | 'getUsers' lists every user on the cluster. Maps to
-- @GET /_security/user@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-users.html>.
getUsers :: (MonadBH m) => m UsersListResponse
getUsers = performBHRequest Requests.getUsers
-- | 'getUser' fetches a single user by username. Maps to
-- @GET /_security/user/{username}@.
getUser :: (MonadBH m) => UserName -> m UsersListResponse
getUser = performBHRequest . Requests.getUser
-- | 'deleteUser' deletes a user by username. Maps to
-- @DELETE /_security/user/{username}@; 'UserDeletedResponse' reports
-- whether the user existed.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-delete-user.html>.
deleteUser :: (MonadBH m) => UserName -> m UserDeletedResponse
deleteUser = performBHRequest . Requests.deleteUser
-- | 'enableUser' enables a user. Maps to
-- @PUT /_security/user/{username}/_enable@.
enableUser :: (MonadBH m) => UserName -> m Acknowledged
enableUser = performBHRequest . Requests.enableUser
-- | 'disableUser' disables a user. Maps to
-- @PUT /_security/user/{username}/_disable@.
disableUser :: (MonadBH m) => UserName -> m Acknowledged
disableUser = performBHRequest . Requests.disableUser
-- | 'changeUserPassword' changes a user's password. Maps to
-- @POST /_security/user/{username}/_password@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-change-password.html>.
changeUserPassword ::
(MonadBH m) =>
UserName ->
ChangePasswordBody ->
m Acknowledged
changeUserPassword username body =
performBHRequest $ Requests.changeUserPassword username body
-- | 'userHasPrivileges' checks the privileges held by a named user.
-- Maps to @POST /_security/user/{username}/_has_privileges@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-has-privileges.html>.
userHasPrivileges ::
(MonadBH m) =>
UserName ->
HasPrivilegesRequest ->
m HasPrivilegesResponse
userHasPrivileges username req =
performBHRequest $ Requests.userHasPrivileges username req
-- | 'selfHasPrivileges' checks the privileges held by the current
-- (authenticated) user. Maps to @POST /_security/user/_has_privileges@.
selfHasPrivileges ::
(MonadBH m) =>
HasPrivilegesRequest ->
m HasPrivilegesResponse
selfHasPrivileges = performBHRequest . Requests.selfHasPrivileges
-- | 'getUserPrivileges' lists the current user's effective privileges.
-- Maps to @GET /_security/user/_privileges@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-privileges.html>.
getUserPrivileges :: (MonadBH m) => m UserPrivileges
getUserPrivileges = performBHRequest Requests.getUserPrivileges
------------------------------------------------------------------------------
-- Security — API keys (/_security/api_key)
-- | 'createApiKey' mints a new API key. Maps to @POST /_security/api_key@.
-- The plaintext 'ApiKeyCreatedResponse' secret is returned exactly once.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-create-api-key.html>.
createApiKey ::
(MonadBH m) =>
CreateApiKeyRequest ->
m ApiKeyCreatedResponse
createApiKey = performBHRequest . Requests.createApiKey
-- | 'grantApiKey' mints an API key on behalf of another principal. Maps
-- to @POST /_security/api_key/grant@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-grant-api-key.html>.
grantApiKey ::
(MonadBH m) =>
GrantApiKeyRequest ->
m ApiKeyCreatedResponse
grantApiKey = performBHRequest . Requests.grantApiKey
-- | 'getApiKey' retrieves API keys matching the filter. Maps to
-- @GET /_security/api_key@. The plaintext key is NOT included.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-api-key.html>.
getApiKey ::
(MonadBH m) =>
RetrieveApiKeyRequest ->
m ApiKeyRetrievalResponse
getApiKey = performBHRequest . Requests.getApiKey
-- | 'invalidateApiKey' revokes API keys matching the filter. Maps to
-- @DELETE /_security/api_key@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-invalidate-api-key.html>.
invalidateApiKey ::
(MonadBH m) =>
InvalidateApiKeyRequest ->
m InvalidateApiKeyResponse
invalidateApiKey = performBHRequest . Requests.invalidateApiKey
-- | 'updateApiKey' updates a key's role descriptors and/or metadata.
-- Maps to @PUT /_security/api_key/{id}@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-update-api-key.html>.
updateApiKey ::
(MonadBH m) =>
ApiKeyId ->
UpdateApiKeyRequest ->
m Acknowledged
updateApiKey apiKeyId body =
performBHRequest $ Requests.updateApiKey apiKeyId body
-- | 'queryApiKey' lists API keys via the Query-DSL paginated endpoint.
-- Maps to @POST /_security/_query/api_key@ (ES 7.16+ \/ 8.x).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/8.17/security-api-query-api-key.html>.
queryApiKey ::
(MonadBH m) =>
QueryApiKeyRequest ->
m QueryApiKeyResponse
queryApiKey = performBHRequest . Requests.queryApiKey
-- | Variant of 'queryApiKey' that also sets the @with_limited_by@,
-- @with_profile_uid@, and @typed_keys@ URI parameters. Calling with
-- 'defaultQueryApiKeyOptions' is byte-for-byte identical to 'queryApiKey'.
queryApiKeyWith ::
(MonadBH m) =>
QueryApiKeyRequest ->
Requests.QueryApiKeyOptions ->
m QueryApiKeyResponse
queryApiKeyWith req opts =
performBHRequest $ Requests.queryApiKeyWith req opts
-- | 'authenticate' returns information about the credentials the request
-- was made with. Maps to @GET /_security/_authenticate@. When the request
-- carries an API key (@Authorization: ApiKey <encoded>@), the response
-- describes that API key.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/8.17/security-api-authenticate.html>.
authenticate :: (MonadBH m) => m AuthenticateResponse
authenticate = performBHRequest Requests.authenticate
-- | 'whoami' returns the identity of the current authenticated user
-- (ES 7.16+). Maps to @GET /_security/_whoami@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-whoami.html>.
whoami :: (MonadBH m) => m WhoAmIResponse
whoami = performBHRequest Requests.whoami
-- | 'logout' logs out of a SAML/OIDC SSO token. Maps to
-- @POST /_security/_logout@ with the SSO token to invalidate.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-logout.html>.
logout :: (MonadBH m) => LogoutRequest -> m LogoutResponse
logout = performBHRequest . Requests.logout
------------------------------------------------------------------------------
-- Security — service accounts (/_security/service/*)
-- | 'getServiceAccounts' lists every service account. Maps to
-- @GET /_security/service@.
getServiceAccounts :: (MonadBH m) => m ServiceAccountsListResponse
getServiceAccounts = performBHRequest Requests.getServiceAccounts
-- | 'getServiceAccountsInNamespace' lists the service accounts in a
-- namespace. Maps to @GET /_security/service/{namespace}@.
getServiceAccountsInNamespace ::
(MonadBH m) =>
ServiceAccountNamespace ->
m ServiceAccountsListResponse
getServiceAccountsInNamespace =
performBHRequest . Requests.getServiceAccountsInNamespace
-- | 'getServiceAccount' retrieves a single service account. Maps to
-- @GET /_security/service/{namespace}/{service}@.
getServiceAccount ::
(MonadBH m) =>
ServiceAccountNamespace ->
ServiceAccountService ->
m ServiceAccountsListResponse
getServiceAccount namespace service =
performBHRequest $ Requests.getServiceAccount namespace service
-- | 'createServiceToken' creates a service account token. The secret
-- token @value@ is returned exactly once. Maps to
-- @POST /_security/service/{namespace}/{service}/credential/token[/{token_name}]@.
createServiceToken ::
(MonadBH m) =>
ServiceAccountNamespace ->
ServiceAccountService ->
Maybe ServiceTokenName ->
m CreateServiceTokenResponse
createServiceToken namespace service maybeTokenName =
performBHRequest $
Requests.createServiceToken namespace service maybeTokenName
-- | 'getServiceCredentials' lists the credentials (tokens) of a service
-- account. Maps to
-- @GET /_security/service/{namespace}/{service}/credential@.
getServiceCredentials ::
(MonadBH m) =>
ServiceAccountNamespace ->
ServiceAccountService ->
m GetServiceCredentialsResponse
getServiceCredentials namespace service =
performBHRequest $ Requests.getServiceCredentials namespace service
-- | 'deleteServiceToken' deletes a service account token. Maps to
-- @DELETE /_security/service/{namespace}/{service}/credential/token/{token_name}@.
deleteServiceToken ::
(MonadBH m) =>
ServiceAccountNamespace ->
ServiceAccountService ->
ServiceTokenName ->
m ServiceTokenDeletedResponse
deleteServiceToken namespace service tokenName =
performBHRequest $
Requests.deleteServiceToken namespace service tokenName
------------------------------------------------------------------------------
-- Security — SSO / token (/_security/oauth2, /_security/oidc, /_security/saml)
-- | 'getToken' mints an OAuth2 bearer token. Maps to
-- @POST /_security/oauth2/token@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-token.html>.
getToken ::
(MonadBH m) =>
GetTokenRequest ->
m GetTokenResponse
getToken = performBHRequest . Requests.getToken
-- | 'invalidateToken' revokes an access/refresh token (or every token
-- for a realm/user). Maps to @DELETE /_security/oauth2/token@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-invalidate-token.html>.
invalidateToken ::
(MonadBH m) =>
InvalidateTokenRequest ->
m InvalidateTokenResponse
invalidateToken = performBHRequest . Requests.invalidateToken
-- | 'prepareSamlAuthentication' mints a SAML @<AuthnRequest>@ redirect
-- URL. Maps to @POST /_security/saml/prepare@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-prepare-authentication.html>.
prepareSamlAuthentication ::
(MonadBH m) =>
SamlPrepareRequest ->
m SamlPrepareResponse
prepareSamlAuthentication = performBHRequest . Requests.prepareSamlAuthentication
-- | 'authenticateSaml' exchanges a SAML @<Response>@ for an ES access
-- and refresh token. Maps to @POST /_security/saml/authenticate@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-authenticate.html>.
authenticateSaml ::
(MonadBH m) =>
SamlAuthenticateRequest ->
m SsoTokenResponse
authenticateSaml = performBHRequest . Requests.authenticateSaml
-- | 'logoutSaml' invalidates a SAML-issued token pair. Maps to
-- @POST /_security/saml/logout@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-logout.html>.
logoutSaml ::
(MonadBH m) =>
SamlLogoutRequest ->
m SsoRedirectResponse
logoutSaml = performBHRequest . Requests.logoutSaml
-- | 'prepareOidcAuthentication' mints an OpenID Connect authentication
-- request URL. Maps to @POST /_security/oidc/prepare@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-oidc-prepare-authentication.html>.
prepareOidcAuthentication ::
(MonadBH m) =>
OidcPrepareRequest ->
m OidcPrepareResponse
prepareOidcAuthentication =
performBHRequest . Requests.prepareOidcAuthentication
-- | 'authenticateOidc' exchanges an OpenID Connect authentication
-- response for an ES access and refresh token. Maps to
-- @POST /_security/oidc/authenticate@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-oidc-authenticate.html>.
authenticateOidc ::
(MonadBH m) =>
OidcAuthenticateRequest ->
m SsoTokenResponse
authenticateOidc = performBHRequest . Requests.authenticateOidc
-- | 'logoutOidc' invalidates an OIDC-issued token pair. Maps to
-- @POST /_security/oidc/logout@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-oidc-logout.html>.
logoutOidc ::
(MonadBH m) =>
OidcLogoutRequest ->
m SsoRedirectResponse
logoutOidc = performBHRequest . Requests.logoutOidc
------------------------------------------------------------------------------
-- Security — application privileges (/_security/privilege/*)
-- | 'putPrivilege' creates or updates a single application privilege. Maps
-- to @PUT /_security/privilege/{application}/{privilege}@.
putPrivilege ::
(MonadBH m) =>
ApplicationName ->
ApplicationPrivilegeName ->
ApplicationPrivilegeDefinition ->
m PrivilegeCreatedResponse
putPrivilege application privilege definition =
performBHRequest $
Requests.putPrivilege application privilege definition
-- | 'getPrivileges' lists every application privilege. Maps to
-- @GET /_security/privilege@.
getPrivileges :: (MonadBH m) => m PrivilegesListResponse
getPrivileges = performBHRequest Requests.getPrivileges
-- | 'getPrivilegesInApplication' lists every privilege for one application.
-- Maps to @GET /_security/privilege/{application}@.
getPrivilegesInApplication ::
(MonadBH m) =>
ApplicationName ->
m PrivilegesListResponse
getPrivilegesInApplication =
performBHRequest . Requests.getPrivilegesInApplication
-- | 'getPrivilege' fetches a single privilege. Maps to
-- @GET /_security/privilege/{application}/{privilege}@.
getPrivilege ::
(MonadBH m) =>
ApplicationName ->
ApplicationPrivilegeName ->
m PrivilegesListResponse
getPrivilege application privilege =
performBHRequest $ Requests.getPrivilege application privilege
-- | 'deletePrivilege' deletes a single application privilege. Maps to
-- @DELETE /_security/privilege/{application}/{privilege}@.
deletePrivilege ::
(MonadBH m) =>
ApplicationName ->
ApplicationPrivilegeName ->
m PrivilegeDeletedResponse
deletePrivilege application privilege =
performBHRequest $ Requests.deletePrivilege application privilege
-- | 'clearPrivilegeCache' evicts application privileges from the native
-- privilege cache. Maps to
-- @POST /_security/privilege/{applications}/_clear_cache@; pass @"*"@
-- (via 'IsString') as one of the applications to clear every application.
clearPrivilegeCache ::
(MonadBH m) =>
NonEmpty ApplicationName ->
m ClearPrivilegeCacheResponse
clearPrivilegeCache =
performBHRequest . Requests.clearPrivilegeCache
------------------------------------------------------------------------------
-- Fleet API
-- | 'getFleetGlobalCheckpoints' returns the current global checkpoints for
-- a single index. Maps to @GET /{index}/_fleet/global_checkpoints@ with
-- 'defaultFleetGlobalCheckpointsOptions'. Use 'getFleetGlobalCheckpointsWith'
-- to poll until the checkpoints advance.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-global-checkpoints.html>.
getFleetGlobalCheckpoints ::
(MonadBH m) =>
IndexName ->
m FleetGlobalCheckpointsResponse
getFleetGlobalCheckpoints indexName =
performBHRequest $ Requests.getFleetGlobalCheckpoints indexName
-- | Like 'getFleetGlobalCheckpoints' but accepts 'FleetGlobalCheckpointsOptions'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-global-checkpoints.html>.
getFleetGlobalCheckpointsWith ::
(MonadBH m) =>
IndexName ->
FleetGlobalCheckpointsOptions ->
m FleetGlobalCheckpointsResponse
getFleetGlobalCheckpointsWith indexName opts =
performBHRequest $ Requests.getFleetGlobalCheckpointsWith indexName opts
-- | 'fleetSearch' runs a checkpoint-aware search against a single index.
-- Maps to @POST /{index}/_fleet/_fleet_search@ with
-- 'defaultFleetSearchOptions'. The request body and response are the
-- standard 'Search' \/ 'SearchResult' shapes.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/fleet-search.html>.
fleetSearch ::
(MonadBH m, FromJSON a) =>
IndexName ->
Search ->
m (SearchResult a)
fleetSearch indexName =
performBHRequest . Requests.fleetSearch indexName
-- | Like 'fleetSearch' but accepts 'FleetSearchOptions' carrying the
-- documented URI parameters @wait_for_checkpoints@ and
-- @allow_partial_search_results@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/fleet-search.html>.
fleetSearchWith ::
(MonadBH m, FromJSON a) =>
IndexName ->
FleetSearchOptions ->
Search ->
m (SearchResult a)
fleetSearchWith indexName opts =
performBHRequest . Requests.fleetSearchWith indexName opts
-- | 'fleetMultiSearch' runs several fleet searches in a single request,
-- following the same NDJSON body shape as @_msearch@. Maps to
-- @POST /{index}/_fleet/_fleet_msearch@ with 'defaultFleetSearchOptions'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/fleet-multi-search.html>.
fleetMultiSearch ::
(MonadBH m, FromJSON a) =>
IndexName ->
NonEmpty MultiSearchItem ->
m (MultiSearchResponse a)
fleetMultiSearch indexName =
performBHRequest . Requests.fleetMultiSearch indexName
-- | Like 'fleetMultiSearch' but accepts 'FleetSearchOptions' carrying the
-- documented URI parameters @wait_for_checkpoints@ and
-- @allow_partial_search_results@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/fleet-multi-search.html>.
fleetMultiSearchWith ::
(MonadBH m, FromJSON a) =>
IndexName ->
FleetSearchOptions ->
NonEmpty MultiSearchItem ->
m (MultiSearchResponse a)
fleetMultiSearchWith indexName opts =
performBHRequest . Requests.fleetMultiSearchWith indexName opts
-- Repositories metering API
-- | 'getRepositoriesMetering' reports the repository metering counters
-- (snapshot creation\/deletion throughput and counts) for each
-- cloud-backed repository on each node. @'Nothing'@ is cluster-wide
-- (@GET /_nodes/_repositories_metering@); @'Just' sel@ scopes to a
-- 'NodeSelection' (@GET /_nodes/{seg}/_repositories_metering@).
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/repository-metering-api.html>.
getRepositoriesMetering ::
(MonadBH m) =>
Maybe NodeSelection ->
m RepositoriesMeteringResponse
getRepositoriesMetering =
performBHRequest . Requests.getRepositoriesMetering
-- | 'deleteRepositoriesMetering' resets the repository metering counters
-- to zero across the cluster (@'Nothing'@) or on a node selection
-- (@'Just'@), returning 'Acknowledged'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/repository-metering-api.html>.
deleteRepositoriesMetering ::
(MonadBH m) =>
Maybe NodeSelection ->
m Acknowledged
deleteRepositoriesMetering =
performBHRequest . Requests.deleteRepositoriesMetering
------------------------------------------------------------------------------
-- Rollup API
-- | 'putRollupJob' creates or replaces a rollup job by id. Maps to
-- @PUT /_rollup/job/{job_id}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-put-job.html>.
putRollupJob ::
(MonadBH m) =>
RollupJobId ->
RollupJobConfig ->
m Acknowledged
putRollupJob jobId config =
performBHRequest $ Requests.putRollupJob jobId config
-- | 'getRollupJob' retrieves the configuration, status, and stats of
-- rollup jobs. @'Nothing'@ returns every job on the cluster; @'Just' jid@
-- returns just that one (as a singleton 'GetRollupJobsResponse').
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-get-job.html>.
getRollupJob ::
(MonadBH m) =>
Maybe RollupJobId ->
m GetRollupJobsResponse
getRollupJob = performBHRequest . Requests.getRollupJob
-- | 'deleteRollupJob' deletes a single rollup job by id. Maps to
-- @DELETE /_rollup/job/{job_id}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-delete-job.html>.
deleteRollupJob ::
(MonadBH m) =>
RollupJobId ->
m Acknowledged
deleteRollupJob = performBHRequest . Requests.deleteRollupJob
-- | 'startRollupJob' starts an existing, stopped rollup job. Maps to
-- @POST /_rollup/job/{job_id}/_start@ and returns 'RollupJobStarted'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-start-job.html>.
startRollupJob ::
(MonadBH m) =>
RollupJobId ->
m RollupJobStarted
startRollupJob = performBHRequest . Requests.startRollupJob
-- | 'stopRollupJob' stops an existing, started rollup job asynchronously.
-- Maps to @POST /_rollup/job/{job_id}/_stop@ and returns 'RollupJobStopped'.
-- Use 'stopRollupJobWith' to block until the job has fully stopped.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-stop-job.html>.
stopRollupJob ::
(MonadBH m) =>
RollupJobId ->
m RollupJobStopped
stopRollupJob = performBHRequest . Requests.stopRollupJob
-- | Like 'stopRollupJob' but accepts 'StopRollupJobOptions' carrying the
-- documented URI parameters @wait_for_completion@ and @timeout@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-stop-job.html>.
stopRollupJobWith ::
(MonadBH m) =>
RollupJobId ->
StopRollupJobOptions ->
m RollupJobStopped
stopRollupJobWith jobId opts =
performBHRequest $ Requests.stopRollupJobWith jobId opts
-- | 'getRollupJobStats' retrieves the transient statistics (and current
-- state) of rollup jobs. Maps to @GET /_rollup/job[/{job_id}|_all]/_stats@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-apis.html>.
getRollupJobStats ::
(MonadBH m) =>
Maybe RollupJobId ->
m GetRollupJobStatsResponse
getRollupJobStats = performBHRequest . Requests.getRollupJobStats
-- | 'getRollupCapabilities' returns the capabilities of any rollup jobs
-- configured for a given index or index pattern. Maps to
-- @GET /_rollup/data/{index}@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-get-rollup-caps.html>.
getRollupCapabilities ::
(MonadBH m) =>
IndexPattern ->
m RollupCapabilitiesResponse
getRollupCapabilities = performBHRequest . Requests.getRollupCapabilities
-- | 'getRollupIndexCapabilities' returns the rollup capabilities of all
-- jobs stored inside a rollup index (or index pattern). Maps to
-- @GET /{target}/_rollup/data@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-get-rollup-index-caps.html>.
getRollupIndexCapabilities ::
(MonadBH m) =>
IndexName ->
m RollupCapabilitiesResponse
getRollupIndexCapabilities =
performBHRequest . Requests.getRollupIndexCapabilities
-- | 'rollupSearchByIndex' runs a standard 'Search' against rolled-up data.
-- Maps to @GET /{index}/_rollup_search@. The response shape is the
-- standard 'SearchResult'; hits are always empty (@size@ must be @0@ or
-- omitted), so callers typically inspect 'aggregations' instead.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-search.html>.
rollupSearchByIndex ::
(FromJSON a, MonadBH m) =>
IndexName ->
Search ->
m (SearchResult a)
rollupSearchByIndex indexName =
performBHRequest . Requests.rollupSearchByIndex indexName
-- | Like 'rollupSearchByIndex' but accepts a 'SearchOptions' record for
-- URI-level parameters such as @preference@ and @routing@.
rollupSearchByIndexWith ::
(FromJSON a, MonadBH m) =>
IndexName ->
SearchOptions ->
Search ->
m (SearchResult a)
rollupSearchByIndexWith indexName opts =
performBHRequest . Requests.rollupSearchByIndexWith indexName opts
------------------------------------------------------------------------------
-- Searchable snapshots API
-- | 'mountSearchableSnapshot' mounts a snapshot as a searchable index.
-- Maps to @POST /_snapshot/{repository}/{snapshot}/_mount@ and returns a
-- 'SearchableSnapshotMountResponse'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-api.html>.
mountSearchableSnapshot ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotName ->
SearchableSnapshotMount ->
m SearchableSnapshotMountResponse
mountSearchableSnapshot repo snap body =
performBHRequest $ Requests.mountSearchableSnapshot repo snap body
-- | Like 'mountSearchableSnapshot' but accepts 'SearchableSnapshotMountOptions'
-- carrying the documented URI parameters @master_timeout@,
-- @wait_for_completion@ and @storage@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-api.html>.
mountSearchableSnapshotWith ::
(MonadBH m) =>
SnapshotRepoName ->
SnapshotName ->
SearchableSnapshotMount ->
SearchableSnapshotMountOptions ->
m SearchableSnapshotMountResponse
mountSearchableSnapshotWith repo snap body opts =
performBHRequest $ Requests.mountSearchableSnapshotWith repo snap body opts
-- | 'getSearchableSnapshotsStats' reports cluster-wide and per-index
-- searchable snapshot statistics. Maps to
-- @GET /_searchable_snapshots/stats@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-api.html>.
getSearchableSnapshotsStats ::
(MonadBH m) =>
m SearchableSnapshotsStatsResponse
getSearchableSnapshotsStats =
performBHRequest Requests.getSearchableSnapshotsStats
-- | 'getSearchableSnapshotsCacheStats' reports cache statistics for a
-- single searchable-snapshot index. Maps to
-- @POST /_searchable_snapshots/{index}/_cache_stats@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-api.html>.
getSearchableSnapshotsCacheStats ::
(MonadBH m) =>
IndexName ->
m SearchableSnapshotsCacheStatsResponse
getSearchableSnapshotsCacheStats =
performBHRequest . Requests.getSearchableSnapshotsCacheStats
-- | 'clearSearchableSnapshotsCache' evicts the node cache for a single
-- searchable-snapshot index. Maps to
-- @POST /_searchable_snapshots/{index}/_clear_cache@ and returns
-- 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-api.html>.
clearSearchableSnapshotsCache ::
(MonadBH m) =>
IndexName ->
m Acknowledged
clearSearchableSnapshotsCache =
performBHRequest . Requests.clearSearchableSnapshotsCache
------------------------------------------------------------------------------
-- Watcher API
-- | 'putWatch' creates or updates a single watch by id. Maps to
-- @PUT /_watcher/watch/{id}@ and returns 'Acknowledged' on success. The
-- 'WatchBody' is carried as an opaque 'Data.Aeson.Value' — see
-- "Database.Bloodhound.Internal.Versions.Common.Types.Watcher" for the
-- rationale.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-put-watch.html>.
putWatch :: (MonadBH m) => WatchId -> WatchBody -> m Acknowledged
putWatch wid body = performBHRequest $ Requests.putWatch wid body
-- | 'getWatch' retrieves a single watch by id. Maps to
-- @GET /_watcher/watch/{id}@ and returns the full 'Watch' (typed envelope
-- + opaque watch DSL). A missing watch surfaces as an 'EsError'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-get-watch.html>.
getWatch :: (MonadBH m) => WatchId -> m Watch
getWatch = performBHRequest . Requests.getWatch
-- | 'deleteWatch' deletes a single watch by id. Maps to
-- @DELETE /_watcher/watch/{id}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-delete-watch.html>.
deleteWatch :: (MonadBH m) => WatchId -> m Acknowledged
deleteWatch = performBHRequest . Requests.deleteWatch
-- | 'executeWatch' dry-runs the stored watch with the given id. Maps to
-- @POST /_watcher/watch/{id}/_execute@ with no body and returns the
-- execution record on success. Equivalent to
-- @'executeWatchWith' 'defaultExecuteWatchOptions' wid 'Nothing'@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-execute-watch.html>.
executeWatch ::
(MonadBH m) =>
WatchId ->
m ExecuteWatchResponse
executeWatch wid =
performBHRequest $ Requests.executeWatch wid
-- | 'executeWatchWith' is the fully-parameterised form of 'executeWatch'.
-- Every URI parameter accepted by @POST /_watcher/watch/{id}/_execute@ is
-- exposed via 'ExecuteWatchOptions'; supplying a 'Just' 'ExecuteWatchRequest'
-- body runs an inline watch instead of the stored one.
executeWatchWith ::
(MonadBH m) =>
ExecuteWatchOptions ->
WatchId ->
Maybe ExecuteWatchRequest ->
m ExecuteWatchResponse
executeWatchWith opts wid mBody =
performBHRequest $ Requests.executeWatchWith opts wid mBody
-- | 'ackWatch' acknowledges the actions of a watch by id. Maps to
-- @PUT /_watcher/watch/{id}/_ack@ and returns the watch's updated
-- acknowledge state.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-ack-watch.html>.
ackWatch :: (MonadBH m) => WatchId -> m AckWatchResponse
ackWatch = performBHRequest . Requests.ackWatch
-- | 'activateWatch' (re)activates a watch by id. Maps to
-- @PUT /_watcher/watch/{id}/_activate@ and returns the watch's updated
-- state.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-activate-watch.html>.
activateWatch ::
(MonadBH m) =>
WatchId ->
m WatchStateResponse
activateWatch = performBHRequest . Requests.activateWatch
-- | 'deactivateWatch' pauses a watch by id. Maps to
-- @PUT /_watcher/watch/{id}/_deactivate@ and returns the watch's updated
-- state.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-deactivate-watch.html>.
deactivateWatch ::
(MonadBH m) =>
WatchId ->
m WatchStateResponse
deactivateWatch = performBHRequest . Requests.deactivateWatch
-- | 'watcherStats' reports cluster-wide Watcher statistics. Maps to
-- @GET /_watcher/_stats@ (every metric). Equivalent to
-- @'watcherStatsWith' 'Nothing'@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-stats.html>.
watcherStats :: (MonadBH m) => m WatcherStatsResponse
watcherStats = performBHRequest Requests.watcherStats
-- | 'watcherStatsWith' is the fully-parameterised form of 'watcherStats'.
-- Supplying 'Just' a 'WatcherStatsMetric' narrows the response to that
-- metric; 'Nothing' (or 'Just' 'WatcherStatsMetricAll') requests every
-- metric.
watcherStatsWith ::
(MonadBH m) =>
Maybe WatcherStatsMetric ->
m WatcherStatsResponse
watcherStatsWith = performBHRequest . Requests.watcherStatsWith
-- | 'getWatcherSettings' reads the cluster-wide Watcher settings. Maps to
-- @GET /_watcher/settings@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-update-settings.html>.
getWatcherSettings :: (MonadBH m) => m WatcherSettings
getWatcherSettings = performBHRequest Requests.getWatcherSettings
-- | 'updateWatcherSettings' updates the cluster-wide Watcher settings.
-- Maps to @PUT /_watcher/settings@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-update-settings.html>.
updateWatcherSettings ::
(MonadBH m) =>
WatcherSettings ->
m Acknowledged
updateWatcherSettings = performBHRequest . Requests.updateWatcherSettings
-- | 'startWatcher' starts the Watcher service cluster-wide. Maps to
-- @POST /_watcher/_start@ and returns 'Acknowledged' on success. This is
-- the inverse of 'stopWatcher'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-start.html>.
startWatcher :: (MonadBH m) => m Acknowledged
startWatcher = performBHRequest Requests.startWatcher
-- | 'stopWatcher' stops the Watcher service cluster-wide. Maps to
-- @POST /_watcher/_stop@ and returns 'Acknowledged' on success. In-flight
-- watch executions are allowed to finish; no new watches will fire until
-- the service is restarted (via 'startWatcher').
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-stop.html>.
stopWatcher :: (MonadBH m) => m Acknowledged
stopWatcher = performBHRequest Requests.stopWatcher
------------------------------------------------------------------------------
-- Text structure API
-- | 'findStructure' inspects a raw plain-text / NDJSON sample and
-- returns the inferred structure. The request body is forwarded
-- verbatim (it is /not/ JSON); see 'Requests.findStructure'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/8.17/find-structure.html>.
findStructure :: (MonadBH m) => L.ByteString -> m FindStructureResponse
findStructure = performBHRequest . Requests.findStructure
-- | 'findStructureWith' is the fully-parameterised form of
-- 'findStructure'; see 'Requests.findStructureWith'.
findStructureWith ::
(MonadBH m) =>
FindStructureOptions ->
L.ByteString ->
m FindStructureResponse
findStructureWith opts =
performBHRequest . Requests.findStructureWith opts
-- | 'findMessageStructure' classifies an explicit list of log messages;
-- see 'Requests.findMessageStructure'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/8.17/find-message-structure.html>.
findMessageStructure ::
(MonadBH m) =>
FindMessageStructureRequest ->
m FindStructureResponse
findMessageStructure =
performBHRequest . Requests.findMessageStructure
-- | 'findMessageStructureWith' is the fully-parameterised form of
-- 'findMessageStructure'; see 'Requests.findMessageStructureWith'.
findMessageStructureWith ::
(MonadBH m) =>
FindMessageStructureOptions ->
FindMessageStructureRequest ->
m FindStructureResponse
findMessageStructureWith opts =
performBHRequest . Requests.findMessageStructureWith opts
-- | 'findFieldStructure' samples the stored values of a field in an
-- existing index; see 'Requests.findFieldStructure'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/8.17/find-field-structure.html>.
findFieldStructure ::
(MonadBH m) =>
Text ->
Text ->
m FindStructureResponse
findFieldStructure index field =
performBHRequest $ Requests.findFieldStructure index field
-- | 'findFieldStructureWith' is the fully-parameterised form of
-- 'findFieldStructure'; see 'Requests.findFieldStructureWith'.
findFieldStructureWith ::
(MonadBH m) =>
FindFieldStructureOptions ->
m FindStructureResponse
findFieldStructureWith =
performBHRequest . Requests.findFieldStructureWith
-- | 'testGrokPattern' compiles a grok pattern and matches it against
-- the supplied strings; see 'Requests.testGrokPattern'.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/8.17/test-grok-pattern.html>.
testGrokPattern ::
(MonadBH m) =>
TestGrokPatternRequest ->
m TestGrokPatternResponse
testGrokPattern = performBHRequest . Requests.testGrokPattern
-- | 'testGrokPatternWith' is the fully-parameterised form of
-- 'testGrokPattern'; see 'Requests.testGrokPatternWith'.
testGrokPatternWith ::
(MonadBH m) =>
TestGrokPatternOptions ->
TestGrokPatternRequest ->
m TestGrokPatternResponse
testGrokPatternWith opts =
performBHRequest . Requests.testGrokPatternWith opts
------------------------------------------------------------------------------
-- Transform API
-- | 'putTransform' creates a transform. Maps to
-- @PUT /_transform/{transform_id}@ and returns 'PutTransformResponse' on
-- success. Use 'putTransformWith' to forward the @defer_validation@ or
-- @timeout@ query parameters.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/create-transform.html>.
putTransform ::
(MonadBH m) =>
TransformId ->
TransformConfig ->
m PutTransformResponse
putTransform tid config =
performBHRequest $ Requests.putTransform tid config
-- | Like 'putTransform' but accepts 'PutTransformOptions' carrying the
-- documented @defer_validation@ and @timeout@ query parameters.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/create-transform.html>.
putTransformWith ::
(MonadBH m) =>
TransformId ->
TransformConfig ->
PutTransformOptions ->
m PutTransformResponse
putTransformWith tid config opts =
performBHRequest $ Requests.putTransformWith tid config opts
-- | 'updateTransform' updates an existing transform. Maps to
-- @POST /_transform/{transform_id}/_update@ and returns 'Acknowledged'
-- on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/update-transform.html>.
updateTransform ::
(MonadBH m) =>
TransformId ->
TransformConfig ->
m Acknowledged
updateTransform tid config =
performBHRequest $ Requests.updateTransform tid config
-- | Like 'updateTransform' but accepts 'UpdateTransformOptions' carrying
-- the documented @defer_validation@ query parameter.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/update-transform.html>.
updateTransformWith ::
(MonadBH m) =>
TransformId ->
TransformConfig ->
UpdateTransformOptions ->
m Acknowledged
updateTransformWith tid config opts =
performBHRequest $ Requests.updateTransformWith tid config opts
-- | 'getTransforms' lists transforms. @'Nothing'@ returns every transform
-- on the cluster; @'Just' tid@ returns just that one.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform.html>.
getTransforms ::
(MonadBH m) =>
Maybe TransformId ->
m TransformsResponse
getTransforms = performBHRequest . Requests.getTransforms
-- | Like 'getTransforms' but accepts 'GetTransformsOptions' carrying the
-- documented @from@, @size@, @allow_no_match@ and @exclude_generated@
-- query parameters.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform.html>.
getTransformsWith ::
(MonadBH m) =>
Maybe TransformId ->
GetTransformsOptions ->
m TransformsResponse
getTransformsWith mTid opts =
performBHRequest $ Requests.getTransformsWith mTid opts
-- | 'deleteTransform' deletes a transform by id. Maps to
-- @DELETE /_transform/{transform_id}@ and returns
-- 'DeleteTransformResponse' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-transform.html>.
deleteTransform ::
(MonadBH m) =>
TransformId ->
m DeleteTransformResponse
deleteTransform = performBHRequest . Requests.deleteTransform
-- | Like 'deleteTransform' but accepts 'DeleteTransformOptions' carrying
-- the documented @force@ and @delete_dest_index@ query parameters.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-transform.html>.
deleteTransformWith ::
(MonadBH m) =>
TransformId ->
DeleteTransformOptions ->
m DeleteTransformResponse
deleteTransformWith tid opts =
performBHRequest $ Requests.deleteTransformWith tid opts
-- | 'startTransform' starts a transform. Maps to
-- @POST /_transform/{transform_id}/_start@ and returns 'Acknowledged'
-- on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/start-transform.html>.
startTransform ::
(MonadBH m) =>
TransformId ->
m Acknowledged
startTransform = performBHRequest . Requests.startTransform
-- | Like 'startTransform' but accepts 'StartTransformOptions' carrying
-- the documented @defer_validation@ and @timeout@ query parameters.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/start-transform.html>.
startTransformWith ::
(MonadBH m) =>
TransformId ->
StartTransformOptions ->
m Acknowledged
startTransformWith tid opts =
performBHRequest $ Requests.startTransformWith tid opts
-- | 'stopTransform' stops a transform. Maps to
-- @POST /_transform/{transform_id}/_stop@ and returns
-- 'StopTransformResponse' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/stop-transform.html>.
stopTransform ::
(MonadBH m) =>
TransformId ->
m StopTransformResponse
stopTransform = performBHRequest . Requests.stopTransform
-- | Like 'stopTransform' but accepts 'StopTransformOptions' carrying the
-- documented @wait_for_checkpoint@, @wait_for_completion@, @timeout@ and
-- @allow_no_match@ query parameters.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/stop-transform.html>.
stopTransformWith ::
(MonadBH m) =>
TransformId ->
StopTransformOptions ->
m StopTransformResponse
stopTransformWith tid opts =
performBHRequest $ Requests.stopTransformWith tid opts
-- | 'previewTransform' previews a transform configuration. Maps to
-- @POST /_transform/_preview@ and returns 'PreviewTransformResponse' on
-- success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/preview-transform.html>.
previewTransform ::
(MonadBH m) =>
TransformConfig ->
m PreviewTransformResponse
previewTransform = performBHRequest . Requests.previewTransform
-- | Like 'previewTransform' but accepts 'PreviewTransformOptions' carrying
-- the documented @timeout@ query parameter.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/preview-transform.html>.
previewTransformWith ::
(MonadBH m) =>
TransformConfig ->
PreviewTransformOptions ->
m PreviewTransformResponse
previewTransformWith config opts =
performBHRequest $ Requests.previewTransformWith config opts
-- | 'getTransformStats' reports execution statistics for transforms.
-- @'Nothing'@ returns stats for every transform; @'Just' tid@ for one.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform-stats.html>.
getTransformStats ::
(MonadBH m) =>
Maybe TransformId ->
m TransformStatsResponse
getTransformStats = performBHRequest . Requests.getTransformStats
-- | Like 'getTransformStats' but accepts 'GetTransformStatsOptions'
-- carrying the documented @from@, @size@ and @allow_no_match@ query
-- parameters.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform-stats.html>.
getTransformStatsWith ::
(MonadBH m) =>
Maybe TransformId ->
GetTransformStatsOptions ->
m TransformStatsResponse
getTransformStatsWith mTid opts =
performBHRequest $ Requests.getTransformStatsWith mTid opts
-- | 'explainTransform' explains the state of a transform. Maps to
-- @GET /_transform/{transform_id}/_explain@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/explain-transform.html>.
explainTransform ::
(MonadBH m) =>
TransformId ->
m TransformExplainResponse
explainTransform = performBHRequest . Requests.explainTransform
-- | 'getMigrationDeprecations' lists the deprecation warnings that would
-- affect a major-version upgrade.
--
-- * @'Nothing'@ → @GET /_migration/deprecations@ scans every index,
-- data stream, template, ILM policy and cluster\/node\/ML setting.
-- * @'Just' ix@ → @GET /{ix}/_migration/deprecations@ restricts the
-- @index_settings@ section to the supplied index.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/migration-api-deprecation.html>.
getMigrationDeprecations ::
(MonadBH m) =>
Maybe IndexName ->
m MigrationDeprecations
getMigrationDeprecations = performBHRequest . Requests.getMigrationDeprecations
-- | 'getSystemFeatures' reports the migration status of every ES
-- feature that stores versioned configuration. Maps to
-- @GET /_migration/system_features@.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/migration-api-feature-upgrade.html>.
getSystemFeatures :: (MonadBH m) => m FeatureUpgradeStatus
getSystemFeatures = performBHRequest Requests.getSystemFeatures
-- | 'upgradeSystemFeatures' kicks off the feature upgrade. Maps to
-- @POST /_migration/system_features@ and returns 'Acknowledged' on
-- success. The upgrade runs in the background; poll 'getSystemFeatures'
-- to observe progress. Mutates cluster state — call deliberately.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/migration-api-feature-upgrade.html>.
upgradeSystemFeatures :: (MonadBH m) => m Acknowledged
upgradeSystemFeatures = performBHRequest Requests.upgradeSystemFeatures
-- | 'deleteAsyncSearch' deletes an async search result and its context by id.
-- Maps to @DELETE /_async_search/{id}@ and returns 'Acknowledged' on success.
--
-- See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/async-search.html#delete-async-search>.
deleteAsyncSearch :: (MonadBH m) => AsyncSearchId -> m Acknowledged
deleteAsyncSearch = performBHRequest . Requests.deleteAsyncSearch
-- | 'submitAsyncSearch' submits a 'Search' for asynchronous execution,
-- returning immediately with an id and partial results. See
-- <https://www.elastic.co/guide/en/elasticsearch/reference/7.17/async-search.html#submit-async-search>.
submitAsyncSearch ::
forall a m.
(FromJSON a, MonadBH m) =>
Search ->
m (AsyncSearchResult a)
submitAsyncSearch = performBHRequest . Requests.submitAsyncSearch
-- | Like 'submitAsyncSearch' but accepts 'AsyncSearchSubmitOptions'
-- carrying the URI parameters documented for @POST /_async_search@
-- (@wait_for_completion@, @keep_on_completion@, @keep_alive@,
-- @batched_reduce_size@, @ccs_minimize_roundtrips@).
-- 'defaultAsyncSearchSubmitOptions' makes this byte-for-byte equivalent
-- to 'submitAsyncSearch'.
submitAsyncSearchWith ::
forall a m.
(FromJSON a, MonadBH m) =>
AsyncSearchSubmitOptions ->
Search ->
m (AsyncSearchResult a)
submitAsyncSearchWith opts = performBHRequest . Requests.submitAsyncSearchWith opts