methodsdk 0.0.3__tar.gz → 0.0.5__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 (38) hide show
  1. {methodsdk-0.0.3 → methodsdk-0.0.5}/PKG-INFO +3 -1
  2. {methodsdk-0.0.3 → methodsdk-0.0.5}/README.md +2 -0
  3. {methodsdk-0.0.3 → methodsdk-0.0.5}/pyproject.toml +1 -1
  4. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/client.py +22 -0
  5. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/client_wrapper.py +19 -4
  6. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/client.py +2 -0
  7. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/__init__.py +0 -0
  8. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/common/__init__.py +0 -0
  9. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/common/types/__init__.py +0 -0
  10. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/common/types/environment_id.py +0 -0
  11. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/__init__.py +0 -0
  12. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/api_error.py +0 -0
  13. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/datetime_utils.py +0 -0
  14. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/file.py +0 -0
  15. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/force_multipart.py +0 -0
  16. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/http_client.py +0 -0
  17. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/http_response.py +0 -0
  18. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/jsonable_encoder.py +0 -0
  19. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/pydantic_utilities.py +0 -0
  20. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/query_encoder.py +0 -0
  21. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/remove_none_from_dict.py +0 -0
  22. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/request_options.py +0 -0
  23. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/core/serialization.py +0 -0
  24. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/__init__.py +0 -0
  25. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/errors/__init__.py +0 -0
  26. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/errors/issue_does_not_exist_error.py +0 -0
  27. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/raw_client.py +0 -0
  28. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/types/__init__.py +0 -0
  29. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/types/issue.py +0 -0
  30. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/types/issue_closed_reason.py +0 -0
  31. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/types/issue_id.py +0 -0
  32. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/types/issue_severity.py +0 -0
  33. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/issues/types/issue_status.py +0 -0
  34. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/objects/__init__.py +0 -0
  35. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/objects/types/__init__.py +0 -0
  36. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/objects/types/object_id.py +0 -0
  37. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/py.typed +0 -0
  38. {methodsdk-0.0.3 → methodsdk-0.0.5}/src/method_security/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: methodsdk
3
- Version: 0.0.3
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
 
@@ -23,6 +23,7 @@ Instantiate and use the client with the following:
23
23
  from method_security import MethodSecurityApi
24
24
 
25
25
  client = MethodSecurityApi(
26
+ o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
26
27
  base_url="https://yourhost.com/path/to/api",
27
28
  )
28
29
  client.issues.get_issue(
@@ -40,6 +41,7 @@ import asyncio
40
41
  from method_security import AsyncMethodSecurityApi
41
42
 
42
43
  client = AsyncMethodSecurityApi(
44
+ o_auth_2_0_bearer_token="YOUR_O_AUTH_2_0_BEARER_TOKEN",
43
45
  base_url="https://yourhost.com/path/to/api",
44
46
  )
45
47
 
@@ -3,7 +3,7 @@ name = "methodsdk"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "methodsdk"
6
- version = "0.0.3"
6
+ version = "0.0.5"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -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.3",
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.3",
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__(headers=headers, base_url=base_url, timeout=timeout)
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__(headers=headers, base_url=base_url, timeout=timeout)
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,
@@ -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