original_docstring: Context manager to create an Elasticsearch snapshot for current collection index.
  
      Will delete the snapshot after context finished.
      
docstring: Context manager to create an Elasticsearch snapshot for current collection index.
  Will delete the snapshot after context finished.
docstring_tokens: Context manager to create an Elasticsearch snapshot for current collection index . Will delete the snapshot after context finished .
code: def snapshot_repo():
      """Context manager to create an Elasticsearch snapshot for current collection index.
  
      Will delete the snapshot after context finished.
      """
  
      es_index = collections.current().es_index
      id = f'{es_index}-{datetime.utcnow().isoformat().lower()}'
      repo = f'{ES_URL}/_snapshot/{id}'
      repo_path = f'/opt/hoover/es-snapshots/{id}'
  
      log.info('Create snapshot repo')
      repo_resp = put_json(repo, {
          'type': 'fs',
          'settings': {
              'location': repo_path,
              'compress': True,
          },
      })
      check_response(repo_resp)
  
      try:
          yield (repo, repo_path)
  
      finally:
          log.info('Delete snapshot repo')
          delete_resp = requests.delete(repo)
          check_response(delete_resp)
  
          log.info('Remove repo files')
          shutil.rmtree(repo_path)
code_tokens: def snapshot_repo ( ) : es_index = collections . current ( ) . es_index id = f'{es_index}-{datetime.utcnow().isoformat().lower()}' repo = f'{ES_URL}/_snapshot/{id}' repo_path = f'/opt/hoover/es-snapshots/{id}' log . info ( 'Create snapshot repo' ) repo_resp = put_json ( repo , { 'type' : 'fs' , 'settings' : { 'location' : repo_path , 'compress' : True , } , } ) check_response ( repo_resp ) try : yield ( repo , repo_path ) finally : log . info ( 'Delete snapshot repo' ) delete_resp = requests . delete ( repo ) check_response ( delete_resp ) log . info ( 'Remove repo files' ) shutil . rmtree ( repo_path )
short_docstring: Context manager to create an Elasticsearch snapshot for current collection index.
short_docstring_tokens: Context manager to create an Elasticsearch snapshot for current collection index .
comment: """Context manager to create an Elasticsearch snapshot for current collection index.
  
      Will delete the snapshot after context finished.
      """