Statistics
| Branch: | Tag: | Revision:

root / commissioning / specs / fscrud.py @ 9f1a1bd0

History | View | Annotate | Download (2.2 kB)

1

    
2
from commissioning  import (Callpoint,
3
                            CanonifyException,
4
                            SpecifyException,
5
                            Specificator,
6
                            Nothing, Integer, String,
7
                            Tuple, ListOf, Dict, Args)
8

    
9
Context             =   Dict(classname='Context')
10

    
11
Command = String    (
12
        classname       =   'Command',
13
        choices         =   (
14
                'CREATE',
15
                'READ',
16
                'UPDATE',
17
                'DELETE',
18
        )
19
)
20

    
21
Path = String   (
22
        classname   =   'Path',
23
        regex       =   '([a-zA-Z_+/]|%[0-9a-fA-F]{2})+'
24
)
25

    
26
Contents = String   (
27
        classname   =   'Contents',
28
        max_length  =   4096,
29
        default     =   None
30
)
31

    
32
Positive = Integer  (
33
        classname   =   'Positive',
34
        minimum     =   0
35
)
36

    
37
DataSpec = Tuple    (
38
                        Positive,
39
                        Contents,
40

    
41
        classname   =   'DataSpec',
42
        default     =   None
43
)
44

    
45
CommisionSpec = Dict    (
46
        classname   =   'CommissionSpec',
47
        command     =   Command,
48
        path        =   Path,
49
        dataspec    =   DataSpec
50
)
51

    
52
PhysicalDescription = Dict  (
53
        classname   =   'PhysicalDescription',
54
        path        =   Path,
55
        dataspec    =   DataSpec
56
)
57

    
58
PhysicalState = Dict    (
59
        classname   =   'PhysicalState',
60
        path        =   Path,
61
        dataspec    =   DataSpec,
62
        retries     =   Positive,
63
        error       =   String(max_length=256)
64
)
65

    
66

    
67
class FSCrudAPI(Specificator):
68

    
69
    def create  (
70
            self,
71
            context     =   Context,
72
            path        =   Path,
73
            dataspec    =   DataSpec
74
        ):
75

    
76
        return Nothing
77

    
78
    def update        (
79
            self,
80
            context     =   Context,
81
            path        =   Path,
82
            dataspec    =   DataSpec
83
        ):
84

    
85
        return Nothing
86

    
87
    def read    (
88
            self,
89
            context     =   Context,
90
            path        =   Path,
91
            dataspec    =   DataSpec
92
        ):
93

    
94
        return DataSpec
95

    
96
    def delete  (
97
            self,
98
            context     =   Context,
99
            path        =   Path
100
        ):
101

    
102
        return Nothing
103

    
104
API_Spec = FSCrudAPI
105