import * as Either from 'fp-ts/lib/Either' ; import * as TaskEither from 'fp-ts/lib/TaskEither' ; import { ElasticsearchClient } from '../../../elasticsearch' ; import { catchRetryableEsClientErrors , RetryableEsClientError , } from './catch_retryable_es_client_errors' ; internal export interface RemoveWriteBlockParams { client : ElasticsearchClient ; index : string ; } /**
 * Removes a write block from an index
 */ export const removeWriteBlock = ( { client , index , } ) : TaskEither . TaskEither < RetryableEsClientError , 'remove_write_block_succeeded' > => ( ) => { return client . indices . putSettings < { acknowledged : boolean ; shards_acknowledged : boolean ; } > ( { index , preserve_existing : true , body : { blocks : { write : false , } , } , } , { maxRetries : 0 } ) . then ( ( res ) => { return res . body . acknowledged === true ? Either . right ( 'remove_write_block_succeeded' as const ) : Either . left ( { type : 'retryable_es_client_error' as const , message : 'remove_write_block_failed' , } ) ; } ) . catch ( catchRetryableEsClientErrors ) ; } ;