Skip to content

Commit f8ce60d

Browse files
feat(api): update via SDK Studio
1 parent 87524c3 commit f8ce60d

File tree

99 files changed

+682
-3885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+682
-3885
lines changed

README.md

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ The full API of this library can be found in [api.md](api.md).
2929
```python
3030
from gitpod import Gitpod
3131

32-
client = Gitpod()
33-
34-
runner = client.runners.create(
35-
connect_protocol_version=1,
32+
client = Gitpod(
33+
connect_protocol_version=True,
34+
connect_timeout_header=0,
3635
)
36+
37+
runner = client.runners.create()
3738
print(runner.access_token)
3839
```
3940

@@ -50,13 +51,14 @@ Simply import `AsyncGitpod` instead of `Gitpod` and use `await` with each API ca
5051
import asyncio
5152
from gitpod import AsyncGitpod
5253

53-
client = AsyncGitpod()
54+
client = AsyncGitpod(
55+
connect_protocol_version=True,
56+
connect_timeout_header=0,
57+
)
5458

5559

5660
async def main() -> None:
57-
runner = await client.runners.create(
58-
connect_protocol_version=1,
59-
)
61+
runner = await client.runners.create()
6062
print(runner.access_token)
6163

6264

@@ -87,12 +89,13 @@ All errors inherit from `gitpod.APIError`.
8789
import gitpod
8890
from gitpod import Gitpod
8991

90-
client = Gitpod()
92+
client = Gitpod(
93+
connect_protocol_version=True,
94+
connect_timeout_header=0,
95+
)
9196

9297
try:
93-
client.runners.create(
94-
connect_protocol_version=1,
95-
)
98+
client.runners.create()
9699
except gitpod.APIConnectionError as e:
97100
print("The server could not be reached")
98101
print(e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -132,12 +135,12 @@ from gitpod import Gitpod
132135
client = Gitpod(
133136
# default is 2
134137
max_retries=0,
138+
connect_protocol_version=True,
139+
connect_timeout_header=0,
135140
)
136141

137142
# Or, configure per-request:
138-
client.with_options(max_retries=5).runners.create(
139-
connect_protocol_version=1,
140-
)
143+
client.with_options(max_retries=5).runners.create()
141144
```
142145

143146
### Timeouts
@@ -152,17 +155,19 @@ from gitpod import Gitpod
152155
client = Gitpod(
153156
# 20 seconds (default is 1 minute)
154157
timeout=20.0,
158+
connect_protocol_version=True,
159+
connect_timeout_header=0,
155160
)
156161

157162
# More granular control:
158163
client = Gitpod(
159164
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
165+
connect_protocol_version=True,
166+
connect_timeout_header=0,
160167
)
161168

162169
# Override per-request:
163-
client.with_options(timeout=5.0).runners.create(
164-
connect_protocol_version=1,
165-
)
170+
client.with_options(timeout=5.0).runners.create()
166171
```
167172

168173
On timeout, an `APITimeoutError` is thrown.
@@ -202,10 +207,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
202207
```py
203208
from gitpod import Gitpod
204209

205-
client = Gitpod()
206-
response = client.runners.with_raw_response.create(
207-
connect_protocol_version=1,
210+
client = Gitpod(
211+
connect_protocol_version=True,
212+
connect_timeout_header=0,
208213
)
214+
response = client.runners.with_raw_response.create()
209215
print(response.headers.get('X-My-Header'))
210216

211217
runner = response.parse() # get the object that `runners.create()` would have returned
@@ -223,9 +229,7 @@ The above interface eagerly reads the full response body when you make the reque
223229
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
224230

225231
```python
226-
with client.runners.with_streaming_response.create(
227-
connect_protocol_version=1,
228-
) as response:
232+
with client.runners.with_streaming_response.create() as response:
229233
print(response.headers.get("X-My-Header"))
230234

231235
for line in response.iter_lines():
@@ -287,6 +291,8 @@ client = Gitpod(
287291
proxy="http://my.test.proxy.example.com",
288292
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
289293
),
294+
connect_protocol_version=True,
295+
connect_timeout_header=0,
290296
)
291297
```
292298

@@ -303,7 +309,10 @@ By default the library closes underlying HTTP connections whenever the client is
303309
```py
304310
from gitpod import Gitpod
305311

