methodsdk 0.0.3__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 (38) hide show
  1. method_security/__init__.py +67 -0
  2. method_security/client.py +137 -0
  3. method_security/common/__init__.py +32 -0
  4. method_security/common/types/__init__.py +32 -0
  5. method_security/common/types/environment_id.py +3 -0
  6. method_security/core/__init__.py +103 -0
  7. method_security/core/api_error.py +23 -0
  8. method_security/core/client_wrapper.py +74 -0
  9. method_security/core/datetime_utils.py +28 -0
  10. method_security/core/file.py +67 -0
  11. method_security/core/force_multipart.py +18 -0
  12. method_security/core/http_client.py +543 -0
  13. method_security/core/http_response.py +55 -0
  14. method_security/core/jsonable_encoder.py +100 -0
  15. method_security/core/pydantic_utilities.py +258 -0
  16. method_security/core/query_encoder.py +58 -0
  17. method_security/core/remove_none_from_dict.py +11 -0
  18. method_security/core/request_options.py +35 -0
  19. method_security/core/serialization.py +276 -0
  20. method_security/issues/__init__.py +40 -0
  21. method_security/issues/client.py +107 -0
  22. method_security/issues/errors/__init__.py +32 -0
  23. method_security/issues/errors/issue_does_not_exist_error.py +11 -0
  24. method_security/issues/raw_client.py +118 -0
  25. method_security/issues/types/__init__.py +42 -0
  26. method_security/issues/types/issue.py +36 -0
  27. method_security/issues/types/issue_closed_reason.py +5 -0
  28. method_security/issues/types/issue_id.py +3 -0
  29. method_security/issues/types/issue_severity.py +5 -0
  30. method_security/issues/types/issue_status.py +5 -0
  31. method_security/objects/__init__.py +32 -0
  32. method_security/objects/types/__init__.py +32 -0
  33. method_security/objects/types/object_id.py +3 -0
  34. method_security/py.typed +0 -0
  35. method_security/version.py +3 -0
  36. methodsdk-0.0.3.dist-info/METADATA +182 -0
  37. methodsdk-0.0.3.dist-info/RECORD +38 -0
  38. methodsdk-0.0.3.dist-info/WHEEL +4 -0
