# This file was auto-generated by Fern from our API Definition.

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.http_validation_error import HttpValidationError
from ..types.reference import Reference
from ..types.workflow_artifact import WorkflowArtifact
from ..types.workflow_response import WorkflowResponse
from ..types.workflow_revision import WorkflowRevision
from ..types.workflow_revision_response import WorkflowRevisionResponse
from ..types.workflow_revisions_response import WorkflowRevisionsResponse
from ..types.workflow_variant import WorkflowVariant
from ..types.workflow_variant_response import WorkflowVariantResponse
from ..types.workflow_variants_response import WorkflowVariantsResponse
from ..types.workflows_response import WorkflowsResponse

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class RawWorkflowsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def list_workflows(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        workflow_flags: typing.Optional[str] = None,
        workflow_meta: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        workflow_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        workflow_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowsResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/",
            method="GET",
            params={
                "workflow_ref": workflow_ref,
                "workflow_flags": workflow_flags,
                "workflow_meta": workflow_meta,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowsResponse,
                    parse_obj_as(
                        type_=WorkflowsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def create_workflow(
        self,
        *,
        workflow: WorkflowArtifact,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow : WorkflowArtifact

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/",
            method="POST",
            json={
                "workflow": convert_and_respect_annotation_metadata(
                    object_=workflow, annotation=WorkflowArtifact, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def fetch_workflow(
        self,
        workflow_id: str,
        *,
        artifact_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        artifact_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}",
            method="GET",
            params={
                "artifact_id": artifact_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def edit_workflow(
        self,
        workflow_id: str,
        *,
        workflow: WorkflowArtifact,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        workflow : WorkflowArtifact

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}",
            method="PUT",
            json={
                "workflow": convert_and_respect_annotation_metadata(
                    object_=workflow, annotation=WorkflowArtifact, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def archive_workflow(
        self,
        workflow_id: str,
        *,
        artifact_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        artifact_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}/archive",
            method="POST",
            params={
                "artifact_id": artifact_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def unarchive_workflow(
        self,
        workflow_id: str,
        *,
        artifact_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        artifact_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}/unarchive",
            method="POST",
            params={
                "artifact_id": artifact_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def query_workflows(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        workflow_flags: typing.Optional[str] = None,
        workflow_meta: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        workflow_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        workflow_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowsResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/query",
            method="POST",
            params={
                "workflow_ref": workflow_ref,
                "workflow_flags": workflow_flags,
                "workflow_meta": workflow_meta,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowsResponse,
                    parse_obj_as(
                        type_=WorkflowsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def list_workflow_variants(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        variant_ref: typing.Optional[str] = None,
        variant_meta: typing.Optional[str] = None,
        variant_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        variant_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantsResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/variants/",
            method="GET",
            params={
                "workflow_ref": workflow_ref,
                "variant_ref": variant_ref,
                "variant_meta": variant_meta,
                "variant_flags": variant_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantsResponse,
                    parse_obj_as(
                        type_=WorkflowVariantsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def create_workflow_variant(
        self,
        *,
        variant: WorkflowVariant,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant : WorkflowVariant

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/variants/",
            method="POST",
            json={
                "variant": convert_and_respect_annotation_metadata(
                    object_=variant, annotation=WorkflowVariant, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def fetch_workflow_variant(
        self,
        variant_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def edit_workflow_variant(
        self,
        variant_id: str,
        *,
        variant: WorkflowVariant,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        variant : WorkflowVariant

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}",
            method="PUT",
            json={
                "variant": convert_and_respect_annotation_metadata(
                    object_=variant, annotation=WorkflowVariant, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def archive_workflow_variant(
        self,
        variant_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/archive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def unarchive_workflow_variant(
        self,
        variant_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/unarchive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def query_workflow_variants(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        variant_ref: typing.Optional[str] = None,
        variant_meta: typing.Optional[str] = None,
        variant_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        variant_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantsResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/variants/query",
            method="POST",
            params={
                "workflow_ref": workflow_ref,
                "variant_ref": variant_ref,
                "variant_meta": variant_meta,
                "variant_flags": variant_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantsResponse,
                    parse_obj_as(
                        type_=WorkflowVariantsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def commit_workflow_revision_by_variant_id(
        self,
        variant_id: typing.Optional[str],
        *,
        revision: WorkflowRevision,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        variant_id : typing.Optional[str]

        revision : WorkflowRevision

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/commit",
            method="POST",
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def fork_workflow_variant(
        self,
        variant_id: typing.Optional[str],
        *,
        revision: WorkflowRevision,
        revision_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : typing.Optional[str]

        revision : WorkflowRevision

        revision_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/fork",
            method="POST",
            params={
                "revision_id": revision_id,
            },
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def list_workflow_revisions(
        self,
        *,
        variant_ref: typing.Optional[str] = None,
        revision_ref: typing.Optional[str] = None,
        revision_meta: typing.Optional[str] = None,
        revision_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionsResponse]:
        """
        Parameters
        ----------
        variant_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        revision_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionsResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/",
            method="GET",
            params={
                "variant_ref": variant_ref,
                "revision_ref": revision_ref,
                "revision_meta": revision_meta,
                "revision_flags": revision_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionsResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def create_workflow_revision(
        self,
        *,
        revision: WorkflowRevision,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision : WorkflowRevision

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/",
            method="POST",
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def fetch_workflow_revision(
        self,
        revision_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def edit_workflow_revision(
        self,
        revision_id: str,
        *,
        revision: WorkflowRevision,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        revision : WorkflowRevision

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}",
            method="PUT",
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def archive_workflow_revision_rpc(
        self,
        revision_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}/archive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def unarchive_workflow_revision_rpc(
        self,
        revision_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}/unarchive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def query_workflow_revisions(
        self,
        *,
        variant_ref: typing.Optional[str] = None,
        revision_ref: typing.Optional[str] = None,
        revision_meta: typing.Optional[str] = None,
        revision_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionsResponse]:
        """
        Parameters
        ----------
        variant_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        revision_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionsResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/query",
            method="POST",
            params={
                "variant_ref": variant_ref,
                "revision_ref": revision_ref,
                "revision_meta": revision_meta,
                "revision_flags": revision_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionsResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def fork_workflow_variant_by_revision_id(
        self,
        revision_id: typing.Optional[str],
        *,
        revision: WorkflowRevision,
        variant_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        revision_id : typing.Optional[str]

        revision : WorkflowRevision

        variant_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}/fork",
            method="POST",
            params={
                "variant_id": variant_id,
            },
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def commit_workflow_revision(
        self,
        *,
        revision: WorkflowRevision,
        variant_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision : WorkflowRevision

        variant_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/commit",
            method="POST",
            params={
                "variant_id": variant_id,
            },
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    def log_workflow_revisions(
        self,
        *,
        depth: typing.Optional[int] = None,
        variant_ref: typing.Optional[Reference] = OMIT,
        revision_ref: typing.Optional[Reference] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[WorkflowRevisionsResponse]:
        """
        Parameters
        ----------
        depth : typing.Optional[int]

        variant_ref : typing.Optional[Reference]

        revision_ref : typing.Optional[Reference]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkflowRevisionsResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/log",
            method="POST",
            params={
                "depth": depth,
            },
            json={
                "variant_ref": convert_and_respect_annotation_metadata(
                    object_=variant_ref, annotation=Reference, direction="write"
                ),
                "revision_ref": convert_and_respect_annotation_metadata(
                    object_=revision_ref, annotation=Reference, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionsResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )


class AsyncRawWorkflowsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def list_workflows(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        workflow_flags: typing.Optional[str] = None,
        workflow_meta: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        workflow_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        workflow_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowsResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/",
            method="GET",
            params={
                "workflow_ref": workflow_ref,
                "workflow_flags": workflow_flags,
                "workflow_meta": workflow_meta,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowsResponse,
                    parse_obj_as(
                        type_=WorkflowsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def create_workflow(
        self,
        *,
        workflow: WorkflowArtifact,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow : WorkflowArtifact

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/",
            method="POST",
            json={
                "workflow": convert_and_respect_annotation_metadata(
                    object_=workflow, annotation=WorkflowArtifact, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def fetch_workflow(
        self,
        workflow_id: str,
        *,
        artifact_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        artifact_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}",
            method="GET",
            params={
                "artifact_id": artifact_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def edit_workflow(
        self,
        workflow_id: str,
        *,
        workflow: WorkflowArtifact,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        workflow : WorkflowArtifact

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}",
            method="PUT",
            json={
                "workflow": convert_and_respect_annotation_metadata(
                    object_=workflow, annotation=WorkflowArtifact, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def archive_workflow(
        self,
        workflow_id: str,
        *,
        artifact_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        artifact_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}/archive",
            method="POST",
            params={
                "artifact_id": artifact_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def unarchive_workflow(
        self,
        workflow_id: str,
        *,
        artifact_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowResponse]:
        """
        Parameters
        ----------
        workflow_id : str

        artifact_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/{jsonable_encoder(workflow_id)}/unarchive",
            method="POST",
            params={
                "artifact_id": artifact_id,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowResponse,
                    parse_obj_as(
                        type_=WorkflowResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def query_workflows(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        workflow_flags: typing.Optional[str] = None,
        workflow_meta: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        workflow_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        workflow_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowsResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/query",
            method="POST",
            params={
                "workflow_ref": workflow_ref,
                "workflow_flags": workflow_flags,
                "workflow_meta": workflow_meta,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowsResponse,
                    parse_obj_as(
                        type_=WorkflowsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def list_workflow_variants(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        variant_ref: typing.Optional[str] = None,
        variant_meta: typing.Optional[str] = None,
        variant_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        variant_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantsResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/variants/",
            method="GET",
            params={
                "workflow_ref": workflow_ref,
                "variant_ref": variant_ref,
                "variant_meta": variant_meta,
                "variant_flags": variant_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantsResponse,
                    parse_obj_as(
                        type_=WorkflowVariantsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def create_workflow_variant(
        self,
        *,
        variant: WorkflowVariant,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant : WorkflowVariant

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/variants/",
            method="POST",
            json={
                "variant": convert_and_respect_annotation_metadata(
                    object_=variant, annotation=WorkflowVariant, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def fetch_workflow_variant(
        self,
        variant_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def edit_workflow_variant(
        self,
        variant_id: str,
        *,
        variant: WorkflowVariant,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        variant : WorkflowVariant

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}",
            method="PUT",
            json={
                "variant": convert_and_respect_annotation_metadata(
                    object_=variant, annotation=WorkflowVariant, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def archive_workflow_variant(
        self,
        variant_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/archive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def unarchive_workflow_variant(
        self,
        variant_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/unarchive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def query_workflow_variants(
        self,
        *,
        workflow_ref: typing.Optional[str] = None,
        variant_ref: typing.Optional[str] = None,
        variant_meta: typing.Optional[str] = None,
        variant_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantsResponse]:
        """
        Parameters
        ----------
        workflow_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_ref : typing.Optional[str]
            JSON string of reference, e.g. {"key": value}

        variant_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        variant_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantsResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/variants/query",
            method="POST",
            params={
                "workflow_ref": workflow_ref,
                "variant_ref": variant_ref,
                "variant_meta": variant_meta,
                "variant_flags": variant_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantsResponse,
                    parse_obj_as(
                        type_=WorkflowVariantsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def commit_workflow_revision_by_variant_id(
        self,
        variant_id: typing.Optional[str],
        *,
        revision: WorkflowRevision,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        variant_id : typing.Optional[str]

        revision : WorkflowRevision

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/commit",
            method="POST",
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def fork_workflow_variant(
        self,
        variant_id: typing.Optional[str],
        *,
        revision: WorkflowRevision,
        revision_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        variant_id : typing.Optional[str]

        revision : WorkflowRevision

        revision_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/variants/{jsonable_encoder(variant_id)}/fork",
            method="POST",
            params={
                "revision_id": revision_id,
            },
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def list_workflow_revisions(
        self,
        *,
        variant_ref: typing.Optional[str] = None,
        revision_ref: typing.Optional[str] = None,
        revision_meta: typing.Optional[str] = None,
        revision_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionsResponse]:
        """
        Parameters
        ----------
        variant_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        revision_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionsResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/",
            method="GET",
            params={
                "variant_ref": variant_ref,
                "revision_ref": revision_ref,
                "revision_meta": revision_meta,
                "revision_flags": revision_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionsResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def create_workflow_revision(
        self,
        *,
        revision: WorkflowRevision,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision : WorkflowRevision

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/",
            method="POST",
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def fetch_workflow_revision(
        self,
        revision_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def edit_workflow_revision(
        self,
        revision_id: str,
        *,
        revision: WorkflowRevision,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        revision : WorkflowRevision

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}",
            method="PUT",
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def archive_workflow_revision_rpc(
        self,
        revision_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}/archive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def unarchive_workflow_revision_rpc(
        self,
        revision_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision_id : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}/unarchive",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def query_workflow_revisions(
        self,
        *,
        variant_ref: typing.Optional[str] = None,
        revision_ref: typing.Optional[str] = None,
        revision_meta: typing.Optional[str] = None,
        revision_flags: typing.Optional[str] = None,
        include_archived: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionsResponse]:
        """
        Parameters
        ----------
        variant_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_ref : typing.Optional[str]
            JSON string of ref, e.g. {"key": value}

        revision_meta : typing.Optional[str]
            JSON string of meta, e.g. {"key": value}

        revision_flags : typing.Optional[str]
            JSON string of flags, e.g. {"key": value}

        include_archived : typing.Optional[bool]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionsResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/query",
            method="POST",
            params={
                "variant_ref": variant_ref,
                "revision_ref": revision_ref,
                "revision_meta": revision_meta,
                "revision_flags": revision_flags,
                "include_archived": include_archived,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionsResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def fork_workflow_variant_by_revision_id(
        self,
        revision_id: typing.Optional[str],
        *,
        revision: WorkflowRevision,
        variant_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowVariantResponse]:
        """
        Parameters
        ----------
        revision_id : typing.Optional[str]

        revision : WorkflowRevision

        variant_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowVariantResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"preview/base/workflows/revisions/{jsonable_encoder(revision_id)}/fork",
            method="POST",
            params={
                "variant_id": variant_id,
            },
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowVariantResponse,
                    parse_obj_as(
                        type_=WorkflowVariantResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def commit_workflow_revision(
        self,
        *,
        revision: WorkflowRevision,
        variant_id: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionResponse]:
        """
        Parameters
        ----------
        revision : WorkflowRevision

        variant_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/commit",
            method="POST",
            params={
                "variant_id": variant_id,
            },
            json={
                "revision": convert_and_respect_annotation_metadata(
                    object_=revision, annotation=WorkflowRevision, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )

    async def log_workflow_revisions(
        self,
        *,
        depth: typing.Optional[int] = None,
        variant_ref: typing.Optional[Reference] = OMIT,
        revision_ref: typing.Optional[Reference] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[WorkflowRevisionsResponse]:
        """
        Parameters
        ----------
        depth : typing.Optional[int]

        variant_ref : typing.Optional[Reference]

        revision_ref : typing.Optional[Reference]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkflowRevisionsResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            "preview/base/workflows/revisions/log",
            method="POST",
            params={
                "depth": depth,
            },
            json={
                "variant_ref": convert_and_respect_annotation_metadata(
                    object_=variant_ref, annotation=Reference, direction="write"
                ),
                "revision_ref": convert_and_respect_annotation_metadata(
                    object_=revision_ref, annotation=Reference, direction="write"
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    WorkflowRevisionsResponse,
                    parse_obj_as(
                        type_=WorkflowRevisionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        HttpValidationError,
                        parse_obj_as(
                            type_=HttpValidationError,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(
                status_code=_response.status_code,
                headers=dict(_response.headers),
                body=_response.text,
            )
        raise ApiError(
            status_code=_response.status_code,
            headers=dict(_response.headers),
            body=_response_json,
        )
