-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_history.py
More file actions
83 lines (74 loc) · 3.46 KB
/
system_history.py
File metadata and controls
83 lines (74 loc) · 3.46 KB
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
from pydantic import HttpUrl
from consys4py.con_sys_api import ConnectedSystemsRequestBuilder
from consys4py.constants import APITerms
def list_system_history(server_addr: HttpUrl, system_id: str, api_root: str = APITerms.API.value, headers: dict = None):
"""
Lists all history versions of a system
:return:
"""
builder = ConnectedSystemsRequestBuilder()
api_request = (builder.with_server_url(server_addr)
.with_api_root(api_root)
.for_resource_type(APITerms.SYSTEMS.value)
.with_resource_id(system_id)
.for_resource_type(APITerms.HISTORY.value)
.build_url_from_base()
.with_headers(headers)
.with_request_method('GET')
.build())
return api_request.make_request()
def retrieve_system_historical_description_by_id(server_addr: HttpUrl, system_id: str, history_id: str,
api_root: str = APITerms.API.value, headers: dict = None):
"""
Retrieves a historical system description by its id
:return:
"""
builder = ConnectedSystemsRequestBuilder()
api_request = (builder.with_server_url(server_addr)
.with_api_root(api_root)
.for_resource_type(APITerms.SYSTEMS.value)
.with_resource_id(system_id)
.for_resource_type(APITerms.HISTORY.value)
.with_secondary_resource_id(history_id)
.build_url_from_base()
.with_headers(headers)
.with_request_method('GET')
.build())
return api_request.make_request()
def update_system_historical_description(server_addr: HttpUrl, system_id: str, history_rev_id: str, request_body: dict,
api_root: str = APITerms.API.value, headers: dict = None):
"""
Updates a historical system description by its id
:return:
"""
builder = ConnectedSystemsRequestBuilder()
api_request = (builder.with_server_url(server_addr)
.with_api_root(api_root)
.for_resource_type(APITerms.SYSTEMS.value)
.with_resource_id(system_id)
.for_resource_type(APITerms.HISTORY.value)
.with_secondary_resource_id(history_rev_id)
.with_request_body(request_body)
.build_url_from_base()
.with_headers(headers)
.with_request_method('PUT')
.build())
return api_request.make_request()
def delete_system_historical_description_by_id(server_addr: HttpUrl, system_id: str, history_rev_id: str,
api_root: str = APITerms.API.value, headers: dict = None):
"""
Deletes a historical system description by its id
:return:
"""
builder = ConnectedSystemsRequestBuilder()
api_request = (builder.with_server_url(server_addr)
.with_api_root(api_root)
.for_resource_type(APITerms.SYSTEMS.value)
.with_resource_id(system_id)
.for_resource_type(APITerms.HISTORY.value)
.with_secondary_resource_id(history_rev_id)
.build_url_from_base()
.with_headers(headers)
.with_request_method('DELETE')
.build())
return api_request.make_request()