Compare commits

..

4 Commits

Author SHA1 Message Date
Andrew
818dd54f2f Merge pull request #35 from andrewthetechie/schedule-blank-string
Exclude none values when creating and updating
2022-01-07 21:24:02 -06:00
Andrew Herrington
376578ac36 Exclude none values when creating and updating 2022-01-07 21:16:03 -06:00
Andrew
67cbd2963f Merge pull request #34 from andrewthetechie/fix-schedule
default schedule to None
2022-01-07 20:53:17 -06:00
Andrew Herrington
960d78bc10 default schedule to None 2022-01-07 20:47:21 -06:00
3 changed files with 9 additions and 5 deletions

View File

@@ -98,7 +98,7 @@ class AsyncClient(AbstractClient):
""" """
request_url = self._get_api_request_url("checks/") request_url = self._get_api_request_url("checks/")
response = self.check_response( response = self.check_response(
await self._client.post(request_url, json=new_check.dict()) await self._client.post(request_url, json=new_check.dict(exclude_none=True))
) )
return Check.from_api_result(response.json()) return Check.from_api_result(response.json())
@@ -118,7 +118,8 @@ class AsyncClient(AbstractClient):
request_url = self._get_api_request_url(f"checks/{uuid}") request_url = self._get_api_request_url(f"checks/{uuid}")
response = self.check_response( response = self.check_response(
await self._client.post( await self._client.post(
request_url, json=update_check.dict(exclude_unset=True) request_url,
json=update_check.dict(exclude_unset=True, exclude_none=True),
) )
) )
return Check.from_api_result(response.json()) return Check.from_api_result(response.json())

View File

@@ -138,7 +138,7 @@ class Client(AbstractClient):
""" """
request_url = self._get_api_request_url("checks/") request_url = self._get_api_request_url("checks/")
response = self.check_response( response = self.check_response(
self._client.post(request_url, json=new_check.dict()) self._client.post(request_url, json=new_check.dict(exclude_none=True))
) )
return Check.from_api_result(response.json()) return Check.from_api_result(response.json())
@@ -163,7 +163,10 @@ class Client(AbstractClient):
""" """
request_url = self._get_api_request_url(f"checks/{uuid}") request_url = self._get_api_request_url(f"checks/{uuid}")
response = self.check_response( response = self.check_response(
self._client.post(request_url, json=update_check.dict(exclude_unset=True)) self._client.post(
request_url,
json=update_check.dict(exclude_unset=True, exclude_none=True),
)
) )
return Check.from_api_result(response.json()) return Check.from_api_result(response.json())

View File

@@ -83,7 +83,7 @@ class CheckCreate(BaseModel):
lte=31536000, lte=31536000,
) )
schedule: Optional[str] = Field( schedule: Optional[str] = Field(
"* * * * *", None,
description="A cron expression defining this check's schedule. " description="A cron expression defining this check's schedule. "
"If you specify both timeout and schedule parameters, " "If you specify both timeout and schedule parameters, "
"Healthchecks.io will create a Cron check and ignore the " "Healthchecks.io will create a Cron check and ignore the "