ttd-workflows 0.1.3__tar.gz

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.
Files changed (51) hide show
  1. ttd_workflows-0.1.3/PKG-INFO +458 -0
  2. ttd_workflows-0.1.3/README-PYPI.md +438 -0
  3. ttd_workflows-0.1.3/py.typed +1 -0
  4. ttd_workflows-0.1.3/pyproject.toml +56 -0
  5. ttd_workflows-0.1.3/src/ttd_workflows/__init__.py +18 -0
  6. ttd_workflows-0.1.3/src/ttd_workflows/_hooks/__init__.py +5 -0
  7. ttd_workflows-0.1.3/src/ttd_workflows/_hooks/registration.py +13 -0
  8. ttd_workflows-0.1.3/src/ttd_workflows/_hooks/sdkhooks.py +76 -0
  9. ttd_workflows-0.1.3/src/ttd_workflows/_hooks/types.py +106 -0
  10. ttd_workflows-0.1.3/src/ttd_workflows/_version.py +15 -0
  11. ttd_workflows-0.1.3/src/ttd_workflows/basesdk.py +362 -0
  12. ttd_workflows-0.1.3/src/ttd_workflows/graphql.py +226 -0
  13. ttd_workflows-0.1.3/src/ttd_workflows/httpclient.py +136 -0
  14. ttd_workflows-0.1.3/src/ttd_workflows/models/__init__.py +61 -0
  15. ttd_workflows-0.1.3/src/ttd_workflows/models/apierror.py +22 -0
  16. ttd_workflows-0.1.3/src/ttd_workflows/models/campaignchannel.py +15 -0
  17. ttd_workflows-0.1.3/src/ttd_workflows/models/campaigncreateroigoalinput.py +149 -0
  18. ttd_workflows-0.1.3/src/ttd_workflows/models/campaigncreationinput.py +50 -0
  19. ttd_workflows-0.1.3/src/ttd_workflows/models/campaignflightcreationinput.py +101 -0
  20. ttd_workflows-0.1.3/src/ttd_workflows/models/contextualdatainput.py +58 -0
  21. ttd_workflows-0.1.3/src/ttd_workflows/models/get_campaign_id_versionop.py +16 -0
  22. ttd_workflows-0.1.3/src/ttd_workflows/models/graphqlqueryinput.py +62 -0
  23. ttd_workflows-0.1.3/src/ttd_workflows/models/problemdetails_error.py +34 -0
  24. ttd_workflows-0.1.3/src/ttd_workflows/models/security.py +25 -0
  25. ttd_workflows-0.1.3/src/ttd_workflows/models/seedcreationinput.py +39 -0
  26. ttd_workflows-0.1.3/src/ttd_workflows/models/seedtargetingdatainput.py +99 -0
  27. ttd_workflows-0.1.3/src/ttd_workflows/models/shared_campaign.py +31 -0
  28. ttd_workflows-0.1.3/src/ttd_workflows/models/shared_seed.py +30 -0
  29. ttd_workflows-0.1.3/src/ttd_workflows/models/thirdpartydatainput.py +62 -0
  30. ttd_workflows-0.1.3/src/ttd_workflows/py.typed +1 -0
  31. ttd_workflows-0.1.3/src/ttd_workflows/sdk.py +146 -0
  32. ttd_workflows-0.1.3/src/ttd_workflows/sdk_campaign.py +428 -0
  33. ttd_workflows-0.1.3/src/ttd_workflows/sdk_seed.py +222 -0
  34. ttd_workflows-0.1.3/src/ttd_workflows/sdkconfiguration.py +56 -0
  35. ttd_workflows-0.1.3/src/ttd_workflows/types/__init__.py +21 -0
  36. ttd_workflows-0.1.3/src/ttd_workflows/types/basemodel.py +39 -0
  37. ttd_workflows-0.1.3/src/ttd_workflows/utils/__init__.py +101 -0
  38. ttd_workflows-0.1.3/src/ttd_workflows/utils/annotations.py +55 -0
  39. ttd_workflows-0.1.3/src/ttd_workflows/utils/enums.py +34 -0
  40. ttd_workflows-0.1.3/src/ttd_workflows/utils/eventstreaming.py +238 -0
  41. ttd_workflows-0.1.3/src/ttd_workflows/utils/forms.py +202 -0
  42. ttd_workflows-0.1.3/src/ttd_workflows/utils/headers.py +136 -0
  43. ttd_workflows-0.1.3/src/ttd_workflows/utils/logger.py +27 -0
  44. ttd_workflows-0.1.3/src/ttd_workflows/utils/metadata.py +118 -0
  45. ttd_workflows-0.1.3/src/ttd_workflows/utils/queryparams.py +205 -0
  46. ttd_workflows-0.1.3/src/ttd_workflows/utils/requestbodies.py +66 -0
  47. ttd_workflows-0.1.3/src/ttd_workflows/utils/retries.py +217 -0
  48. ttd_workflows-0.1.3/src/ttd_workflows/utils/security.py +192 -0
  49. ttd_workflows-0.1.3/src/ttd_workflows/utils/serializers.py +219 -0
  50. ttd_workflows-0.1.3/src/ttd_workflows/utils/url.py +155 -0
  51. ttd_workflows-0.1.3/src/ttd_workflows/utils/values.py +137 -0
