rough in '/agent/share/http-healthcheck' for remoted healthchecks (#1002)

This commit is contained in:
Michael Quigley
2025-07-18 11:57:30 -04:00
parent a73125977b
commit b99e414fce
37 changed files with 2536 additions and 0 deletions

View File

@@ -28,6 +28,8 @@ docs/EnvironmentApi.md
docs/Frontend.md
docs/GetSparklines200Response.md
docs/GetSparklinesRequest.md
docs/HttpHealthcheck200Response.md
docs/HttpHealthcheckRequest.md
docs/InviteRequest.md
docs/InviteTokenGenerateRequest.md
docs/ListFrontends200ResponseInner.md
@@ -103,6 +105,8 @@ test/test_environment_api.py
test/test_frontend.py
test/test_get_sparklines200_response.py
test/test_get_sparklines_request.py
test/test_http_healthcheck200_response.py
test/test_http_healthcheck_request.py
test/test_invite_request.py
test/test_invite_token_generate_request.py
test/test_list_frontends200_response_inner.py
@@ -184,6 +188,8 @@ zrok_api/models/environment_and_resources.py
zrok_api/models/frontend.py
zrok_api/models/get_sparklines200_response.py
zrok_api/models/get_sparklines_request.py
zrok_api/models/http_healthcheck200_response.py
zrok_api/models/http_healthcheck_request.py
zrok_api/models/invite_request.py
zrok_api/models/invite_token_generate_request.py
zrok_api/models/list_frontends200_response_inner.py

View File

@@ -119,6 +119,7 @@ Class | Method | HTTP request | Description
*AdminApi* | [**remove_organization_member**](docs/AdminApi.md#remove_organization_member) | **POST** /organization/remove |
*AdminApi* | [**update_frontend**](docs/AdminApi.md#update_frontend) | **PATCH** /frontend |
*AgentApi* | [**enroll**](docs/AgentApi.md#enroll) | **POST** /agent/enroll |
*AgentApi* | [**http_healthcheck**](docs/AgentApi.md#http_healthcheck) | **POST** /agent/share/http-healthcheck |
*AgentApi* | [**ping**](docs/AgentApi.md#ping) | **POST** /agent/ping |
*AgentApi* | [**remote_access**](docs/AgentApi.md#remote_access) | **POST** /agent/access |
*AgentApi* | [**remote_share**](docs/AgentApi.md#remote_share) | **POST** /agent/share |
@@ -179,6 +180,8 @@ Class | Method | HTTP request | Description
- [Frontend](docs/Frontend.md)
- [GetSparklines200Response](docs/GetSparklines200Response.md)
- [GetSparklinesRequest](docs/GetSparklinesRequest.md)
- [HttpHealthcheck200Response](docs/HttpHealthcheck200Response.md)
- [HttpHealthcheckRequest](docs/HttpHealthcheckRequest.md)
- [InviteRequest](docs/InviteRequest.md)
- [InviteTokenGenerateRequest](docs/InviteTokenGenerateRequest.md)
- [ListFrontends200ResponseInner](docs/ListFrontends200ResponseInner.md)

View File

@@ -5,6 +5,7 @@ All URIs are relative to */api/v1*
Method | HTTP request | Description
------------- | ------------- | -------------
[**enroll**](AgentApi.md#enroll) | **POST** /agent/enroll |
[**http_healthcheck**](AgentApi.md#http_healthcheck) | **POST** /agent/share/http-healthcheck |
[**ping**](AgentApi.md#ping) | **POST** /agent/ping |
[**remote_access**](AgentApi.md#remote_access) | **POST** /agent/access |
[**remote_share**](AgentApi.md#remote_share) | **POST** /agent/share |
@@ -92,6 +93,84 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **http_healthcheck**
> HttpHealthcheck200Response http_healthcheck(body=body)
### Example
* Api Key Authentication (key):
```python
import zrok_api
from zrok_api.models.http_healthcheck200_response import HttpHealthcheck200Response
from zrok_api.models.http_healthcheck_request import HttpHealthcheckRequest
from zrok_api.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to /api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = zrok_api.Configuration(
host = "/api/v1"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: key
configuration.api_key['key'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['key'] = 'Bearer'
# Enter a context with an instance of the API client
with zrok_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = zrok_api.AgentApi(api_client)
body = zrok_api.HttpHealthcheckRequest() # HttpHealthcheckRequest | (optional)
try:
api_response = api_instance.http_healthcheck(body=body)
print("The response of AgentApi->http_healthcheck:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AgentApi->http_healthcheck: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**HttpHealthcheckRequest**](HttpHealthcheckRequest.md)| | [optional]
### Return type
[**HttpHealthcheck200Response**](HttpHealthcheck200Response.md)
### Authorization
[key](../README.md#key)
### HTTP request headers
- **Content-Type**: application/zrok.v1+json
- **Accept**: application/zrok.v1+json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | ok | - |
**401** | unauthorized | - |
**500** | internal server error | - |
**502** | bad gateway; agent not reachable | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **ping**
> Ping200Response ping(body=body)

View File

@@ -0,0 +1,30 @@
# HttpHealthcheck200Response
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**healthy** | **bool** | | [optional]
**error** | **str** | | [optional]
## Example
```python
from zrok_api.models.http_healthcheck200_response import HttpHealthcheck200Response
# TODO update the JSON string below
json = "{}"
# create an instance of HttpHealthcheck200Response from a JSON string
http_healthcheck200_response_instance = HttpHealthcheck200Response.from_json(json)
# print the JSON string representation of the object
print(HttpHealthcheck200Response.to_json())
# convert the object into a dict
http_healthcheck200_response_dict = http_healthcheck200_response_instance.to_dict()
# create an instance of HttpHealthcheck200Response from a dict
http_healthcheck200_response_from_dict = HttpHealthcheck200Response.from_dict(http_healthcheck200_response_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,34 @@
# HttpHealthcheckRequest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**env_zid** | **str** | | [optional]
**share_token** | **str** | | [optional]
**http_verb** | **str** | | [optional]
**endpoint** | **str** | | [optional]
**expected_http_response** | **float** | | [optional]
**timeout_ms** | **float** | | [optional]
## Example
```python
from zrok_api.models.http_healthcheck_request import HttpHealthcheckRequest
# TODO update the JSON string below
json = "{}"
# create an instance of HttpHealthcheckRequest from a JSON string
http_healthcheck_request_instance = HttpHealthcheckRequest.from_json(json)
# print the JSON string representation of the object
print(HttpHealthcheckRequest.to_json())
# convert the object into a dict
http_healthcheck_request_dict = http_healthcheck_request_instance.to_dict()
# create an instance of HttpHealthcheckRequest from a dict
http_healthcheck_request_from_dict = HttpHealthcheckRequest.from_dict(http_healthcheck_request_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -32,6 +32,12 @@ class TestAgentApi(unittest.TestCase):
"""
pass
def test_http_healthcheck(self) -> None:
"""Test case for http_healthcheck
"""
pass
def test_ping(self) -> None:
"""Test case for ping

View File

@@ -0,0 +1,52 @@
# coding: utf-8
"""
zrok
zrok client access
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
from zrok_api.models.http_healthcheck200_response import HttpHealthcheck200Response
class TestHttpHealthcheck200Response(unittest.TestCase):
"""HttpHealthcheck200Response unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> HttpHealthcheck200Response:
"""Test HttpHealthcheck200Response
include_optional is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `HttpHealthcheck200Response`
"""
model = HttpHealthcheck200Response()
if include_optional:
return HttpHealthcheck200Response(
healthy = True,
error = ''
)
else:
return HttpHealthcheck200Response(
)
"""
def testHttpHealthcheck200Response(self):
"""Test HttpHealthcheck200Response"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,56 @@
# coding: utf-8
"""
zrok
zrok client access
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
from zrok_api.models.http_healthcheck_request import HttpHealthcheckRequest
class TestHttpHealthcheckRequest(unittest.TestCase):
"""HttpHealthcheckRequest unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> HttpHealthcheckRequest:
"""Test HttpHealthcheckRequest
include_optional is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `HttpHealthcheckRequest`
"""
model = HttpHealthcheckRequest()
if include_optional:
return HttpHealthcheckRequest(
env_zid = '',
share_token = '',
http_verb = '',
endpoint = '',
expected_http_response = 1.337,
timeout_ms = 1.337
)
else:
return HttpHealthcheckRequest(
)
"""
def testHttpHealthcheckRequest(self):
"""Test HttpHealthcheckRequest"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -57,6 +57,8 @@ __all__ = [
"Frontend",
"GetSparklines200Response",
"GetSparklinesRequest",
"HttpHealthcheck200Response",
"HttpHealthcheckRequest",
"InviteRequest",
"InviteTokenGenerateRequest",
"ListFrontends200ResponseInner",
@@ -145,6 +147,8 @@ from zrok_api.models.environment_and_resources import EnvironmentAndResources as
from zrok_api.models.frontend import Frontend as Frontend
from zrok_api.models.get_sparklines200_response import GetSparklines200Response as GetSparklines200Response
from zrok_api.models.get_sparklines_request import GetSparklinesRequest as GetSparklinesRequest
from zrok_api.models.http_healthcheck200_response import HttpHealthcheck200Response as HttpHealthcheck200Response
from zrok_api.models.http_healthcheck_request import HttpHealthcheckRequest as HttpHealthcheckRequest
from zrok_api.models.invite_request import InviteRequest as InviteRequest
from zrok_api.models.invite_token_generate_request import InviteTokenGenerateRequest as InviteTokenGenerateRequest
from zrok_api.models.list_frontends200_response_inner import ListFrontends200ResponseInner as ListFrontends200ResponseInner

View File

@@ -20,6 +20,8 @@ from typing import Optional
from zrok_api.models.create_frontend201_response import CreateFrontend201Response
from zrok_api.models.enroll200_response import Enroll200Response
from zrok_api.models.enroll_request import EnrollRequest
from zrok_api.models.http_healthcheck200_response import HttpHealthcheck200Response
from zrok_api.models.http_healthcheck_request import HttpHealthcheckRequest
from zrok_api.models.ping200_response import Ping200Response
from zrok_api.models.remote_access_request import RemoteAccessRequest
from zrok_api.models.remote_share200_response import RemoteShare200Response
@@ -326,6 +328,286 @@ class AgentApi:
@validate_call
def http_healthcheck(
self,
body: Optional[HttpHealthcheckRequest] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> HttpHealthcheck200Response:
"""http_healthcheck
:param body:
:type body: HttpHealthcheckRequest
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501
_param = self._http_healthcheck_serialize(
body=body,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)
_response_types_map: Dict[str, Optional[str]] = {
'200': "HttpHealthcheck200Response",
'401': None,
'500': None,
'502': None,
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
).data
@validate_call
def http_healthcheck_with_http_info(
self,
body: Optional[HttpHealthcheckRequest] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> ApiResponse[HttpHealthcheck200Response]:
"""http_healthcheck
:param body:
:type body: HttpHealthcheckRequest
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501
_param = self._http_healthcheck_serialize(
body=body,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)
_response_types_map: Dict[str, Optional[str]] = {
'200': "HttpHealthcheck200Response",
'401': None,
'500': None,
'502': None,
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
response_data.read()
return self.api_client.response_deserialize(
response_data=response_data,
response_types_map=_response_types_map,
)
@validate_call
def http_healthcheck_without_preload_content(
self,
body: Optional[HttpHealthcheckRequest] = None,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Tuple[
Annotated[StrictFloat, Field(gt=0)],
Annotated[StrictFloat, Field(gt=0)]
]
] = None,
_request_auth: Optional[Dict[StrictStr, Any]] = None,
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> RESTResponseType:
"""http_healthcheck
:param body:
:type body: HttpHealthcheckRequest
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:type _request_timeout: int, tuple(int, int), optional
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the
authentication in the spec for a single request.
:type _request_auth: dict, optional
:param _content_type: force content-type for the request.
:type _content_type: str, Optional
:param _headers: set to override the headers for a single
request; this effectively ignores the headers
in the spec for a single request.
:type _headers: dict, optional
:param _host_index: set to override the host_index for a single
request; this effectively ignores the host_index
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501
_param = self._http_healthcheck_serialize(
body=body,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
_host_index=_host_index
)
_response_types_map: Dict[str, Optional[str]] = {
'200': "HttpHealthcheck200Response",
'401': None,
'500': None,
'502': None,
}
response_data = self.api_client.call_api(
*_param,
_request_timeout=_request_timeout
)
return response_data.response
def _http_healthcheck_serialize(
self,
body,
_request_auth,
_content_type,
_headers,
_host_index,
) -> RequestSerialized:
_host = None
_collection_formats: Dict[str, str] = {
}
_path_params: Dict[str, str] = {}
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
] = {}
_body_params: Optional[bytes] = None
# process the path parameters
# process the query parameters
# process the header parameters
# process the form parameters
# process the body parameter
if body is not None:
_body_params = body
# set the HTTP header `Accept`
if 'Accept' not in _header_params:
_header_params['Accept'] = self.api_client.select_header_accept(
[
'application/zrok.v1+json'
]
)
# set the HTTP header `Content-Type`
if _content_type:
_header_params['Content-Type'] = _content_type
else:
_default_content_type = (
self.api_client.select_header_content_type(
[
'application/zrok.v1+json'
]
)
)
if _default_content_type is not None:
_header_params['Content-Type'] = _default_content_type
# authentication setting
_auth_settings: List[str] = [
'key'
]
return self.api_client.param_serialize(
method='POST',
resource_path='/agent/share/http-healthcheck',
path_params=_path_params,
query_params=_query_params,
header_params=_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
auth_settings=_auth_settings,
collection_formats=_collection_formats,
_host=_host,
_request_auth=_request_auth
)
@validate_call
def ping(
self,

View File

@@ -38,6 +38,8 @@ from zrok_api.models.environment_and_resources import EnvironmentAndResources
from zrok_api.models.frontend import Frontend
from zrok_api.models.get_sparklines200_response import GetSparklines200Response
from zrok_api.models.get_sparklines_request import GetSparklinesRequest
from zrok_api.models.http_healthcheck200_response import HttpHealthcheck200Response
from zrok_api.models.http_healthcheck_request import HttpHealthcheckRequest
from zrok_api.models.invite_request import InviteRequest
from zrok_api.models.invite_token_generate_request import InviteTokenGenerateRequest
from zrok_api.models.list_frontends200_response_inner import ListFrontends200ResponseInner

View File

@@ -0,0 +1,89 @@
# coding: utf-8
"""
zrok
zrok client access
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self
class HttpHealthcheck200Response(BaseModel):
"""
HttpHealthcheck200Response
""" # noqa: E501
healthy: Optional[StrictBool] = None
error: Optional[StrictStr] = None
__properties: ClassVar[List[str]] = ["healthy", "error"]
model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of HttpHealthcheck200Response from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of HttpHealthcheck200Response from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"healthy": obj.get("healthy"),
"error": obj.get("error")
})
return _obj

View File

@@ -0,0 +1,97 @@
# coding: utf-8
"""
zrok
zrok client access
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self
class HttpHealthcheckRequest(BaseModel):
"""
HttpHealthcheckRequest
""" # noqa: E501
env_zid: Optional[StrictStr] = Field(default=None, alias="envZId")
share_token: Optional[StrictStr] = Field(default=None, alias="shareToken")
http_verb: Optional[StrictStr] = Field(default=None, alias="httpVerb")
endpoint: Optional[StrictStr] = None
expected_http_response: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="expectedHttpResponse")
timeout_ms: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="timeoutMs")
__properties: ClassVar[List[str]] = ["envZId", "shareToken", "httpVerb", "endpoint", "expectedHttpResponse", "timeoutMs"]
model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of HttpHealthcheckRequest from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of HttpHealthcheckRequest from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"envZId": obj.get("envZId"),
"shareToken": obj.get("shareToken"),
"httpVerb": obj.get("httpVerb"),
"endpoint": obj.get("endpoint"),
"expectedHttpResponse": obj.get("expectedHttpResponse"),
"timeoutMs": obj.get("timeoutMs")
})
return _obj