Skip to content

Commit

Permalink
INT-2169: Add workflow config validation endpoint
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 981b37c0830768e1505d2cefb34c79f759c79830
  • Loading branch information
maxdubrinsky committed Jul 3, 2024
1 parent 87cdb20 commit 3d9098b
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/gretel_client/rest_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
from gretel_client.rest_v1.models.validate_workflow_action_response import (
ValidateWorkflowActionResponse,
)
from gretel_client.rest_v1.models.validate_workflow_config_request import (
ValidateWorkflowConfigRequest,
)
from gretel_client.rest_v1.models.workflow import Workflow
from gretel_client.rest_v1.models.workflow_run import WorkflowRun
from gretel_client.rest_v1.models.workflow_run_cancellation_request import (
Expand Down
157 changes: 157 additions & 0 deletions src/gretel_client/rest_v1/api/workflows_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
from gretel_client.rest_v1.models.validate_workflow_action_response import (
ValidateWorkflowActionResponse,
)
from gretel_client.rest_v1.models.validate_workflow_config_request import (
ValidateWorkflowConfigRequest,
)
from gretel_client.rest_v1.models.workflow import Workflow
from gretel_client.rest_v1.models.workflow_run import WorkflowRun
from gretel_client.rest_v1.models.workflow_task import WorkflowTask
Expand Down Expand Up @@ -2149,3 +2152,157 @@ def validate_workflow_action_with_http_info(
collection_formats=_collection_formats,
_request_auth=_params.get("_request_auth"),
)

@validate_arguments
def validate_workflow_config(
self, validate_workflow_config_request: ValidateWorkflowConfigRequest, **kwargs
) -> None: # noqa: E501
"""validate_workflow_config # noqa: E501
Validate a workflow config. This endpoint will validate a workflow config, returning a status and message indicating if the config is valid # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.validate_workflow_config(validate_workflow_config_request, async_req=True)
>>> result = thread.get()
:param validate_workflow_config_request: (required)
:type validate_workflow_config_request: ValidateWorkflowConfigRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
: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.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: None
"""
kwargs["_return_http_data_only"] = True
if "_preload_content" in kwargs:
raise ValueError(
"Error! Please call the validate_workflow_config_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"
)
return self.validate_workflow_config_with_http_info(
validate_workflow_config_request, **kwargs
) # noqa: E501

@validate_arguments
def validate_workflow_config_with_http_info(
self, validate_workflow_config_request: ValidateWorkflowConfigRequest, **kwargs
) -> ApiResponse: # noqa: E501
"""validate_workflow_config # noqa: E501
Validate a workflow config. This endpoint will validate a workflow config, returning a status and message indicating if the config is valid # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.validate_workflow_config_with_http_info(validate_workflow_config_request, async_req=True)
>>> result = thread.get()
:param validate_workflow_config_request: (required)
:type validate_workflow_config_request: ValidateWorkflowConfigRequest
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the ApiResponse.data will
be set to none and raw_data will store the
HTTP response body without reading/decoding.
Default is True.
:type _preload_content: bool, optional
:param _return_http_data_only: response data instead of ApiResponse
object with status code, headers, etc
:type _return_http_data_only: bool, optional
: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.
: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
:type _content_type: string, optional: force content-type for the request
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: None
"""

_params = locals()

_all_params = ["validate_workflow_config_request"]
_all_params.extend(
[
"async_req",
"_return_http_data_only",
"_preload_content",
"_request_timeout",
"_request_auth",
"_content_type",
"_headers",
]
)

# validate the arguments
for _key, _val in _params["kwargs"].items():
if _key not in _all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method validate_workflow_config" % _key
)
_params[_key] = _val
del _params["kwargs"]

_collection_formats = {}

# process the path parameters
_path_params = {}

# process the query parameters
_query_params = []
# process the header parameters
_header_params = dict(_params.get("_headers", {}))
# process the form parameters
_form_params = []
_files = {}
# process the body parameter
_body_params = None
if _params["validate_workflow_config_request"] is not None:
_body_params = _params["validate_workflow_config_request"]

# set the HTTP header `Accept`
_header_params["Accept"] = self.api_client.select_header_accept(
["application/json"]
) # noqa: E501

# set the HTTP header `Content-Type`
_content_types_list = _params.get(
"_content_type",
self.api_client.select_header_content_type(["application/json"]),
)
if _content_types_list:
_header_params["Content-Type"] = _content_types_list

# authentication setting
_auth_settings = [] # noqa: E501

_response_types_map = {}

return self.api_client.call_api(
"/v1/workflows/validate-config",
"POST",
_path_params,
_query_params,
_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
response_types_map=_response_types_map,
auth_settings=_auth_settings,
async_req=_params.get("async_req"),
_return_http_data_only=_params.get("_return_http_data_only"), # noqa: E501
_preload_content=_params.get("_preload_content", True),
_request_timeout=_params.get("_request_timeout"),
collection_formats=_collection_formats,
_request_auth=_params.get("_request_auth"),
)
3 changes: 3 additions & 0 deletions src/gretel_client/rest_v1/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
from gretel_client.rest_v1.models.validate_workflow_action_response import (
ValidateWorkflowActionResponse,
)
from gretel_client.rest_v1.models.validate_workflow_config_request import (
ValidateWorkflowConfigRequest,
)
from gretel_client.rest_v1.models.workflow import Workflow
from gretel_client.rest_v1.models.workflow_run import WorkflowRun
from gretel_client.rest_v1.models.workflow_run_cancellation_request import (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# coding: utf-8

"""
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 0.0.1
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501


from __future__ import annotations

import json
import pprint
import re # noqa: F401

from typing import Any, Dict, Optional

from pydantic import BaseModel, Field, StrictStr, validator


class ValidateWorkflowConfigRequest(BaseModel):
"""
ValidateWorkflowConfigRequest
"""

config: Dict[str, Any] = Field(...)
runner_mode: Optional[StrictStr] = None
__properties = ["config", "runner_mode"]

@validator("runner_mode")
def runner_mode_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in (
"RUNNER_MODE_UNSET",
"RUNNER_MODE_CLOUD",
"RUNNER_MODE_HYBRID",
"RUNNER_MODE_INVALID",
):
raise ValueError(
"must be one of enum values ('RUNNER_MODE_UNSET', 'RUNNER_MODE_CLOUD', 'RUNNER_MODE_HYBRID', 'RUNNER_MODE_INVALID')"
)
return value

class Config:
"""Pydantic configuration"""

allow_population_by_field_name = True
validate_assignment = True

def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> ValidateWorkflowConfigRequest:
"""Create an instance of ValidateWorkflowConfigRequest from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
return _dict

@classmethod
def from_dict(cls, obj: dict) -> ValidateWorkflowConfigRequest:
"""Create an instance of ValidateWorkflowConfigRequest from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return ValidateWorkflowConfigRequest.parse_obj(obj)

_obj = ValidateWorkflowConfigRequest.parse_obj(
{"config": obj.get("config"), "runner_mode": obj.get("runner_mode")}
)
return _obj

0 comments on commit 3d9098b

Please sign in to comment.