"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from .basesdk import BaseSDK
from apideck_unify import models, utils
from apideck_unify._hooks import HookContext
from apideck_unify.types import OptionalNullable, UNSET
from apideck_unify.utils import get_security_from_env
from apideck_unify.utils.unmarshal_json_response import unmarshal_json_response
from enum import Enum
import io
from typing import Any, Dict, IO, Mapping, Optional, Union


class GetAcceptEnum(str, Enum):
    APPLICATION_JSON = "application/json"
    TEXT_CSV = "text/csv"
    TEXT_PLAIN = "text/plain"
    APPLICATION_OCTET_STREAM = "application/octet-stream"
    APPLICATION_PDF = "application/pdf"
    APPLICATION_XML = "application/xml"
    TEXT_HTML = "text/html"


class OptionsAcceptEnum(str, Enum):
    APPLICATION_JSON = "application/json"
    TEXT_CSV = "text/csv"
    TEXT_PLAIN = "text/plain"
    APPLICATION_OCTET_STREAM = "application/octet-stream"
    APPLICATION_PDF = "application/pdf"
    APPLICATION_XML = "application/xml"
    TEXT_HTML = "text/html"


class PostAcceptEnum(str, Enum):
    APPLICATION_JSON = "application/json"
    TEXT_CSV = "text/csv"
    TEXT_PLAIN = "text/plain"
    APPLICATION_OCTET_STREAM = "application/octet-stream"
    APPLICATION_PDF = "application/pdf"
    APPLICATION_XML = "application/xml"
    TEXT_HTML = "text/html"


class PutAcceptEnum(str, Enum):
    APPLICATION_JSON = "application/json"
    TEXT_CSV = "text/csv"
    TEXT_PLAIN = "text/plain"
    APPLICATION_OCTET_STREAM = "application/octet-stream"
    APPLICATION_PDF = "application/pdf"
    APPLICATION_XML = "application/xml"
    TEXT_HTML = "text/html"


class PatchAcceptEnum(str, Enum):
    APPLICATION_JSON = "application/json"
    TEXT_CSV = "text/csv"
    TEXT_PLAIN = "text/plain"
    APPLICATION_OCTET_STREAM = "application/octet-stream"
    APPLICATION_PDF = "application/pdf"
    APPLICATION_XML = "application/xml"
    TEXT_HTML = "text/html"


class DeleteAcceptEnum(str, Enum):
    APPLICATION_JSON = "application/json"
    TEXT_CSV = "text/csv"
    TEXT_PLAIN = "text/plain"
    APPLICATION_OCTET_STREAM = "application/octet-stream"
    APPLICATION_PDF = "application/pdf"
    APPLICATION_XML = "application/xml"
    TEXT_HTML = "text/html"


