Tests/store_packs.py
def _parse_pack_metadata(user_metadata, pack_content_items, pack_id, integration_images, author_image):
        """Parses pack metadata according to issue #19786 and #20091. Part of field may change over the time.

        Args:
            user_metadata (dict): user metadata that was created in pack initialization.
            pack_content_items (dict): content items located inside specific pack.
            pack_id (str): pack unique identifier.
            integration_images (list): list of gcs uploaded integration images.
            author_image (str): gcs uploaded author image

        Returns:
            dict: parsed pack metadata.

        """
        pack_metadata = {}
        # part of old packs are initialized with empty list
        user_metadata = {} if isinstance(user_metadata, list) else user_metadata
        pack_metadata['name'] = user_metadata.get('name') if user_metadata.get('name') else pack_id
        pack_metadata['id'] = pack_id
        pack_metadata['description'] = user_metadata.get('description') if user_metadata.get('description') else pack_id
        pack_metadata['created'] = user_metadata.get('created', datetime.utcnow().strftime(Pack.DATE_FORMAT))
        pack_metadata['updated'] = datetime.utcnow().strftime(Pack.DATE_FORMAT)
        pack_metadata['support'] = user_metadata.get('support', '')
        pack_metadata['supportDetails'] = {}
        support_url = user_metadata.get('url')
        if support_url:
            pack_metadata['supportDetails']['url'] = support_url

        support_email = user_metadata.get('email')
        if support_email:
            pack_metadata['supportDetails']['email'] = support_email
        pack_metadata['author'] = user_metadata.get('author', '')
        # todo get vendor image and upload to storage
        pack_metadata['authorImage'] = author_image
        is_beta = user_metadata.get('beta', False)
        pack_metadata['beta'] = bool(strtobool(is_beta)) if isinstance(is_beta, str) else is_beta
        is_deprecated = user_metadata.get('deprecated', False)
        pack_metadata['deprecated'] = bool(strtobool(is_beta)) if isinstance(is_deprecated, str) else is_deprecated
        pack_metadata['certification'] = user_metadata.get('certification', '')
        try:
            pack_metadata['price'] = int(user_metadata.get('price'))
        except Exception as e:
            print_warning(f"{pack_id} pack price is not valid. The price was set to 0. Additional details {e}")
            pack_metadata['price'] = 0
        pack_metadata['serverMinVersion'] = user_metadata.get('serverMinVersion', '')
        pack_metadata['serverLicense'] = user_metadata.get('serverLicense', '')
        pack_metadata['currentVersion'] = user_metadata.get('currentVersion', '')
        # todo check if this field is necessary
        pack_metadata['general'] = input_to_list(user_metadata.get('general'))
        pack_metadata['tags'] = input_to_list(user_metadata.get('tags'))
        pack_metadata['categories'] = input_to_list(user_metadata.get('categories'))
        pack_metadata['contentItems'] = {DIR_NAME_TO_CONTENT_TYPE[k]: v for (k, v) in pack_content_items.items()
                                         if k in DIR_NAME_TO_CONTENT_TYPE and v}
        # todo collect all dependencies integrations display name
        pack_metadata['integrations'] = integration_images
        pack_metadata['useCases'] = input_to_list(user_metadata.get('useCases'))
        pack_metadata['keywords'] = input_to_list(user_metadata.get('keywords'))
        pack_metadata['dependencies'] = user_metadata.get('dependencies', {})

        return pack_metadata
Parses pack metadata according to issue #19786 and #20091. Part of field may change over the time.

        Args:
            user_metadata (dict): user metadata that was created in pack initialization.
            pack_content_items (dict): content items located inside specific pack.
            pack_id (str): pack unique identifier.
            integration_images (list): list of gcs uploaded integration images.
            author_image (str): gcs uploaded author image

        Returns:
            dict: parsed pack metadata.

        
Parses pack metadata according to issue #19786 and #20091. Part of field may change over the time.
Parses pack metadata according to issue #19786 and #20091 . Part of field may change over the time .
def _parse_pack_metadata(user_metadata, pack_content_items, pack_id, integration_images, author_image):
        pack_metadata = {}
        user_metadata = {} if isinstance(user_metadata, list) else user_metadata
        pack_metadata['name'] = user_metadata.get('name') if user_metadata.get('name') else pack_id
        pack_metadata['id'] = pack_id
        pack_metadata['description'] = user_metadata.get('description') if user_metadata.get('description') else pack_id
        pack_metadata['created'] = user_metadata.get('created', datetime.utcnow().strftime(Pack.DATE_FORMAT))
        pack_metadata['updated'] = datetime.utcnow().strftime(Pack.DATE_FORMAT)
        pack_metadata['support'] = user_metadata.get('support', '')
        pack_metadata['supportDetails'] = {}
        support_url = user_metadata.get('url')
        if support_url:
            pack_metadata['supportDetails']['url'] = support_url
        support_email = user_metadata.get('email')
        if support_email:
            pack_metadata['supportDetails']['email'] = support_email
        pack_metadata['author'] = user_metadata.get('author', '')
        pack_metadata['authorImage'] = author_image
        is_beta = user_metadata.get('beta', False)
        pack_metadata['beta'] = bool(strtobool(is_beta)) if isinstance(is_beta, str) else is_beta
        is_deprecated = user_metadata.get('deprecated', False)
        pack_metadata['deprecated'] = bool(strtobool(is_beta)) if isinstance(is_deprecated, str) else is_deprecated
        pack_metadata['certification'] = user_metadata.get('certification', '')
        try:
            pack_metadata['price'] = int(user_metadata.get('price'))
        except Exception as e:
            print_warning(f"{pack_id} pack price is not valid. The price was set to 0. Additional details {e}")
            pack_metadata['price'] = 0
        pack_metadata['serverMinVersion'] = user_metadata.get('serverMinVersion', '')
        pack_metadata['serverLicense'] = user_metadata.get('serverLicense', '')
        pack_metadata['currentVersion'] = user_metadata.get('currentVersion', '')
        pack_metadata['general'] = input_to_list(user_metadata.get('general'))
        pack_metadata['tags'] = input_to_list(user_metadata.get('tags'))
        pack_metadata['categories'] = input_to_list(user_metadata.get('categories'))
        pack_metadata['contentItems'] = {DIR_NAME_TO_CONTENT_TYPE[k]: v for (k, v) in pack_content_items.items()
                                         if k in DIR_NAME_TO_CONTENT_TYPE and v}
        pack_metadata['integrations'] = integration_images
        pack_metadata['useCases'] = input_to_list(user_metadata.get('useCases'))
        pack_metadata['keywords'] = input_to_list(user_metadata.get('keywords'))
        pack_metadata['dependencies'] = user_metadata.get('dependencies', {})
        return pack_metadata
