Filtering
Some checks are pending
gl/check check status: pending (3e3e86ceca03ea7c1284bbd033f2a35422b6d99d)

This commit is contained in:
SebastianGode 2023-06-23 11:47:26 +02:00
parent 2ed3bc4bf5
commit 3e3e86ceca

View File

@ -22,6 +22,11 @@ def parse_args():
help='Option deletes old index with the same name and creates new ' help='Option deletes old index with the same name and creates new '
'one.' 'one.'
) )
parser.add_argument(
'--all-doc-types',
action='store_true',
help='Upload all doc-types instead of only umn, api-ref and dev'
)
parser.add_argument( parser.add_argument(
'--hosts', '--hosts',
metavar='<host:port>', metavar='<host:port>',
@ -62,7 +67,8 @@ def main():
logging.debug("Obtaining data from otc_metadata") logging.debug("Obtaining data from otc_metadata")
data = getData( data = getData(
environment=args.target_environment environment=args.target_environment,
all_doc_types=args.all_doc_types
) )
logging.debug("Indexing data into OpenSearch") logging.debug("Indexing data into OpenSearch")
@ -76,10 +82,16 @@ def main():
) )
def getData(environment): def getData(environment, all_doc_types):
return metadata.service_types_with_doc_types( metadatadata = metadata.service_types_with_doc_types(
environment=environment environment=environment
) )
if not all_doc_types:
for i, doc in enumerate(metadatadata["docs"], 0):
if doc["type"] not in ["umn", "api-ref", "dev"]:
metadatadata["docs"].pop(i)
return metadatadata
def indexData(deleteIndex, hosts, index, username, password, data): def indexData(deleteIndex, hosts, index, username, password, data):