當前位置: 首頁>>代碼示例>>Python>>正文


Python ActionAliasAPI.validate方法代碼示例

本文整理匯總了Python中st2common.models.api.action.ActionAliasAPI.validate方法的典型用法代碼示例。如果您正苦於以下問題:Python ActionAliasAPI.validate方法的具體用法?Python ActionAliasAPI.validate怎麽用?Python ActionAliasAPI.validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在st2common.models.api.action.ActionAliasAPI的用法示例。


在下文中一共展示了ActionAliasAPI.validate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_action_alias_db

# 需要導入模塊: from st2common.models.api.action import ActionAliasAPI [as 別名]
# 或者: from st2common.models.api.action.ActionAliasAPI import validate [as 別名]
    def _get_action_alias_db(self, pack, action_alias, ignore_metadata_file_error=False):
        """
        Retrieve ActionAliasDB object.

        :param ignore_metadata_file_error: True to ignore the error when we can't infer
                                            metadata_file attribute (e.g. inside tests).
        :type ignore_metadata_file_error: ``bool``
        """
        content = self._meta_loader.load(action_alias)
        pack_field = content.get('pack', None)
        if not pack_field:
            content['pack'] = pack
            pack_field = pack
        if pack_field != pack:
            raise Exception('Model is in pack "%s" but field "pack" is different: %s' %
                            (pack, pack_field))

        # Add in "metadata_file" attribute which stores path to the pack metadata file relative to
        # the pack directory
        try:
            metadata_file = content_utils.get_relative_path_to_pack_file(pack_ref=pack,
                                                                         file_path=action_alias,
                                                                         use_pack_cache=True)
        except ValueError as e:
            if not ignore_metadata_file_error:
                raise e
        else:
            content['metadata_file'] = metadata_file

        action_alias_api = ActionAliasAPI(**content)
        action_alias_api.validate()
        action_alias_db = ActionAliasAPI.to_model(action_alias_api)

        return action_alias_db
開發者ID:nzlosh,項目名稱:st2,代碼行數:36,代碼來源:aliasesregistrar.py

示例2: _register_action_alias

# 需要導入模塊: from st2common.models.api.action import ActionAliasAPI [as 別名]
# 或者: from st2common.models.api.action.ActionAliasAPI import validate [as 別名]
    def _register_action_alias(self, pack, action_alias):
        content = self._meta_loader.load(action_alias)
        pack_field = content.get('pack', None)
        if not pack_field:
            content['pack'] = pack
            pack_field = pack
        if pack_field != pack:
            raise Exception('Model is in pack "%s" but field "pack" is different: %s' %
                            (pack, pack_field))

        action_alias_api = ActionAliasAPI(**content)
        action_alias_api.validate()
        action_alias_db = ActionAliasAPI.to_model(action_alias_api)

        try:
            action_alias_db.id = ActionAlias.get_by_name(action_alias_api.name).id
        except ValueError:
            LOG.info('ActionAlias %s not found. Creating new one.', action_alias)

        try:
            action_alias_db = ActionAlias.add_or_update(action_alias_db)
            extra = {'action_alias_db': action_alias_db}
            LOG.audit('Action alias updated. Action alias %s from %s.', action_alias_db,
                      action_alias, extra=extra)
        except Exception:
            LOG.exception('Failed to create action alias %s.', action_alias_api.name)
            raise
開發者ID:ruslantum,項目名稱:st2,代碼行數:29,代碼來源:aliasesregistrar.py

示例3: _get_action_alias_db

# 需要導入模塊: from st2common.models.api.action import ActionAliasAPI [as 別名]
# 或者: from st2common.models.api.action.ActionAliasAPI import validate [as 別名]
    def _get_action_alias_db(self, pack, action_alias):
        """
        Retrieve ActionAliasDB object.
        """
        content = self._meta_loader.load(action_alias)
        pack_field = content.get("pack", None)
        if not pack_field:
            content["pack"] = pack
            pack_field = pack
        if pack_field != pack:
            raise Exception('Model is in pack "%s" but field "pack" is different: %s' % (pack, pack_field))

        action_alias_api = ActionAliasAPI(**content)
        action_alias_api.validate()
        action_alias_db = ActionAliasAPI.to_model(action_alias_api)

        return action_alias_db
開發者ID:rlugojr,項目名稱:st2,代碼行數:19,代碼來源:aliasesregistrar.py


注:本文中的st2common.models.api.action.ActionAliasAPI.validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。