✨(api) define dimail timeout as a setting
Allow to param dimail timeout for each env
This commit is contained in:
@@ -10,6 +10,7 @@ and this project adheres to
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- ✨(api) define dimail timeout as a setting
|
||||||
- ✨(frontend) feature modal add new access role to domain
|
- ✨(frontend) feature modal add new access role to domain
|
||||||
- ✨(api) allow invitations for domain management #708
|
- ✨(api) allow invitations for domain management #708
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class DimailAPIClient:
|
|||||||
|
|
||||||
API_URL = settings.MAIL_PROVISIONING_API_URL
|
API_URL = settings.MAIL_PROVISIONING_API_URL
|
||||||
API_CREDENTIALS = settings.MAIL_PROVISIONING_API_CREDENTIALS
|
API_CREDENTIALS = settings.MAIL_PROVISIONING_API_CREDENTIALS
|
||||||
|
API_TIMEOUT = settings.MAIL_PROVISIONING_API_TIMEOUT
|
||||||
|
|
||||||
def get_headers(self, user_sub=None):
|
def get_headers(self, user_sub=None):
|
||||||
"""
|
"""
|
||||||
@@ -59,7 +60,7 @@ class DimailAPIClient:
|
|||||||
f"{self.API_URL}/token/",
|
f"{self.API_URL}/token/",
|
||||||
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
||||||
params=params,
|
params=params,
|
||||||
timeout=20,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
if response.status_code == status.HTTP_200_OK:
|
if response.status_code == status.HTTP_200_OK:
|
||||||
@@ -93,7 +94,7 @@ class DimailAPIClient:
|
|||||||
json=payload,
|
json=payload,
|
||||||
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -129,7 +130,7 @@ class DimailAPIClient:
|
|||||||
json=payload,
|
json=payload,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -169,7 +170,7 @@ class DimailAPIClient:
|
|||||||
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
||||||
json=payload,
|
json=payload,
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -209,7 +210,7 @@ class DimailAPIClient:
|
|||||||
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
||||||
json=payload,
|
json=payload,
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -304,7 +305,7 @@ class DimailAPIClient:
|
|||||||
f"{self.API_URL}/domains/{domain.name}/mailboxes/",
|
f"{self.API_URL}/domains/{domain.name}/mailboxes/",
|
||||||
headers=self.get_headers(),
|
headers=self.get_headers(),
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -365,7 +366,7 @@ class DimailAPIClient:
|
|||||||
json={"active": "no"},
|
json={"active": "no"},
|
||||||
headers=self.get_headers(user_sub),
|
headers=self.get_headers(user_sub),
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
if response.status_code == status.HTTP_200_OK:
|
if response.status_code == status.HTTP_200_OK:
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -389,7 +390,7 @@ class DimailAPIClient:
|
|||||||
},
|
},
|
||||||
headers=self.get_headers(user_sub),
|
headers=self.get_headers(user_sub),
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
if response.status_code == status.HTTP_200_OK:
|
if response.status_code == status.HTTP_200_OK:
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -425,7 +426,7 @@ class DimailAPIClient:
|
|||||||
f"{self.API_URL}/domains/{domain.name}/check/",
|
f"{self.API_URL}/domains/{domain.name}/check/",
|
||||||
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=20,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -445,7 +446,7 @@ class DimailAPIClient:
|
|||||||
f"{self.API_URL}/domains/{domain.name}/fix/",
|
f"{self.API_URL}/domains/{domain.name}/fix/",
|
||||||
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
if response.status_code == status.HTTP_200_OK:
|
if response.status_code == status.HTTP_200_OK:
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -530,7 +531,7 @@ class DimailAPIClient:
|
|||||||
f"{self.API_URL}/domains/{domain.name}/spec/",
|
f"{self.API_URL}/domains/{domain.name}/spec/",
|
||||||
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
headers={"Authorization": f"Basic {self.API_CREDENTIALS}"},
|
||||||
verify=True,
|
verify=True,
|
||||||
timeout=10,
|
timeout=self.API_TIMEOUT,
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
|
|||||||
@@ -512,6 +512,11 @@ class Base(Configuration):
|
|||||||
environ_name="MAIL_PROVISIONING_API_CREDENTIALS",
|
environ_name="MAIL_PROVISIONING_API_CREDENTIALS",
|
||||||
environ_prefix=None,
|
environ_prefix=None,
|
||||||
)
|
)
|
||||||
|
MAIL_PROVISIONING_API_TIMEOUT = values.IntegerValue(
|
||||||
|
default=20,
|
||||||
|
environ_name="MAIL_PROVISIONING_API_TIMEOUT",
|
||||||
|
environ_prefix=None,
|
||||||
|
)
|
||||||
DNS_PROVISIONING_API_URL = values.Value(
|
DNS_PROVISIONING_API_URL = values.Value(
|
||||||
default="https://api.scaleway.com",
|
default="https://api.scaleway.com",
|
||||||
environ_name="DNS_PROVISIONING_API_URL",
|
environ_name="DNS_PROVISIONING_API_URL",
|
||||||
|
|||||||
Reference in New Issue
Block a user