@stainless-api/docs 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +1 -0
- package/CHANGELOG.md +13 -0
- package/README.md +11 -0
- package/components/variables.css +139 -0
- package/eslint.config.js +10 -0
- package/package.json +74 -0
- package/plugin/assets/fonts/geist/OFL.txt +93 -0
- package/plugin/assets/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-italic-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-latin.woff2 +0 -0
- package/plugin/assets/languages/curl.svg +10 -0
- package/plugin/assets/languages/go.svg +4 -0
- package/plugin/assets/languages/java.svg +7 -0
- package/plugin/assets/languages/kotlin.svg +10 -0
- package/plugin/assets/languages/powershell.svg +3 -0
- package/plugin/assets/languages/python.svg +19 -0
- package/plugin/assets/languages/ruby.svg +125 -0
- package/plugin/assets/languages/terraform.svg +5 -0
- package/plugin/assets/languages/typescript.svg +11 -0
- package/plugin/assets/stainless-logo-dark.png +0 -0
- package/plugin/assets/stainless-logo.png +0 -0
- package/plugin/buildAlgoliaIndex.ts +72 -0
- package/plugin/cms/client.ts +62 -0
- package/plugin/cms/server.ts +268 -0
- package/plugin/cms/sidebar-builder.ts +420 -0
- package/plugin/cms/worker.ts +122 -0
- package/plugin/components/SDKSelect.astro +154 -0
- package/plugin/components/SnippetCode.tsx +212 -0
- package/plugin/components/search/Search.astro +6 -0
- package/plugin/components/search/SearchAlgolia.astro +87 -0
- package/plugin/components/search/SearchIsland.tsx +100 -0
- package/plugin/generateAPIReferenceLink.ts +71 -0
- package/plugin/globalJs/ai-dropdown.ts +57 -0
- package/plugin/globalJs/code-snippets.ts +87 -0
- package/plugin/globalJs/copy.ts +37 -0
- package/plugin/globalJs/navigation.ts +81 -0
- package/plugin/globalJs/tooltip.ts +32 -0
- package/plugin/helpers/getPageLoadEvent.ts +8 -0
- package/plugin/index.ts +308 -0
- package/plugin/languages.ts +67 -0
- package/plugin/loadPluginConfig.ts +273 -0
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +5 -0
- package/plugin/middlewareBuilder/stlStarlightMiddleware.ts +5 -0
- package/plugin/react/Routing.tsx +435 -0
- package/plugin/referencePlaceholderUtils.ts +82 -0
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +50 -0
- package/plugin/routes/Docs.astro +171 -0
- package/plugin/routes/DocsStatic.astro +14 -0
- package/plugin/routes/Overview.astro +67 -0
- package/plugin/routes/markdown.ts +58 -0
- package/plugin/vendor/preview.worker.docs.js +21657 -0
- package/plugin/vendor/templates/go.md +314 -0
- package/plugin/vendor/templates/java.md +87 -0
- package/plugin/vendor/templates/kotlin.md +87 -0
- package/plugin/vendor/templates/node.md +233 -0
- package/plugin/vendor/templates/python.md +249 -0
- package/plugin/vendor/templates/ruby.md +145 -0
- package/plugin/vendor/templates/terraform.md +60 -0
- package/plugin/vendor/templates/typescript.md +317 -0
- package/scripts/vendor_deps.ts +50 -0
- package/shared/virtualModule.ts +7 -0
- package/stl-docs/components/APIReferenceAIDropdown.tsx +86 -0
- package/stl-docs/components/ClientRouterHead.astro +41 -0
- package/stl-docs/components/Header.astro +91 -0
- package/stl-docs/components/Sidebar.astro +11 -0
- package/stl-docs/components/ThemeSelect.astro +225 -0
- package/stl-docs/components/content-panel/ContentBreadcrumbs.tsx +84 -0
- package/stl-docs/components/content-panel/ContentPanel.astro +72 -0
- package/stl-docs/components/content-panel/ProseAIDropdown.tsx +64 -0
- package/stl-docs/components/headers/DefaultHeader.astro +36 -0
- package/stl-docs/components/headers/HeaderLinks.astro +16 -0
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +49 -0
- package/stl-docs/components/headers/StackedHeader.astro +75 -0
- package/stl-docs/components/mintlify-compat/Accordion.astro +46 -0
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +25 -0
- package/stl-docs/components/mintlify-compat/Card.tsx +32 -0
- package/stl-docs/components/mintlify-compat/Columns.astro +66 -0
- package/stl-docs/components/mintlify-compat/Frame.astro +37 -0
- package/stl-docs/components/mintlify-compat/Step.astro +58 -0
- package/stl-docs/components/mintlify-compat/Steps.astro +17 -0
- package/stl-docs/components/mintlify-compat/Tab.astro +13 -0
- package/stl-docs/components/mintlify-compat/Tabs.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/index.ts +9 -0
- package/stl-docs/components/mintlify-compat/card.css +44 -0
- package/stl-docs/components/mintlify-compat/index.ts +15 -0
- package/stl-docs/components/nav-tabs/NavDropdown.astro +106 -0
- package/stl-docs/components/nav-tabs/NavTabs.astro +165 -0
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +62 -0
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +14 -0
- package/stl-docs/index.ts +174 -0
- package/stl-docs/loadStlDocsConfig.ts +160 -0
- package/stl-docs/redirects.ts +33 -0
- package/stl-docs/tabsMiddleware.ts +183 -0
- package/styles/code.css +189 -0
- package/styles/fonts.css +68 -0
- package/styles/links.css +51 -0
- package/styles/mintlify-compat.css +1 -0
- package/styles/overrides.css +79 -0
- package/styles/page.css +76 -0
- package/styles/sdk_select.css +11 -0
- package/styles/search.css +85 -0
- package/styles/sidebar.css +168 -0
- package/styles/toc.css +42 -0
- package/styles/variables.css +18 -0
- package/theme.css +15 -0
- package/tsconfig.json +18 -0
- package/virtual-module.d.ts +43 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# SDK_PackageTitle API Library
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/package/SDK_NPMPackage) SDK_JSRShield
|
|
4
|
+
|
|
5
|
+
SDK_ReadmeOpening
|
|
6
|
+
|
|
7
|
+
SDK_ScreencastURL
|
|
8
|
+
|
|
9
|
+
SDK_DocumentationReference
|
|
10
|
+
|
|
11
|
+
SDK_GeneratedByStainless
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
SDK_NPMInstallInstructions
|
|
16
|
+
|
|
17
|
+
SDK_JSRInstallation
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
SDK_APIReference
|
|
22
|
+
|
|
23
|
+
<!-- prettier-ignore -->
|
|
24
|
+
```js
|
|
25
|
+
SDK_Usage
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
SDK_StreamingUsage
|
|
29
|
+
|
|
30
|
+
### Request & Response types
|
|
31
|
+
|
|
32
|
+
This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
|
|
33
|
+
|
|
34
|
+
<!-- prettier-ignore -->
|
|
35
|
+
```ts
|
|
36
|
+
SDK_TypeScriptUsage
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
|
|
40
|
+
|
|
41
|
+
SDK_FileUploadsUsage
|
|
42
|
+
|
|
43
|
+
SDK_BinaryUploadsUsage
|
|
44
|
+
|
|
45
|
+
## Handling errors
|
|
46
|
+
|
|
47
|
+
When the library is unable to connect to the API,
|
|
48
|
+
or if the API returns a non-success status code (i.e., 4xx or 5xx response),
|
|
49
|
+
a subclass of `APIError` will be thrown:
|
|
50
|
+
|
|
51
|
+
<!-- prettier-ignore -->
|
|
52
|
+
```ts
|
|
53
|
+
SDK_ErrorsExample
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Error codes are as follows:
|
|
57
|
+
|
|
58
|
+
| Status Code | Error Type |
|
|
59
|
+
| ----------- | -------------------------- |
|
|
60
|
+
| 400 | `BadRequestError` |
|
|
61
|
+
| 401 | `AuthenticationError` |
|
|
62
|
+
| 403 | `PermissionDeniedError` |
|
|
63
|
+
| 404 | `NotFoundError` |
|
|
64
|
+
| 422 | `UnprocessableEntityError` |
|
|
65
|
+
| 429 | `RateLimitError` |
|
|
66
|
+
| >=500 | `InternalServerError` |
|
|
67
|
+
| N/A | `APIConnectionError` |
|
|
68
|
+
|
|
69
|
+
### Retries
|
|
70
|
+
|
|
71
|
+
Certain errors will be automatically retried SDK_DefaultMaxRetries times by default, with a short exponential backoff.
|
|
72
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
|
73
|
+
429 Rate Limit, and >=500 Internal errors will all be retried by default.
|
|
74
|
+
|
|
75
|
+
You can use the `maxRetries` option to configure or disable this:
|
|
76
|
+
|
|
77
|
+
<!-- prettier-ignore -->
|
|
78
|
+
```js
|
|
79
|
+
SDK_RetriesExample
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Timeouts
|
|
83
|
+
|
|
84
|
+
Requests time out after SDK_HumanReadableDefaultTimeout by default. You can configure this with a `timeout` option:
|
|
85
|
+
|
|
86
|
+
<!-- prettier-ignore -->
|
|
87
|
+
```ts
|
|
88
|
+
SDK_TimeoutsExample
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
On timeout, an `APIConnectionTimeoutError` is thrown.
|
|
92
|
+
|
|
93
|
+
Note that requests which time out will be [retried twice by default](#retries).
|
|
94
|
+
|
|
95
|
+
SDK_Pagination
|
|
96
|
+
|
|
97
|
+
SDK_DefaultHeaders
|
|
98
|
+
|
|
99
|
+
## Advanced Usage
|
|
100
|
+
|
|
101
|
+
### Accessing raw Response data (e.g., headers)
|
|
102
|
+
|
|
103
|
+
The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
|
|
104
|
+
|
|
105
|
+
You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
|
|
106
|
+
|
|
107
|
+
<!-- prettier-ignore -->
|
|
108
|
+
```ts
|
|
109
|
+
SDK_RawResponseExample
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Making custom/undocumented requests
|
|
113
|
+
|
|
114
|
+
This library is typed for convenient access to the documented API. If you need to access undocumented
|
|
115
|
+
endpoints, params, or response properties, the library can still be used.
|
|
116
|
+
|
|
117
|
+
#### Undocumented endpoints
|
|
118
|
+
|
|
119
|
+
To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
|
|
120
|
+
Options on the client, such as retries, will be respected when making these requests.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
await SDK_ClientName.post('/some/path', {
|
|
124
|
+
body: { some_prop: 'foo' },
|
|
125
|
+
query: { some_query_arg: 'bar' },
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Undocumented request params
|
|
130
|
+
|
|
131
|
+
To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
|
|
132
|
+
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
|
|
133
|
+
send will be sent as-is.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
SDK_ClientName.foo.create({
|
|
137
|
+
foo: 'my_param',
|
|
138
|
+
bar: 12,
|
|
139
|
+
// @ts-expect-error baz is not yet public
|
|
140
|
+
baz: 'undocumented option',
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
|
|
145
|
+
extra param in the body.
|
|
146
|
+
|
|
147
|
+
If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
|
|
148
|
+
options.
|
|
149
|
+
|
|
150
|
+
#### Undocumented response properties
|
|
151
|
+
|
|
152
|
+
To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
|
|
153
|
+
the response object, or cast the response object to the requisite type. Like the request params, we do not
|
|
154
|
+
validate or strip extra properties from the response from the API.
|
|
155
|
+
|
|
156
|
+
### Customizing the fetch client
|
|
157
|
+
|
|
158
|
+
By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.
|
|
159
|
+
|
|
160
|
+
If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment,
|
|
161
|
+
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
|
|
162
|
+
add the following import before your first import `from "SDK_PackageName"`:
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
|
|
166
|
+
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
|
|
167
|
+
import 'SDK_NPMPackage/shims/web';
|
|
168
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
To do the inverse, add `import "SDK_NPMPackage/shims/node"` (which does import polyfills).
|
|
172
|
+
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](SDK_GitHubRepoCodeURL/src/_shims#readme)).
|
|
173
|
+
|
|
174
|
+
### Logging and middleware
|
|
175
|
+
|
|
176
|
+
You may also provide a custom `fetch` function when instantiating the client,
|
|
177
|
+
which can be used to inspect or alter the `Request` or `Response` before/after each request:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import { fetch } from 'undici'; // as one example
|
|
181
|
+
import SDK_PackageName from 'SDK_NPMPackage';
|
|
182
|
+
|
|
183
|
+
const SDK_ClientName = new SDK_PackageName({
|
|
184
|
+
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
|
|
185
|
+
console.log('About to make a request', url, init);
|
|
186
|
+
const response = await fetch(url, init);
|
|
187
|
+
console.log('Got response', response);
|
|
188
|
+
return response;
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
|
|
194
|
+
This is intended for debugging purposes only and may change in the future without notice.
|
|
195
|
+
|
|
196
|
+
### Configuring an HTTP(S) Agent (e.g., for proxies)
|
|
197
|
+
|
|
198
|
+
By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.
|
|
199
|
+
|
|
200
|
+
If you would like to disable or customize this behavior, for example to use the API behind a proxy, you can pass an `httpAgent` which is used for all requests (be they http or https), for example:
|
|
201
|
+
|
|
202
|
+
<!-- prettier-ignore -->
|
|
203
|
+
```ts
|
|
204
|
+
SDK_HTTPAgentExample
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Semantic versioning
|
|
208
|
+
|
|
209
|
+
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
210
|
+
|
|
211
|
+
1. Changes that only affect static types, without breaking runtime behavior.
|
|
212
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
213
|
+
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
214
|
+
|
|
215
|
+
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
216
|
+
|
|
217
|
+
We are keen for your feedback; please open an [issue](SDK_GitHubRepoURL/issues) with questions, bugs, or suggestions.
|
|
218
|
+
|
|
219
|
+
## Requirements
|
|
220
|
+
|
|
221
|
+
TypeScript >= 4.5 is supported.
|
|
222
|
+
|
|
223
|
+
The following runtimes are supported:
|
|
224
|
+
|
|
225
|
+
SDK_SupportedRuntimes
|
|
226
|
+
|
|
227
|
+
Note that React Native is not supported at this time.
|
|
228
|
+
|
|
229
|
+
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
|
|
230
|
+
|
|
231
|
+
## Contributing
|
|
232
|
+
|
|
233
|
+
See [the contributing documentation](./CONTRIBUTING.md).
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# SDK_PackageTitle API library
|
|
2
|
+
|
|
3
|
+
<!-- prettier-ignore -->
|
|
4
|
+
[)](https://pypi.org/project/SDK_PythonPackageName/)
|
|
5
|
+
|
|
6
|
+
SDK_ReadmeOpening
|
|
7
|
+
|
|
8
|
+
SDK_ScreencastURL
|
|
9
|
+
|
|
10
|
+
SDK_GeneratedByStainless
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
SDK_DocumentationCallout SDK_APIReferenceCallout
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
SDK_PythonPackageInstallInstructions
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
SDK_APIReferenceCallout
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
SDK_Usage
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
SDK_AuthenticationDocs
|
|
29
|
+
|
|
30
|
+
## Async usage
|
|
31
|
+
|
|
32
|
+
Simply import `SDK_AsyncPackageClassName` instead of `SDK_PackageClassName` and use `await` with each API call:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
SDK_AsyncUsage
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Functionality between the synchronous and asynchronous clients is otherwise identical.
|
|
39
|
+
|
|
40
|
+
### With aiohttp
|
|
41
|
+
|
|
42
|
+
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
|
|
43
|
+
|
|
44
|
+
You can enable this by installing `aiohttp`:
|
|
45
|
+
|
|
46
|
+
SDK_AioHttpInstallDocs
|
|
47
|
+
|
|
48
|
+
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
SDK_AioHttpUsage
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
SDK_StreamingUsage
|
|
55
|
+
|
|
56
|
+
## Using types
|
|
57
|
+
|
|
58
|
+
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
|
|
59
|
+
|
|
60
|
+
- Serializing back into JSON, `model.to_json()`
|
|
61
|
+
- Converting to a dictionary, `model.to_dict()`
|
|
62
|
+
|
|
63
|
+
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
|
|
64
|
+
|
|
65
|
+
SDK_Pagination
|
|
66
|
+
|
|
67
|
+
SDK_NestedParams
|
|
68
|
+
|
|
69
|
+
SDK_FileUploadsUsage
|
|
70
|
+
|
|
71
|
+
## Handling errors
|
|
72
|
+
|
|
73
|
+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `SDK_PackageImportName.APIConnectionError` is raised.
|
|
74
|
+
|
|
75
|
+
When the API returns a non-success status code (that is, 4xx or 5xx
|
|
76
|
+
response), a subclass of `SDK_PackageImportName.APIStatusError` is raised, containing `status_code` and `response` properties.
|
|
77
|
+
|
|
78
|
+
All errors inherit from `SDK_PackageImportName.APIError`.
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
SDK_ErrorsExample
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Error codes are as follows:
|
|
85
|
+
|
|
86
|
+
| Status Code | Error Type |
|
|
87
|
+
| ----------- | -------------------------- |
|
|
88
|
+
| 400 | `BadRequestError` |
|
|
89
|
+
| 401 | `AuthenticationError` |
|
|
90
|
+
| 403 | `PermissionDeniedError` |
|
|
91
|
+
| 404 | `NotFoundError` |
|
|
92
|
+
| 422 | `UnprocessableEntityError` |
|
|
93
|
+
| 429 | `RateLimitError` |
|
|
94
|
+
| >=500 | `InternalServerError` |
|
|
95
|
+
| N/A | `APIConnectionError` |
|
|
96
|
+
|
|
97
|
+
### Retries
|
|
98
|
+
|
|
99
|
+
Certain errors are automatically retried SDK_DefaultMaxRetries times by default, with a short exponential backoff.
|
|
100
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
|
|
101
|
+
429 Rate Limit, and >=500 Internal errors are all retried by default.
|
|
102
|
+
|
|
103
|
+
You can use the `max_retries` option to configure or disable retry settings:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
SDK_RetriesExample
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Timeouts
|
|
110
|
+
|
|
111
|
+
By default requests time out after SDK_HumanReadableDefaultTimeout. You can configure this with a `timeout` option,
|
|
112
|
+
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
SDK_TimeoutsExample
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
On timeout, an `APITimeoutError` is thrown.
|
|
119
|
+
|
|
120
|
+
Note that requests that time out are [retried twice by default](#retries).
|
|
121
|
+
|
|
122
|
+
SDK_DefaultHeaders
|
|
123
|
+
|
|
124
|
+
## Advanced
|
|
125
|
+
|
|
126
|
+
### Logging
|
|
127
|
+
|
|
128
|
+
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
|
|
129
|
+
|
|
130
|
+
You can enable logging by setting the environment variable `SDK_PackageLoggingEnvVar` to `info`.
|
|
131
|
+
|
|
132
|
+
```shell
|
|
133
|
+
$ export SDK_PackageLoggingEnvVar=info
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Or to `debug` for more verbose logging.
|
|
137
|
+
|
|
138
|
+
### How to tell whether `None` means `null` or missing
|
|
139
|
+
|
|
140
|
+
In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
|
|
141
|
+
|
|
142
|
+
```py
|
|
143
|
+
if response.my_field is None:
|
|
144
|
+
if 'my_field' not in response.model_fields_set:
|
|
145
|
+
print('Got json like {}, without a "my_field" key present at all.')
|
|
146
|
+
else:
|
|
147
|
+
print('Got json like {"my_field": null}.')
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Accessing raw response data (e.g. headers)
|
|
151
|
+
|
|
152
|
+
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
|
|
153
|
+
|
|
154
|
+
```py
|
|
155
|
+
SDK_RawResponseExample
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
SDK_WithStreamingResponseReadme
|
|
159
|
+
|
|
160
|
+
### Making custom/undocumented requests
|
|
161
|
+
|
|
162
|
+
This library is typed for convenient access to the documented API.
|
|
163
|
+
|
|
164
|
+
If you need to access undocumented endpoints, params, or response properties, the library can still be used.
|
|
165
|
+
|
|
166
|
+
#### Undocumented endpoints
|
|
167
|
+
|
|
168
|
+
To make requests to undocumented endpoints, you can make requests using `SDK_ClientName.get`, `SDK_ClientName.post`, and other
|
|
169
|
+
http verbs. Options on the client will be respected (such as retries) when making this request.
|
|
170
|
+
|
|
171
|
+
```py
|
|
172
|
+
import httpx
|
|
173
|
+
|
|
174
|
+
response = SDK_ClientName.post(
|
|
175
|
+
"/foo",
|
|
176
|
+
cast_to=httpx.Response,
|
|
177
|
+
body={"my_param": True},
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
print(response.headers.get("x-foo"))
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### Undocumented request params
|
|
184
|
+
|
|
185
|
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
|
|
186
|
+
options.
|
|
187
|
+
|
|
188
|
+
#### Undocumented response properties
|
|
189
|
+
|
|
190
|
+
To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
|
|
191
|
+
can also get all the extra fields on the Pydantic model as a dict with
|
|
192
|
+
[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).
|
|
193
|
+
|
|
194
|
+
### Configuring the HTTP client
|
|
195
|
+
|
|
196
|
+
You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
|
|
197
|
+
|
|
198
|
+
- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
|
|
199
|
+
- Custom [transports](https://www.python-httpx.org/advanced/transports/)
|
|
200
|
+
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
SDK_CustomHTTPClientExample
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
You can also customize the client on a per-request basis by using `with_options()`:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
SDK_ClientName.with_options(http_client=DefaultHttpxClient(...))
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Managing HTTP resources
|
|
213
|
+
|
|
214
|
+
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
|
|
215
|
+
|
|
216
|
+
```py
|
|
217
|
+
SDK_HTTPClientManagementExample
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Versioning
|
|
221
|
+
|
|
222
|
+
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
223
|
+
|
|
224
|
+
1. Changes that only affect static types, without breaking runtime behavior.
|
|
225
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
226
|
+
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
227
|
+
|
|
228
|
+
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
229
|
+
|
|
230
|
+
We are keen for your feedback; please open an [issue](SDK_GitHubRepoURL/issues) with questions, bugs, or suggestions.
|
|
231
|
+
|
|
232
|
+
### Determining the installed version
|
|
233
|
+
|
|
234
|
+
If you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.
|
|
235
|
+
|
|
236
|
+
You can determine the version that is being used at runtime with:
|
|
237
|
+
|
|
238
|
+
```py
|
|
239
|
+
import SDK_PythonPackageImportName
|
|
240
|
+
print(SDK_PythonPackageImportName.__version__)
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Requirements
|
|
244
|
+
|
|
245
|
+
Python 3.8 or higher.
|
|
246
|
+
|
|
247
|
+
## Contributing
|
|
248
|
+
|
|
249
|
+
See [the contributing documentation](./CONTRIBUTING.md).
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# SDK_PackageTitle API library
|
|
2
|
+
|
|
3
|
+
SDK_ReadmeOpening It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](SDK_GitHubURL#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
|
|
4
|
+
|
|
5
|
+
SDK_ScreencastURL
|
|
6
|
+
|
|
7
|
+
SDK_GeneratedByStainless
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
Documentation for releases of this gem can be found [on RubyDoc](SDK_RubyDocInfoURL).
|
|
12
|
+
|
|
13
|
+
SDK_DocumentationCallout
|
|
14
|
+
|
|
15
|
+
SDK_Installation
|
|
16
|
+
|
|
17
|
+
SDK_Usage
|
|
18
|
+
|
|
19
|
+
SDK_StreamingUsage
|
|
20
|
+
|
|
21
|
+
SDK_Pagination
|
|
22
|
+
|
|
23
|
+
SDK_FileUploadsUsage
|
|
24
|
+
|
|
25
|
+
### Handling errors
|
|
26
|
+
|
|
27
|
+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `SDK_ModuleName::Errors::APIError` will be thrown:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
SDK_ErrorsExample
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Error codes are as follows:
|
|
34
|
+
|
|
35
|
+
SDK_ErrorsTable
|
|
36
|
+
|
|
37
|
+
### Retries
|
|
38
|
+
|
|
39
|
+
Certain errors will be automatically retried SDK_DefaultMaxRetries times by default, with a short exponential backoff.
|
|
40
|
+
|
|
41
|
+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
|
|
42
|
+
|
|
43
|
+
You can use the `max_retries` option to configure or disable this:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
SDK_RetriesExample
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Timeouts
|
|
50
|
+
|
|
51
|
+
By default, requests will time out after SDK_DefaultTimeoutInSeconds seconds. You can use the timeout option to configure or disable this:
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
SDK_TimeoutsExample
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
On timeout, `SDK_ModuleName::Errors::APITimeoutError` is raised.
|
|
58
|
+
|
|
59
|
+
Note that requests that time out are retried by default.
|
|
60
|
+
|
|
61
|
+
## Advanced concepts
|
|
62
|
+
|
|
63
|
+
### BaseModel
|
|
64
|
+
|
|
65
|
+
All parameter and response objects inherit from `SDK_ModuleName::Internal::Type::BaseModel`, which provides several conveniences, including:
|
|
66
|
+
|
|
67
|
+
1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.
|
|
68
|
+
|
|
69
|
+
2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
|
|
70
|
+
|
|
71
|
+
3. Both instances and the classes themselves can be pretty-printed.
|
|
72
|
+
|
|
73
|
+
4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.
|
|
74
|
+
|
|
75
|
+
### Making custom or undocumented requests
|
|
76
|
+
|
|
77
|
+
#### Undocumented properties
|
|
78
|
+
|
|
79
|
+
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
|
|
80
|
+
|
|
81
|
+
Note: the `extra_` parameters of the same name overrides the documented parameters.
|
|
82
|
+
|
|
83
|
+
```ruby
|
|
84
|
+
SDK_UndocumentedProperties
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Undocumented request params
|
|
88
|
+
|
|
89
|
+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.
|
|
90
|
+
|
|
91
|
+
#### Undocumented endpoints
|
|
92
|
+
|
|
93
|
+
To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
response = client.request(
|
|
97
|
+
method: :post,
|
|
98
|
+
path: '/undocumented/endpoint',
|
|
99
|
+
query: {"dog": "woof"},
|
|
100
|
+
headers: {"useful-header": "interesting-value"},
|
|
101
|
+
body: {"hello": "world"}
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Concurrency & connection pooling
|
|
106
|
+
|
|
107
|
+
The `SDK_ModuleName::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
|
|
108
|
+
|
|
109
|
+
Each instance of `SDK_ModuleName::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
|
|
110
|
+
|
|
111
|
+
When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
|
|
112
|
+
|
|
113
|
+
Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
|
|
114
|
+
|
|
115
|
+
## Sorbet
|
|
116
|
+
|
|
117
|
+
This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
|
|
118
|
+
|
|
119
|
+
You can provide typesafe request parameters like so:
|
|
120
|
+
|
|
121
|
+
```ruby
|
|
122
|
+
SDK_SorbetParamPassing
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Or, equivalently:
|
|
126
|
+
|
|
127
|
+
```ruby
|
|
128
|
+
SDK_SorbetParamTrick
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
SDK_SorbetEnums
|
|
132
|
+
|
|
133
|
+
## Versioning
|
|
134
|
+
|
|
135
|
+
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
|
|
136
|
+
|
|
137
|
+
This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
|
|
138
|
+
|
|
139
|
+
## Requirements
|
|
140
|
+
|
|
141
|
+
Ruby SDK_RubyMinVersion or higher.
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
|
|
145
|
+
See [the contributing documentation](SDK_GitHubAssetURL/CONTRIBUTING.md).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# SDK_PackageTitle Provider
|
|
2
|
+
|
|
3
|
+
The [SDK_PackageTitle provider](SDK_TerraformDocumentationUrl) provides convenient access to
|
|
4
|
+
the SDK_RestAPIName from Terraform.
|
|
5
|
+
|
|
6
|
+
SDK_GeneratedByStainless
|
|
7
|
+
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
This provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)
|
|
11
|
+
on Hashicorp's website.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Add the following to your `main.tf` file:
|
|
16
|
+
|
|
17
|
+
SDK_ReleasePleaseMarkdownBlockStart
|
|
18
|
+
|
|
19
|
+
```hcl
|
|
20
|
+
# Declare the provider and version
|
|
21
|
+
terraform {
|
|
22
|
+
required_providers {
|
|
23
|
+
SDK_ProviderTypeName = {
|
|
24
|
+
source = "SDK_ProviderImportPath"
|
|
25
|
+
version = "~> SDK_Version"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# Initialize the provider
|
|
31
|
+
SDK_ProviderExample
|
|
32
|
+
|
|
33
|
+
# Configure a resource
|
|
34
|
+
SDK_ResourceExample
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
SDK_ReleasePleaseMarkdownBlockEnd
|
|
38
|
+
|
|
39
|
+
Initialize your project by running `terraform init` in the directory.
|
|
40
|
+
|
|
41
|
+
Additional examples can be found in the [./examples](./examples) folder within this repository, and you can
|
|
42
|
+
refer to the full documentation on [the Terraform Registry](SDK_TerraformDocumentationUrl).
|
|
43
|
+
|
|
44
|
+
SDK_ConfigOptionsSection
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Semantic versioning
|
|
48
|
+
|
|
49
|
+
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
|
50
|
+
|
|
51
|
+
1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
52
|
+
2. Changes that we do not expect to impact the vast majority of users in practice.
|
|
53
|
+
|
|
54
|
+
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
55
|
+
|
|
56
|
+
We are keen for your feedback; please open an [issue](SDK_GitHubRepoURL/issues) with questions, bugs, or suggestions.
|
|
57
|
+
|
|
58
|
+
## Contributing
|
|
59
|
+
|
|
60
|
+
See [the contributing documentation](./CONTRIBUTING.md).
|