306-
with Gitpod() as client:
312+
with Gitpod(
313+
connect_protocol_version=True,
314+
connect_timeout_header=0,
315+
) as client:
307316
# make requests here
308317
...
309318

src/gitpod/_client.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,15 @@ class Gitpod(SyncAPIClient):
5454

5555
# client options
5656
bearer_token: str
57+
connect_protocol_version: bool
58+
connect_timeout_header: float
5759

5860
def __init__(
5961
self,
6062
*,
6163
bearer_token: str | None = None,
64+
connect_protocol_version: bool | None = 1,
65+
connect_timeout_header: float,
6266
base_url: str | httpx.URL | None = None,
6367
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
6468
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -90,6 +94,12 @@ def __init__(
9094
)
9195
self.bearer_token = bearer_token
9296

97+
if connect_protocol_version is None:
98+
connect_protocol_version = 1
99+
self.connect_protocol_version = connect_protocol_version
100+
101+
self.connect_timeout_header = connect_timeout_header
102+
93103
if base_url is None:
94104
base_url = os.environ.get("GITPOD_BASE_URL")
95105
if base_url is None:
@@ -134,13 +144,17 @@ def default_headers(self) -> dict[str, str | Omit]:
134144
return {
135145
**super().default_headers,
136146
"X-Stainless-Async": "false",
147+
"Connect-Protocol-Version": str(self.connect_protocol_version),
148+
"Connect-Timeout-Ms": str(self.connect_timeout_header),
137149
**self._custom_headers,
138150
}
139151

140152
def copy(
141153
self,
142154
*,
143155
bearer_token: str | None = None,
156+
connect_protocol_version: bool | None = None,
157+
connect_timeout_header: float | None = None,
144158
base_url: str | httpx.URL | None = None,
145159
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
146160
http_client: httpx.Client | None = None,
@@ -175,6 +189,8 @@ def copy(
175189
http_client = http_client or self._client
176190
return self.__class__(
177191
bearer_token=bearer_token or self.bearer_token,
192+
connect_protocol_version=connect_protocol_version or self.connect_protocol_version,
193+
connect_timeout_header=connect_timeout_header or self.connect_timeout_header,
178194
base_url=base_url or self.base_url,
179195
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
180196
http_client=http_client,
@@ -236,11 +252,15 @@ class AsyncGitpod(AsyncAPIClient):
236252

237253
# client options
238254
bearer_token: str
255+
connect_protocol_version: bool
256+
connect_timeout_header: float
239257

240258
def __init__(
241259
self,
242260
*,
243261
bearer_token: str | None = None,
262+
connect_protocol_version: bool | None = 1,
263+
connect_timeout_header: float,
244264
base_url: str | httpx.URL | None = None,
245265
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
246266
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -272,6 +292,12 @@ def __init__(
272292
)
273293
self.bearer_token = bearer_token
274294

295+
if connect_protocol_version is None:
296+
connect_protocol_version = 1
297+
self.connect_protocol_version = connect_protocol_version
298+
299+
self.connect_timeout_header = connect_timeout_header
300+
275301
if base_url is None:
276302
base_url = os.environ.get("GITPOD_BASE_URL")
277303
if base_url is None:
@@ -316,13 +342,17 @@ def default_headers(self) -> dict[str, str | Omit]:
316342
return {
317343
**super().default_headers,
318344
"X-Stainless-Async": f"async:{get_async_library()}",
345+
"Connect-Protocol-Version": str(self.connect_protocol_version),
346+
"Connect-Timeout-Ms": str(self.connect_timeout_header),
319347
**self._custom_headers,
320348
}
321349

322350
def copy(
323351
self,
324352
*,
325353
bearer_token: str | None = None,
354+
connect_protocol_version: bool | None = None,
355+
connect_timeout_header: float | None = None,
326356
base_url: str | httpx.URL | None = None,
327357
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
328358
http_client: httpx.AsyncClient | None = None,
@@ -357,6 +387,8 @@ def copy(
357387
http_client = http_client or self._client
358388
return self.__class__(
359389
bearer_token=bearer_token or self.bearer_token,
390+
connect_protocol_version=connect_protocol_version or self.connect_protocol_version,
391+
connect_timeout_header=connect_timeout_header or self.connect_timeout_header,
360392
base_url=base_url or self.base_url,
361393
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
362394
http_client=http_client,

src/gitpod/resources/environment_classes.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Literal
6-
75
import httpx
86

97
from ..types import environment_class_list_params
108
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
119
from .._utils import (
12-
is_given,
1310
maybe_transform,
14-
strip_not_given,
1511
async_maybe_transform,
1612
)
1713
from .._compat import cached_property
@@ -51,10 +47,8 @@ def with_streaming_response(self) -> EnvironmentClassesResourceWithStreamingResp
5147
def list(
5248
self,
5349
*,
54-
connect_protocol_version: Literal[1],
5550
filter: environment_class_list_params.Filter | NotGiven = NOT_GIVEN,
5651
pagination: environment_class_list_params.Pagination | NotGiven = NOT_GIVEN,
57-
connect_timeout_ms: float | NotGiven = NOT_GIVEN,
5852
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5953
# The extra values given here take precedence over values defined on the client or passed to this method.
6054
extra_headers: Headers | None = None,
@@ -69,12 +63,8 @@ def list(
6963
query buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE
7064
7165
Args:
72-
connect_protocol_version: Define the version of the Connect protocol
73-
7466
pagination: pagination contains the pagination options for listing environment classes
7567
76-
connect_timeout_ms: Define the timeout, in ms
77-
7868
extra_headers: Send extra headers
7969
8070
extra_query: Add additional query parameters to the request
@@ -83,15 +73,6 @@ def list(
8373
8474
timeout: Override the client-level default timeout for this request, in seconds
8575
"""
86-
extra_headers = {
87-
**strip_not_given(
88-
{
89-
"Connect-Protocol-Version": str(connect_protocol_version),
90-
"Connect-Timeout-Ms": str(connect_timeout_ms) if is_given(connect_timeout_ms) else NOT_GIVEN,
91-
}
92-
),
93-
**(extra_headers or {}),
94-
}
9576
return self._post(
9677
"/gitpod.v1.EnvironmentService/ListEnvironmentClasses",
9778
body=maybe_transform(
@@ -131,10 +112,8 @@ def with_streaming_response(self) -> AsyncEnvironmentClassesResourceWithStreamin
131112
async def list(
132113
self,
133114
*,
134-
connect_protocol_version: Literal[1],
135115
filter: environment_class_list_params.Filter | NotGiven = NOT_GIVEN,
136116
pagination: environment_class_list_params.Pagination | NotGiven = NOT_GIVEN,
137-
connect_timeout_ms: float | NotGiven = NOT_GIVEN,
138117
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
139118
# The extra values given here take precedence over values defined on the client or passed to this method.
140119
extra_headers: Headers | None = None,
@@ -149,12 +128,8 @@ async def list(
149128
query buf:lint:ignore RPC_REQUEST_RESPONSE_UNIQUE
150129
151130
Args:
152-
connect_protocol_version: Define the version of the Connect protocol
153-
154131
pagination: pagination contains the pagination options for listing environment classes
155132
156-
connect_timeout_ms: Define the timeout, in ms
157-
158133
extra_headers: Send extra headers
159134
160135
extra_query: Add additional query parameters to the request
@@ -163,15 +138,6 @@ async def list(
163138
164139
timeout: Override the client-level default timeout for this request, in seconds
165140
"""
166-
extra_headers = {
167-
**strip_not_given(
168-
{
169-
"Connect-Protocol-Version": str(connect_protocol_version),
170-
"Connect-Timeout-Ms": str(connect_timeout_ms) if is_given(connect_timeout_ms) else NOT_GIVEN,
171-
}
172-
),
173-
**(extra_headers or {}),
174-
}
175141
return await self._post(
176142
"/gitpod.v1.EnvironmentService/ListEnvironmentClasses",
177143
body=await async_maybe_transform(

0 commit comments

Comments
 (0)