forked from casework/CASE-Utility-Verifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NLG.py
5033 lines (4301 loc) · 261 KB
/
NLG.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# NOTICE
#
# This software was produced for the U.S. Government under
# contract SB-1341-14-CQ-0010, and is subject to the Rights
# in Data-General Clause 52.227-14, Alt. IV (DEC 2007)
#
# (c) 2018 The MITRE Corporation. All Rights Reserved.
#====================================================
# CASE NLG VERIFIER v0.1.0
"""
The Natural Language Glossary (NLG) is an alphabetical list of types of CASE classes (categories of CASE types).
The functions in this file create CASE objects (instances of such types) while automatically checking ontology and type.
The API (case.py) could be used directly to create non-typed objects if ontology and type checking are not requirements.
However, we advise against this to maintain consistency across community usage of the ontology.
Note that different versions of the NLG exist for different realizations of the Unified Cyber Ontology.
The human legible NLG corresponding to this version of CASE (one realization of UCO) can be found here:
https://casework.github.io/case/case-v0.1.0-natural-language-glossary.html
-----------------------------------------------------
NOTES ON FUNCTION STRUCTURE
CASE objects: Search "CREATE A CASE OBJECT" in the API (case.py) to understand the high-level CASE objects.
Parameters: All parameters use underscores coming in and are set by default to a Missing object.
Required parameters: The CASE Document class is passed in ('_sub' functions also require their superseding CASE class).
Ontology parameters: All other parameters are specified by the CASE ontology, and may be required or optional.
Function docstrings: 'Any number of' = must be a list (otherwise pass in a single Python object)
'Exactly one' or 'At least one' = required parameter
'At most one' = optional parameter
Body asserts: 1) superseding CASE class/type (if applicable)
2) required parameters
3) optional parameters
Return: The desired object is instantiated and parameters converted to CamelCase for JSON-LD output.
See examples/NLG_template.txt for a list of all instances of function definitions, docstrings, and assert statements found in the NLG.
-----------------------------------------------------
ORGANIZATION FOR DEVELOPERS
As development of the ontology moves forward new functions and API classes may be added.
If you wish to contribute to improvement, follow these note-taking standards to help us stay on the same proverbial page.
- #TODO:NothingElseToCheck - If no parameters are checked (incomplete ontology or ambiguity).
- #NOCHECK:<param_name> - If a parameter does not have a check (but at least one other parameter does).
- #TODO:<type_name> - If a standard has not been defined yet for a type check (e.g. #TODO:URI).
Custom functions for such types may be found in the last section of this file.
- There are two 'Identity' NLG types, one a 'core_' and one a 'propbundle_'.
In assert output state which is required via "of type Identity (core)" or "of type Identity (propbundle)".
"""
import case
import sys
import unittest
import datetime
class Missing(object):
def __init__(self):
self.is_missing = True
#====================================================
#-- CORE IN ALPHABETICAL ORDER
def core_Action(uco_document, action_status=Missing(), start_time=Missing(), end_time=Missing(), errors=Missing(),
action_count=Missing(), subaction_refs=Missing()):
'''
:param ActionStatus: At most one occurrence of type ControlledVocabulary.
:param StartTime: At most one value of type Datetime.
:param EndTime: At most one value of type Datetime.
:param Errors: Any number of values of any type.
:param ActionCount: At most one value of type PositiveInteger.
:param SubactionRefs: Any number of occurrences of type Action.
:return: A CoreObject object.
'''
if not isinstance(action_status, Missing):
assert (isinstance(action_status, case.CoreObject) and (action_status.type=='ControlledVocabulary')),\
"[core_Action] action_status must be of type ControlledVocab."
if not isinstance(start_time, Missing):
assert isinstance(start_time, datetime.datetime),\
"[core_Action] start_time must be of type Datetime."
if not isinstance(end_time, Missing):
assert isinstance(end_time, datetime.datetime),\
"[core_Action] end_time must be of type Datetime."
#NOCHECK:errors
if not isinstance(action_count, Missing):
assert (isinstance(action_count, int) and (action_count > 0)),\
"[core_Action] action_count must be of type Int and positive."
if not isinstance(subaction_refs, Missing):
assert isinstance(subaction_refs, list),\
"[core_Action] subaction_refs must be of type List of Action."
assert all( (isinstance(i, case.CoreObject) and i.type=='Action') for i in subaction_refs),\
"[core_Action] subaction_refs must be of type List of Action."
return uco_document.create_CoreObject('Action', ActionStatus=action_status, StartTime=start_time, EndTime=end_time,
Errors=errors, ActionCount=action_count, SubactionRefs=subaction_refs)
def core_Assertion(uco_document):
'''
:return: A CoreObject object.
'''
#TODO:NothingElseToCheck
return uco_document.create_CoreObject('Assertion')
def core_Bundle(uco_document):
'''
:return: A CoreObject object.
'''
#TODO:NothingElseToCheck
return uco_document.create_CoreObject('Bundle')
def core_ControlledVocabulary(uco_document, value=Missing(), constraining_vocabulary_name=Missing(),
constraining_vocabulary_ref=Missing()):
'''
:param Value: Exactly one value of type String.
:param ConstrainingVocabularyName: At most one value of type String.
:param ConstrainingVocabularyReference: At most one value of type URI.
:return: A CoreObject object.
'''
assert not isinstance(value, Missing),\
"[core_ControlledVocabulary] value is required."
if not isinstance(value, Missing):
assert isinstance(value, str),\
"[core_ControlledVocabulary] value must be of type String."
if not isinstance(constraining_vocabulary_name, Missing):
assert isinstance(constraining_vocabulary_name, str),\
"[core_ControlledVocabulary] constraining_vocabulary_name must be of type URI."
#TODO:URI
return uco_document.create_CoreObject('ControlledVocabulary', Value=value,
ConstrainingVocabularyName=constraining_vocabulary_name,
ConstrainingVocabularyRef=constraining_vocabulary_ref)
def core_Identity(uco_document):
'''
:return: A CoreObject object.
'''
#TODO:NothingElseToCheck
return uco_document.create_CoreObject('Identity')
def core_Location(uco_document):
'''
:return: A CoreObject object.
'''
#TODO:NothingElseToCheck
return uco_document.create_CoreObject('Location')
def core_MarkingDefinition(uco_document, definition_type=Missing(), definition=Missing()):
'''
:param DefinitionType: Exactly one value of type String.
:param Definition: Any number of occurrences of type MarkingModel.
:return: A CoreObject object.
'''
assert not isinstance(definition_type, Missing),\
"[core_MarkingDefinition] defintion_type is required."
if not isinstance(definition_type, Missing):
assert isinstance(definition_type, str),\
"[core_MarkingDefinition] definition_type must be of type String."
if not isinstance(definition, Missing):
assert isinstance(definition, list),\
"[core_MarkingDefinition] definition must be of type List of MarkingModel."
assert all( (isinstance(i, case.DuckObject) and i.type=='MarkingModel') for i in definition),\
"[core_MarkingDefinition] definition must be of type List of MarkingModel."
return uco_document.create_CoreObject('MarkingDefinition', DefinitionType=definition_type, Definition=definition)
def core_Relationship(uco_document, is_directional=Missing(), target_ref=Missing(), source_ref=Missing(),
start_time=Missing(), end_time=Missing(), kind_of_relationship=Missing()):
'''
:param IsDirectional: Exactly one value of type Bool.
:param TargetRef: Exactly one ocurrence of type CoreObject.
:param SourceRef: At least one ocurrence of type CoreObject.
:param StartTime: Any number of values of type Datetime.
:param EndTime: Any number of values of Datetime.
:param KindOfRelationship: At most one occurrence of type ControlledVocabulary.
:return: A CoreObject object.
'''
assert not isinstance(is_directional, Missing),\
"[core_Relationship] is_directional is required."
if not isinstance(is_directional, Missing):
assert isinstance(is_directional, bool),\
"[core_Relationship] is_directional must be of type Bool."
assert not isinstance(target_ref, Missing),\
"[core_Relationship] target_ref is required."
if not isinstance(target_ref, Missing):
assert isinstance(target_ref, case.CoreObject),\
"[core_Relationship] target_ref must be of type CoreObject."
assert not isinstance(source_ref, Missing),\
"[core_Relationship] source_ref is required."
if not isinstance(source_ref, Missing):
assert isinstance(source_ref, list),\
"[core_Relationship] source_ref must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in source_ref),\
"[core_Relationship] source_ref must be of type List of CoreObject."
if not isinstance(start_time, Missing):
assert isinstance(start_time, list),\
"[core_Relationship] start_time must be of type List of Datetime."
assert all(isinstance(i, datetime.datetime) for i in start_time),\
"[core_Relationship] start_time must be of type List of Datetime."
if not isinstance(end_time, Missing):
assert isinstance(end_time, list),\
"[core_Relationship] end_time must be of type List of Datetime."
assert all(isinstance(i, datetime.datetime) for i in end_time),\
"[core_Relationship] end_time must be of type List of Datetime."
if not isinstance(kind_of_relationship, Missing):
assert (isinstance(kind_of_relationship, case.CoreObject) and (kind_of_relationship.type=='ControlledVocabulary')),\
"[core_Relationship] kind_of_relationship must be of type ControlledVocabulary."
return uco_document.create_CoreObject('Relationship', IsDirectional=is_directional, TargetRef=target_ref,
SourceRef=source_ref, StartTime=start_time, EndTime=end_time,
KindOfRelationship=kind_of_relationship)
def core_Role(uco_document):
'''
:return: A CoreObject object.
'''
#TODO:NothingElseToCheck
return uco_document.create_CoreObject('Role')
def core_Tool(uco_document, name=Missing(), version=Missing(), tool_type=Missing(), service_pack=Missing(),
creator=Missing(), references=Missing()):
'''
:param Name: At most one value of type String.
:param Version: At most one value of type String.
:param ToolType: At most one value of type String.
:param ServicePack: At most one value of type String.
:param Creator: At most one value of type String.
:param References: Any number of values of URI.
:return: A CoreObject object.
'''
if not isinstance(name, Missing):
assert isinstance(name, str),\
"[core_Tool] name must be of type String."
if not isinstance(version, Missing):
assert isinstance(version, str),\
"[core_Tool] version must be of type String."
if not isinstance(tool_type, Missing):
assert isinstance(tool_type, str),\
"[core_Tool] tool_type must be of type String."
if not isinstance(service_pack, Missing):
assert isinstance(service_pack, str),\
"[core_Tool] service_pack must be of type String."
if not isinstance(creator, Missing):
assert isinstance(creator, str),\
"[core_Tool] creator must be of type String."
#TODO:URI
#check for list and then URI type
return uco_document.create_CoreObject('Tool', Name=name, Version=version, ToolType=tool_type,
ServicePack=service_pack, Creator=creator, References=references)
def core_Trace(uco_document, has_changed=Missing(), state=Missing()):
'''
:param HasChanged: Exactly one value of type Bool.
:param State: At most one occurrence of type ControlledVocabulary.
:return: A CoreObject object.
'''
assert not isinstance(has_changed, Missing),\
"[core_Trace] has_changed is required."
if not isinstance(has_changed, Missing):
assert isinstance(has_changed, bool),\
"[core_Trace] has_changed must be of type Bool."
if not isinstance(state, Missing):
assert (isinstance(state, case.CoreObject) and (state.type=='ControlledVocabulary')),\
"[core_Trace] state must be of type ControlledVocabulary."
return uco_document.create_CoreObject('Trace', HasChanged=has_changed, State=state)
#====================================================
#-- CORE CHILDREN IN ALPHABETICAL ORDER
def core_sub_ActionLifecycle(uco_document, uco_object):
'''
:param PhraseRefs: Exactly one occurrence of type ArrayOfAction.
:param ActionStatus: Exactly zero occurrences of type ControlledVocabulary.
:param StartTime: Exactly zero values of type Datetime.
:param EndTime: Exactly zero values of type Datetime.
:param (Unnamed Class): Exactly zero values of any type.
:param ActionCount: Exactly zero values of type PositiveInteger.
:return: A SubObject object.
'''
assert (isinstance(uco_object, case.CoreObject) and (uco_object.type=='Action')),\
"[core_sub_ActionLifecycle] uco_object must be of type Action."
# TODO:This class checks if the fields for core_Action are not present.
# If they are this object cannot be used and an error should be thrown. Is this a correct interpretation?
return uco_document.create_SubObject('ActionLifecycle')
def core_sub_ForensicAction(uco_document, uco_object):
'''
:return: A SubObject object.
'''
assert (isinstance(uco_object, case.CoreObject) and (uco_object.type=='Action')),\
"[core_sub_ForensicAction] uco_object must be of type Action."
#TODO:NothingElseToCheck
return uco_document.create_SubObject('ForensicAction')
#====================================================
#-- CONTEXT IN ALPHABETICAL ORDER
def context_Grouping(uco_document, context_strings=Missing()):
'''
:param Context: At least one value of type String.
:return: A ContextObject object.
'''
assert not isinstance(context_strings, Missing),\
"[context_Grouping] context_strings is required."
if not isinstance(context_strings, Missing):
assert isinstance(context_strings, list),\
"[context_Grouping] context_strings must be of type List of String."
assert all(isinstance(i, str) for i in context_strings),\
"[context_Grouping] context_strings must be of type List of String."
return uco_document.create_ContextObject('Grouping', ContextStrings=context_strings)
def context_Investigation(uco_document, investigation_form=Missing(), investigation_status=Missing(),
start_time=Missing(), end_time=Missing, focus=Missing(), object_refs=Missing()):
'''
:param InvestigationForm: Exactly one occurrence of type ControlledVocabulary.
:param InvestigationStatus: At most one occurrence of type ControlledVocabulary.
:param StartTime: At most one value of type Datetime.
:param EndTime: At most one value of type Datetime.
:param Focus: Any number of values of type String.
:param ObjectRefs: Any number of occurrences of type CoreObject.
:return: A ContextObject object.
'''
assert not isinstance(investigation_form, Missing),\
"[context_Investigation] investigation_form is required."
if not isinstance(investigation_form, Missing):
assert (isinstance(investigation_form, case.CoreObject) and (investigation_form.type=='ControlledVocabulary')),\
"[context_Investigation] investigation_form must be of type ControlledVocabulary."
if not isinstance(investigation_status, Missing):
assert (isinstance(investigation_status, case.CoreObject) and (investigation_status.type=='ControlledVocabulary')),\
"[context_Investigation] investigation_status must be of type ControlledVocabulary."
if not isinstance(start_time, Missing):
assert isinstance(start_time, datetime.datetime),\
"[context_Investigation] start_time must be of type Datetime."
if not isinstance(end_time, Missing):
assert isinstance(end_time, datetime.datetime),\
"[context_Investigation] end_time must be of type Datetime."
if not isinstance(focus, Missing):
assert isinstance(focus, list),\
"[context_Investigation] focus must be of type List of Strings."
assert all(isinstance(i, str) for i in focus),\
"[context_Investigation] focus must be of type List of Strings."
if not isinstance(object_refs, Missing):
assert isinstance(object_refs, list),\
"[context_Investigation] object_refs must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in object_refs),\
"[context_Investigation] object_refs must be of type List of CoreObject."
return uco_document.create_ContextObject('Investigation', InvestigationForm=investigation_form,
InvestigationStatus=investigation_status, StartTime=start_time,
EndTime=end_time, Focus=focus, ObjectRefs=object_refs)
def context_ProvenanceRecord(uco_document, exhibit_number=Missing(), object_refs=Missing()):
'''
:param ExhibitNumber: At most one value of type String.
:param ObjectRefs: Any number of occurrences of type CoreObject.
:return: A ContextObject object.
'''
if not isinstance(exhibit_number, Missing):
assert isinstance(exhibit_number, str),\
"[context_ProvenanceRecord] exhibit_number must be of type String."
if not isinstance(object_refs, Missing):
assert isinstance(object_refs, list),\
"[context_ProvenanceRecord] object_refs must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in object_refs),\
"[context_ProvenanceRecord] object_refs must be of type List of CoreObject."
return uco_document.create_ContextObject('ProvenanceRecord', ExhibitNumber=exhibit_number, ObjectRefs=object_refs)
#====================================================
#-- CONTEXT CHILDREN IN ALPHABETICAL ORDER
# NO CHILDREN OF CONTEXT YET
#====================================================
#-- PROPERTYBUNDLES IN ALPHABETICAL ORDER
def propbundle_Account(uco_object, account_id=Missing(), expiration_time=Missing(), created_time=Missing(),
account_type=Missing(), account_issuer_ref=Missing(), is_active=Missing(),
modified_time=Missing(), owner_ref=Missing()):
'''
:param AccoundID: Exactly one value of type String.
:param ExprationTime: At most one value of type Datetime.
:param CreatedTime: At most one value of type Datetime.
:param AccountType: At most one occurrence of type ControlledVocabulary.
:param AccountIssuerRef: At most one occurrence of type CoreObject.
:param IsActive: At most one value of type Bool.
:param ModifiedTime: At most one value of type Datetime.
:param OwnerRef: At most one occurrence of type CoreObject.
:return: A PropertyBundle object.
'''
assert not isinstance(account_id, Missing),\
"[propbundle_Account] account_id is required."
if not isinstance(account_id, Missing):
assert isinstance(account_id, str),\
"[propbundle_Account] account_id must be of type String."
if not isinstance(expiration_time, Missing):
assert isinstance(expiration_time, datetime.datetime),\
"[propbundle_Account] expiration_time must be of type Datetime."
if not isinstance(created_time, Missing):
assert isinstance(created_time, datetime.datetime),\
"[propbundle_Account] created_time must be of type TimeStamp."
if not isinstance(account_type, Missing):
assert (isinstance(account_type, case.CoreObject) and (account_type.type=='ControlledVocabulary')),\
"[propbundle_Account] account_type must be of type ControlledVocabulary."
if not isinstance(account_issuer_ref, Missing):
assert isinstance(account_issuer_ref, case.CoreObject),\
"[propbundle_Account] account_issuer_ref must be of type CoreObject."
if not isinstance(is_active, Missing):
assert isinstance(is_active, bool),\
"[propbundle_Account] is_active must be of type Bool."
if not isinstance(modified_time, Missing):
assert isinstance(modified_time, datetime.datetime),\
"[propbundle_Account] modified_time must be of type Datetime."
if not isinstance(owner_ref, Missing):
assert isinstance(owner_ref, case.CoreObject),\
"[propbundle_Account] owner_ref must be of type CoreObject."
return uco_object.create_PropertyBundle('Account', AccoundID=account_id, ExpirationTime=expiration_time,
CreatedTime=created_time, AccountType=account_type,
AccountIssuerRef=account_issuer_ref, IsActive=is_active,
ModifiedTime=modified_time, OwnerRef=owner_ref)
def propbundle_AccountAuthentication(uco_object, password=Missing(), password_type=Missing(),
password_last_changed=Missing()):
'''
:param Password: At most one value of type String.
:param PasswordType: At most one value of type String.
:param PasswordLastChanged: At most one value of type Datetime.
:return: A PropertyBundle object.
'''
if not isinstance(password, Missing):
assert isinstance(password, str),\
"[propbundle_AccountAuthentication] password must be of type String."
if not isinstance(password_type, Missing):
assert isinstance(password_type, str),\
"[propbundle_AccountAuthentication] password_type must be of type String."
if not isinstance(password_last_changed, Missing):
assert isinstance(password_last_changed, datetime.datetime),\
"[propbundle_AccountAuthentication] password_last_changed must be of type Datetime."
return uco_object.create_PropertyBundle('AccountAuthentication', Password=password,
PasswordType=password_type,
PasswordLastChanged = password_last_changed)
def propbundle_ActionReferences(uco_object, environment_ref=Missing(), result_refs=Missing(),
performer_refs=Missing(), participant_refs=Missing(),
object_refs=Missing(), location_refs=Missing(), instrument_refs=Missing()):
'''
:param EnvironmentRef: At most one occurrence of type CoreObject.
:param ResultRefs: Any number of occurrences of type CoreObject.
:param PerformerRef: At most one occurrence of type CoreObject.
:param ParticipantRefs: Any number of occurrences of type CoreObject.
:param ObjectRefs: Any number of occurrences of type CoreObject.
:param LocationRefs: Any number of occurrences of type Location.
:param InstrumentRefs: Any number of occurrences of type CoreObject.
:return: A PropertyBundle object.
'''
if not isinstance(environment_ref, Missing):
assert isinstance(environment_ref, case.CoreObject),\
"[propbundles_ActionReferences] environment_ref must be of type CoreObject."
if not isinstance(result_refs, Missing):
assert isinstance(result_refs, list),\
"[propbundles_ActionReferences] result_refs must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in result_refs),\
"[propbundles_ActionReferences] result_refs must be of type List of CoreObject."
if not isinstance(performer_refs, Missing):
assert isinstance(performer_refs, case.CoreObject),\
"[propbundles_ActionReferences] performer_refs must be of type CoreObject."
if not isinstance(participant_refs, Missing):
assert isinstance(participant_refs, list),\
"[propbundles_ActionReferences] participant_refs must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in participant_refs),\
"[propbundles_ActionReferences] participant_refs must be of type List of CoreObject."
if not isinstance(object_refs, Missing):
assert isinstance(object_refs, list),\
"[propbundles_ActionReferences] object_refs must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in object_refs),\
"[propbundles_ActionReferences] object_refs must be of type List of CoreObject."
if not isinstance(location_refs, Missing):
assert isinstance(location_refs, list),\
"[propbundles_ActionReferences] location_refs must be of type List of Location."
assert all( (isinstance(i, case.CoreObject)) and (i.type=='Location') for i in location_refs),\
"[propbundles_ActionReferences] location_refs must be of type List of Location."
if not isinstance(instrument_refs, Missing):
assert isinstance(instrument_refs, list),\
"[propbundles_ActionReferences] instrument_refs must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in instrument_refs),\
"[propbundles_ActionReferences] instrument_refs must be of type List of CoreObject."
return uco_object.create_PropertyBundle('ActionReferences', EnvironmentRef=environment_ref,
ResultRefs=result_refs, PerformerRefs=performer_refs,
ParticipantRefs=participant_refs, ObjectRefs=object_refs,
LocationRefs=location_refs, InstrumentRefs=instrument_refs)
def propbundle_Application(uco_object, application_identifier=Missing(), version=Missing(),
operating_system_ref=Missing(), number_of_launches=Missing()):
'''
:param ApplicationIdentifier: At most one value of type String.
:param Version: At most one value of type String.
:param OperatingSystemRef: At most one occurrence of type Trace.
:param NumberOfLaunches: At most one value of type PositiveInteger.
:return: A PropertyBundle object.
'''
if not isinstance(application_identifier, Missing):
assert isinstance(application_identifier, str),\
"[propbundle_Application] application_identifier must be of type String."
if not isinstance(version, Missing):
assert isinstance(version, str),\
"[propbundle_Application] version must be of type String."
if not isinstance(operating_system_ref, Missing):
assert (isinstance(operating_system_ref, case.CoreObject) and (operating_system_ref.type=='Trace')),\
"[propbundle_Application] operating_system_ref must be of type Trace."
if not isinstance(number_of_launches, Missing):
assert (isinstance(number_of_launches, int) and (number_of_launches > 0)),\
"[propbundle_Application] number_of_launches must be of type PositiveInteger."
return uco_object.create_PropertyBundle('Application', ApplicationIdentifier=application_identifier,
Version=version, OperatingSystemRef=operating_system_ref,
NumberOfLaunches=number_of_launches)
def propbundle_ApplicationAccount(uco_object, application_ref=Missing()):
'''
:param ApplicationRef: Exactly one occurrence of type Trace.
:return: A PropertyBundle object.
'''
assert not isinstance(application_ref, Missing),\
"[propbundle_ApplicationAccount] application_ref is required."
if not isinstance(application_ref, Missing):
assert (isinstance(application_ref, case.CoreObject) and (application_ref.type=='Trace')),\
"[propbundle_ApplicationAccount] application_ref must be of type Trace."
return uco_object.create_PropertyBundle('ApplicationAccount', ApplicationRef=application_ref)
def propbundle_ArchiveFile(uco_object, version=Missing(), comment=Missing(), archive_type=Missing()):
'''
:param Version: At most one value of type String.
:param Comment: At most one value of type String.
:param ArchiveType: At most one value of type String.
:return: A PropertyBundle object.
'''
if not isinstance(version, Missing):
assert isinstance(version, str),\
"[propbundle_ArchiveFile] version must be of type String."
if not isinstance(comment, Missing):
assert isinstance(comment, str),\
"[propbundle_ArchiveFile] comment must be of type String."
if not isinstance(archive_type, Missing):
assert isinstance(archive_type, str),\
"[propbundle_ArchiveFile] archive_type must be of type String."
return uco_object.create_PropertyBundle('ArchiveFile', Version=version, Comment=comment, ArchiveType=archive_type)
def propbundle_Attachment(uco_object, url):
'''
:param URL: Exactly one value of type URI.
:return: A PropertyBundle object.
'''
#TODO:URL
return uco_object.create_PropertyBundle('Attachment', URL=url)
def propbundle_Audio(uco_object, audio_format=Missing(), audio_type=Missing(), bit_rate=Missing(), duration=Missing()):
'''
:param AudioFormat: At most one value of type String.
:param AudioType: At most one value of type String.
:param BitRate: At most one value of type Long.
:param Duration: At most one value of type Long.
:return: A PropertyBundle object.
'''
if not isinstance(audio_format, Missing):
assert isinstance(audio_format, str),\
"[propbundle_Audio] audio_format must be of type String."
if not isinstance(audio_type, Missing):
assert isinstance(audio_type, str),\
"[propbundle_Audio] audio_type must be of type String."
if not isinstance(bit_rate, Missing):
assert isinstance(bit_rate, long),\
"[propbundle_Audio] bit_rate must be of type Long."
if not isinstance(duration, Missing):
assert isinstance(duration, long),\
"[propbundle_Audio] duration must be of type Long."
return uco_object.create_PropertyBundle('Audio', AudioFormat=audio_format, AudioType=audio_type,
BitRate=bit_rate, Duration=duration)
def propbundle_Authorization(uco_object, authorization_type=Missing(), authorization_identifier=Missing()):
'''
:param AuthorizationType: Exactly one occurrence of type ControlledVocabulary.
:param AuthorizationIdentifier: At least one value of type String.
:return: A PropertyBundle object.
'''
assert not isinstance(authorization_type, Missing),\
"[propbundle_Authorization] authorization_type is required."
if not isinstance(authorization_type, Missing):
assert (isinstance(authorization_type, case.CoreObject) and (authorization_type.type=='ControlledVocabulary')),\
"[propbundle_Authorization] authorization_type must be of type ControlledVocabulary."
if not isinstance(authorization_identifier, Missing):
assert isinstance(authorization_identifier, str),\
"[propbundle_Authorization] authorization_identifier must be of type String."
return uco_object.create_PropertyBundle('Authorization', AuthorizationType=authorization_type,
AuthorizationIdentifier=authorization_identifier)
def propbundle_AutonomousSystem(uco_object, number=Missing(), as_handle=Missing(),
regional_internet_registry=Missing()):
'''
:param Number: Exactly one value of type Integer.
:param AsHandle: At most one value of type String.
:param RegionalInternetRegistry: At most one occurrence of type ControlledVocabulary.
:return: A PropertyBundle object.
'''
assert not isinstance(number, Missing),\
"[propbundle_AutonomousSystem] number is required."
if not isinstance(number, Missing):
assert isinstance(number, int),\
"[propbundle_AutonomousSystem] number must be of type Integer."
if not isinstance(as_handle, Missing):
assert isinstance(as_handle, str),\
"[propbundle_AutonomousSystem] as_handle must be of type String."
if not isinstance(regional_internet_registry, Missing):
assert (isinstance(regional_internet_registry, case.CoreObject) and
(regional_internet_registry.type=='ControlledVocabulary')),\
"[propbundle_AutonomousSystem] regional_internet_registry must be of type ControlledVocabulary."
return uco_object.create_PropertyBundle('AutonomousSystem', Number=number, AsHandle=as_handle,
RegionalInternetRegistry=regional_internet_registry)
def propbundle_BrowserBookmark(uco_object, accessed_time=Missing(), application_ref=Missing(),
created_time=Missing(), modified_time=Missing(), bookmark_path=Missing(),
url_targeted=Missing(), visit_count=Missing()):
'''
:param AccessedTime: At most one value of type Datetime.
:param ApplicationRef: At most one occurrence of type Trace.
:param CreatedTime: At most one value of type Datetime.
:param ModifiedTime: At most one value of type Datetime.
:param BookmarkPath: At most one value of type String.
:param URLTargeted: At most one occurrence of type URL.
:param VisitCount: At most one value of type Integer.
:return: A PropertyBundle object.
'''
if not isinstance(accessed_time, Missing):
assert isinstance(accessed_time, datetime.datetime),\
"[propbundle_BrowserBookmark] accessed_time must be of type Datetime."
if not isinstance(application_ref, Missing):
assert (isinstance(application_ref, case.CoreObject) and (application_ref.type=='Trace')),\
"[propbundle_BrowserBookmark] application_ref must be of type Trace."
if not isinstance(created_time, Missing):
assert isinstance(created_time, datetime.datetime),\
"[propbundle_BrowserBookmark] created_time must be of type Datetime."
if not isinstance(modified_time, Missing):
assert isinstance(modified_time, datetime.datetime),\
"[propbundle_BrowserBookmark] modified_time must be of type Datetime."
if not isinstance(bookmark_path, Missing):
assert isinstance(bookmark_path, str),\
"[propbundle_BrowserBookmark] bookmark_path must be of type String."
#TODO:URL
if not isinstance(visit_count, Missing):
assert isinstance(visit_count, int),\
"[propbundle_BrowserBookmark] visit_count must be of type Integer."
return uco_object.create_PropertyBundle('BrowserBookmark', AccessedTime=accessed_time,
ApplicationRef=application_ref, CreatedTime=created_time,
ModifiedTime=modified_time, BookmarkPath=bookmark_path,
URLTargeted=url_targeted, VisitCount=visit_count)
def propbundle_BrowserCookie(uco_object, accessed_time=Missing(), application_ref=Missing(),
created_time=Missing(), expiration_time=Missing(), domain_ref=Missing(),
cookie_name=Missing(), cookie_path=Missing(), is_secure=Missing()):
'''
:param AccessedTime: At most one value of type Datetime.
:param ApplicationRef: At most one occurrence of type Trace.
:param CreatedTime: At most one value of type Datetime.
:param ExpirationTime: At most one value of type Datetime.
:param DomainRef: At most one occurrence of type Trace.
:param CookieName: At most one value of type String.
:param CookiePath: At most one value of type String.
:param IsSecure: At most one value of type Bool.
:return: A PropertyBundle object.
'''
if not isinstance(accessed_time, Missing):
assert isinstance(accessed_time, datetime.datetime),\
"[propbundle_BrowserCookie] accessed_time must be of type Datetime."
if not isinstance(application_ref, Missing):
assert (isinstance(application_ref, case.CoreObject) and (application_ref.type=='Trace')),\
"[propbundle_BrowserCookie] application_ref must be of type Trace."
if not isinstance(created_time, Missing):
assert isinstance(created_time, datetime.datetime),\
"[propbundle_BrowserCookie] created_time must be of type Datetime."
if not isinstance(expiration_time, Missing):
assert isinstance(expiration_time, datetime.datetime),\
"[propbundle_BrowserCookie] expiration_time must be of type Datetime."
if not isinstance(domain_ref, Missing):
assert (isinstance(domain_ref, case.CoreObject) and (domain_ref.type=='Trace')),\
"[propbundle_BrowserCookie] domain_ref must be of type Trace."
if not isinstance(cookie_name, Missing):
assert isinstance(cookie_name, str),\
"[propbundle_BrowserCookie] cookie_name must be of type String."
if not isinstance(cookie_path, Missing):
assert isinstance(cookie_path, str),\
"[propbundle_BrowserCookie] cookie_path must be of type String."
if not isinstance(is_secure, Missing):
assert isinstance(is_secure, bool),\
"[propbundle_BrowserCookie] is_secure must be of type Bool."
return uco_object.create_PropertyBundle('BrowserCookie', AccessedTime=accessed_time,
ApplicationRef=application_ref, CreatedTime=created_time,
ExpirationTime=expiration_time, DomainRef=domain_ref,
CookieName=cookie_name, CookiePath=cookie_path, IsSecure=is_secure)
def propbundle_Build(uco_object, build_information=Missing()):
'''
:param BuildInformation: Exactly one occurrence of type BuildInformationType.
:return: A PropertyBundle object.
'''
assert not isinstance(build_information, Missing),\
"[propbundle_Build] build_information is required."
if not isinstance(build_information, Missing):
assert (isinstance(build_information, case.DuckObject) and (build_information.type=='BuildInformationType')),\
"[propbundle_Build] build_information must be of type BuildInformationType."
return uco_object.create_PropertyBundle('Build', BuildInformation=build_information)
def propbundle_Calendar(uco_object, application_ref=Missing(), owner=Missing()):
'''
:param ApplicationRef: At most one occurrence of type Trace.
:param Owner: At most one occurrence of type Trace.
:return: A PropertyBundle object.
'''
if not isinstance(application_ref, Missing):
assert (isinstance(application_ref, case.CoreObject) and (application_ref.type=='Trace')),\
"[propbundle_Calendar] application_ref must be of type Trace."
if not isinstance(owner, Missing):
assert (isinstance(owner, case.CoreObject) and (owner.type=='Trace')),\
"[propbundle_Calendar] owner must be of type Trace."
return uco_object.create_PropertyBundle('Calendar', ApplicationRef=application_ref, Owner=owner)
def propbundle_CalendarEntry(uco_object, application_ref=Missing(), attendant_refs=Missing(),
categories=Missing(), created_time=Missing(), modified_time=Missing(), duration=Missing(),
end_time=Missing(), start_time=Missing(), labels=Missing(), location_ref=Missing(),
owner_ref=Missing(), is_private=Missing(), recurrence=Missing(), remind_time=Missing(),
event_status=Missing(), subject=Missing(), event_type=Missing()):
'''
:param ApplicationRef: At most one occurrence of type Trace.
:param AttendantRefs: Any number of occurrences of type CoreObject.
:param Categories: Any number of values of type String.
:param CreatedTime: At most one value of type Datetime.
:param ModifiedTime: At most one value of type Datetime.
:param Duration: At most one value of type Long.
:param EndTime: At most one value of type Datetime.
:param StartTime: At most one value of type Datetime.
:param Labels: Any number of values of type String.
:param LocationRef: At most one occurrence of type Location.
:param OwnerRef: At most one occurrence of type Identity (core).
:param IsPrivate: At most one value of type Bool.
:param Recurrence: At most one value of type String.
:param RemindTime: At most one value of type Datetime.
:param EventStatus: At most one value of type String.
:param Subject: At most one value of type String.
:param EventType: At most one value of type String.
:return: A PropertyBundle object.
'''
if not isinstance(application_ref, Missing):
assert (isinstance(application_ref, case.CoreObject) and (application_ref.type=='Trace')),\
"[propbundle_CalendarEntry] application_ref must be of type Trace."
if not isinstance(attendant_refs, Missing):
assert isinstance(attendant_refs, list),\
"[propbundle_CalendarEntry] attendant_refs must be of type List of CoreObject."
assert all(isinstance(i, case.CoreObject) for i in attendant_refs),\
"[propbundle_CalendarEntry] attendant_refs must be of type List of CoreObject."
if not isinstance(categories, Missing):
assert isinstance(categories, list),\
"[propbundle_CalendarEntry] categories must be of type List of String."
assert all(isinstance(i, str) for i in categories),\
"[propbundle_CalendarEntry] categories must be of type List of String."
if not isinstance(created_time, Missing):
assert isinstance(created_time, datetime.datetime),\
"[propbundle_CalendarEntry] created_time must be of type Datetime."
if not isinstance(modified_time, Missing):
assert isinstance(modified_time, datetime.datetime),\
"[propbundle_CalendarEntry] modified_time must be of type Datetime."
if not isinstance(duration, Missing):
assert isinstance(duration, datetime.datetime),\
"[propbundle_CalendarEntry] duration must be of type Datetime."
if not isinstance(end_time, Missing):
assert isinstance(end_time, datetime.datetime),\
"[propbundle_CalendarEntry] end_time must be of type Datetime."
if not isinstance(start_time, Missing):
assert isinstance(start_time, datetime.datetime),\
"[propbundle_CalendarEntry] start_time must be of type Datetime."
if not isinstance(labels, Missing):
assert isinstance(labels, list),\
"[propbundle_CalendarEntry] labels must be of type List of String."
assert all(isinstance(i, str) for i in labels),\
"[propbundle_CalendarEntry] labels must be of type List of String."
if not isinstance(location_ref, Missing):
assert (isinstance(location_ref, case.CoreObject) and (location_ref.type=='Location')),\
"[propbundle_CalendarEntry] location_ref must be of type Location."
if not isinstance(owner_ref, Missing):
assert (isinstance(owner_ref, case.CoreObject) and (owner_ref.type=='Identity')),\
"[propbundle_CalendarEntry] owner_ref must be of type Identity."
if not isinstance(is_private, Missing):
assert isinstance(is_private, bool),\
"[propbundle_CalendarEntry] is_private must be of type Bool."
if not isinstance(recurrence, Missing):
assert isinstance(recurrence, str),\
"[propbundle_CalendarEntry] recurrence must be of type String."
if not isinstance(remind_time, Missing):
assert isinstance(remind_time, datetime.datetime),\
"[propbundle_CalendarEntry] remind_time must be of type Datetime."
if not isinstance(event_status, Missing):
assert isinstance(event_status, str),\
"[propbundle_CalendarEntry] event_status must be of type String."
if not isinstance(subject, Missing):
assert isinstance(subject, str),\
"[propbundle_CalendarEntry] subject must be of type String."
if not isinstance(event_type, Missing):
assert isinstance(event_type, str),\
"[propbundle_CalendarEntry] event_type must be of type String."
return uco_object.create_PropertyBundle('CalendarEntry', ApplicationRef=application_ref,
AttendantRefs=attendant_refs, Categories=categories,
CreatedTime=created_time, ModifiedTime=modified_time,
Duration=duration, EndTime=end_time, StartTime=start_time,
Labels=labels, LocationRef=location_ref, OwnerRef=owner_ref,
IsPrivate=is_private, Recurrence=recurrence, RemindTime=remind_time,
EventStatus=event_status, Subject=subject, EventType=event_type )
def propbundle_CompressedStream(uco_object, compression_method=Missing(), compression_ratio=Missing()):
'''
:param CompressionMethod: At most one value of type String.
:param CompressionRatio: At most one value of type Float.
:return: A PropertyBundle object.
'''
if not isinstance(compression_method, Missing):
assert isinstance(compression_method, str),\
"[propbundle_CompressedStream] compression_method must be of type String."
if not isinstance(compression_ratio, Missing):
assert isinstance(compression_ratio, float),\
"[propbundle_CompressedStream] compression_ratio must be of type Float."
return uco_object.create_PropertyBundle('CompressedStream', CompressionMethod=compression_method,
CompressionRatio=compression_ratio)
def propbundle_ComputerSpecification(uco_object, available_ram=Missing(), bios_date=Missing(),
bios_manufacturer=Missing(), bios_release_date=Missing(),
bios_serial_number=Missing(), bios_version=Missing(),
current_system_date=Missing(), hostname=Missing(),
local_time=Missing(), network_interface_refs=Missing(),
processor_architecture=Missing(), cpu_family=Missing(),
cpu=Missing(), gpu_family=Missing(), gpu=Missing(), system_time=Missing(),
timezone_dst=Missing(), timezone_standard=Missing(), total_ram=Missing(),
uptime=Missing()):
'''
:param AvailableRAM: At most one value of type Long.
:param BIOSDate: At most one value of type Datetime.
:param BIOSManufacturer: At most one value of type String.
:param BIOSReleaseDate: At most one value of type Datetime.
:param BIOSSerialNumber: At most one value of type String.
:param BIOSVersion: At most one value of type String.
:param LocalTime: At most one value of type Datetime.
:param NetworkInterfaceRefs: Any number of occurrences of type Trace.
:param ProcessorArchitecture: At most one value of type String.
:param CPUFamily: At most one value of type String.
:param CPU: At most one value of type String.
:param GPUFamily: At most one value of type String.
:param GPU: At most one value of type String.
:param SystemTime: At most one value of type Datetime.
:param TimezoneDST: At most one value of type String.
:param TimezoneStandard: At most one value of type String.
:param TotalRAM: At most one value of type Long.
:param Uptime: At most one value of type String.
:return: A PropertyBundle object.
'''
if not isinstance(available_ram, Missing):
assert isinstance(available_ram, long),\
"[propbundle_ComputerSpecification] available_ram must be of type Long."
if not isinstance(bios_date, Missing):
assert isinstance(bios_date, datetime.datetime),\
"[propbundle_ComputerSpecification] bios_date must be of type Datetime."
if not isinstance(bios_manufacturer, Missing):
assert isinstance(bios_manufacturer, str),\
"[propbundle_ComputerSpecification] bios_manufacturer must be of type String."
if not isinstance(bios_release_date, Missing):
assert isinstance(bios_release_date, datetime.datetime),\
"[propbundle_ComputerSpecification] bios_release_date must be of type Datetime."
if not isinstance(bios_serial_number, Missing):
assert isinstance(bios_serial_number, str),\
"[propbundle_ComputerSpecification] bios_serial_number must be of type String."
if not isinstance(bios_version, Missing):
assert isinstance(bios_version, str),\
"[propbundle_ComputerSpecification] bios_version must be of type String."
if not isinstance(local_time, Missing):
assert isinstance(local_time, datetime.datetime),\
"[propbundle_ComputerSpecification] local_time must be of type Datetime."
if not isinstance(network_interface_refs, Missing):
assert isinstance(network_interface_refs, list),\
"[propbundle_ComputerSpecification] network_interface_refs must be of type List of Trace."
assert all( (isinstance(i, case.CoreObject) and i.type=='Trace') for i in network_interface_refs),\
"[propbundle_ComputerSpecification] network_interface_refs must be of type List of Trace."
if not isinstance(processor_architecture, Missing):
assert isinstance(processor_architecture, str),\
"[propbundle_ComputerSpecification] processor_architecture must be of type String."
if not isinstance(cpu_family, Missing):
assert isinstance(cpu_family, str),\
"[propbundle_ComputerSpecification] cpu_family must be of type String."
if not isinstance(cpu, Missing):
assert isinstance(cpu, str),\
"[propbundle_ComputerSpecification] cpu must be of type String."
if not isinstance(gpu_family, Missing):
assert isinstance(gpu_family, str),\
"[propbundle_ComputerSpecification] gpu_family must be of type String."