summaryrefslogtreecommitdiff
path: root/pycadf
diff options
context:
space:
mode:
authorStanisław Pitucha <stanislaw.pitucha@hp.com>2015-09-24 11:50:21 +1000
committerStanisław Pitucha <stanislaw.pitucha@hp.com>2015-09-24 12:01:30 +1000
commita8a31471b00fb4f09d63f77bb641e11873425628 (patch)
tree4ad9e1028e6e8aff968b3a005fb418430b2447e1 /pycadf
parentde8739162137ea3a165eddac2a89427660008e9a (diff)
downloadpycadf-a8a31471b00fb4f09d63f77bb641e11873425628.tar.gz
Add event name
Add support for event name (defined in CADF 1.0.0). Change-Id: I924cafa42cfcd052114fbff7cf9b847452166415
Diffstat (limited to 'pycadf')
-rw-r--r--pycadf/event.py13
-rw-r--r--pycadf/tests/test_cadf_spec.py3
2 files changed, 14 insertions, 2 deletions
diff --git a/pycadf/event.py b/pycadf/event.py
index 384fa40..69f6167 100644
--- a/pycadf/event.py
+++ b/pycadf/event.py
@@ -40,6 +40,7 @@ EVENT_KEYNAME_TARGETID = "targetId"
EVENT_KEYNAME_OUTCOME = "outcome"
EVENT_KEYNAME_REASON = "reason"
EVENT_KEYNAME_SEVERITY = "severity"
+EVENT_KEYNAME_NAME = "name"
EVENT_KEYNAME_MEASUREMENTS = "measurements"
EVENT_KEYNAME_TAGS = "tags"
EVENT_KEYNAME_ATTACHMENTS = "attachments"
@@ -59,6 +60,7 @@ EVENT_KEYNAMES = [EVENT_KEYNAME_TYPEURI,
EVENT_KEYNAME_OUTCOME,
EVENT_KEYNAME_REASON,
EVENT_KEYNAME_SEVERITY,
+ EVENT_KEYNAME_NAME,
EVENT_KEYNAME_MEASUREMENTS,
EVENT_KEYNAME_TAGS,
EVENT_KEYNAME_ATTACHMENTS,
@@ -94,6 +96,9 @@ class Event(cadftype.CADFAbstractType):
reason = cadftype.ValidatorDescriptor(
EVENT_KEYNAME_REASON,
lambda x: isinstance(x, reason.Reason) and x.is_valid())
+ name = cadftype.ValidatorDescriptor(EVENT_KEYNAME_NAME,
+ lambda x: isinstance(
+ x, six.string_types))
severity = cadftype.ValidatorDescriptor(EVENT_KEYNAME_SEVERITY,
lambda x: isinstance(
x, six.string_types))
@@ -107,7 +112,8 @@ class Event(cadftype.CADFAbstractType):
id=None, eventTime=None,
action=cadftaxonomy.UNKNOWN, outcome=cadftaxonomy.UNKNOWN,
initiator=None, initiatorId=None, target=None, targetId=None,
- severity=None, reason=None, observer=None, observerId=None):
+ severity=None, reason=None, observer=None, observerId=None,
+ name=None):
"""Create an Event
:param eventType: eventType of Event. Defaults to 'activity' type
@@ -123,6 +129,7 @@ class Event(cadftype.CADFAbstractType):
:param reason: domain-specific Reason type
:param observer: Event's Observer Resource
:param observerId: Event's Observer Resource id
+ :param name: descriptive name for the event
"""
# Establish typeURI for the CADF Event data type
# TODO(mrutkows): support extended typeURIs for Event subtypes
@@ -165,6 +172,10 @@ class Event(cadftype.CADFAbstractType):
if targetId is not None:
setattr(self, EVENT_KEYNAME_TARGETID, targetId)
+ # Event.name (Optional)
+ if name is not None:
+ setattr(self, EVENT_KEYNAME_NAME, name)
+
# Event.severity (Optional)
if severity is not None:
setattr(self, EVENT_KEYNAME_SEVERITY, severity)
diff --git a/pycadf/tests/test_cadf_spec.py b/pycadf/tests/test_cadf_spec.py
index afa1da1..a5a4dde 100644
--- a/pycadf/tests/test_cadf_spec.py
+++ b/pycadf/tests/test_cadf_spec.py
@@ -219,7 +219,8 @@ class TestCADFSpec(base.TestCase):
outcome='success',
reason=reason.Reason(reasonType='HTTP',
reasonCode='200'),
- severity='high')
+ severity='high',
+ name='descriptive name')
ev.add_measurement(
measurement.Measurement(result='100',
metricId=identifier.generate_uuid())),