groundx 2.0.11__py3-none-any.whl

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 (80) hide show
  1. groundx/__init__.py +107 -0
  2. groundx/buckets/__init__.py +2 -0
  3. groundx/buckets/client.py +761 -0
  4. groundx/client.py +160 -0
  5. groundx/core/__init__.py +47 -0
  6. groundx/core/api_error.py +15 -0
  7. groundx/core/client_wrapper.py +54 -0
  8. groundx/core/datetime_utils.py +28 -0
  9. groundx/core/file.py +67 -0
  10. groundx/core/http_client.py +499 -0
  11. groundx/core/jsonable_encoder.py +101 -0
  12. groundx/core/pydantic_utilities.py +296 -0
  13. groundx/core/query_encoder.py +58 -0
  14. groundx/core/remove_none_from_dict.py +11 -0
  15. groundx/core/request_options.py +35 -0
  16. groundx/core/serialization.py +272 -0
  17. groundx/customer/__init__.py +2 -0
  18. groundx/customer/client.py +112 -0
  19. groundx/documents/__init__.py +5 -0
  20. groundx/documents/client.py +1544 -0
  21. groundx/documents/types/__init__.py +6 -0
  22. groundx/documents/types/document_remote_ingest_request_documents_item.py +45 -0
  23. groundx/documents/types/website_crawl_request_websites_item.py +46 -0
  24. groundx/environment.py +7 -0
  25. groundx/errors/__init__.py +6 -0
  26. groundx/errors/bad_request_error.py +9 -0
  27. groundx/errors/unauthorized_error.py +9 -0
  28. groundx/groups/__init__.py +2 -0
  29. groundx/groups/client.py +1098 -0
  30. groundx/health/__init__.py +2 -0
  31. groundx/health/client.py +236 -0
  32. groundx/py.typed +0 -0
  33. groundx/search/__init__.py +5 -0
  34. groundx/search/client.py +489 -0
  35. groundx/search/types/__init__.py +5 -0
  36. groundx/search/types/search_content_request_id.py +5 -0
  37. groundx/types/__init__.py +83 -0
  38. groundx/types/bounding_box_detail.py +54 -0
  39. groundx/types/bucket_detail.py +46 -0
  40. groundx/types/bucket_list_response.py +20 -0
  41. groundx/types/bucket_response.py +20 -0
  42. groundx/types/bucket_update_detail.py +22 -0
  43. groundx/types/bucket_update_response.py +20 -0
  44. groundx/types/customer_detail.py +39 -0
  45. groundx/types/customer_response.py +20 -0
  46. groundx/types/document_detail.py +62 -0
  47. groundx/types/document_list_response.py +23 -0
  48. groundx/types/document_lookup_response.py +32 -0
  49. groundx/types/document_response.py +20 -0
  50. groundx/types/document_type.py +7 -0
  51. groundx/types/group_detail.py +52 -0
  52. groundx/types/group_list_response.py +20 -0
  53. groundx/types/group_response.py +20 -0
  54. groundx/types/health_response.py +20 -0
  55. groundx/types/health_response_health.py +20 -0
  56. groundx/types/health_service.py +36 -0
  57. groundx/types/health_service_status.py +5 -0
  58. groundx/types/ingest_response.py +20 -0
  59. groundx/types/ingest_response_ingest.py +23 -0
  60. groundx/types/message_response.py +19 -0
  61. groundx/types/meter_detail.py +40 -0
  62. groundx/types/process_status_response.py +20 -0
  63. groundx/types/process_status_response_ingest.py +26 -0
  64. groundx/types/process_status_response_ingest_progress.py +26 -0
  65. groundx/types/process_status_response_ingest_progress_cancelled.py +21 -0
  66. groundx/types/process_status_response_ingest_progress_complete.py +21 -0
  67. groundx/types/process_status_response_ingest_progress_errors.py +21 -0
  68. groundx/types/process_status_response_ingest_progress_processing.py +21 -0
  69. groundx/types/processing_status.py +5 -0
  70. groundx/types/search_response.py +20 -0
  71. groundx/types/search_response_search.py +59 -0
  72. groundx/types/search_result_item.py +96 -0
  73. groundx/types/sort.py +5 -0
  74. groundx/types/sort_order.py +5 -0
  75. groundx/types/subscription_detail.py +24 -0
  76. groundx/types/subscription_detail_meters.py +23 -0
  77. groundx/version.py +3 -0
  78. groundx-2.0.11.dist-info/METADATA +177 -0
  79. groundx-2.0.11.dist-info/RECORD +80 -0
  80. groundx-2.0.11.dist-info/WHEEL +4 -0
