GeezerVison is showing dolphinscheduler.apache.org — HTTP — apache-dolphinscheduler 4.1.0-dev documentation
HTTP
Task shell.
-
class pydolphinscheduler.tasks.http.Http(name: str, url: str, http_method: str | None = 'GET', http_params: dict | None = None, http_check_condition: str | None = 'STATUS_CODE_DEFAULT', condition: str | None = None, connect_timeout: int | None = 60000, socket_timeout: int | None = 60000, *args, **kwargs)[source]
Bases: BatchTask
Task HTTP object, declare behavior for HTTP task to dolphinscheduler.
- param name:
The name or identifier for the HTTP task.
- param url:
The URL endpoint for the HTTP request.
- param http_method:
The HTTP method for the request (GET, POST, etc.). Defaults to HttpMethod.GET.
- param http_params:
Parameters for the HTTP request. Defaults to None.
- param http_check_condition:
Condition for checking the HTTP response status.
Defaults to HttpCheckCondition.STATUS_CODE_DEFAULT.
- param condition:
Additional condition to evaluate if http_check_condition is not STATUS_CODE_DEFAULT.
- param connect_timeout:
Connection timeout for the HTTP request in milliseconds. Defaults to 60000.
- param socket_timeout:
Socket timeout for the HTTP request in milliseconds. Defaults to 60000.
- Attributes:
- _task_custom_attr (set): A set containing custom attributes specific to the Http task,
including ‘url’, ‘http_method’, ‘http_params’, and more.
- Raises:
PyDSParamException: Exception raised for invalid parameters, such as unsupported HTTP methods or conditions.
- Example:
Usage example for creating an HTTP task:
http_task = Http(name=”http_task”, url=”https://api.example.com”, http_method=”POST”, http_params={“key”: “value”})
-
_downstream_task_codes: set[int]
-
_task_custom_attr: set = {'condition', 'connect_timeout', 'http_check_condition', 'http_method', 'http_params', 'socket_timeout', 'url'}
-
_task_relation: set[TaskRelation]
-
_timeout: timedelta | int
-
_upstream_task_codes: set[int]
-
property http_params
Property to convert http_params using ParameterHelper when accessed.
-
class pydolphinscheduler.tasks.http.HttpCheckCondition[source]
Bases: object
Constant of HTTP check condition.
For now it contain four value:
- STATUS_CODE_DEFAULT: when http response code equal to 200, mark as success.
- STATUS_CODE_CUSTOM: when http response code equal to the code user define, mark as success.
- BODY_CONTAINS: when http response body contain text user define, mark as success.
- BODY_NOT_CONTAINS: when http response body do not contain text user define, mark as success.
-
BODY_CONTAINS = 'BODY_CONTAINS'
-
BODY_NOT_CONTAINS = 'BODY_NOT_CONTAINS'
-
STATUS_CODE_CUSTOM = 'STATUS_CODE_CUSTOM'
-
STATUS_CODE_DEFAULT = 'STATUS_CODE_DEFAULT'
-
class pydolphinscheduler.tasks.http.HttpMethod[source]
Bases: object
Constant of HTTP method.
-
DELETE = 'DELETE'
-
GET = 'GET'
-
HEAD = 'HEAD'
-
POST = 'POST'
-
PUT = 'PUT'
YAML file example
# Define the workflow
workflow:
name: "Http"
# Define the tasks within the workflow
tasks:
- name: task
task_type: Http
url: "https://httpbin.org/get"
http_method: "GET"
http_params:
- { "prop": "a", "httpParametersType": "PARAMETER", "value": "1" }
- { "prop": "b", "httpParametersType": "PARAMETER", "value": "2" }
- {
"prop": "Content-Type",
"httpParametersType": "header",
"value": "test",
}
http_check_condition: "STATUS_CODE_CUSTOM"
condition: "404"
|