|
| 1 | +# File generated from our OpenAPI spec by Stainless. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import Optional |
| 6 | + |
| 7 | +from ..types import RequestForwardingForwardResponse, request_forwarding_forward_params |
| 8 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 9 | +from .._utils import maybe_transform |
| 10 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 11 | +from .._base_client import make_request_options |
| 12 | + |
| 13 | +__all__ = ["RequestForwarding", "AsyncRequestForwarding"] |
| 14 | + |
| 15 | + |
| 16 | +class RequestForwarding(SyncAPIResource): |
| 17 | + def forward( |
| 18 | + self, |
| 19 | + *, |
| 20 | + method: str, |
| 21 | + route: str, |
| 22 | + data: Optional[str] | NotGiven = NOT_GIVEN, |
| 23 | + headers: Optional[object] | NotGiven = NOT_GIVEN, |
| 24 | + params: Optional[object] | NotGiven = NOT_GIVEN, |
| 25 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 26 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 27 | + extra_headers: Headers | None = None, |
| 28 | + extra_query: Query | None = None, |
| 29 | + extra_body: Body | None = None, |
| 30 | + timeout: float | None | NotGiven = NOT_GIVEN, |
| 31 | + ) -> RequestForwardingForwardResponse: |
| 32 | + """ |
| 33 | + The Forward API allows you to make direct requests to an employment system. |
| 34 | +
|
| 35 | + Args: |
| 36 | + method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST` |
| 37 | + , `PUT` , `DELETE` , and `PATCH`. |
| 38 | +
|
| 39 | + route: The URL route path for the forwarded request. This value must begin with a |
| 40 | + forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and |
| 41 | + underscores. |
| 42 | +
|
| 43 | + data: The body for the forwarded request. This value must be specified as either a |
| 44 | + string or a valid JSON object. |
| 45 | +
|
| 46 | + headers: The HTTP headers to include on the forwarded request. This value must be |
| 47 | + specified as an object of key-value pairs. Example: |
| 48 | + `{"Content-Type": "application/xml", "X-API-Version": "v1" }` |
| 49 | +
|
| 50 | + params: The query parameters for the forwarded request. This value must be specified as |
| 51 | + a valid JSON object rather than a query string. |
| 52 | +
|
| 53 | + extra_headers: Send extra headers |
| 54 | +
|
| 55 | + extra_query: Add additional query parameters to the request |
| 56 | +
|
| 57 | + extra_body: Add additional JSON properties to the request |
| 58 | +
|
| 59 | + timeout: Override the client-level default timeout for this request, in seconds |
| 60 | + """ |
| 61 | + return self._post( |
| 62 | + "/forward", |
| 63 | + body=maybe_transform( |
| 64 | + { |
| 65 | + "method": method, |
| 66 | + "route": route, |
| 67 | + "data": data, |
| 68 | + "headers": headers, |
| 69 | + "params": params, |
| 70 | + }, |
| 71 | + request_forwarding_forward_params.RequestForwardingForwardParams, |
| 72 | + ), |
| 73 | + options=make_request_options( |
| 74 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 75 | + ), |
| 76 | + cast_to=RequestForwardingForwardResponse, |
| 77 | + ) |
| 78 | + |
| 79 | + |
| 80 | +class AsyncRequestForwarding(AsyncAPIResource): |
| 81 | + async def forward( |
| 82 | + self, |
| 83 | + *, |
| 84 | + method: str, |
| 85 | + route: str, |
| 86 | + data: Optional[str] | NotGiven = NOT_GIVEN, |
| 87 | + headers: Optional[object] | NotGiven = NOT_GIVEN, |
| 88 | + params: Optional[object] | NotGiven = NOT_GIVEN, |
| 89 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 90 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 91 | + extra_headers: Headers | None = None, |
| 92 | + extra_query: Query | None = None, |
| 93 | + extra_body: Body | None = None, |
| 94 | + timeout: float | None | NotGiven = NOT_GIVEN, |
| 95 | + ) -> RequestForwardingForwardResponse: |
| 96 | + """ |
| 97 | + The Forward API allows you to make direct requests to an employment system. |
| 98 | +
|
| 99 | + Args: |
| 100 | + method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST` |
| 101 | + , `PUT` , `DELETE` , and `PATCH`. |
| 102 | +
|
| 103 | + route: The URL route path for the forwarded request. This value must begin with a |
| 104 | + forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and |
| 105 | + underscores. |
| 106 | +
|
| 107 | + data: The body for the forwarded request. This value must be specified as either a |
| 108 | + string or a valid JSON object. |
| 109 | +
|
| 110 | + headers: The HTTP headers to include on the forwarded request. This value must be |
| 111 | + specified as an object of key-value pairs. Example: |
| 112 | + `{"Content-Type": "application/xml", "X-API-Version": "v1" }` |
| 113 | +
|
| 114 | + params: The query parameters for the forwarded request. This value must be specified as |
| 115 | + a valid JSON object rather than a query string. |
| 116 | +
|
| 117 | + extra_headers: Send extra headers |
| 118 | +
|
| 119 | + extra_query: Add additional query parameters to the request |
| 120 | +
|
| 121 | + extra_body: Add additional JSON properties to the request |
| 122 | +
|
| 123 | + timeout: Override the client-level default timeout for this request, in seconds |
| 124 | + """ |
| 125 | + return await self._post( |
| 126 | + "/forward", |
| 127 | + body=maybe_transform( |
| 128 | + { |
| 129 | + "method": method, |
| 130 | + "route": route, |
| 131 | + "data": data, |
| 132 | + "headers": headers, |
| 133 | + "params": params, |
| 134 | + }, |
| 135 | + request_forwarding_forward_params.RequestForwardingForwardParams, |
| 136 | + ), |
| 137 | + options=make_request_options( |
| 138 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 139 | + ), |
| 140 | + cast_to=RequestForwardingForwardResponse, |
| 141 | + ) |
0 commit comments