Skip to content

Commit

Permalink
Manually apply API changes for workflow cancellations
Browse files Browse the repository at this point in the history
GitOrigin-RevId: fc8f668b6297db6af28af1eb992bb979c4975ec8
  • Loading branch information
misberner committed May 16, 2023
1 parent c195551 commit 4445007
Show file tree
Hide file tree
Showing 12 changed files with 659 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gretel_client/rest_v1/api/connections_api.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
ListConnectionsResponse,
)
from gretel_client.rest_v1.model.status import Status
from gretel_client.rest_v1.model.validate_connection_credentials_response import (
ValidateConnectionCredentialsResponse,
)
from gretel_client.rest_v1.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
Expand Down Expand Up @@ -705,7 +708,7 @@ def __validate_connection_credentials(self, connection_id, **kwargs):
async_req (bool): execute request asynchronously
Returns:
Connection
ValidateConnectionCredentialsResponse
If the method is called asynchronously, returns the request
thread.
"""
Expand All @@ -723,7 +726,7 @@ def __validate_connection_credentials(self, connection_id, **kwargs):

self.validate_connection_credentials = _Endpoint(
settings={
"response_type": (Connection,),
"response_type": (ValidateConnectionCredentialsResponse,),
"auth": [],
"endpoint_path": "/v1/connections/{connection_id}/validate-credentials",
"operation_id": "validate_connection_credentials",
Expand Down
103 changes: 103 additions & 0 deletions src/gretel_client/rest_v1/api/workflows_api.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

from gretel_client.rest_v1.api_client import ApiClient
from gretel_client.rest_v1.api_client import Endpoint as _Endpoint
from gretel_client.rest_v1.model.cancel_workflow_run_request import (
CancelWorkflowRunRequest,
)
from gretel_client.rest_v1.model.get_workflows_response import GetWorkflowsResponse
from gretel_client.rest_v1.model.search_workflow_runs_response import (
SearchWorkflowRunsResponse,
Expand Down Expand Up @@ -49,6 +52,106 @@ def __init__(self, api_client=None):
api_client = ApiClient()
self.api_client = api_client

def __cancel_workflow_run(
self, workflow_run_id, cancel_workflow_run_request, **kwargs
):
"""cancel_workflow_run # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.cancel_workflow_run(workflow_run_id, cancel_workflow_run_request, async_req=True)
>>> result = thread.get()
Args:
workflow_run_id (str):
cancel_workflow_run_request (CancelWorkflowRunRequest):
Keyword Args:
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): 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.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
WorkflowRun
If the method is called asynchronously, returns the request
thread.
"""
kwargs["async_req"] = kwargs.get("async_req", False)
kwargs["_return_http_data_only"] = kwargs.get(
"_return_http_data_only", True
)
kwargs["_preload_content"] = kwargs.get("_preload_content", True)
kwargs["_request_timeout"] = kwargs.get("_request_timeout", None)
kwargs["_check_input_type"] = kwargs.get("_check_input_type", True)
kwargs["_check_return_type"] = kwargs.get("_check_return_type", True)
kwargs["_host_index"] = kwargs.get("_host_index")
kwargs["workflow_run_id"] = workflow_run_id
kwargs["cancel_workflow_run_request"] = cancel_workflow_run_request
return self.call_with_http_info(**kwargs)

self.cancel_workflow_run = _Endpoint(
settings={
"response_type": (WorkflowRun,),
"auth": [],
"endpoint_path": "/v1/workflows/runs/{workflow_run_id}/cancel",
"operation_id": "cancel_workflow_run",
"http_method": "POST",
"servers": None,
},
params_map={
"all": [
"workflow_run_id",
"cancel_workflow_run_request",
],
"required": [
"workflow_run_id",
"cancel_workflow_run_request",
],
"nullable": [],
"enum": [],
"validation": [],
},
root_map={
"validations": {},
"allowed_values": {},
"openapi_types": {
"workflow_run_id": (str,),
"cancel_workflow_run_request": (CancelWorkflowRunRequest,),
},
"attribute_map": {
"workflow_run_id": "workflow_run_id",
},
"location_map": {
"workflow_run_id": "path",
"cancel_workflow_run_request": "body",
},
"collection_format_map": {},
},
headers_map={
"accept": ["application/json"],
"content_type": ["application/json"],
},
api_client=api_client,
callable=__cancel_workflow_run,
)

def __create_workflow(self, workflow, **kwargs):
"""create_workflow # noqa: E501
Expand Down
170 changes: 170 additions & 0 deletions src/gretel_client/rest_v1/model/cancel_workflow_run_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
"""
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""


import re # noqa: F401
import sys # noqa: F401

from gretel_client.rest_v1.model_utils import ( # noqa: F401
ApiTypeError,
cached_property,
change_keys_js_to_python,
convert_js_args_to_python_args,
date,
datetime,
file_type,
ModelComposed,
ModelNormal,
ModelSimple,
none_type,
validate_get_composed_info,
)


class CancelWorkflowRunRequest(ModelNormal):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
Attributes:
allowed_values (dict): The key is the tuple path to the attribute
and the for var_name this is (var_name,). The value is a dict
with a capitalized key describing the allowed value and an allowed
value. These dicts store the allowed enum values.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
discriminator_value_class_map (dict): A dict to go from the discriminator
variable value to the discriminator class name.
validations (dict): The key is the tuple path to the attribute
and the for var_name this is (var_name,). The value is a dict
that stores validations for max_length, min_length, max_items,
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
inclusive_minimum, and regex.
additional_properties_type (tuple): A tuple of classes accepted
as additional properties values.
"""

