diff --git a/dcicutils/_version.py b/dcicutils/_version.py index 940f292c3..1582477c3 100644 --- a/dcicutils/_version.py +++ b/dcicutils/_version.py @@ -1,4 +1,4 @@ """Version information.""" # The following line *must* be the last in the module, exactly as formatted: -__version__ = "0.3.1" +__version__ = "0.3.2" diff --git a/dcicutils/es_utils.py b/dcicutils/es_utils.py index b2ad065e1..e986aeae5 100644 --- a/dcicutils/es_utils.py +++ b/dcicutils/es_utils.py @@ -8,35 +8,41 @@ ''' -def get_index_list(client, name, days_old=0, timestring='%Y.%m.%d', ilo=None): - if ilo is None: - ilo = curator.IndexList(client) - - ilo.filter_by_regex(kind='prefix', value=name) - ilo.filter_by_age(source='name', direction='older', timestring=timestring, unit='days', - unit_count=days_old) - return ilo - - -def create_es_client(es_url, use_aws_auth=False): +def create_es_client(es_url, use_aws_auth=True, **options): + """ + Use to create a ES that supports the signature version 4 signing process. + Need to do role-based IAM access control for AWS hosted ES. + Takes a string es server url, boolean whether or not to use aws auth + signing procedure, and any additional kwargs that will be passed to + creation of the Elasticsearch client. + """ + # may be passed in as a list, as was done previously if isinstance(es_url, (list, tuple)): - addresses = es_url - else: - addresses = [es_url, ] + es_url = es_url[0] es_options = {'retry_on_timeout': True, - 'maxsize': 50 # parallellism... - } + 'maxsize': 50} # parallellism... if use_aws_auth: - host = addresses[0].split('//') + host = es_url.split('//') # remove schema from url host = host[-1].split(":") auth = BotoAWSRequestsAuth(aws_host=host[0].rstrip('/'), aws_region='us-east-1', aws_service='es') es_options['connection_class'] = RequestsHttpConnection es_options['http_auth'] = auth + es_options.update(**options) # add any given keyword options at the end - return Elasticsearch(addresses, **es_options) + return Elasticsearch(es_url, **es_options) + + +def get_index_list(client, name, days_old=0, timestring='%Y.%m.%d', ilo=None): + if ilo is None: + ilo = curator.IndexList(client) + + ilo.filter_by_regex(kind='prefix', value=name) + ilo.filter_by_age(source='name', direction='older', timestring=timestring, unit='days', + unit_count=days_old) + return ilo def create_snapshot_repo(client, repo_name, s3_bucket): diff --git a/setup.py b/setup.py index 59cdc5923..47624aa13 100644 --- a/setup.py +++ b/setup.py @@ -27,8 +27,8 @@ packages=['dcicutils'], include_package_data=True, zip_safe=False, - author='$dn Team at Harvard Medical School', - author_email='jeremy_johnson@hms.harvard.edu', + author='4DN Team at Harvard Medical School', + author_email='burak_alver@hms.harvard.edu', url='https://data.4dnucleome.org', license='MIT', install_requires=requires,