1+ from typing import Union
2+
13from pydantic import HttpUrl
24
35from conSys .con_sys_api import ConnectedSystemsRequestBuilder
46from conSys .constants import APITerms
57
68
7- def list_all_deployments (server_addr : HttpUrl , api_root : str = APITerms .API .value ):
9+ def list_all_deployments (server_addr : HttpUrl , api_root : str = APITerms .API .value , headers : dict = None ):
810 """
911 Lists all deployments in the server at the default API endpoint
1012 :return:
@@ -14,11 +16,14 @@ def list_all_deployments(server_addr: HttpUrl, api_root: str = APITerms.API.valu
1416 .with_api_root (api_root )
1517 .for_resource_type (APITerms .DEPLOYMENTS .value )
1618 .build_url_from_base ()
19+ .with_headers (headers )
20+ .with_request_method ('GET' )
1721 .build ())
18- return api_request
22+ return api_request . make_request ()
1923
2024
21- def create_new_deployments (server_addr : HttpUrl , request_body : dict , api_root : str = APITerms .API .value ):
25+ def create_new_deployments (server_addr : HttpUrl , request_body : Union [str , dict ], api_root : str = APITerms .API .value ,
26+ headers : dict = None ):
2227 """
2328 Create a new deployment as defined by the request body
2429 :return:
@@ -29,11 +34,14 @@ def create_new_deployments(server_addr: HttpUrl, request_body: dict, api_root: s
2934 .for_resource_type (APITerms .DEPLOYMENTS .value )
3035 .with_request_body (request_body )
3136 .build_url_from_base ()
37+ .with_headers (headers )
38+ .with_request_method ('POST' )
3239 .build ())
33- return api_request
40+ return api_request . make_request ()
3441
3542
36- def retrieve_deployment_by_id (server_addr : HttpUrl , deployment_id : str , api_root : str = APITerms .API .value ):
43+ def retrieve_deployment_by_id (server_addr : HttpUrl , deployment_id : str , api_root : str = APITerms .API .value ,
44+ headers : dict = None ):
3745 """
3846 Retrieve a deployment by its ID
3947 :return:
@@ -44,12 +52,14 @@ def retrieve_deployment_by_id(server_addr: HttpUrl, deployment_id: str, api_root
4452 .for_resource_type (APITerms .DEPLOYMENTS .value )
4553 .with_resource_id (deployment_id )
4654 .build_url_from_base ()
55+ .with_headers (headers )
56+ .with_request_method ('GET' )
4757 .build ())
48- return api_request
58+ return api_request . make_request ()
4959
5060
51- def update_deployment_by_id (server_addr : HttpUrl , deployment_id : str , request_body : dict ,
52- api_root : str = APITerms .API .value ):
61+ def update_deployment_by_id (server_addr : HttpUrl , deployment_id : str , request_body : Union [ str , dict ] ,
62+ api_root : str = APITerms .API .value , headers : dict = None ):
5363 """
5464 Update a deployment by its ID
5565 :return:
@@ -61,11 +71,14 @@ def update_deployment_by_id(server_addr: HttpUrl, deployment_id: str, request_bo
6171 .with_resource_id (deployment_id )
6272 .with_request_body (request_body )
6373 .build_url_from_base ()
74+ .with_headers (headers )
75+ .with_request_method ('PUT' )
6476 .build ())
65- return api_request
77+ return api_request . make_request ()
6678
6779
68- def delete_deployment_by_id (server_addr : HttpUrl , deployment_id : str , api_root : str = APITerms .API .value ):
80+ def delete_deployment_by_id (server_addr : HttpUrl , deployment_id : str , api_root : str = APITerms .API .value ,
81+ headers : dict = None ):
6982 """
7083 Delete a deployment by its ID
7184 :return:
@@ -76,11 +89,14 @@ def delete_deployment_by_id(server_addr: HttpUrl, deployment_id: str, api_root:
7689 .for_resource_type (APITerms .DEPLOYMENTS .value )
7790 .with_resource_id (deployment_id )
7891 .build_url_from_base ()
92+ .with_headers (headers )
93+ .with_request_method ('DELETE' )
7994 .build ())
8095 return api_request
8196
8297
83- def list_deployed_systems (server_addr : HttpUrl , deployment_id , api_root : str = APITerms .API .value ):
98+ def list_deployed_systems (server_addr : HttpUrl , deployment_id , api_root : str = APITerms .API .value ,
99+ headers : dict = None ):
84100 """
85101 Lists all deployed systems in the server at the default API endpoint
86102 :return:
@@ -92,12 +108,14 @@ def list_deployed_systems(server_addr: HttpUrl, deployment_id, api_root: str = A
92108 .with_resource_id (deployment_id )
93109 .for_sub_resource_type (APITerms .SYSTEMS .value )
94110 .build_url_from_base ()
111+ .with_headers (headers )
112+ .with_request_method ('GET' )
95113 .build ())
96- return api_request
114+ return api_request . make_request ()
97115
98116
99117def add_systems_to_deployment (server_addr : HttpUrl , deployment_id : str , uri_list : str ,
100- api_root : str = APITerms .API .value ):
118+ api_root : str = APITerms .API .value , headers : dict = None ):
101119 """
102120 Lists all systems in the server at the default API endpoint
103121 :return:
@@ -110,12 +128,14 @@ def add_systems_to_deployment(server_addr: HttpUrl, deployment_id: str, uri_list
110128 .for_sub_resource_type (APITerms .SYSTEMS .value )
111129 .with_request_body (uri_list )
112130 .build_url_from_base ()
131+ .with_headers (headers )
132+ .with_request_method ('POST' )
113133 .build ())
114- return api_request
134+ return api_request . make_request ()
115135
116136
117137def retrieve_deployed_system_by_id (server_addr : HttpUrl , deployment_id : str , system_id : str ,
118- api_root : str = APITerms .API .value ):
138+ api_root : str = APITerms .API .value , headers : dict = None ):
119139 """
120140 Retrieves a system by its id
121141 :return:
@@ -130,12 +150,14 @@ def retrieve_deployed_system_by_id(server_addr: HttpUrl, deployment_id: str, sys
130150 .for_sub_resource_type (APITerms .SYSTEMS .value )
131151 .with_secondary_resource_id (system_id )
132152 .build_url_from_base ()
153+ .with_headers (headers )
154+ .with_request_method ('GET' )
133155 .build ())
134- return api_request
156+ return api_request . make_request ()
135157
136158
137159def update_deployed_system_by_id (server_addr : HttpUrl , deployment_id : str , system_id : str , request_body : dict ,
138- api_root : str = APITerms .API .value ):
160+ api_root : str = APITerms .API .value , headers : dict = None ):
139161 """
140162 Update a system by its ID
141163 :return:
@@ -149,13 +171,15 @@ def update_deployed_system_by_id(server_addr: HttpUrl, deployment_id: str, syste
149171 .with_secondary_resource_id (system_id )
150172 .with_request_body (request_body )
151173 .build_url_from_base ()
174+ .with_headers (headers )
175+ .with_request_method ('PUT' )
152176 .build ())
153177
154178 return api_request
155179
156180
157181def delete_deployed_system_by_id (server_addr : HttpUrl , deployment_id : str , system_id : str ,
158- api_root : str = APITerms .API .value ):
182+ api_root : str = APITerms .API .value , headers : dict = None ):
159183 """
160184 Delete a system by its ID
161185 :return:
@@ -168,11 +192,14 @@ def delete_deployed_system_by_id(server_addr: HttpUrl, deployment_id: str, syste
168192 .for_sub_resource_type (APITerms .SYSTEMS .value )
169193 .with_secondary_resource_id (system_id )
170194 .build_url_from_base ()
195+ .with_headers (headers )
196+ .with_request_method ('DELETE' )
171197 .build ())
172- return api_request
198+ return api_request . make_request ()
173199
174200
175- def list_deployments_of_specific_system (server_addr : HttpUrl , system_id : str , api_root : str = APITerms .API .value ):
201+ def list_deployments_of_specific_system (server_addr : HttpUrl , system_id : str , api_root : str = APITerms .API .value ,
202+ headers : dict = None ):
176203 """
177204 Lists all deployments of a specific system in the server at the default API endpoint
178205 :return:
@@ -184,4 +211,7 @@ def list_deployments_of_specific_system(server_addr: HttpUrl, system_id: str, ap
184211 .with_resource_id (system_id )
185212 .for_sub_resource_type (APITerms .DEPLOYMENTS .value )
186213 .build_url_from_base ()
214+ .with_headers (headers )
215+ .with_request_method ('GET' )
187216 .build ())
217+ return api_request .make_request ()
0 commit comments