def _parse_pack_metadata ( user_metadata , pack_content_items , pack_id , integration_images , author_image ) : pack_metadata = { } user_metadata = { } if isinstance ( user_metadata , list ) else user_metadata pack_metadata [ 'name' ] = user_metadata . get ( 'name' ) if user_metadata . get ( 'name' ) else pack_id pack_metadata [ 'id' ] = pack_id pack_metadata [ 'description' ] = user_metadata . get ( 'description' ) if user_metadata . get ( 'description' ) else pack_id pack_metadata [ 'created' ] = user_metadata . get ( 'created' , datetime . utcnow ( ) . strftime ( Pack . DATE_FORMAT ) ) pack_metadata [ 'updated' ] = datetime . utcnow ( ) . strftime ( Pack . DATE_FORMAT ) pack_metadata [ 'support' ] = user_metadata . get ( 'support' , '' ) pack_metadata [ 'supportDetails' ] = { } support_url = user_metadata . get ( 'url' ) if support_url : pack_metadata [ 'supportDetails' ] [ 'url' ] = support_url support_email = user_metadata . get ( 'email' ) if support_email : pack_metadata [ 'supportDetails' ] [ 'email' ] = support_email pack_metadata [ 'author' ] = user_metadata . get ( 'author' , '' ) pack_metadata [ 'authorImage' ] = author_image is_beta = user_metadata . get ( 'beta' , False ) pack_metadata [ 'beta' ] = bool ( strtobool ( is_beta ) ) if isinstance ( is_beta , str ) else is_beta is_deprecated = user_metadata . get ( 'deprecated' , False ) pack_metadata [ 'deprecated' ] = bool ( strtobool ( is_beta ) ) if isinstance ( is_deprecated , str ) else is_deprecated pack_metadata [ 'certification' ] = user_metadata . get ( 'certification' , '' ) try : pack_metadata [ 'price' ] = int ( user_metadata . get ( 'price' ) ) except Exception as e : print_warning ( f"{pack_id} pack price is not valid. The price was set to 0. Additional details {e}" ) pack_metadata [ 'price' ] = 0 pack_metadata [ 'serverMinVersion' ] = user_metadata . get ( 'serverMinVersion' , '' ) pack_metadata [ 'serverLicense' ] = user_metadata . get ( 'serverLicense' , '' ) pack_metadata [ 'currentVersion' ] = user_metadata . get ( 'currentVersion' , '' ) pack_metadata [ 'general' ] = input_to_list ( user_metadata . get ( 'general' ) ) pack_metadata [ 'tags' ] = input_to_list ( user_metadata . get ( 'tags' ) ) pack_metadata [ 'categories' ] = input_to_list ( user_metadata . get ( 'categories' ) ) pack_metadata [ 'contentItems' ] = { DIR_NAME_TO_CONTENT_TYPE [ k ] : v for ( k , v ) in pack_content_items . items ( ) if k in DIR_NAME_TO_CONTENT_TYPE and v } pack_metadata [ 'integrations' ] = integration_images pack_metadata [ 'useCases' ] = input_to_list ( user_metadata . get ( 'useCases' ) ) pack_metadata [ 'keywords' ] = input_to_list ( user_metadata . get ( 'keywords' ) ) pack_metadata [ 'dependencies' ] = user_metadata . get ( 'dependencies' , { } ) return pack_metadata
Parses pack metadata according to issue #19786 and #20091.
Parses pack metadata according to issue #19786 and #20091 .
"""Parses pack metadata according to issue #19786 and #20091. Part of field may change over the time.

        Args:
            user_metadata (dict): user metadata that was created in pack initialization.
            pack_content_items (dict): content items located inside specific pack.
            pack_id (str): pack unique identifier.
            integration_images (list): list of gcs uploaded integration images.
            author_image (str): gcs uploaded author image

        Returns:
            dict: parsed pack metadata.

        """ # part of old packs are initialized with empty list # todo get vendor image and upload to storage # todo check if this field is necessary # todo collect all dependencies integrations display name
parsed pack metadata.
parsed pack metadata .
dict
user_metadata
user metadata that was created in pack initialization.
user metadata that was created in pack initialization .
pack_content_items
content items located inside specific pack.
content items located inside specific pack .
pack_id
pack unique identifier.
pack unique identifier .
integration_images
list of gcs uploaded integration images.
list of gcs uploaded integration images .
author_image
gcs uploaded author image
gcs uploaded author image