groundx/client.py ADDED
@@ -0,0 +1,160 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from .environment import GroundXEnvironment
5
+ import httpx
6
+ from .core.client_wrapper import SyncClientWrapper
7
+ from .documents.client import DocumentsClient
8
+ from .search.client import SearchClient
9
+ from .buckets.client import BucketsClient
10
+ from .groups.client import GroupsClient
11
+ from .customer.client import CustomerClient
12
+ from .health.client import HealthClient
13
+ from .core.client_wrapper import AsyncClientWrapper
14
+ from .documents.client import AsyncDocumentsClient
15
+ from .search.client import AsyncSearchClient
16
+ from .buckets.client import AsyncBucketsClient
17
+ from .groups.client import AsyncGroupsClient
18
+ from .customer.client import AsyncCustomerClient
19
+ from .health.client import AsyncHealthClient
20
+
21
+
22
+ class GroundX:
23
+ """
24
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
25
+
26
+ Parameters
27
+ ----------
28
+ base_url : typing.Optional[str]
29
+ The base url to use for requests from the client.
30
+
31
+ environment : GroundXEnvironment
32
+ The environment to use for requests from the client. from .environment import GroundXEnvironment
33
+
34
+
35
+
36
+ Defaults to GroundXEnvironment.DEFAULT
37
+
38
+
39
+
40
+ api_key : str
41
+ timeout : typing.Optional[float]
42
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
43
+
44
+ follow_redirects : typing.Optional[bool]
45
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
46
+
47
+ httpx_client : typing.Optional[httpx.Client]
48
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
49
+
50
+ Examples
51
+ --------
52
+ from groundx import GroundX
53
+
54
+ client = GroundX(
55
+ api_key="YOUR_API_KEY",
56
+ )
57
+ """
58
+
59
+ def __init__(
60
+ self,
61
+ *,
62
+ base_url: typing.Optional[str] = None,
63
+ environment: GroundXEnvironment = GroundXEnvironment.DEFAULT,
64
+ api_key: str,
65
+ timeout: typing.Optional[float] = None,
66
+ follow_redirects: typing.Optional[bool] = True,
67
+ httpx_client: typing.Optional[httpx.Client] = None,
68
+ ):
69
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
70
+ self._client_wrapper = SyncClientWrapper(
71
+ base_url=_get_base_url(base_url=base_url, environment=environment),
72
+ api_key=api_key,
73
+ httpx_client=httpx_client
74
+ if httpx_client is not None
75
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
76
+ if follow_redirects is not None
77
+ else httpx.Client(timeout=_defaulted_timeout),
78
+ timeout=_defaulted_timeout,
79
+ )
80
+ self.documents = DocumentsClient(client_wrapper=self._client_wrapper)
81
+ self.search = SearchClient(client_wrapper=self._client_wrapper)
82
+ self.buckets = BucketsClient(client_wrapper=self._client_wrapper)
83
+ self.groups = GroupsClient(client_wrapper=self._client_wrapper)
84
+ self.customer = CustomerClient(client_wrapper=self._client_wrapper)
85
+ self.health = HealthClient(client_wrapper=self._client_wrapper)
86
+
87
+
88
+ class AsyncGroundX:
89
+ """
90
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
91
+
92
+ Parameters
93
+ ----------
94
+ base_url : typing.Optional[str]
95
+ The base url to use for requests from the client.
96
+
97
+ environment : GroundXEnvironment
98
+ The environment to use for requests from the client. from .environment import GroundXEnvironment
99
+
100
+
101
+
102
+ Defaults to GroundXEnvironment.DEFAULT
103
+
104
+
105
+
106
+ api_key : str
107
+ timeout : typing.Optional[float]
108
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
109
+
110
+ follow_redirects : typing.Optional[bool]
111
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
112
+
113
+ httpx_client : typing.Optional[httpx.AsyncClient]
114
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
115
+
116
+ Examples
117
+ --------
118
+ from groundx import AsyncGroundX
119
+
120
+ client = AsyncGroundX(
121
+ api_key="YOUR_API_KEY",
122
+ )
123
+ """
124
+
125
+ def __init__(
126
+ self,
127
+ *,
128
+ base_url: typing.Optional[str] = None,
129
+ environment: GroundXEnvironment = GroundXEnvironment.DEFAULT,
130
+ api_key: str,
131
+ timeout: typing.Optional[float] = None,
132
+ follow_redirects: typing.Optional[bool] = True,
133
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
134
+ ):
135
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
136
+ self._client_wrapper = AsyncClientWrapper(
137
+ base_url=_get_base_url(base_url=base_url, environment=environment),
138
+ api_key=api_key,
139
+ httpx_client=httpx_client
140
+ if httpx_client is not None
141
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
142
+ if follow_redirects is not None
143
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
144
+ timeout=_defaulted_timeout,
145
+ )
146
+ self.documents = AsyncDocumentsClient(client_wrapper=self._client_wrapper)
147
+ self.search = AsyncSearchClient(client_wrapper=self._client_wrapper)
148
+ self.buckets = AsyncBucketsClient(client_wrapper=self._client_wrapper)
149
+ self.groups = AsyncGroupsClient(client_wrapper=self._client_wrapper)
150
+ self.customer = AsyncCustomerClient(client_wrapper=self._client_wrapper)
151
+ self.health = AsyncHealthClient(client_wrapper=self._client_wrapper)
152
+
153
+
154
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: GroundXEnvironment) -> str:
155
+ if base_url is not None:
156
+ return base_url
157
+ elif environment is not None:
158
+ return environment.value
159
+ else:
160
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,47 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .api_error import ApiError
4
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
5
+ from .datetime_utils import serialize_datetime
6
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
7
+ from .http_client import AsyncHttpClient, HttpClient
8
+ from .jsonable_encoder import jsonable_encoder
9
+ from .pydantic_utilities import (
10
+ IS_PYDANTIC_V2,
11
+ UniversalBaseModel,
12
+ UniversalRootModel,
13
+ parse_obj_as,
14
+ universal_field_validator,
15
+ universal_root_validator,
16
+ update_forward_refs,
17
+ )
18
+ from .query_encoder import encode_query
19
+ from .remove_none_from_dict import remove_none_from_dict
20
+ from .request_options import RequestOptions
21
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
22
+
23
+ __all__ = [
24
+ "ApiError",
25
+ "AsyncClientWrapper",
26
+ "AsyncHttpClient",
27
+ "BaseClientWrapper",
28
+ "FieldMetadata",
29
+ "File",
30
+ "HttpClient",
31
+ "IS_PYDANTIC_V2",
32
+ "RequestOptions",
33
+ "SyncClientWrapper",
34
+ "UniversalBaseModel",
35
+ "UniversalRootModel",
36
+ "convert_and_respect_annotation_metadata",
37
+ "convert_file_dict_to_httpx_tuples",
38
+ "encode_query",
39
+ "jsonable_encoder",
40
+ "parse_obj_as",
41
+ "remove_none_from_dict",
42
+ "serialize_datetime",
43
+ "universal_field_validator",
44
+ "universal_root_validator",
45
+ "update_forward_refs",
46
+ "with_content_type",
47
+ ]
@@ -0,0 +1,15 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+
6
+ class ApiError(Exception):
7
+ status_code: typing.Optional[int]
8
+ body: typing.Any
9
+
10
+ def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None):
11
+ self.status_code = status_code
12
+ self.body = body
13
+
14
+ def __str__(self) -> str:
15
+ return f"status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,54 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import httpx
5
+ from .http_client import HttpClient
6
+ from .http_client import AsyncHttpClient
7
+
8
+
9
+ class BaseClientWrapper:
10
+ def __init__(self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None):
11
+ self.api_key = api_key
12
+ self._base_url = base_url
13
+ self._timeout = timeout
14
+
15
+ def get_headers(self) -> typing.Dict[str, str]:
16
+ headers: typing.Dict[str, str] = {
17
+ "X-Fern-Language": "Python",
18
+ "X-Fern-SDK-Name": "groundx",
19
+ "X-Fern-SDK-Version": "2.0.11",
20
+ }
21
+ headers["X-API-Key"] = self.api_key
22
+ return headers
23
+
24
+ def get_base_url(self) -> str:
25
+ return self._base_url
26
+
27
+ def get_timeout(self) -> typing.Optional[float]:
28
+ return self._timeout
29
+
30
+
31
+ class SyncClientWrapper(BaseClientWrapper):
32
+ def __init__(
33
+ self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.Client
34
+ ):
35
+ super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
36
+ self.httpx_client = HttpClient(
37
+ httpx_client=httpx_client,
38
+ base_headers=self.get_headers,
39
+ base_timeout=self.get_timeout,
40
+ base_url=self.get_base_url,
41
+ )
42
+
43
+
44
+ class AsyncClientWrapper(BaseClientWrapper):
45
+ def __init__(
46
+ self, *, api_key: str, base_url: str, timeout: typing.Optional[float] = None, httpx_client: httpx.AsyncClient
47
+ ):
48
+ super().__init__(api_key=api_key, base_url=base_url, timeout=timeout)
49
+ self.httpx_client = AsyncHttpClient(
50
+ httpx_client=httpx_client,
51
+ base_headers=self.get_headers,
52
+ base_timeout=self.get_timeout,
53
+ base_url=self.get_base_url,
54
+ )
@@ -0,0 +1,28 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+
5
+
6
+ def serialize_datetime(v: dt.datetime) -> str:
7
+ """
8
+ Serialize a datetime including timezone info.
9
+
10
+ Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11
+
12
+ UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13
+ """
14
+
15
+ def _serialize_zoned_datetime(v: dt.datetime) -> str:
16
+ if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
17
+ # UTC is a special case where we use "Z" at the end instead of "+00:00"
18
+ return v.isoformat().replace("+00:00", "Z")
19
+ else:
20
+ # Delegate to the typical +/- offset format
21
+ return v.isoformat()
22
+
23
+ if v.tzinfo is not None:
24
+ return _serialize_zoned_datetime(v)
25
+ else:
26
+ local_tz = dt.datetime.now().astimezone().tzinfo
27
+ localized_dt = v.replace(tzinfo=local_tz)
28
+ return _serialize_zoned_datetime(localized_dt)
groundx/core/file.py ADDED
@@ -0,0 +1,67 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import IO, Dict, List, Mapping, Optional, Tuple, Union, cast
4
+
5
+ # File typing inspired by the flexibility of types within the httpx library
6
+ # https://github.com/encode/httpx/blob/master/httpx/_types.py
7
+ FileContent = Union[IO[bytes], bytes, str]
8
+ File = Union[
9
+ # file (or bytes)
10
+ FileContent,
11
+ # (filename, file (or bytes))
12
+ Tuple[Optional[str], FileContent],
13
+ # (filename, file (or bytes), content_type)
14
+ Tuple[Optional[str], FileContent, Optional[str]],
15
+ # (filename, file (or bytes), content_type, headers)
16
+ Tuple[
17
+ Optional[str],
18
+ FileContent,
19
+ Optional[str],
20
+ Mapping[str, str],
21
+ ],
22
+ ]
23
+
24
+
25
+ def convert_file_dict_to_httpx_tuples(
26
+ d: Dict[str, Union[File, List[File]]],
27
+ ) -> List[Tuple[str, File]]:
28
+ """
29
+ The format we use is a list of tuples, where the first element is the
30
+ name of the file and the second is the file object. Typically HTTPX wants
31
+ a dict, but to be able to send lists of files, you have to use the list
32
+ approach (which also works for non-lists)
33
+ https://github.com/encode/httpx/pull/1032
34
+ """
35
+
36
+ httpx_tuples = []
37
+ for key, file_like in d.items():
38
+ if isinstance(file_like, list):
39
+ for file_like_item in file_like:
40
+ httpx_tuples.append((key, file_like_item))
41
+ else:
42
+ httpx_tuples.append((key, file_like))
43
+ return httpx_tuples
44
+
45
+
46
+ def with_content_type(*, file: File, default_content_type: str) -> File:
47
+ """
48
+ This function resolves to the file's content type, if provided, and defaults
49
+ to the default_content_type value if not.
50
+ """
51
+ if isinstance(file, tuple):
52
+ if len(file) == 2:
53
+ filename, content = cast(Tuple[Optional[str], FileContent], file) # type: ignore
54
+ return (filename, content, default_content_type)
55
+ elif len(file) == 3:
56
+ filename, content, file_content_type = cast(Tuple[Optional[str], FileContent, Optional[str]], file) # type: ignore
57
+ out_content_type = file_content_type or default_content_type
58
+ return (filename, content, out_content_type)
59
+ elif len(file) == 4:
60
+ filename, content, file_content_type, headers = cast( # type: ignore
61
+ Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file
62
+ )
63
+ out_content_type = file_content_type or default_content_type
64
+ return (filename, content, out_content_type, headers)
65
+ else:
66
+ raise ValueError(f"Unexpected tuple length: {len(file)}")
67
+ return (None, file, default_content_type)