class Proxy(BaseSDK):
    def get(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[GetAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyGetProxyResponse:
        r"""GET

        Proxies a downstream GET request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyGetProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
        )

        req = self._build_request(
            method="GET",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyGetProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.getProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyGetProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyGetProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyGetProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = utils.stream_to_text(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    async def get_async(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[GetAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyGetProxyResponse:
        r"""GET

        Proxies a downstream GET request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyGetProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
        )

        req = self._build_request_async(
            method="GET",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyGetProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.getProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyGetProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyGetProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyGetProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = await utils.stream_to_text_async(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    def options(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[OptionsAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyOptionsProxyResponse:
        r"""OPTIONS

        Proxies a downstream OPTION request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyOptionsProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
        )

        req = self._build_request(
            method="OPTIONS",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyOptionsProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.optionsProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyOptionsProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyOptionsProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyOptionsProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = utils.stream_to_text(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    async def options_async(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[OptionsAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyOptionsProxyResponse:
        r"""OPTIONS

        Proxies a downstream OPTION request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyOptionsProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
        )

        req = self._build_request_async(
            method="OPTIONS",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyOptionsProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.optionsProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyOptionsProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyOptionsProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyOptionsProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = await utils.stream_to_text_async(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    def post(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        request_body: Optional[Union[bytes, IO[bytes], io.BufferedReader]] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[PostAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyPostProxyResponse:
        r"""POST

        Proxies a downstream POST request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param request_body: Depending on the verb/method of the request this will contain the request body you want to POST/PATCH/PUT.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyPostProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
            request_body=request_body,
        )

        req = self._build_request(
            method="POST",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyPostProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.request_body,
                False,
                True,
                "raw",
                Optional[Union[bytes, IO[bytes], io.BufferedReader]],
            ),
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.postProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyPostProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyPostProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPostProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = utils.stream_to_text(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    async def post_async(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        request_body: Optional[Union[bytes, IO[bytes], io.BufferedReader]] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[PostAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyPostProxyResponse:
        r"""POST

        Proxies a downstream POST request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param request_body: Depending on the verb/method of the request this will contain the request body you want to POST/PATCH/PUT.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyPostProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
            request_body=request_body,
        )

        req = self._build_request_async(
            method="POST",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyPostProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.request_body,
                False,
                True,
                "raw",
                Optional[Union[bytes, IO[bytes], io.BufferedReader]],
            ),
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.postProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyPostProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyPostProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPostProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = await utils.stream_to_text_async(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    def put(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        request_body: Optional[Union[bytes, IO[bytes], io.BufferedReader]] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[PutAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyPutProxyResponse:
        r"""PUT

        Proxies a downstream PUT request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param request_body: Depending on the verb/method of the request this will contain the request body you want to POST/PATCH/PUT.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyPutProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
            request_body=request_body,
        )

        req = self._build_request(
            method="PUT",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyPutProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.request_body,
                False,
                True,
                "raw",
                Optional[Union[bytes, IO[bytes], io.BufferedReader]],
            ),
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.putProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyPutProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyPutProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPutProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = utils.stream_to_text(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    async def put_async(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        request_body: Optional[Union[bytes, IO[bytes], io.BufferedReader]] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[PutAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyPutProxyResponse:
        r"""PUT

        Proxies a downstream PUT request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param request_body: Depending on the verb/method of the request this will contain the request body you want to POST/PATCH/PUT.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyPutProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
            request_body=request_body,
        )

        req = self._build_request_async(
            method="PUT",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyPutProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.request_body,
                False,
                True,
                "raw",
                Optional[Union[bytes, IO[bytes], io.BufferedReader]],
            ),
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.putProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyPutProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyPutProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPutProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = await utils.stream_to_text_async(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    def patch(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        request_body: Optional[Union[bytes, IO[bytes], io.BufferedReader]] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[PatchAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyPatchProxyResponse:
        r"""PATCH

        Proxies a downstream PATCH request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param request_body: Depending on the verb/method of the request this will contain the request body you want to POST/PATCH/PUT.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyPatchProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
            request_body=request_body,
        )

        req = self._build_request(
            method="PATCH",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyPatchProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.request_body,
                False,
                True,
                "raw",
                Optional[Union[bytes, IO[bytes], io.BufferedReader]],
            ),
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.patchProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyPatchProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyPatchProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyPatchProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = utils.stream_to_text(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    async def patch_async(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        request_body: Optional[Union[bytes, IO[bytes], io.BufferedReader]] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[PatchAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyPatchProxyResponse:
        r"""PATCH

        Proxies a downstream PATCH request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param request_body: Depending on the verb/method of the request this will contain the request body you want to POST/PATCH/PUT.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyPatchProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
            request_body=request_body,
        )

        req = self._build_request_async(
            method="PATCH",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyPatchProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            get_serialized_body=lambda: utils.serialize_request_body(
                request.request_body,
                False,
                True,
                "raw",
                Optional[Union[bytes, IO[bytes], io.BufferedReader]],
            ),
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.patchProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyPatchProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyPatchProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyPatchProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = await utils.stream_to_text_async(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    def delete(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[DeleteAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyDeleteProxyResponse:
        r"""DELETE

        Proxies a downstream DELETE request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyDeleteProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
        )

        req = self._build_request(
            method="DELETE",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyDeleteProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = self.do_request(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.deleteProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyDeleteProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyDeleteProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = utils.stream_to_text(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = utils.stream_to_text(http_res)
            return models.ProxyDeleteProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = utils.stream_to_text(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)

    async def delete_async(
        self,
        *,
        service_id: str,
        downstream_url: str,
        consumer_id: Optional[str] = None,
        app_id: Optional[str] = None,
        unified_api: Optional[str] = None,
        downstream_authorization: Optional[str] = None,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        accept_header_override: Optional[DeleteAcceptEnum] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    ) -> models.ProxyDeleteProxyResponse:
        r"""DELETE

        Proxies a downstream DELETE request to a service and injects the necessary credentials into a request stored in Vault. This allows you to have an additional security layer and logging without needing to rely on Unify for normalization.
        **Note**: Vault will proxy all data to the downstream URL and method/verb in the headers.


        :param service_id: Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.
        :param downstream_url: Downstream URL
        :param consumer_id: ID of the consumer which you want to get or push data from
        :param app_id: The ID of your Unify application
        :param unified_api: Specify which unified API to use for the connection lookup. Required for multi-API connectors (e.g., Workday) to ensure the correct credentials are used.
        :param downstream_authorization: Downstream authorization header. This will skip the Vault token injection.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param accept_header_override: Override the default accept header for this method
        :param http_headers: Additional headers to set or replace on requests.
        """
        base_url = None
        url_variables = None
        if timeout_ms is None:
            timeout_ms = self.sdk_configuration.timeout_ms

        if server_url is not None:
            base_url = server_url
        else:
            base_url = self._get_url(base_url, url_variables)

        request = models.ProxyDeleteProxyRequest(
            consumer_id=consumer_id,
            app_id=app_id,
            service_id=service_id,
            unified_api=unified_api,
            downstream_url=downstream_url,
            downstream_authorization=downstream_authorization,
        )

        req = self._build_request_async(
            method="DELETE",
            path="/proxy",
            base_url=base_url,
            url_variables=url_variables,
            request=request,
            request_body_required=False,
            request_has_path_params=False,
            request_has_query_params=True,
            user_agent_header="user-agent",
            accept_header_value=accept_header_override.value
            if accept_header_override is not None
            else "application/json;q=1, text/csv;q=0.9, text/plain;q=0.7, application/octet-stream;q=0.6, application/pdf;q=0.4, application/xml;q=0.3, text/html;q=0",
            http_headers=http_headers,
            _globals=models.ProxyDeleteProxyGlobals(
                consumer_id=self.sdk_configuration.globals.consumer_id,
                app_id=self.sdk_configuration.globals.app_id,
            ),
            security=self.sdk_configuration.security,
            timeout_ms=timeout_ms,
        )

        if retries == UNSET:
            if self.sdk_configuration.retry_config is not UNSET:
                retries = self.sdk_configuration.retry_config
            else:
                retries = utils.RetryConfig(
                    "backoff", utils.BackoffStrategy(500, 60000, 1.5, 900000), True
                )

        retry_config = None
        if isinstance(retries, utils.RetryConfig):
            retry_config = (retries, ["408", "500", "502", "503", "504"])

        http_res = await self.do_request_async(
            hook_ctx=HookContext(
                config=self.sdk_configuration,
                base_url=base_url or "",
                operation_id="proxy.deleteProxy",
                oauth2_scopes=None,
                security_source=get_security_from_env(
                    self.sdk_configuration.security, models.Security
                ),
            ),
            request=req,
            error_status_codes=["401", "4XX", "5XX"],
            stream=True,
            retry_config=retry_config,
        )

        response_data: Any = None
        if utils.match_response(http_res, "200", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                response_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/octet-stream"):
            return models.ProxyDeleteProxyResponse(
                response_binary=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/pdf"):
            return models.ProxyDeleteProxyResponse(
                response_pdf=http_res,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                response_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/csv"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                response_csv=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "200", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                response_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers={},
            )
        if utils.match_response(http_res, "401", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            response_data = unmarshal_json_response(
                models.UnauthorizedData, http_res, http_res_text
            )
            raise models.Unauthorized(response_data, http_res, http_res_text)
        if utils.match_response(http_res, "4XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "5XX", "*"):
            http_res_text = await utils.stream_to_text_async(http_res)
            raise models.APIError("API error occurred", http_res, http_res_text)
        if utils.match_response(http_res, "default", "application/json"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                error_json=unmarshal_json_response(
                    Optional[Dict[str, Any]], http_res, http_res_text
                ),
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "application/xml"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                error_xml=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/html"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                error_html=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )
        if utils.match_response(http_res, "default", "text/plain"):
            http_res_text = await utils.stream_to_text_async(http_res)
            return models.ProxyDeleteProxyResponse(
                error_text=http_res_text,
                http_meta=models.HTTPMetadata(request=req, response=http_res),
                headers=utils.get_response_headers(http_res.headers),
            )

        http_res_text = await utils.stream_to_text_async(http_res)
        raise models.APIError("Unexpected response received", http_res, http_res_text)
