methodsdk 0.0.3__py3-none-any.whl → 0.0.5__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.
- method_security/client.py +22 -0
- method_security/core/client_wrapper.py +19 -4
- method_security/issues/client.py +2 -0
- {methodsdk-0.0.3.dist-info → methodsdk-0.0.5.dist-info}/METADATA +3 -1
- {methodsdk-0.0.3.dist-info → methodsdk-0.0.5.dist-info}/RECORD +6 -6
- {methodsdk-0.0.3.dist-info → methodsdk-0.0.5.dist-info}/WHEEL +0 -0
method_security/client.py
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
from __future__ import annotations
|
4
4
|
|
5
|
+
import os
|
5
6
|
import typing
|
6
7
|
|
7
8
|
import httpx
|
9
|
+
from .core.api_error import ApiError
|
8
10
|
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
11
|
|
10
12
|
if typing.TYPE_CHECKING:
|
@@ -20,6 +22,7 @@ class MethodSecurityApi:
|
|
20
22
|
base_url : str
|
21
23
|
The base url to use for requests from the client.
|
22
24
|
|
25
|
+
o_auth_2_0_bearer_token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
|
23
26
|
headers : typing.Optional[typing.Dict[str, str]]
|
24
27
|
Additional headers to send with every request.
|
25
28
|
|
@@ -37,6 +40,7 @@ class MethodSecurityApi:
|
|
37
40
|
from method_security import MethodSecurityApi
|
38
41
|
|
39
42
|
client = MethodSecurityApi(
|
43
|
+
o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
|
40
44
|
base_url="https://yourhost.com/path/to/api",
|
41
45
|
)
|
42
46
|
"""
|
@@ -45,6 +49,9 @@ class MethodSecurityApi:
|
|
45
49
|
self,
|
46
50
|
*,
|
47
51
|
base_url: str,
|
52
|
+
o_auth_2_0_bearer_token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv(
|
53
|
+
"BEARER_TOKEN"
|
54
|
+
),
|
48
55
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
49
56
|
timeout: typing.Optional[float] = None,
|
50
57
|
follow_redirects: typing.Optional[bool] = True,
|
@@ -53,8 +60,13 @@ class MethodSecurityApi:
|
|
53
60
|
_defaulted_timeout = (
|
54
61
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
55
62
|
)
|
63
|
+
if o_auth_2_0_bearer_token is None:
|
64
|
+
raise ApiError(
|
65
|
+
body="The client must be instantiated be either passing in o_auth_2_0_bearer_token or setting BEARER_TOKEN"
|
66
|
+
)
|
56
67
|
self._client_wrapper = SyncClientWrapper(
|
57
68
|
base_url=base_url,
|
69
|
+
o_auth_2_0_bearer_token=o_auth_2_0_bearer_token,
|
58
70
|
headers=headers,
|
59
71
|
httpx_client=httpx_client
|
60
72
|
if httpx_client is not None
|
@@ -83,6 +95,7 @@ class AsyncMethodSecurityApi:
|
|
83
95
|
base_url : str
|
84
96
|
The base url to use for requests from the client.
|
85
97
|
|
98
|
+
o_auth_2_0_bearer_token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
|
86
99
|
headers : typing.Optional[typing.Dict[str, str]]
|
87
100
|
Additional headers to send with every request.
|
88
101
|
|
@@ -100,6 +113,7 @@ class AsyncMethodSecurityApi:
|
|
100
113
|
from method_security import AsyncMethodSecurityApi
|
101
114
|
|
102
115
|
client = AsyncMethodSecurityApi(
|
116
|
+
o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
|
103
117
|
base_url="https://yourhost.com/path/to/api",
|
104
118
|
)
|
105
119
|
"""
|
@@ -108,6 +122,9 @@ class AsyncMethodSecurityApi:
|
|
108
122
|
self,
|
109
123
|
*,
|
110
124
|
base_url: str,
|
125
|
+
o_auth_2_0_bearer_token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv(
|
126
|
+
"BEARER_TOKEN"
|
127
|
+
),
|
111
128
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
112
129
|
timeout: typing.Optional[float] = None,
|
113
130
|
follow_redirects: typing.Optional[bool] = True,
|
@@ -116,8 +133,13 @@ class AsyncMethodSecurityApi:
|
|
116
133
|
_defaulted_timeout = (
|
117
134
|
timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
|
118
135
|
)
|
136
|
+
if o_auth_2_0_bearer_token is None:
|
137
|
+
raise ApiError(
|
138
|
+
body="The client must be instantiated be either passing in o_auth_2_0_bearer_token or setting BEARER_TOKEN"
|
139
|
+
)
|
119
140
|
self._client_wrapper = AsyncClientWrapper(
|
120
141
|
base_url=base_url,
|
142
|
+
o_auth_2_0_bearer_token=o_auth_2_0_bearer_token,
|
121
143
|
headers=headers,
|
122
144
|
httpx_client=httpx_client
|
123
145
|
if httpx_client is not None
|
@@ -10,24 +10,33 @@ class BaseClientWrapper:
|
|
10
10
|
def __init__(
|
11
11
|
self,
|
12
12
|
*,
|
13
|
+
o_auth_2_0_bearer_token: typing.Union[str, typing.Callable[[], str]],
|
13
14
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
14
15
|
base_url: str,
|
15
16
|
timeout: typing.Optional[float] = None,
|
16
17
|
):
|
18
|
+
self._o_auth_2_0_bearer_token = o_auth_2_0_bearer_token
|
17
19
|
self._headers = headers
|
18
20
|
self._base_url = base_url
|
19
21
|
self._timeout = timeout
|
20
22
|
|
21
23
|
def get_headers(self) -> typing.Dict[str, str]:
|
22
24
|
headers: typing.Dict[str, str] = {
|
23
|
-
"User-Agent": "methodsdk/0.0.
|
25
|
+
"User-Agent": "methodsdk/0.0.5",
|
24
26
|
"X-Fern-Language": "Python",
|
25
27
|
"X-Fern-SDK-Name": "methodsdk",
|
26
|
-
"X-Fern-SDK-Version": "0.0.
|
28
|
+
"X-Fern-SDK-Version": "0.0.5",
|
27
29
|
**(self.get_custom_headers() or {}),
|
28
30
|
}
|
31
|
+
headers["Authorization"] = f"Bearer {self._get_o_auth_2_0_bearer_token()}"
|
29
32
|
return headers
|
30
33
|
|
34
|
+
def _get_o_auth_2_0_bearer_token(self) -> str:
|
35
|
+
if isinstance(self._o_auth_2_0_bearer_token, str):
|
36
|
+
return self._o_auth_2_0_bearer_token
|
37
|
+
else:
|
38
|
+
return self._o_auth_2_0_bearer_token()
|
39
|
+
|
31
40
|
def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
|
32
41
|
return self._headers
|
33
42
|
|
@@ -42,12 +51,15 @@ class SyncClientWrapper(BaseClientWrapper):
|
|
42
51
|
def __init__(
|
43
52
|
self,
|
44
53
|
*,
|
54
|
+
o_auth_2_0_bearer_token: typing.Union[str, typing.Callable[[], str]],
|
45
55
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
46
56
|
base_url: str,
|
47
57
|
timeout: typing.Optional[float] = None,
|
48
58
|
httpx_client: httpx.Client,
|
49
59
|
):
|
50
|
-
super().__init__(
|
60
|
+
super().__init__(
|
61
|
+
o_auth_2_0_bearer_token=o_auth_2_0_bearer_token, headers=headers, base_url=base_url, timeout=timeout
|
62
|
+
)
|
51
63
|
self.httpx_client = HttpClient(
|
52
64
|
httpx_client=httpx_client,
|
53
65
|
base_headers=self.get_headers,
|
@@ -60,12 +72,15 @@ class AsyncClientWrapper(BaseClientWrapper):
|
|
60
72
|
def __init__(
|
61
73
|
self,
|
62
74
|
*,
|
75
|
+
o_auth_2_0_bearer_token: typing.Union[str, typing.Callable[[], str]],
|
63
76
|
headers: typing.Optional[typing.Dict[str, str]] = None,
|
64
77
|
base_url: str,
|
65
78
|
timeout: typing.Optional[float] = None,
|
66
79
|
httpx_client: httpx.AsyncClient,
|
67
80
|
):
|
68
|
-
super().__init__(
|
81
|
+
super().__init__(
|
82
|
+
o_auth_2_0_bearer_token=o_auth_2_0_bearer_token, headers=headers, base_url=base_url, timeout=timeout
|
83
|
+
)
|
69
84
|
self.httpx_client = AsyncHttpClient(
|
70
85
|
httpx_client=httpx_client,
|
71
86
|
base_headers=self.get_headers,
|
method_security/issues/client.py
CHANGED
@@ -44,6 +44,7 @@ class IssuesClient:
|
|
44
44
|
from method_security import MethodSecurityApi
|
45
45
|
|
46
46
|
client = MethodSecurityApi(
|
47
|
+
o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
|
47
48
|
base_url="https://yourhost.com/path/to/api",
|
48
49
|
)
|
49
50
|
client.issues.get_issue(
|
@@ -91,6 +92,7 @@ class AsyncIssuesClient:
|
|
91
92
|
from method_security import AsyncMethodSecurityApi
|
92
93
|
|
93
94
|
client = AsyncMethodSecurityApi(
|
95
|
+
o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
|
94
96
|
base_url="https://yourhost.com/path/to/api",
|
95
97
|
)
|
96
98
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: methodsdk
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.5
|
4
4
|
Summary:
|
5
5
|
Requires-Python: >=3.8,<4.0
|
6
6
|
Classifier: Intended Audience :: Developers
|
@@ -49,6 +49,7 @@ Instantiate and use the client with the following:
|
|
49
49
|
from method_security import MethodSecurityApi
|
50
50
|
|
51
51
|
client = MethodSecurityApi(
|
52
|
+
o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
|
52
53
|
base_url="https://yourhost.com/path/to/api",
|
53
54
|
)
|
54
55
|
client.issues.get_issue(
|
@@ -66,6 +67,7 @@ import asyncio
|
|
66
67
|
from method_security import AsyncMethodSecurityApi
|
67
68
|
|
68
69
|
client = AsyncMethodSecurityApi(
|
70
|
+
o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
|
69
71
|
base_url="https://yourhost.com/path/to/api",
|
70
72
|
)
|
71
73
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
method_security/__init__.py,sha256=AOD5vMc55opE3103X8GMj53ga7-7ryT4lCWAJfVEuzc,1940
|
2
|
-
method_security/client.py,sha256=
|
2
|
+
method_security/client.py,sha256=NbBkCge2G2iZER2-yatSFasaHWxCusrwEUSZtdvyqgU,6345
|
3
3
|
method_security/common/__init__.py,sha256=PIZFn7O33jJ8d5gotcFDUB0Jfa0cr5IbU1PMvdxHWEQ,996
|
4
4
|
method_security/common/types/__init__.py,sha256=VcZmN-hKZp8sITvG--3RIT2TPvu3eXArM7JVIUjDsTA,1014
|
5
5
|
method_security/common/types/environment_id.py,sha256=rTVX5tfhkyuShEgOeFNdXNLYd2xFcifdp6bjc_AZh-4,85
|
6
6
|
method_security/core/__init__.py,sha256=JEuWUBvwpp2bG8dysycjfsGZW5A7U1iFuTUdKCYBe18,3561
|
7
7
|
method_security/core/api_error.py,sha256=44vPoTyWN59gonCIZMdzw7M1uspygiLnr3GNFOoVL2Q,614
|
8
|
-
method_security/core/client_wrapper.py,sha256=
|
8
|
+
method_security/core/client_wrapper.py,sha256=Al25t4BeA4CAfEq7yzE6qRWpG8bfRaMiRRD6B_XPAd4,2941
|
9
9
|
method_security/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
10
10
|
method_security/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
|
11
11
|
method_security/core/force_multipart.py,sha256=cH981xLy0kZVKiZZkFoeUjgJ2Zuq7KXB2aRAnmHzRDc,477
|
@@ -18,7 +18,7 @@ method_security/core/remove_none_from_dict.py,sha256=EU9SGgYidWq7SexuJbNs4-PZ-5B
|
|
18
18
|
method_security/core/request_options.py,sha256=h0QUNCFVdCW_7GclVySCAY2w4NhtXVBUCmHgmzaxpcg,1681
|
19
19
|
method_security/core/serialization.py,sha256=ECL3bvv_0i7U4uvPidZCNel--MUbA0iq0aGcNKi3kws,9818
|
20
20
|
method_security/issues/__init__.py,sha256=dxu6m_AgSfueonv3pZEooW0IStxVtTwM2SQq020d0g8,1333
|
21
|
-
method_security/issues/client.py,sha256=
|
21
|
+
method_security/issues/client.py,sha256=ipXMelVTJP_TVg4M-PaOQvfIbO0tjCxpvRFFcx3QHTk,3104
|
22
22
|
method_security/issues/errors/__init__.py,sha256=8EWUlufeGM4jiCck5oNhzpyykjUHUAFf36OV7ap1yK4,1065
|
23
23
|
method_security/issues/errors/issue_does_not_exist_error.py,sha256=M36fSibrza_M2s6zFy3USbKD7oiZvYu5qNy2hI5RWbE,363
|
24
24
|
method_security/issues/raw_client.py,sha256=nGtOdhWKP-1LxRRvkzTRBxXaRNibH5ffTU4fDSSfUJI,4350
|
@@ -33,6 +33,6 @@ method_security/objects/types/__init__.py,sha256=jlVLwR0gVExvWY_8aX8lkCj2yCg1h8g
|
|
33
33
|
method_security/objects/types/object_id.py,sha256=qM0JqAh4F93p99NmwrlCDFWrz_IirFcHrJsrX5XvvM8,80
|
34
34
|
method_security/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
35
|
method_security/version.py,sha256=UtvKA1fp_ZsNGUtAHi8_yoFObAUaWBXYSPiKhoyD_68,76
|
36
|
-
methodsdk-0.0.
|
37
|
-
methodsdk-0.0.
|
38
|
-
methodsdk-0.0.
|
36
|
+
methodsdk-0.0.5.dist-info/METADATA,sha256=kGuOUmGCHmfRGyfP83nEL5QF2aB2ByAVKt-DNwb9Mag,5438
|
37
|
+
methodsdk-0.0.5.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
38
|
+
methodsdk-0.0.5.dist-info/RECORD,,
|
File without changes
|