本文整理汇总了Python中st2common.models.api.tag.TagsHelper类的典型用法代码示例。如果您正苦于以下问题:Python TagsHelper类的具体用法?Python TagsHelper怎么用?Python TagsHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TagsHelper类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: to_model
def to_model(cls, action):
name = getattr(action, 'name', None)
description = getattr(action, 'description', None)
enabled = bool(getattr(action, 'enabled', True))
entry_point = str(action.entry_point)
pack = str(action.pack)
runner_type = {'name': str(action.runner_type)}
parameters = getattr(action, 'parameters', dict())
tags = TagsHelper.to_model(getattr(action, 'tags', []))
ref = ResourceReference.to_string_reference(pack=pack, name=name)
if getattr(action, 'notify', None):
notify = NotificationsHelper.to_model(action.notify)
else:
# We use embedded document model for ``notify`` in action model. If notify is
# set notify to None, Mongoengine interprets ``None`` as unmodified
# field therefore doesn't delete the embedded document. Therefore, we need
# to use an empty document.
notify = NotificationsHelper.to_model({})
model = cls.model(name=name, description=description, enabled=enabled,
entry_point=entry_point, pack=pack, runner_type=runner_type,
tags=tags, parameters=parameters, notify=notify,
ref=ref)
return model
开发者ID:Bala96,项目名称:st2,代码行数:26,代码来源:action.py
示例2: to_model
def to_model(cls, triggertype):
model = super(cls, cls).to_model(triggertype)
model.pack = getattr(triggertype, 'pack', None)
model.payload_schema = getattr(triggertype, 'payload_schema', {})
model.parameters_schema = getattr(triggertype, 'parameters_schema', {})
model.tags = TagsHelper.to_model(getattr(triggertype, 'tags', []))
return model
开发者ID:BlazeMediaGroup,项目名称:st2,代码行数:7,代码来源:reactor.py
示例3: to_model
def to_model(cls, action):
name = getattr(action, "name", None)
description = getattr(action, "description", None)
enabled = bool(getattr(action, "enabled", True))
entry_point = str(action.entry_point)
pack = str(action.pack)
runner_type = {"name": str(action.runner_type)}
parameters = getattr(action, "parameters", dict())
tags = TagsHelper.to_model(getattr(action, "tags", []))
ref = ResourceReference.to_string_reference(pack=pack, name=name)
if getattr(action, "notify", None):
notify = NotificationsHelper.to_model(action.notify)
else:
notify = None
model = cls.model(
name=name,
description=description,
enable=enabled,
enabled=enabled,
entry_point=entry_point,
pack=pack,
runner_type=runner_type,
tags=tags,
parameters=parameters,
notify=notify,
ref=ref,
)
return model
开发者ID:jspittman,项目名称:st2,代码行数:31,代码来源:action.py
示例4: to_model
def to_model(cls, rule):
kwargs = {}
kwargs['name'] = getattr(rule, 'name', None)
kwargs['description'] = getattr(rule, 'description', None)
# Create a trigger for the provided rule
trigger_db = TriggerService.create_trigger_db_from_rule(rule)
kwargs['trigger'] = reference.get_str_resource_ref_from_model(trigger_db)
# Validate trigger parameters
validator.validate_trigger_parameters(trigger_db=trigger_db)
kwargs['pack'] = getattr(rule, 'pack', DEFAULT_PACK_NAME)
kwargs['ref'] = ResourceReference.to_string_reference(pack=kwargs['pack'],
name=kwargs['name'])
# Validate criteria
kwargs['criteria'] = dict(getattr(rule, 'criteria', {}))
validator.validate_criteria(kwargs['criteria'])
kwargs['action'] = ActionExecutionSpecDB(ref=rule.action['ref'],
parameters=rule.action.get('parameters', {}))
rule_type = dict(getattr(rule, 'type', {}))
if rule_type:
kwargs['type'] = RuleTypeSpecDB(ref=rule_type['ref'],
parameters=rule_type.get('parameters', {}))
kwargs['enabled'] = getattr(rule, 'enabled', False)
kwargs['tags'] = TagsHelper.to_model(getattr(rule, 'tags', []))
model = cls.model(**kwargs)
return model
开发者ID:hejin,项目名称:st2,代码行数:33,代码来源:rule.py
示例5: to_model
def to_model(cls, rule):
name = getattr(rule, 'name', None)
description = getattr(rule, 'description', None)
# Create a trigger for the provided rule
trigger_db = TriggerService.create_trigger_db_from_rule(rule)
trigger = reference.get_str_resource_ref_from_model(trigger_db)
criteria = dict(getattr(rule, 'criteria', {}))
pack = getattr(rule, 'pack', DEFAULT_PACK_NAME)
ref = ResourceReference.to_string_reference(pack=pack, name=name)
# Validate criteria
validator.validate_criteria(criteria)
# Validate trigger parameters
validator.validate_trigger_parameters(trigger_db=trigger_db)
action = ActionExecutionSpecDB(ref=rule.action['ref'],
parameters=rule.action['parameters'])
enabled = rule.enabled
tags = TagsHelper.to_model(getattr(rule, 'tags', []))
model = cls.model(name=name, description=description, pack=pack, ref=ref, trigger=trigger,
criteria=criteria, action=action, enabled=enabled, tags=tags)
return model
开发者ID:joshgre,项目名称:st2,代码行数:27,代码来源:rule.py
示例6: from_model
def from_model(cls, model, mask_secrets=False):
action = cls._from_model(model)
action['runner_type'] = action['runner_type']['name']
action['tags'] = TagsHelper.from_model(model.tags)
if getattr(model, 'notify', None):
action['notify'] = NotificationsHelper.from_model(model.notify)
return cls(**action)
开发者ID:hejin,项目名称:st2,代码行数:9,代码来源:action.py
示例7: to_model
def to_model(cls, trigger_type):
name = getattr(trigger_type, 'name', None)
description = getattr(trigger_type, 'description', None)
pack = getattr(trigger_type, 'pack', None)
payload_schema = getattr(trigger_type, 'payload_schema', {})
parameters_schema = getattr(trigger_type, 'parameters_schema', {})
tags = TagsHelper.to_model(getattr(trigger_type, 'tags', []))
model = cls.model(name=name, description=description, pack=pack,
payload_schema=payload_schema, parameters_schema=parameters_schema,
tags=tags)
return model
开发者ID:KenMercusLai,项目名称:st2,代码行数:12,代码来源:trigger.py
示例8: from_model
def from_model(cls, model):
rule = cls._from_model(model)
trigger_db = reference.get_model_by_resource_ref(Trigger, model.trigger)
if not trigger_db:
raise ValueError('Missing TriggerDB object for rule %s' % (rule['id']))
rule['trigger'] = vars(TriggerAPI.from_model(trigger_db))
del rule['trigger']['id']
del rule['trigger']['name']
rule['tags'] = TagsHelper.from_model(model.tags)
return cls(**rule)
开发者ID:bsyk,项目名称:st2,代码行数:12,代码来源:rule.py
示例9: to_model
def to_model(cls, rule):
model = super(cls, cls).to_model(rule)
trigger_db = TriggerService.create_trigger_db_from_rule(rule)
model.trigger = reference.get_str_resource_ref_from_model(trigger_db)
model.criteria = dict(getattr(rule, 'criteria', {}))
validator.validate_criteria(model.criteria)
model.action = ActionExecutionSpecDB()
model.action.ref = rule.action['ref']
model.action.parameters = rule.action['parameters']
model.enabled = rule.enabled
model.tags = TagsHelper.to_model(getattr(rule, 'tags', []))
return model
开发者ID:BlazeMediaGroup,项目名称:st2,代码行数:12,代码来源:rule.py
示例10: to_model
def to_model(cls, action):
model = super(cls, cls).to_model(action)
model.enabled = bool(action.enabled)
model.entry_point = str(action.entry_point)
model.pack = str(action.pack)
model.runner_type = {'name': str(action.runner_type)}
model.parameters = getattr(action, 'parameters', dict())
model.tags = TagsHelper.to_model(getattr(action, 'tags', []))
model.ref = ResourceReference.to_string_reference(pack=model.pack, name=model.name)
if getattr(action, 'notify', None):
model.notify = NotificationsHelper.to_model(action.notify)
return model
开发者ID:rgaertner,项目名称:st2,代码行数:13,代码来源:action.py
示例11: from_model
def from_model(cls, model, mask_secrets=False):
rule = cls._from_model(model, mask_secrets=mask_secrets)
trigger_db = reference.get_model_by_resource_ref(Trigger, model.trigger)
if not trigger_db:
raise ValueError('Missing TriggerDB object for rule %s' % (rule['id']))
rule['trigger'] = {
'type': trigger_db.type,
'parameters': trigger_db.parameters,
'ref': model.trigger
}
rule['tags'] = TagsHelper.from_model(model.tags)
return cls(**rule)
开发者ID:alexmakarski,项目名称:st2,代码行数:13,代码来源:rule.py
示例12: to_model
def to_model(cls, rule):
kwargs = {}
kwargs['name'] = getattr(rule, 'name', None)
kwargs['description'] = getattr(rule, 'description', None)
# Validate trigger parameters
# Note: This must happen before we create a trigger, otherwise create trigger could fail
# with a cryptic error
trigger = getattr(rule, 'trigger', {})
trigger_type_ref = trigger.get('type', None)
parameters = trigger.get('parameters', {})
validator.validate_trigger_parameters(trigger_type_ref=trigger_type_ref,
parameters=parameters)
# Create a trigger for the provided rule
trigger_db = TriggerService.create_trigger_db_from_rule(rule)
kwargs['trigger'] = reference.get_str_resource_ref_from_model(trigger_db)
kwargs['pack'] = getattr(rule, 'pack', DEFAULT_PACK_NAME)
kwargs['ref'] = ResourceReference.to_string_reference(pack=kwargs['pack'],
name=kwargs['name'])
# Validate criteria
kwargs['criteria'] = dict(getattr(rule, 'criteria', {}))
validator.validate_criteria(kwargs['criteria'])
kwargs['action'] = ActionExecutionSpecDB(ref=rule.action['ref'],
parameters=rule.action.get('parameters', {}))
rule_type = dict(getattr(rule, 'type', {}))
if rule_type:
kwargs['type'] = RuleTypeSpecDB(ref=rule_type['ref'],
parameters=rule_type.get('parameters', {}))
kwargs['enabled'] = getattr(rule, 'enabled', False)
kwargs['context'] = getattr(rule, 'context', dict())
kwargs['tags'] = TagsHelper.to_model(getattr(rule, 'tags', []))
kwargs['metadata_file'] = getattr(rule, 'metadata_file', None)
model = cls.model(**kwargs)
return model
开发者ID:nzlosh,项目名称:st2,代码行数:42,代码来源:rule.py
示例13: from_model
def from_model(cls, model):
triggertype = cls._from_model(model)
triggertype['tags'] = TagsHelper.from_model(model.tags)
return cls(**triggertype)
开发者ID:BlazeMediaGroup,项目名称:st2,代码行数:4,代码来源:reactor.py
示例14: from_model
def from_model(cls, model, mask_secrets=False):
triggertype = cls._from_model(model, mask_secrets=mask_secrets)
triggertype['tags'] = TagsHelper.from_model(model.tags)
return cls(**triggertype)
开发者ID:KenMercusLai,项目名称:st2,代码行数:4,代码来源:trigger.py
注:本文中的st2common.models.api.tag.TagsHelper类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论