allowed_values = {}

validations = {}

additional_properties_type = None

_nullable = False

@cached_property
def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
return {
"workflow_run_id": (str,), # noqa: E501
}

@cached_property
def discriminator():
return None

attribute_map = {
"workflow_run_id": "workflow_run_id", # noqa: E501
}

_composed_schemas = {}

required_properties = set(
[
"_data_store",
"_check_type",
"_spec_property_naming",
"_path_to_item",
"_configuration",
"_visited_composed_classes",
]
)

@convert_js_args_to_python_args
def __init__(self, workflow_run_id, *args, **kwargs): # noqa: E501
"""CancelWorkflowRunRequest - a model defined in OpenAPI
Args:
workflow_run_id (str):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wrong type is input.
Defaults to True
_path_to_item (tuple/list): This is a list of keys or values to
drill down to the model in received_data
when deserializing a response
_spec_property_naming (bool): True if the variable names in the input data
are serialized names, as specified in the OpenAPI document.
False if the variable names in the input data
are pythonic names, e.g. snake case (default)
_configuration (Configuration): the instance to use when
deserializing a file_type parameter.
If passed, type conversion is attempted
If omitted no type conversion is done.
_visited_composed_classes (tuple): This stores a tuple of
classes that we have traveled through so that
if we see that class again we will not use its
discriminator again.
When traveling through a discriminator, the
composed schema that is
is traveled through is added to this set.
For example if Animal has a discriminator
petType and we pass in "Dog", and the class Dog
allOf includes Animal, we move through Animal
once using the discriminator, and pick Dog.
Then in Dog, we will make an instance of the
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
"""

_check_type = kwargs.pop("_check_type", True)
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
_path_to_item = kwargs.pop("_path_to_item", ())
_configuration = kwargs.pop("_configuration", None)
_visited_composed_classes = kwargs.pop("_visited_composed_classes", ())

if args:
raise ApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments."
% (
args,
self.__class__.__name__,
),
path_to_item=_path_to_item,
valid_classes=(self.__class__,),
)

self._data_store = {}
self._check_type = _check_type
self._spec_property_naming = _spec_property_naming
self._path_to_item = _path_to_item
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.workflow_run_id = workflow_run_id
for var_name, var_value in kwargs.items():
if (
var_name not in self.attribute_map
and self._configuration is not None
and self._configuration.discard_unknown_keys
and self.additional_properties_type is None
):
# discard variable.
continue
setattr(self, var_name, var_value)
5 changes: 5 additions & 0 deletions src/gretel_client/rest_v1/model/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def openapi_types():
"credentials": (
{str: (bool, date, datetime, dict, float, int, list, str, none_type)},
), # noqa: E501
"encrypted_credentials": (
{str: (bool, date, datetime, dict, float, int, list, str, none_type)},
), # noqa: E501
"created_at": (datetime,), # noqa: E501
"project_id": (str,), # noqa: E501
"created_by": (str,), # noqa: E501
Expand All @@ -98,6 +101,7 @@ def discriminator():
"name": "name", # noqa: E501
"validation_status": "validation_status", # noqa: E501
"credentials": "credentials", # noqa: E501
"encrypted_credentials": "encrypted_credentials", # noqa: E501
"created_at": "created_at", # noqa: E501
"project_id": "project_id", # noqa: E501
"created_by": "created_by", # noqa: E501
Expand Down Expand Up @@ -158,6 +162,7 @@ def __init__(self, type, *args, **kwargs): # noqa: E501
name (str): [optional] # noqa: E501
validation_status (str): [optional] # noqa: E501
credentials ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501
encrypted_credentials ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501
created_at (datetime): [optional] # noqa: E501
project_id (str): [optional] # noqa: E501
created_by (str): [optional] # noqa: E501
Expand Down
2 changes: 2 additions & 0 deletions src/gretel_client/rest_v1/model/model_run.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class ModelRun(ModelNormal):
"ERROR": "RUN_STATUS_ERROR",
"LOST": "RUN_STATUS_LOST",
"COMPLETED": "RUN_STATUS_COMPLETED",
"CANCELLING": "RUN_STATUS_CANCELLING",
"CANCELLED": "RUN_STATUS_CANCELLED",
},
}

Expand Down
2 changes: 2 additions & 0 deletions src/gretel_client/rest_v1/model/update_model_run_status_request.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class UpdateModelRunStatusRequest(ModelNormal):
"ERROR": "RUN_STATUS_ERROR",
"LOST": "RUN_STATUS_LOST",
"COMPLETED": "RUN_STATUS_COMPLETED",
"CANCELLING": "RUN_STATUS_CANCELLING",
"CANCELLED": "RUN_STATUS_CANCELLED",
},
}

Expand Down
2 changes: 2 additions & 0 deletions src/gretel_client/rest_v1/model/update_workflow_run_status_request.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class UpdateWorkflowRunStatusRequest(ModelNormal):
"ERROR": "RUN_STATUS_ERROR",
"LOST": "RUN_STATUS_LOST",
"COMPLETED": "RUN_STATUS_COMPLETED",
"CANCELLING": "RUN_STATUS_CANCELLING",
"CANCELLED": "RUN_STATUS_CANCELLED",
},
}

Expand Down
Loading

0 comments on commit 4445007

Please sign in to comment.