2023-04-10 22:51:37 -05:00
|
|
|
def c_get_containers(req_obj, host, port, access_token, endpoint):
|
2022-10-17 17:18:17 -05:00
|
|
|
url = f'https://{host}:{port}/api/endpoints/{endpoint}/docker/containers/json?all=true'
|
2023-04-10 22:51:37 -05:00
|
|
|
c_get_containers_response = req_obj.get(url, headers={"X-API-Key": access_token},verify=False)
|
2022-10-17 17:18:17 -05:00
|
|
|
return c_get_containers_response.json()
|
|
|
|
|
2023-04-10 22:51:37 -05:00
|
|
|
def c_get_filtered_containers(req_obj, j_obj, host, port, access_token, endpoint, containers, statuses):
|
|
|
|
filter_string = j_obj.dumps({"name":containers,"status":statuses})
|
|
|
|
url = f'https://{host}:{port}/api/endpoints/{endpoint}/docker/containers/json?filters={filter_string}'
|
|
|
|
c_get_containers_response = req_obj.get(url, headers={"X-API-Key": access_token}, verify=False)
|
2023-03-21 12:16:01 -05:00
|
|
|
return c_get_containers_response.json()
|
|
|
|
|
2023-04-10 22:51:37 -05:00
|
|
|
def c_start_container(req_obj, host, port, access_token, endpoint, cid):
|
2022-10-17 17:18:17 -05:00
|
|
|
url = f'https://{host}:{port}/api/endpoints/{endpoint}/docker/containers/{cid}/start'
|
2023-04-10 22:51:37 -05:00
|
|
|
c_start_container_response = req_obj.post(url, headers={"X-API-Key": access_token},verify=False)
|
2022-10-18 14:14:53 -05:00
|
|
|
return c_start_container_response.status_code
|
|
|
|
|
2023-04-10 22:51:37 -05:00
|
|
|
def c_stop_container(req_obj, host, port, access_token, endpoint, cid):
|
2022-10-18 14:14:53 -05:00
|
|
|
url = f'https://{host}:{port}/api/endpoints/{endpoint}/docker/containers/{cid}/stop'
|
2023-04-10 22:51:37 -05:00
|
|
|
c_start_container_response = req_obj.post(url, headers={"X-API-Key": access_token},verify=False)
|
2022-10-17 17:18:17 -05:00
|
|
|
return c_start_container_response.status_code
|