|
1 |
| -# |
2 |
| -# (c) 2023 Copyright, Real-Time Innovations, Inc. All rights reserved. |
3 |
| -# |
4 |
| -# RTI grants Licensee a license to use, modify, compile, and create derivative |
5 |
| -# works of the Software solely for use with RTI products. The Software is |
6 |
| -# provided "as is", with no warranty of any type, including any warranty for |
7 |
| -# fitness for any purpose. RTI is under no obligation to maintain or support |
8 |
| -# the Software. RTI shall not be liable for any incidental or consequential |
9 |
| -# damages arising out of the use or inability to use the software. |
10 |
| -# |
11 |
| - |
12 |
| -from abc import ABC |
13 |
| -from dataclasses import field |
14 |
| -from typing import Sequence |
15 |
| -import rti.idl as idl |
16 |
| -import rti.rpc as rpc |
17 |
| - |
18 |
| - |
19 |
| -@idl.struct |
20 |
| -class Item: |
21 |
| - name: str = "" |
22 |
| - quantity: int = 0 |
23 |
| - |
24 |
| - |
25 |
| -@idl.struct |
26 |
| -class InventoryContents: |
27 |
| - items: Sequence[Item] = field(default_factory=list) |
28 |
| - |
29 |
| - |
30 |
| -@idl.struct |
31 |
| -class UnknownItemError(Exception): |
32 |
| - name: str = "" |
33 |
| - |
34 |
| - |
35 |
| -@rpc.service |
36 |
| -class InventoryService(ABC): |
37 |
| - @rpc.operation |
38 |
| - def get_inventory(self) -> InventoryContents: |
39 |
| - """Get the current inventory inventory""" |
40 |
| - ... |
41 |
| - |
42 |
| - @rpc.operation |
43 |
| - def add_item(self, item: Item): |
44 |
| - """Add quantity to an existing item""" |
45 |
| - ... |
46 |
| - |
47 |
| - @rpc.operation(raises=[UnknownItemError]) |
48 |
| - def remove_item(self, item: Item): |
49 |
| - """Remove quantity from an existing item""" |
50 |
| - ... |
| 1 | +# |
| 2 | +# (c) 2023 Copyright, Real-Time Innovations, Inc. All rights reserved. |
| 3 | +# |
| 4 | +# RTI grants Licensee a license to use, modify, compile, and create derivative |
| 5 | +# works of the Software solely for use with RTI products. The Software is |
| 6 | +# provided "as is", with no warranty of any type, including any warranty for |
| 7 | +# fitness for any purpose. RTI is under no obligation to maintain or support |
| 8 | +# the Software. RTI shall not be liable for any incidental or consequential |
| 9 | +# damages arising out of the use or inability to use the software. |
| 10 | +# |
| 11 | + |
| 12 | +from abc import ABC |
| 13 | +from dataclasses import field |
| 14 | +from typing import Sequence |
| 15 | +import rti.idl as idl |
| 16 | +import rti.rpc as rpc |
| 17 | + |
| 18 | + |
| 19 | +@idl.struct |
| 20 | +class Item: |
| 21 | + name: str = "" |
| 22 | + quantity: int = 0 |
| 23 | + |
| 24 | + |
| 25 | +@idl.struct |
| 26 | +class InventoryContents: |
| 27 | + items: Sequence[Item] = field(default_factory=list) |
| 28 | + |
| 29 | + |
| 30 | +@idl.struct |
| 31 | +class UnknownItemError(Exception): |
| 32 | + name: str = "" |
| 33 | + |
| 34 | + |
| 35 | +@rpc.service |
| 36 | +class InventoryService(ABC): |
| 37 | + @rpc.operation |
| 38 | + def get_inventory(self) -> InventoryContents: |
| 39 | + """Get the current inventory inventory""" |
| 40 | + ... |
| 41 | + |
| 42 | + @rpc.operation |
| 43 | + def add_item(self, item: Item): |
| 44 | + """Add quantity to an existing item""" |
| 45 | + ... |
| 46 | + |
| 47 | + @rpc.operation(raises=[UnknownItemError]) |
| 48 | + def remove_item(self, item: Item): |
| 49 | + """Remove quantity from an existing item""" |
| 50 | + ... |
0 commit comments