@@ -0,0 +1,458 @@
1
+ Metadata-Version: 2.3
2
+ Name: ttd-workflows
3
+ Version: 0.1.3
4
+ Summary: Python Client SDK Generated by Speakeasy.
5
+ Author: Speakeasy
6
+ Requires-Python: >=3.9
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.9
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Dist: eval-type-backport (>=0.2.0)
14
+ Requires-Dist: httpx (>=0.28.1)
15
+ Requires-Dist: pydantic (>=2.10.3)
16
+ Requires-Dist: python-dateutil (>=2.8.2)
17
+ Requires-Dist: typing-inspection (>=0.4.0)
18
+ Description-Content-Type: text/markdown
19
+
20
+ # ttd-workflows-python
21
+
22
+ <!-- Start Summary [summary] -->
23
+ ## Summary
24
+
25
+ Workflows API: A RESTful service for commonly used workflows.
26
+ <!-- End Summary [summary] -->
27
+
28
+ <!-- Start Table of Contents [toc] -->
29
+ ## Table of Contents
30
+ <!-- $toc-max-depth=2 -->
31
+ * [ttd-workflows-python](#ttd-workflows-python)
32
+ * [SDK Installation](#sdk-installation)
33
+ * [IDE Support](#ide-support)
34
+ * [SDK Example Usage](#sdk-example-usage)
35
+ * [Authentication](#authentication)
36
+ * [Available Resources and Operations](#available-resources-and-operations)
37
+ * [Retries](#retries)
38
+ * [Error Handling](#error-handling)
39
+ * [Server Selection](#server-selection)
40
+ * [Custom HTTP Client](#custom-http-client)
41
+ * [Resource Management](#resource-management)
42
+ * [Debugging](#debugging)
43
+
44
+ <!-- End Table of Contents [toc] -->
45
+
46
+ <!-- Start SDK Installation [installation] -->
47
+ ## SDK Installation
48
+
49
+ > [!TIP]
50
+ > To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
51
+
52
+
53
+ > [!NOTE]
54
+ > **Python version upgrade policy**
55
+ >
56
+ > Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
57
+
58
+ The SDK can be installed with either *pip* or *poetry* package managers.
59
+
60
+ ### PIP
61
+
62
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
63
+
64
+ ```bash
65
+ pip install git+<UNSET>.git
66
+ ```
67
+
68
+ ### Poetry
69
+
70
+ *Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
71
+
72
+ ```bash
73
+ poetry add git+<UNSET>.git
74
+ ```
75
+
76
+ ### Shell and script usage with `uv`
77
+
78
+ You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
79
+
80
+ ```shell
81
+ uvx --from ttd-workflows python
82
+ ```
83
+
84
+ It's also possible to write a standalone Python script without needing to set up a whole project like so:
85
+
86
+ ```python
87
+ #!/usr/bin/env -S uv run --script
88
+ # /// script
89
+ # requires-python = ">=3.9"
90
+ # dependencies = [
91
+ # "ttd-workflows",
92
+ # ]
93
+ # ///
94
+
95
+ from ttd_workflows import Workflows
96
+
97
+ sdk = Workflows(
98
+ # SDK arguments
99
+ )
100
+
101
+ # Rest of script here...
102
+ ```
103
+
104
+ Once that is saved to a file, you can run it with `uv run script.py` where
105
+ `script.py` can be replaced with the actual file name.
106
+ <!-- End SDK Installation [installation] -->
107
+
108
+ <!-- Start IDE Support [idesupport] -->
109
+ ## IDE Support
110
+
111
+ ### PyCharm
112
+
113
+ Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
114
+
115
+ - [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
116
+ <!-- End IDE Support [idesupport] -->
117
+
118
+ <!-- Start SDK Example Usage [usage] -->
119
+ ## SDK Example Usage
120
+
121
+ ### Example
122
+
123
+ ```python
124
+ # Synchronous Example
125
+ import os
126
+ from ttd_workflows import Workflows
127
+
128
+
129
+ with Workflows(
130
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
131
+ ) as workflows:
132
+
133
+ res = workflows.campaign.create()
134
+
135
+ # Handle response
136
+ print(res)
137
+ ```
138
+
139
+ </br>
140
+
141
+ The same SDK client can also be used to make asychronous requests by importing asyncio.
142
+ ```python
143
+ # Asynchronous Example
144
+ import asyncio
145
+ import os
146
+ from ttd_workflows import Workflows
147
+
148
+ async def main():
149
+
150
+ async with Workflows(
151
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
152
+ ) as workflows:
153
+
154
+ res = await workflows.campaign.create_async()
155
+
156
+ # Handle response
157
+ print(res)
158
+
159
+ asyncio.run(main())
160
+ ```
161
+ <!-- End SDK Example Usage [usage] -->
162
+
163
+ <!-- Start Authentication [security] -->
164
+ ## Authentication
165
+
166
+ ### Per-Client Security Schemes
167
+
168
+ This SDK supports the following security scheme globally:
169
+
170
+ | Name | Type | Scheme | Environment Variable |
171
+ | ---------- | ------ | ------- | -------------------- |
172
+ | `ttd_auth` | apiKey | API key | `WORKFLOWS_TTD_AUTH` |
173
+
174
+ To authenticate with the API the `ttd_auth` parameter must be set when initializing the SDK client instance. For example:
175
+ ```python
176
+ import os
177
+ from ttd_workflows import Workflows
178
+
179
+
180
+ with Workflows(
181
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
182
+ ) as workflows:
183
+
184
+ res = workflows.campaign.create()
185
+
186
+ # Handle response
187
+ print(res)
188
+
189
+ ```
190
+ <!-- End Authentication [security] -->
191
+
192
+ <!-- Start Available Resources and Operations [operations] -->
193
+ ## Available Resources and Operations
194
+
195
+ <details open>
196
+ <summary>Available methods</summary>
197
+
198
+ ### [campaign](docs/sdks/sdkcampaign/README.md)
199
+
200
+ * [create](docs/sdks/sdkcampaign/README.md#create) - Create a new campaign with required fields
201
+ * [get_version](docs/sdks/sdkcampaign/README.md#get_version) - GET a campaign's version
202
+
203
+ ### [graphql](docs/sdks/graphql/README.md)
204
+
205
+ * [execute](docs/sdks/graphql/README.md#execute) - An endpoint that executes valid GraphQL queries.
206
+
207
+ ### [seed](docs/sdks/sdkseed/README.md)
208
+
209
+ * [create](docs/sdks/sdkseed/README.md#create) - Create a new seed with required fields
210
+
211
+
212
+ </details>
213
+ <!-- End Available Resources and Operations [operations] -->
214
+
215
+ <!-- Start Retries [retries] -->
216
+ ## Retries
217
+
218
+ 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.
219
+
220
+ To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
221
+ ```python
222
+ import os
223
+ from ttd_workflows import Workflows
224
+ from ttd_workflows.utils import BackoffStrategy, RetryConfig
225
+
226
+
227
+ with Workflows(
228
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
229
+ ) as workflows:
230
+
231
+ res = workflows.campaign.create(,
232
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
233
+
234
+ # Handle response
235
+ print(res)
236
+
237
+ ```
238
+
239
+ If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
240
+ ```python
241
+ import os
242
+ from ttd_workflows import Workflows
243
+ from ttd_workflows.utils import BackoffStrategy, RetryConfig
244
+
245
+
246
+ with Workflows(
247
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
248
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
249
+ ) as workflows:
250
+
251
+ res = workflows.campaign.create()
252
+
253
+ # Handle response
254
+ print(res)
255
+
256
+ ```
257
+ <!-- End Retries [retries] -->
258
+
259
+ <!-- Start Error Handling [errors] -->
260
+ ## Error Handling
261
+
262
+ Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
263
+
264
+ By default, an API error will raise a models.APIError exception, which has the following properties:
265
+
266
+ | Property | Type | Description |
267
+ |-----------------|------------------|-----------------------|
268
+ | `.status_code` | *int* | The HTTP status code |
269
+ | `.message` | *str* | The error message |
270
+ | `.raw_response` | *httpx.Response* | The raw HTTP response |
271
+ | `.body` | *str* | The response content |
272
+
273
+ When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create_async` method may raise the following exceptions:
274
+
275
+ | Error Type | Status Code | Content Type |
276
+ | -------------------------- | ----------- | ---------------- |
277
+ | models.ProblemDetailsError | 400 | application/json |
278
+ | models.APIError | 4XX, 5XX | \*/\* |
279
+
280
+ ### Example
281
+
282
+ ```python
283
+ import os
284
+ from ttd_workflows import Workflows, models
285
+
286
+
287
+ with Workflows(
288
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
289
+ ) as workflows:
290
+ res = None
291
+ try:
292
+
293
+ res = workflows.campaign.create()
294
+
295
+ # Handle response
296
+ print(res)
297
+
298
+ except models.ProblemDetailsError as e:
299
+ # handle e.data: models.ProblemDetailsErrorData
300
+ raise(e)
301
+ except models.APIError as e:
302
+ # handle exception
303
+ raise(e)
304
+ ```
305
+ <!-- End Error Handling [errors] -->
306
+
307
+ <!-- Start Server Selection [server] -->
308
+ ## Server Selection
309
+
310
+ ### Override Server URL Per-Client
311
+
312
+ The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
313
+ ```python
314
+ import os
315
+ from ttd_workflows import Workflows
316
+
317
+
318
+ with Workflows(
319
+ server_url="https://api.thetradedesk.com/workflows",
320
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
321
+ ) as workflows:
322
+
323
+ res = workflows.campaign.create()
324
+
325
+ # Handle response
326
+ print(res)
327
+
328
+ ```
329
+ <!-- End Server Selection [server] -->
330
+
331
+ <!-- Start Custom HTTP Client [http-client] -->
332
+ ## Custom HTTP Client
333
+
334
+ The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
335
+ Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
336
+ This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
337
+
338
+ For example, you could specify a header for every request that this sdk makes as follows:
339
+ ```python
340
+ from ttd_workflows import Workflows
341
+ import httpx
342
+
343
+ http_client = httpx.Client(headers={"x-custom-header": "someValue"})
344
+ s = Workflows(client=http_client)
345
+ ```
346
+
347
+ or you could wrap the client with your own custom logic:
348
+ ```python
349
+ from ttd_workflows import Workflows
350
+ from ttd_workflows.httpclient import AsyncHttpClient
351
+ import httpx
352
+
353
+ class CustomClient(AsyncHttpClient):
354
+ client: AsyncHttpClient
355
+
356
+ def __init__(self, client: AsyncHttpClient):
357
+ self.client = client
358
+
359
+ async def send(
360
+ self,
361
+ request: httpx.Request,
362
+ *,
363
+ stream: bool = False,
364
+ auth: Union[
365
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
366
+ ] = httpx.USE_CLIENT_DEFAULT,
367
+ follow_redirects: Union[
368
+ bool, httpx._client.UseClientDefault
369
+ ] = httpx.USE_CLIENT_DEFAULT,
370
+ ) -> httpx.Response:
371
+ request.headers["Client-Level-Header"] = "added by client"
372
+
373
+ return await self.client.send(
374
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
375
+ )
376
+
377
+ def build_request(
378
+ self,
379
+ method: str,
380
+ url: httpx._types.URLTypes,
381
+ *,
382
+ content: Optional[httpx._types.RequestContent] = None,
383
+ data: Optional[httpx._types.RequestData] = None,
384
+ files: Optional[httpx._types.RequestFiles] = None,
385
+ json: Optional[Any] = None,
386
+ params: Optional[httpx._types.QueryParamTypes] = None,
387
+ headers: Optional[httpx._types.HeaderTypes] = None,
388
+ cookies: Optional[httpx._types.CookieTypes] = None,
389
+ timeout: Union[
390
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
391
+ ] = httpx.USE_CLIENT_DEFAULT,
392
+ extensions: Optional[httpx._types.RequestExtensions] = None,
393
+ ) -> httpx.Request:
394
+ return self.client.build_request(
395
+ method,
396
+ url,
397
+ content=content,
398
+ data=data,
399
+ files=files,
400
+ json=json,
401
+ params=params,
402
+ headers=headers,
403
+ cookies=cookies,
404
+ timeout=timeout,
405
+ extensions=extensions,
406
+ )
407
+
408
+ s = Workflows(async_client=CustomClient(httpx.AsyncClient()))
409
+ ```
410
+ <!-- End Custom HTTP Client [http-client] -->
411
+
412
+ <!-- Start Resource Management [resource-management] -->
413
+ ## Resource Management
414
+
415
+ The `Workflows` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
416
+
417
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
418
+
419
+ ```python
420
+ import os
421
+ from ttd_workflows import Workflows
422
+ def main():
423
+
424
+ with Workflows(
425
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
426
+ ) as workflows:
427
+ # Rest of application here...
428
+
429
+
430
+ # Or when using async:
431
+ async def amain():
432
+
433
+ async with Workflows(
434
+ ttd_auth=os.getenv("WORKFLOWS_TTD_AUTH", ""),
435
+ ) as workflows:
436
+ # Rest of application here...
437
+ ```
438
+ <!-- End Resource Management [resource-management] -->
439
+
440
+ <!-- Start Debugging [debug] -->
441
+ ## Debugging
442
+
443
+ You can setup your SDK to emit debug logs for SDK requests and responses.
444
+
445
+ You can pass your own logger class directly into your SDK.
446
+ ```python
447
+ from ttd_workflows import Workflows
448
+ import logging
449
+
450
+ logging.basicConfig(level=logging.DEBUG)
451
+ s = Workflows(debug_logger=logging.getLogger("ttd_workflows"))
452
+ ```
453
+
454
+ You can also enable a default debug logger by setting an environment variable `WORKFLOWS_DEBUG` to true.
455
+ <!-- End Debugging [debug] -->
456
+
457
+ <!-- Placeholder for Future Speakeasy SDK Sections -->
458
+