|
| 1 | + |
| 2 | +from . import resources |
| 3 | +from typing import Union |
| 4 | +from ._config import ClientConfig |
| 5 | +import os |
| 6 | + |
| 7 | + |
| 8 | +class JigsawStack: |
| 9 | + audio: resources.Audio |
| 10 | + vision : resources.Vision |
| 11 | + prediction: resources.Prediction |
| 12 | + sql: resources.SQL |
| 13 | + file: resources.File |
| 14 | + kv: resources.KV |
| 15 | + translate: resources.Translate |
| 16 | + web: resources.Web |
| 17 | + sentiment: resources.Sentiment |
| 18 | + validate: resources.Validate |
| 19 | + summary: resources.Summary |
| 20 | + search: resources.Search |
| 21 | + api_key: str |
| 22 | + api_url: str |
| 23 | + |
| 24 | + |
| 25 | + def __init__(self, api_key: Union[str, None] = None, api_url: Union[str, None] = None) -> None: |
| 26 | + if api_key is None: |
| 27 | + api_key = os.environ.get("JIGSAWSTACK_API_KEY") |
| 28 | + |
| 29 | + if api_key is None: |
| 30 | + raise ValueError("The api_key client option must be set either by passing api_key to the client or by setting the JIGSAWSTACK_API_KEY environment variable") |
| 31 | + |
| 32 | + if api_url is None: |
| 33 | + api_url = os.environ.get("JIGSAWSTACK_API_URL") |
| 34 | + if api_url is None: |
| 35 | + api_url = f"https://api.jigsawstack.com/v1" |
| 36 | + |
| 37 | + self.api_key = api_key |
| 38 | + self.api_url = api_url |
| 39 | + |
| 40 | + |
| 41 | + self.audio = resources.Audio(api_key=api_key, api_url=api_url) |
| 42 | + self.web = resources.Web(api_key=api_key, api_url=api_url) |
| 43 | + self.search = resources.Search(api_key=api_key, api_url=api_url) |
| 44 | + self.sentiment = resources.Sentiment(api_key=api_key, api_url=api_url) |
| 45 | + self.validate = resources.Validate(api_key=api_key, api_url=api_url) |
| 46 | + self.summary = resources.Summary(api_key=api_key, api_url=api_url) |
| 47 | + self.vision = resources.Vision(api_key=api_key, api_url=api_url) |
| 48 | + self.prediction = resources.Prediction(api_key=api_key, api_url=api_url) |
| 49 | + self.sql = resources.SQL(api_key=api_key, api_url=api_url) |
| 50 | + self.file = resources.File(api_key=api_key, api_url=api_url) |
| 51 | + self.kv = resources.KV(api_key=api_key, api_url=api_url) |
| 52 | + self.translate = resources.Translate(api_key=api_key, api_url=api_url) |
0 commit comments