diff --git a/dsp_permissions_scripts/ap/ap_get.py b/dsp_permissions_scripts/ap/ap_get.py index d1a9c199..cdea0f13 100644 --- a/dsp_permissions_scripts/ap/ap_get.py +++ b/dsp_permissions_scripts/ap/ap_get.py @@ -47,7 +47,7 @@ def _get_all_aps_of_project( project_iri = quote_plus(project_iri, safe="") protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/ap/{project_iri}" - response = requests.get(url, headers=headers, timeout=5) + response = requests.get(url, headers=headers, timeout=10) if response.status_code != 200: raise ApiError("Could not get APs of project", response.text, response.status_code) aps: list[dict[str, Any]] = response.json()["administrative_permissions"] diff --git a/dsp_permissions_scripts/ap/ap_set.py b/dsp_permissions_scripts/ap/ap_set.py index 95962f1c..27cad133 100644 --- a/dsp_permissions_scripts/ap/ap_set.py +++ b/dsp_permissions_scripts/ap/ap_set.py @@ -34,7 +34,7 @@ def _delete_single_ap( ap_iri = quote_plus(ap.iri, safe="") protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/{ap_iri}" - response = requests.delete(url, headers=headers, timeout=5) + response = requests.delete(url, headers=headers, timeout=10) if response.status_code != 200: raise ApiError(f"Could not delete Administrative Permission {ap.iri}", response.text, response.status_code) logger.info(f"Deleted Administrative Permission {ap.iri} on host {host}") @@ -53,7 +53,7 @@ def _update_ap( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/{iri}/hasPermissions" payload = {"hasPermissions": create_admin_route_object_from_ap(ap)["hasPermissions"]} - response = requests.put(url, headers=headers, json=payload, timeout=5) + response = requests.put(url, headers=headers, json=payload, timeout=10) if response.status_code != 200: raise ApiError( message=f"Could not update Administrative Permission {ap.iri}", diff --git a/dsp_permissions_scripts/doap/doap_get.py b/dsp_permissions_scripts/doap/doap_get.py index 4d45d66e..7870369b 100644 --- a/dsp_permissions_scripts/doap/doap_get.py +++ b/dsp_permissions_scripts/doap/doap_get.py @@ -47,7 +47,7 @@ def _get_all_doaps_of_project( project_iri = quote_plus(project_iri, safe="") protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/doap/{project_iri}" - response = requests.get(url, headers=headers, timeout=5) + response = requests.get(url, headers=headers, timeout=10) if response.status_code != 200: raise ApiError(f"Error while getting DOAPs of project {project_iri}", response.text, response.status_code) doaps: list[dict[str, Any]] = response.json()["default_object_access_permissions"] diff --git a/dsp_permissions_scripts/doap/doap_set.py b/dsp_permissions_scripts/doap/doap_set.py index c4a1ae28..a4b310b4 100644 --- a/dsp_permissions_scripts/doap/doap_set.py +++ b/dsp_permissions_scripts/doap/doap_set.py @@ -30,7 +30,7 @@ def _update_doap_scope( protocol = get_protocol(host) url = f"{protocol}://{host}/admin/permissions/{iri}/hasPermissions" payload = {"hasPermissions": create_admin_route_object_from_scope(scope)} - response = requests.put(url, headers=headers, json=payload, timeout=5) + response = requests.put(url, headers=headers, json=payload, timeout=10) if response.status_code != 200: raise ApiError( f"Could not update scope of DOAP {doap_iri}", response.text, response.status_code, payload) new_doap = create_doap_from_admin_route_response(response.json()["default_object_access_permission"]) diff --git a/dsp_permissions_scripts/oap/oap_get_set.py b/dsp_permissions_scripts/oap/oap_get_set.py index 1426a61a..bb88472d 100644 --- a/dsp_permissions_scripts/oap/oap_get_set.py +++ b/dsp_permissions_scripts/oap/oap_get_set.py @@ -49,7 +49,7 @@ def _get_resource( protocol = get_protocol(host) url = f"{protocol}://{host}/v2/resources/{iri}" headers = {"Authorization": f"Bearer {token}"} - response = requests.get(url, headers=headers, timeout=5) + response = requests.get(url, headers=headers, timeout=10) if response.status_code != 200: raise ApiError( f"Error while getting resource {resource_iri}", response.text, response.status_code) data: dict[str, Any] = response.json() @@ -103,7 +103,7 @@ def _update_permissions_for_value( protocol = get_protocol(host) url = f"{protocol}://{host}/v2/values" headers = {"Authorization": f"Bearer {token}"} - response = requests.put(url, headers=headers, json=payload, timeout=5) + response = requests.put(url, headers=headers, json=payload, timeout=10) if response.status_code == 400 and response.text: already = "dsp.errors.BadRequestException: The submitted permissions are the same as the current ones" if already in response.text: @@ -143,7 +143,7 @@ def _update_permissions_for_resource( protocol = get_protocol(host) url = f"{protocol}://{host}/v2/resources" headers = {"Authorization": f"Bearer {token}"} - response = requests.put(url, headers=headers, json=payload, timeout=5) + response = requests.put(url, headers=headers, json=payload, timeout=10) if response.status_code != 200: raise ApiError( message=f"ERROR while updating permissions of resource {resource_iri}", diff --git a/dsp_permissions_scripts/utils/authentication.py b/dsp_permissions_scripts/utils/authentication.py index 427c107b..173caef6 100644 --- a/dsp_permissions_scripts/utils/authentication.py +++ b/dsp_permissions_scripts/utils/authentication.py @@ -11,7 +11,7 @@ def _get_token(host: str, email: str, pw: str) -> str: """ protocol = get_protocol(host) url = f"{protocol}://{host}/v2/authentication" - response = requests.post(url, json={"email": email, "password": pw}, timeout=5) + response = requests.post(url, json={"email": email, "password": pw}, timeout=10) if response.status_code != 200: raise ApiError("Could not login", response.text, response.status_code) token: str = response.json()["token"] diff --git a/dsp_permissions_scripts/utils/project.py b/dsp_permissions_scripts/utils/project.py index 3363bec5..ddec0c9f 100644 --- a/dsp_permissions_scripts/utils/project.py +++ b/dsp_permissions_scripts/utils/project.py @@ -45,7 +45,7 @@ def _get_onto_iris_of_project( protocol = get_protocol(host) url = f"{protocol}://{host}/v2/ontologies/metadata" headers = {"Authorization": f"Bearer {token}"} - response = requests.get(url, headers=headers, timeout=5) + response = requests.get(url, headers=headers, timeout=10) if response.status_code != 200: raise ApiError("Could not get onto IRIs", response.text, response.status_code) all_ontologies = response.json().get("@graph") @@ -61,7 +61,7 @@ def _get_class_iris_of_onto( protocol = get_protocol(host) url = f"{protocol}://{host}/v2/ontologies/allentities/{quote_plus(onto_iri)}" headers = {"Authorization": f"Bearer {token}"} - response = requests.get(url, headers=headers, timeout=5) + response = requests.get(url, headers=headers, timeout=10) if response.status_code != 200: raise ApiError("Could not get class IRIs", response.text, response.status_code) all_entities = response.json()["@graph"] @@ -122,7 +122,7 @@ def _get_next_page( This means that the page must be incremented until the response contains 0 or 1 resource. """ url = f"{protocol}://{host}/v2/resources?resourceClass={quote_plus(resclass_iri)}&page={page}" - response = requests.get(url, headers=headers, timeout=5) + response = requests.get(url, headers=headers, timeout=20) if response.status_code != 200: raise ApiError("Could not get next page", response.text, response.status_code) result = response.json() @@ -148,7 +148,7 @@ def get_project_iri_by_shortcode(shortcode: str, host: str) -> str: """ protocol = get_protocol(host) url = f"{protocol}://{host}/admin/projects/shortcode/{shortcode}" - response = requests.get(url, timeout=5) + response = requests.get(url, timeout=10) if response.status_code != 200: raise ApiError("Cannot retrieve project IRI", response.text, response.status_code) iri: str = response.json()["project"]["id"]