@@ -0,0 +1,67 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from . import common, issues, objects
10
+ from .client import AsyncMethodSecurityApi, MethodSecurityApi
11
+ from .common import EnvironmentId
12
+ from .issues import Issue, IssueClosedReason, IssueDoesNotExistError, IssueId, IssueSeverity, IssueStatus
13
+ from .objects import ObjectId
14
+ from .version import __version__
15
+ _dynamic_imports: typing.Dict[str, str] = {
16
+ "AsyncMethodSecurityApi": ".client",
17
+ "EnvironmentId": ".common",
18
+ "Issue": ".issues",
19
+ "IssueClosedReason": ".issues",
20
+ "IssueDoesNotExistError": ".issues",
21
+ "IssueId": ".issues",
22
+ "IssueSeverity": ".issues",
23
+ "IssueStatus": ".issues",
24
+ "MethodSecurityApi": ".client",
25
+ "ObjectId": ".objects",
26
+ "__version__": ".version",
27
+ "common": ".",
28
+ "issues": ".",
29
+ "objects": ".",
30
+ }
31
+
32
+
33
+ def __getattr__(attr_name: str) -> typing.Any:
34
+ module_name = _dynamic_imports.get(attr_name)
35
+ if module_name is None:
36
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
37
+ try:
38
+ module = import_module(module_name, __package__)
39
+ result = getattr(module, attr_name)
40
+ return result
41
+ except ImportError as e:
42
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
43
+ except AttributeError as e:
44
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
45
+
46
+
47
+ def __dir__():
48
+ lazy_attrs = list(_dynamic_imports.keys())
49
+ return sorted(lazy_attrs)
50
+
51
+
52
+ __all__ = [
53
+ "AsyncMethodSecurityApi",
54
+ "EnvironmentId",
55
+ "Issue",
56
+ "IssueClosedReason",
57
+ "IssueDoesNotExistError",
58
+ "IssueId",
59
+ "IssueSeverity",
60
+ "IssueStatus",
61
+ "MethodSecurityApi",
62
+ "ObjectId",
63
+ "__version__",
64
+ "common",
65
+ "issues",
66
+ "objects",
67
+ ]
@@ -0,0 +1,137 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from .issues.client import AsyncIssuesClient, IssuesClient
12
+
13
+
14
+ class MethodSecurityApi:
15
+ """
16
+ 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.
17
+
18
+ Parameters
19
+ ----------
20
+ base_url : str
21
+ The base url to use for requests from the client.
22
+
23
+ headers : typing.Optional[typing.Dict[str, str]]
24
+ Additional headers to send with every request.
25
+
26
+ timeout : typing.Optional[float]
27
+ 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.
28
+
29
+ follow_redirects : typing.Optional[bool]
30
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
31
+
32
+ httpx_client : typing.Optional[httpx.Client]
33
+ 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.
34
+
35
+ Examples
36
+ --------
37
+ from method_security import MethodSecurityApi
38
+
39
+ client = MethodSecurityApi(
40
+ base_url="https://yourhost.com/path/to/api",
41
+ )
42
+ """
43
+
44
+ def __init__(
45
+ self,
46
+ *,
47
+ base_url: str,
48
+ headers: typing.Optional[typing.Dict[str, str]] = None,
49
+ timeout: typing.Optional[float] = None,
50
+ follow_redirects: typing.Optional[bool] = True,
51
+ httpx_client: typing.Optional[httpx.Client] = None,
52
+ ):
53
+ _defaulted_timeout = (
54
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
55
+ )
56
+ self._client_wrapper = SyncClientWrapper(
57
+ base_url=base_url,
58
+ headers=headers,
59
+ httpx_client=httpx_client
60
+ if httpx_client is not None
61
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
62
+ if follow_redirects is not None
63
+ else httpx.Client(timeout=_defaulted_timeout),
64
+ timeout=_defaulted_timeout,
65
+ )
66
+ self._issues: typing.Optional[IssuesClient] = None
67
+
68
+ @property
69
+ def issues(self):
70
+ if self._issues is None:
71
+ from .issues.client import IssuesClient # noqa: E402
72
+
73
+ self._issues = IssuesClient(client_wrapper=self._client_wrapper)
74
+ return self._issues
75
+
76
+
77
+ class AsyncMethodSecurityApi:
78
+ """
79
+ 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.
80
+
81
+ Parameters
82
+ ----------
83
+ base_url : str
84
+ The base url to use for requests from the client.
85
+
86
+ headers : typing.Optional[typing.Dict[str, str]]
87
+ Additional headers to send with every request.
88
+
89
+ timeout : typing.Optional[float]
90
+ 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.
91
+
92
+ follow_redirects : typing.Optional[bool]
93
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
94
+
95
+ httpx_client : typing.Optional[httpx.AsyncClient]
96
+ 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.
97
+
98
+ Examples
99
+ --------
100
+ from method_security import AsyncMethodSecurityApi
101
+
102
+ client = AsyncMethodSecurityApi(
103
+ base_url="https://yourhost.com/path/to/api",
104
+ )
105
+ """
106
+
107
+ def __init__(
108
+ self,
109
+ *,
110
+ base_url: str,
111
+ headers: typing.Optional[typing.Dict[str, str]] = None,
112
+ timeout: typing.Optional[float] = None,
113
+ follow_redirects: typing.Optional[bool] = True,
114
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
115
+ ):
116
+ _defaulted_timeout = (
117
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
118
+ )
119
+ self._client_wrapper = AsyncClientWrapper(
120
+ base_url=base_url,
121
+ headers=headers,
122
+ httpx_client=httpx_client
123
+ if httpx_client is not None
124
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
125
+ if follow_redirects is not None
126
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
127
+ timeout=_defaulted_timeout,
128
+ )
129
+ self._issues: typing.Optional[AsyncIssuesClient] = None
130
+
131
+ @property
132
+ def issues(self):
133
+ if self._issues is None:
134
+ from .issues.client import AsyncIssuesClient # noqa: E402
135
+
136
+ self._issues = AsyncIssuesClient(client_wrapper=self._client_wrapper)
137
+ return self._issues
@@ -0,0 +1,32 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import EnvironmentId
10
+ _dynamic_imports: typing.Dict[str, str] = {"EnvironmentId": ".types"}
11
+
12
+
13
+ def __getattr__(attr_name: str) -> typing.Any:
14
+ module_name = _dynamic_imports.get(attr_name)
15
+ if module_name is None:
16
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
17
+ try:
18
+ module = import_module(module_name, __package__)
19
+ result = getattr(module, attr_name)
20
+ return result
21
+ except ImportError as e:
22
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
23
+ except AttributeError as e:
24
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
25
+
26
+
27
+ def __dir__():
28
+ lazy_attrs = list(_dynamic_imports.keys())
29
+ return sorted(lazy_attrs)
30
+
31
+
32
+ __all__ = ["EnvironmentId"]
@@ -0,0 +1,32 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .environment_id import EnvironmentId
10
+ _dynamic_imports: typing.Dict[str, str] = {"EnvironmentId": ".environment_id"}
11
+
12
+
13
+ def __getattr__(attr_name: str) -> typing.Any:
14
+ module_name = _dynamic_imports.get(attr_name)
15
+ if module_name is None:
16
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
17
+ try:
18
+ module = import_module(module_name, __package__)
19
+ result = getattr(module, attr_name)
20
+ return result
21
+ except ImportError as e:
22
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
23
+ except AttributeError as e:
24
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
25
+
26
+
27
+ def __dir__():
28
+ lazy_attrs = list(_dynamic_imports.keys())
29
+ return sorted(lazy_attrs)
30
+
31
+
32
+ __all__ = ["EnvironmentId"]
@@ -0,0 +1,3 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ EnvironmentId = str
@@ -0,0 +1,103 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .api_error import ApiError
10
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
11
+ from .datetime_utils import serialize_datetime
12
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
13
+ from .http_client import AsyncHttpClient, HttpClient
14
+ from .http_response import AsyncHttpResponse, HttpResponse
15
+ from .jsonable_encoder import jsonable_encoder
16
+ from .pydantic_utilities import (
17
+ IS_PYDANTIC_V2,
18
+ UniversalBaseModel,
19
+ UniversalRootModel,
20
+ parse_obj_as,
21
+ universal_field_validator,
22
+ universal_root_validator,
23
+ update_forward_refs,
24
+ )
25
+ from .query_encoder import encode_query
26
+ from .remove_none_from_dict import remove_none_from_dict
27
+ from .request_options import RequestOptions
28
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
29
+ _dynamic_imports: typing.Dict[str, str] = {
30
+ "ApiError": ".api_error",
31
+ "AsyncClientWrapper": ".client_wrapper",
32
+ "AsyncHttpClient": ".http_client",
33
+ "AsyncHttpResponse": ".http_response",
34
+ "BaseClientWrapper": ".client_wrapper",
35
+ "FieldMetadata": ".serialization",
36
+ "File": ".file",
37
+ "HttpClient": ".http_client",
38
+ "HttpResponse": ".http_response",
39
+ "IS_PYDANTIC_V2": ".pydantic_utilities",
40
+ "RequestOptions": ".request_options",
41
+ "SyncClientWrapper": ".client_wrapper",
42
+ "UniversalBaseModel": ".pydantic_utilities",
43
+ "UniversalRootModel": ".pydantic_utilities",
44
+ "convert_and_respect_annotation_metadata": ".serialization",
45
+ "convert_file_dict_to_httpx_tuples": ".file",
46
+ "encode_query": ".query_encoder",
47
+ "jsonable_encoder": ".jsonable_encoder",
48
+ "parse_obj_as": ".pydantic_utilities",
49
+ "remove_none_from_dict": ".remove_none_from_dict",
50
+ "serialize_datetime": ".datetime_utils",
51
+ "universal_field_validator": ".pydantic_utilities",
52
+ "universal_root_validator": ".pydantic_utilities",
53
+ "update_forward_refs": ".pydantic_utilities",
54
+ "with_content_type": ".file",
55
+ }
56
+
57
+
58
+ def __getattr__(attr_name: str) -> typing.Any:
59
+ module_name = _dynamic_imports.get(attr_name)
60
+ if module_name is None:
61
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
62
+ try:
63
+ module = import_module(module_name, __package__)
64
+ result = getattr(module, attr_name)
65
+ return result
66
+ except ImportError as e:
67
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
68
+ except AttributeError as e:
69
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
70
+
71
+
72
+ def __dir__():
73
+ lazy_attrs = list(_dynamic_imports.keys())
74
+ return sorted(lazy_attrs)
75
+
76
+
77
+ __all__ = [
78
+ "ApiError",
79
+ "AsyncClientWrapper",
80
+ "AsyncHttpClient",
81
+ "AsyncHttpResponse",
82
+ "BaseClientWrapper",
83
+ "FieldMetadata",
84
+ "File",
85
+ "HttpClient",
86
+ "HttpResponse",
87
+ "IS_PYDANTIC_V2",
88
+ "RequestOptions",
89
+ "SyncClientWrapper",
90
+ "UniversalBaseModel",
91
+ "UniversalRootModel",
92
+ "convert_and_respect_annotation_metadata",
93
+ "convert_file_dict_to_httpx_tuples",
94
+ "encode_query",
95
+ "jsonable_encoder",
96
+ "parse_obj_as",
97
+ "remove_none_from_dict",
98
+ "serialize_datetime",
99
+ "universal_field_validator",
100
+ "universal_root_validator",
101
+ "update_forward_refs",
102
+ "with_content_type",
103
+ ]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,74 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .http_client import AsyncHttpClient, HttpClient
7
+
8
+
9
+ class BaseClientWrapper:
10
+ def __init__(
11
+ self,
12
+ *,
13
+ headers: typing.Optional[typing.Dict[str, str]] = None,
14
+ base_url: str,
15
+ timeout: typing.Optional[float] = None,
16
+ ):
17
+ self._headers = headers
18
+ self._base_url = base_url
19
+ self._timeout = timeout
20
+
21
+ def get_headers(self) -> typing.Dict[str, str]:
22
+ headers: typing.Dict[str, str] = {
23
+ "User-Agent": "methodsdk/0.0.3",
24
+ "X-Fern-Language": "Python",
25
+ "X-Fern-SDK-Name": "methodsdk",
26
+ "X-Fern-SDK-Version": "0.0.3",
27
+ **(self.get_custom_headers() or {}),
28
+ }
29
+ return headers
30
+
31
+ def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
32
+ return self._headers
33
+
34
+ def get_base_url(self) -> str:
35
+ return self._base_url
36
+
37
+ def get_timeout(self) -> typing.Optional[float]:
38
+ return self._timeout
39
+
40
+
41
+ class SyncClientWrapper(BaseClientWrapper):
42
+ def __init__(
43
+ self,
44
+ *,
45
+ headers: typing.Optional[typing.Dict[str, str]] = None,
46
+ base_url: str,
47
+ timeout: typing.Optional[float] = None,
48
+ httpx_client: httpx.Client,
49
+ ):
50
+ super().__init__(headers=headers, base_url=base_url, timeout=timeout)
51
+ self.httpx_client = HttpClient(
52
+ httpx_client=httpx_client,
53
+ base_headers=self.get_headers,
54
+ base_timeout=self.get_timeout,
55
+ base_url=self.get_base_url,
56
+ )
57
+
58
+
59
+ class AsyncClientWrapper(BaseClientWrapper):
60
+ def __init__(
61
+ self,
62
+ *,
63
+ headers: typing.Optional[typing.Dict[str, str]] = None,
64
+ base_url: str,
65
+ timeout: typing.Optional[float] = None,
66
+ httpx_client: httpx.AsyncClient,
67
+ ):
68
+ super().__init__(headers=headers, base_url=base_url, timeout=timeout)
69
+ self.httpx_client = AsyncHttpClient(
70
+ httpx_client=httpx_client,
71
+ base_headers=self.get_headers,
72
+ base_timeout=self.get_timeout,
73
+ base_url=self.get_base_url,
74
+ )
@@ -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)
@@ -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)
@@ -0,0 +1,18 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict
4
+
5
+
6
+ class ForceMultipartDict(Dict[str, Any]):
7
+ """
8
+ A dictionary subclass that always evaluates to True in boolean contexts.
9
+
10
+ This is used to force multipart/form-data encoding in HTTP requests even when
11
+ the dictionary is empty, which would normally evaluate to False.
12
+ """
13
+
14
+ def __bool__(self) -> bool:
15
+ return True
16
+
17
+
18
+ FORCE_MULTIPART = ForceMultipartDict()