Skip to content

Commit fc53592

Browse files
committed
ci: regenerated with OpenAPI Doc 0.4.0, Speakeasy CLI 1.176.0
1 parent a64eca0 commit fc53592

File tree

12 files changed

+204
-23
lines changed

12 files changed

+204
-23
lines changed

.speakeasy/gen.lock

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
lockVersion: 2.0.0
22
id: 89968bf0-a755-4d50-9acb-d47410010f05
33
management:
4-
docChecksum: dff663dce4f21ddf3fc2332b7d7be92b
4+
docChecksum: 557634d4bb5964b949ae70f79f40d856
55
docVersion: 0.4.0
66
speakeasyVersion: internal
7-
generationVersion: 2.250.16
8-
releaseVersion: 3.0.1
9-
configChecksum: 99b8e5f3cd48d97507fa9ab6fd6e05cc
7+
generationVersion: 2.250.22
8+
releaseVersion: 3.1.0
9+
configChecksum: 54549759930fcd5f880c2ea492dac967
1010
repoURL: https://github.com/speakeasy-api/speakeasy-client-sdk-typescript.git
1111
repoSubDirectory: .
1212
installationURL: https://github.com/speakeasy-api/speakeasy-client-sdk-typescript
@@ -20,6 +20,7 @@ features:
2020
globalServerURLs: 2.82.1
2121
globals: 2.81.1
2222
inputOutputModels: 2.83.0
23+
retries: 2.82.1
2324
serverIDs: 2.81.2
2425
generatedFiles:
2526
- src/sdk/apis.ts
@@ -205,6 +206,7 @@ generatedFiles:
205206
- docs/sdks/auth/README.md
206207
- docs/sdks/requests/README.md
207208
- docs/sdks/embeds/README.md
209+
- docs/internal/utils/retryconfig.md
208210
- docs/sdks/events/README.md
209211
- USAGE.md
210212
- .gitattributes

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,116 @@ run();
356356
```
357357
<!-- End Global Parameters [global-parameters] -->
358358

359+
<!-- Start Retries [retries] -->
360+
## Retries
361+
362+
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
363+
364+
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
365+
```typescript
366+
import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";
367+
import {
368+
GenerateBumpType,
369+
InteractionType,
370+
} from "@speakeasy-api/speakeasy-client-sdk-typescript/dist/sdk/models/shared";
371+
372+
async function run() {
373+
const sdk = new Speakeasy({
374+
security: {
375+
apiKey: "<YOUR_API_KEY_HERE>",
376+
},
377+
workspaceID: "string",
378+
});
379+
380+
const res = await sdk.events.postWorkspaceEvents(
381+
{
382+
requestBody: [
383+
{
384+
createdAt: new Date("2024-11-21T06:58:42.120Z"),
385+
executionId: "string",
386+
id: "<ID>",
387+
interactionType: InteractionType.CliExec,
388+
localStartedAt: new Date("2024-05-07T12:35:47.182Z"),
389+
speakeasyApiKeyName: "string",
390+
speakeasyVersion: "string",
391+
success: false,
392+
workspaceId: "string",
393+
},
394+
],
395+
},
396+
{
397+
strategy: "backoff",
398+
backoff: {
399+
initialInterval: 1,
400+
maxInterval: 50,
401+
exponent: 1.1,
402+
maxElapsedTime: 100,
403+
},
404+
retryConnectionErrors: false,
405+
}
406+
);
407+
408+
if (res.statusCode == 200) {
409+
// handle response
410+
}
411+
}
412+
413+
run();
414+
415+
```
416+
417+
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
418+
```typescript
419+
import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";
420+
import {
421+
GenerateBumpType,
422+
InteractionType,
423+
} from "@speakeasy-api/speakeasy-client-sdk-typescript/dist/sdk/models/shared";
424+
425+
async function run() {
426+
const sdk = new Speakeasy({
427+
retry_config: {
428+
strategy: "backoff",
429+
backoff: {
430+
initialInterval: 1,
431+
maxInterval: 50,
432+
exponent: 1.1,
433+
maxElapsedTime: 100,
434+
},
435+
retryConnectionErrors: false,
436+
},
437+
security: {
438+
apiKey: "<YOUR_API_KEY_HERE>",
439+
},
440+
workspaceID: "string",
441+
});
442+
443+
const res = await sdk.events.postWorkspaceEvents({
444+
requestBody: [
445+
{
446+
createdAt: new Date("2024-11-21T06:58:42.120Z"),
447+
executionId: "string",
448+
id: "<ID>",
449+
interactionType: InteractionType.CliExec,
450+
localStartedAt: new Date("2024-05-07T12:35:47.182Z"),
451+
speakeasyApiKeyName: "string",
452+
speakeasyVersion: "string",
453+
success: false,
454+
workspaceId: "string",
455+
},
456+
],
457+
});
458+
459+
if (res.statusCode == 200) {
460+
// handle response
461+
}
462+
}
463+
464+
run();
465+
466+
```
467+
<!-- End Retries [retries] -->
468+
359469
<!-- Placeholder for Future Speakeasy SDK Sections -->
360470

361471

RELEASES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,4 +1116,14 @@ Based on:
11161116
### Generated
11171117
- [typescript v3.0.1] .
11181118
### Releases
1119-
- [NPM v3.0.1] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/3.0.1 - .
1119+
- [NPM v3.0.1] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/3.0.1 - .
1120+
1121+
## 2024-02-09 00:10:59
1122+
### Changes
1123+
Based on:
1124+
- OpenAPI Doc 0.4.0 https://docs.speakeasyapi.dev/openapi.yaml
1125+
- Speakeasy CLI 1.176.0 (2.250.22) https://github.com/speakeasy-api/speakeasy
1126+
### Generated
1127+
- [typescript v3.1.0] .
1128+
### Releases
1129+
- [NPM v3.1.0] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/3.1.0 - .

docs/internal/utils/retryconfig.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# RetryConfig
2+
3+
Allows customizing the default retry configuration. Only usable with methods that mention they support retries.
4+
5+
## Fields
6+
7+
| Name | Type | Description | Example |
8+
| ------------------------- | ----------------------------------- | --------------------------------------- | --------- |
9+
| `strategy` | `*string*` | The retry strategy to use. | `backoff` |
10+
| `backoff` | [BackoffStrategy](#backoffstrategy) | Configuration for the backoff strategy. | |
11+
| `retryConnectionErrors` | `*boolean*` | Whether to retry on connection errors. | `true` |
12+
13+
## BackoffStrategy
14+
15+
The backoff strategy allows retrying a request with an exponential backoff between each retry.
16+
17+
### Fields
18+
19+
| Name | Type | Description | Example |
20+
| ------------------ | --------- | ----------------------------------------- | -------- |
21+
| `initialInterval` | `*number*` | The initial interval in milliseconds. | `500` |
22+
| `maxInterval` | `*number*` | The maximum interval in milliseconds. | `60000` |
23+
| `exponent` | `*number*` | The exponent to use for the backoff. | `1.5` |
24+
| `maxElapsedTime` | `*number*` | The maximum elapsed time in milliseconds. | `300000` |

docs/sdk/models/operations/postworkspaceeventsresponse.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
| Field | Type | Required | Description |
77
| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- |
88
| `contentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation |
9+
| `error` | [shared.ErrorT](../../../sdk/models/shared/errort.md) | :heavy_minus_sign: | N/A |
910
| `statusCode` | *number* | :heavy_check_mark: | HTTP response status code for this operation |
1011
| `rawResponse` | [AxiosResponse](https://axios-http.com/docs/res_schema) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing |

docs/sdks/events/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ run();
5656
| Parameter | Type | Required | Description |
5757
| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
5858
| `request` | [operations.PostWorkspaceEventsRequest](../../sdk/models/operations/postworkspaceeventsrequest.md) | :heavy_check_mark: | The request object to use for the request. |
59+
| `retries` | [utils.RetryConfig](../../internal/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. |
5960
| `config` | [AxiosRequestConfig](https://axios-http.com/docs/req_config) | :heavy_minus_sign: | Available config options for making requests. |
6061

6162

gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ generation:
88
parameterOrderingFeb2024: false
99
requestResponseComponentNamesFeb2024: false
1010
typescript:
11-
version: 3.0.1
11+
version: 3.1.0
1212
author: Speakeasy
1313
clientServerStatusCodesAsErrors: false
1414
flattenGlobalSecurity: false

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@speakeasy-api/speakeasy-client-sdk-typescript",
3-
"version": "3.0.1",
3+
"version": "3.1.0",
44
"author": "Speakeasy",
55
"scripts": {
66
"prepare": "tsc --build",

src/sdk/events.ts

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import * as utils from "../internal/utils";
6+
import * as errors from "../sdk/models/errors";
67
import * as operations from "../sdk/models/operations";
78
import * as shared from "../sdk/models/shared";
89
import { SDKConfiguration } from "./sdk";
@@ -27,6 +28,7 @@ export class Events {
2728
*/
2829
async postWorkspaceEvents(
2930
req: operations.PostWorkspaceEventsRequest,
31+
retries?: utils.RetryConfig,
3032
config?: AxiosRequestConfig
3133
): Promise<operations.PostWorkspaceEventsResponse> {
3234
if (!(req instanceof utils.SpeakeasyBase)) {
@@ -68,19 +70,34 @@ export class Events {
6870
...properties.headers,
6971
};
7072
if (reqBody == null) throw new Error("request body is required");
71-
headers["Accept"] = "*/*";
73+
headers["Accept"] = "application/json";
7274

7375
headers["user-agent"] = this.sdkConfiguration.userAgent;
7476

75-
const httpRes: AxiosResponse = await client.request({
76-
validateStatus: () => true,
77-
url: operationUrl,
78-
method: "post",
79-
headers: headers,
80-
responseType: "arraybuffer",
81-
data: reqBody,
82-
...config,
83-
});
77+
const globalRetryConfig = this.sdkConfiguration.retryConfig;
78+
let retryConfig: utils.RetryConfig | undefined = retries;
79+
if (!retryConfig) {
80+
if (globalRetryConfig) {
81+
retryConfig = globalRetryConfig;
82+
} else {
83+
retryConfig = new utils.RetryConfig(
84+
"backoff",
85+
new utils.BackoffStrategy(100, 2000, 1.5, 30000),
86+
true
87+
);
88+
}
89+
}
90+
const httpRes: AxiosResponse = await utils.Retry(() => {
91+
return client.request({
92+
validateStatus: () => true,
93+
url: operationUrl,
94+
method: "post",
95+
headers: headers,
96+
responseType: "arraybuffer",
97+
data: reqBody,
98+
...config,
99+
});
100+
}, new utils.Retries(retryConfig, ["408", "500", "502", "503"]));
84101

85102
const responseContentType: string = httpRes?.headers?.["content-type"] ?? "";
86103

@@ -94,8 +111,21 @@ export class Events {
94111
contentType: responseContentType,
95112
rawResponse: httpRes,
96113
});
114+
const decodedRes = new TextDecoder().decode(httpRes?.data);
97115
switch (true) {
98-
default:
116+
case httpRes?.status >= 200 && httpRes?.status < 300:
117+
break;
118+
case httpRes?.status >= 500 && httpRes?.status < 600:
119+
if (utils.matchContentType(responseContentType, `application/json`)) {
120+
res.error = utils.objectToClass(JSON.parse(decodedRes), shared.ErrorT);
121+
} else {
122+
throw new errors.SDKError(
123+
"unknown content-type received: " + responseContentType,
124+
httpRes.status,
125+
decodedRes,
126+
httpRes
127+
);
128+
}
99129
break;
100130
}
101131

src/sdk/models/operations/postworkspaceevents.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export class PostWorkspaceEventsResponse extends SpeakeasyBase {
2424
@SpeakeasyMetadata()
2525
contentType: string;
2626

27+
@SpeakeasyMetadata()
28+
error?: shared.ErrorT;
29+
2730
/**
2831
* HTTP response status code for this operation
2932
*/

src/sdk/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export class SDKConfiguration {
6464
serverDefaults: any;
6565
language = "typescript";
6666
openapiDocVersion = "0.4.0";
67-
sdkVersion = "3.0.1";
68-
genVersion = "2.250.16";
67+
sdkVersion = "3.1.0";
68+
genVersion = "2.250.22";
6969
userAgent =
70-
"speakeasy-sdk/typescript 3.0.1 2.250.16 0.4.0 @speakeasy-api/speakeasy-client-sdk-typescript";
70+
"speakeasy-sdk/typescript 3.1.0 2.250.22 0.4.0 @speakeasy-api/speakeasy-client-sdk-typescript";
7171
globals: any;
7272
retryConfig?: utils.RetryConfig;
7373
public constructor(init?: Partial<SDKConfiguration>) {

0 commit comments

Comments
 (0)