pygeai 0.6.0b13__py3-none-any.whl → 0.6.1__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 (217) hide show
  1. pygeai/__init__.py +1 -2
  2. pygeai/_docs/source/content/api_reference/project.rst +392 -0
  3. pygeai/_docs/source/content/authentication.rst +130 -1
  4. pygeai/_docs/source/content/debugger.rst +327 -157
  5. pygeai/_docs/source/content/migration.rst +391 -7
  6. pygeai/_docs/source/pygeai.core.common.rst +8 -0
  7. pygeai/_docs/source/pygeai.tests.auth.rst +56 -0
  8. pygeai/_docs/source/pygeai.tests.cli.rst +8 -0
  9. pygeai/admin/clients.py +1 -3
  10. pygeai/analytics/clients.py +1 -1
  11. pygeai/assistant/clients.py +2 -7
  12. pygeai/assistant/data/clients.py +0 -8
  13. pygeai/assistant/data_analyst/clients.py +0 -2
  14. pygeai/assistant/managers.py +1 -1
  15. pygeai/assistant/rag/clients.py +0 -2
  16. pygeai/assistant/rag/mappers.py +9 -11
  17. pygeai/auth/clients.py +26 -7
  18. pygeai/auth/endpoints.py +2 -1
  19. pygeai/chat/clients.py +2 -2
  20. pygeai/chat/managers.py +1 -1
  21. pygeai/cli/commands/admin.py +13 -25
  22. pygeai/cli/commands/analytics.py +56 -88
  23. pygeai/cli/commands/assistant.py +84 -138
  24. pygeai/cli/commands/auth.py +23 -46
  25. pygeai/cli/commands/base.py +0 -1
  26. pygeai/cli/commands/chat.py +218 -209
  27. pygeai/cli/commands/common.py +5 -5
  28. pygeai/cli/commands/configuration.py +79 -29
  29. pygeai/cli/commands/docs.py +3 -4
  30. pygeai/cli/commands/embeddings.py +13 -19
  31. pygeai/cli/commands/evaluation.py +133 -344
  32. pygeai/cli/commands/feedback.py +7 -15
  33. pygeai/cli/commands/files.py +26 -53
  34. pygeai/cli/commands/gam.py +28 -69
  35. pygeai/cli/commands/lab/ai_lab.py +96 -142
  36. pygeai/cli/commands/lab/common.py +1 -1
  37. pygeai/cli/commands/lab/spec.py +12 -32
  38. pygeai/cli/commands/llm.py +9 -18
  39. pygeai/cli/commands/migrate.py +43 -99
  40. pygeai/cli/commands/organization.py +223 -196
  41. pygeai/cli/commands/rag.py +35 -58
  42. pygeai/cli/commands/rerank.py +21 -25
  43. pygeai/cli/commands/secrets.py +39 -67
  44. pygeai/cli/commands/usage_limits.py +50 -136
  45. pygeai/cli/commands/validators.py +1 -1
  46. pygeai/cli/geai.py +32 -3
  47. pygeai/cli/geai_proxy.py +6 -2
  48. pygeai/cli/install_man.py +1 -1
  49. pygeai/cli/parsers.py +1 -1
  50. pygeai/core/base/clients.py +90 -21
  51. pygeai/core/base/mappers.py +39 -55
  52. pygeai/core/base/session.py +134 -22
  53. pygeai/core/common/config.py +50 -13
  54. pygeai/core/common/constants.py +8 -0
  55. pygeai/core/common/exceptions.py +6 -0
  56. pygeai/core/embeddings/clients.py +0 -1
  57. pygeai/core/embeddings/managers.py +0 -1
  58. pygeai/core/feedback/clients.py +0 -2
  59. pygeai/core/feedback/models.py +1 -1
  60. pygeai/core/files/clients.py +0 -3
  61. pygeai/core/files/managers.py +1 -1
  62. pygeai/core/files/mappers.py +4 -5
  63. pygeai/core/llm/clients.py +0 -1
  64. pygeai/core/models.py +4 -4
  65. pygeai/core/plugins/clients.py +0 -3
  66. pygeai/core/plugins/models.py +2 -2
  67. pygeai/core/rerank/clients.py +0 -2
  68. pygeai/core/secrets/clients.py +0 -2
  69. pygeai/core/services/rest.py +80 -14
  70. pygeai/core/singleton.py +24 -0
  71. pygeai/dbg/__init__.py +2 -2
  72. pygeai/dbg/debugger.py +276 -38
  73. pygeai/evaluation/clients.py +2 -4
  74. pygeai/evaluation/dataset/clients.py +0 -1
  75. pygeai/evaluation/plan/clients.py +0 -2
  76. pygeai/evaluation/result/clients.py +0 -2
  77. pygeai/gam/clients.py +1 -3
  78. pygeai/health/clients.py +1 -3
  79. pygeai/lab/clients.py +0 -1
  80. pygeai/lab/managers.py +0 -1
  81. pygeai/lab/models.py +0 -1
  82. pygeai/lab/strategies/clients.py +1 -2
  83. pygeai/lab/tools/clients.py +2 -2
  84. pygeai/lab/tools/mappers.py +1 -1
  85. pygeai/migration/strategies.py +5 -6
  86. pygeai/migration/tools.py +1 -1
  87. pygeai/organization/clients.py +118 -12
  88. pygeai/organization/endpoints.py +1 -0
  89. pygeai/organization/limits/clients.py +4 -6
  90. pygeai/organization/limits/managers.py +1 -4
  91. pygeai/organization/managers.py +2 -2
  92. pygeai/proxy/config.py +1 -0
  93. pygeai/proxy/managers.py +6 -5
  94. pygeai/tests/admin/test_clients.py +11 -11
  95. pygeai/tests/assistants/rag/test_clients.py +1 -1
  96. pygeai/tests/assistants/rag/test_models.py +1 -2
  97. pygeai/tests/assistants/test_clients.py +1 -1
  98. pygeai/tests/assistants/test_managers.py +1 -3
  99. pygeai/tests/auth/test_cli_configuration.py +252 -0
  100. pygeai/tests/auth/test_client_initialization.py +411 -0
  101. pygeai/tests/auth/test_clients.py +29 -27
  102. pygeai/tests/auth/test_config_manager.py +305 -0
  103. pygeai/tests/auth/test_header_injection.py +294 -0
  104. pygeai/tests/auth/test_oauth.py +3 -1
  105. pygeai/tests/auth/test_session_logging.py +119 -0
  106. pygeai/tests/auth/test_session_validation.py +408 -0
  107. pygeai/tests/auth/test_singleton_reset.py +201 -0
  108. pygeai/tests/chat/test_clients.py +1 -1
  109. pygeai/tests/chat/test_iris.py +1 -1
  110. pygeai/tests/chat/test_ui.py +0 -2
  111. pygeai/tests/cli/commands/lab/test_ai_lab.py +1 -3
  112. pygeai/tests/cli/commands/lab/test_common.py +0 -1
  113. pygeai/tests/cli/commands/test_chat.py +1 -1
  114. pygeai/tests/cli/commands/test_common.py +0 -1
  115. pygeai/tests/cli/commands/test_embeddings.py +2 -2
  116. pygeai/tests/cli/commands/test_evaluation.py +1 -9
  117. pygeai/tests/cli/commands/test_llm.py +1 -1
  118. pygeai/tests/cli/commands/test_migrate.py +1 -1
  119. pygeai/tests/cli/commands/test_rerank.py +0 -1
  120. pygeai/tests/cli/commands/test_secrets.py +1 -1
  121. pygeai/tests/cli/commands/test_show_help.py +0 -1
  122. pygeai/tests/cli/commands/test_validators.py +0 -1
  123. pygeai/tests/cli/test_credentials_flag.py +312 -0
  124. pygeai/tests/cli/test_error_handler.py +0 -1
  125. pygeai/tests/core/base/test_mappers.py +2 -2
  126. pygeai/tests/core/base/test_models.py +4 -4
  127. pygeai/tests/core/common/test_config.py +2 -7
  128. pygeai/tests/core/common/test_decorators.py +0 -1
  129. pygeai/tests/core/embeddings/test_managers.py +1 -1
  130. pygeai/tests/core/feedback/test_clients.py +2 -2
  131. pygeai/tests/core/files/test_clients.py +6 -6
  132. pygeai/tests/core/files/test_models.py +0 -1
  133. pygeai/tests/core/files/test_responses.py +0 -1
  134. pygeai/tests/core/llm/test_clients.py +1 -1
  135. pygeai/tests/core/plugins/test_clients.py +4 -4
  136. pygeai/tests/core/rerank/test_mappers.py +1 -3
  137. pygeai/tests/core/secrets/test_clients.py +2 -3
  138. pygeai/tests/core/services/test_rest.py +10 -10
  139. pygeai/tests/core/utils/test_console.py +0 -1
  140. pygeai/tests/dbg/test_debugger.py +95 -8
  141. pygeai/tests/evaluation/dataset/test_clients.py +24 -27
  142. pygeai/tests/evaluation/plan/test_clients.py +16 -18
  143. pygeai/tests/evaluation/result/test_clients.py +4 -5
  144. pygeai/tests/health/test_clients.py +2 -2
  145. pygeai/tests/integration/lab/agents/test_create_agent.py +1 -3
  146. pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
  147. pygeai/tests/integration/lab/processes/test_create_process.py +2 -2
  148. pygeai/tests/integration/lab/processes/test_create_task.py +2 -3
  149. pygeai/tests/integration/lab/processes/test_delete_process.py +0 -1
  150. pygeai/tests/integration/lab/processes/test_get_process.py +2 -4
  151. pygeai/tests/integration/lab/processes/test_list_process_instances.py +1 -3
  152. pygeai/tests/integration/lab/processes/test_update_process.py +3 -9
  153. pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -2
  154. pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
  155. pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
  156. pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
  157. pygeai/tests/lab/agents/test_clients.py +17 -17
  158. pygeai/tests/lab/processes/test_clients.py +67 -67
  159. pygeai/tests/lab/processes/test_mappers.py +23 -23
  160. pygeai/tests/lab/spec/test_loader.py +0 -2
  161. pygeai/tests/lab/spec/test_parsers.py +1 -2
  162. pygeai/tests/lab/strategies/test_clients.py +10 -10
  163. pygeai/tests/lab/test_managers.py +3 -5
  164. pygeai/tests/lab/test_mappers.py +1 -4
  165. pygeai/tests/lab/tools/test_clients.py +21 -21
  166. pygeai/tests/lab/tools/test_mappers.py +0 -1
  167. pygeai/tests/organization/limits/test_clients.py +33 -33
  168. pygeai/tests/organization/limits/test_managers.py +7 -7
  169. pygeai/tests/organization/test_clients.py +78 -60
  170. pygeai/tests/proxy/test_clients.py +1 -1
  171. pygeai/tests/proxy/test_integration.py +1 -4
  172. pygeai/tests/proxy/test_managers.py +1 -2
  173. pygeai/tests/proxy/test_servers.py +1 -2
  174. pygeai/tests/snippets/assistants/rag/delete_rag_assistant.py +0 -1
  175. pygeai/tests/snippets/assistants/rag/get_documents.py +0 -1
  176. pygeai/tests/snippets/assistants/rag/get_rag_assistant_data.py +0 -1
  177. pygeai/tests/snippets/chat/get_request_status.py +0 -1
  178. pygeai/tests/snippets/dbg/file_debugging.py +72 -0
  179. pygeai/tests/snippets/dbg/module_debugging.py +60 -0
  180. pygeai/tests/snippets/embeddings/cohere_example.py +2 -2
  181. pygeai/tests/snippets/embeddings/openai_base64_example.py +1 -1
  182. pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +8 -8
  183. pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +5 -5
  184. pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +3 -3
  185. pygeai/tests/snippets/lab/agentic_flow_example_1.py +1 -1
  186. pygeai/tests/snippets/lab/agentic_flow_example_2.py +3 -4
  187. pygeai/tests/snippets/lab/agents/create_agent_with_permissions.py +2 -2
  188. pygeai/tests/snippets/lab/agents/delete_agent.py +1 -2
  189. pygeai/tests/snippets/lab/agents/get_agent.py +1 -1
  190. pygeai/tests/snippets/lab/agents/get_agent_with_new_fields.py +10 -10
  191. pygeai/tests/snippets/lab/agents/get_sharing_link.py +0 -1
  192. pygeai/tests/snippets/lab/agents/list_agents.py +1 -1
  193. pygeai/tests/snippets/lab/agents/publish_agent_revision.py +0 -1
  194. pygeai/tests/snippets/lab/agents/update_agent_properties.py +1 -1
  195. pygeai/tests/snippets/lab/crud_ui.py +3 -5
  196. pygeai/tests/snippets/lab/processes/kbs/get_kb.py +0 -1
  197. pygeai/tests/snippets/lab/processes/kbs/list_kbs.py +0 -1
  198. pygeai/tests/snippets/lab/processes/list_processes.py +1 -1
  199. pygeai/tests/snippets/lab/samples/summarize_files.py +0 -3
  200. pygeai/tests/snippets/lab/strategies/get_reasoning_strategy.py +0 -1
  201. pygeai/tests/snippets/lab/strategies/list_reasoning_strategies.py +1 -1
  202. pygeai/tests/snippets/lab/tools/get_tool.py +1 -1
  203. pygeai/tests/snippets/lab/tools/publish_tool_revision.py +0 -1
  204. pygeai/tests/snippets/lab/tools/set_parameters.py +1 -2
  205. pygeai/tests/snippets/lab/use_cases/c_code_fixer_agent_flow.py +2 -3
  206. pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +1 -1
  207. pygeai/tests/snippets/lab/use_cases/update_cli_expert.py +0 -1
  208. pygeai/tests/snippets/lab/use_cases/update_lab_expert.py +0 -1
  209. pygeai/tests/snippets/lab/use_cases/update_web_designer.py +0 -1
  210. pygeai/tests/snippets/lab/use_cases/update_web_reader.py +0 -1
  211. pygeai/tests/snippets/migrate/orchestrator_examples.py +1 -1
  212. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/METADATA +32 -7
  213. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/RECORD +217 -206
  214. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/WHEEL +0 -0
  215. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/entry_points.txt +0 -0
  216. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/licenses/LICENSE +0 -0
  217. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  from pygeai.cli.commands import Command, Option, ArgumentsEnum
2
2
  from pygeai.cli.commands.builders import build_help_text
3
3
  from pygeai.cli.texts.help import FEEDBACK_HELP_TEXT
4
- from pygeai.core.common.exceptions import MissingRequirementException, WrongArgumentError
4
+ from pygeai.core.common.exceptions import MissingRequirementException
5
5
  from pygeai.core.feedback.clients import FeedbackClient
6
6
  from pygeai.core.utils.console import Console
7
7
 
@@ -15,20 +15,12 @@ def show_help():
15
15
 
16
16
 
17
17
  def send_feedback(option_list: list):
18
- request_id = None
19
- origin = "user-feedback"
20
- answer_score = None
21
- comments = None
22
-
23
- for option_flag, option_arg in option_list:
24
- if option_flag.name == "request_id":
25
- request_id = option_arg
26
- if option_flag.name == "origin":
27
- origin = option_arg
28
- if option_flag.name == "answer_score":
29
- answer_score = option_arg
30
- if option_flag.name == "comments":
31
- comments = option_arg
18
+ opts = {opt.name: arg for opt, arg in option_list}
19
+
20
+ request_id = opts.get('request_id')
21
+ origin = opts.get('origin', 'user-feedback')
22
+ answer_score = opts.get('answer_score')
23
+ comments = opts.get('comments')
32
24
 
33
25
  if not (request_id and answer_score and answer_score):
34
26
  raise MissingRequirementException("Cannot send feedback without specifying request_id and answer_score")
@@ -15,22 +15,13 @@ def show_help():
15
15
 
16
16
 
17
17
  def upload_file(option_list: list):
18
- organization = None
19
- project = None
20
- file_name = None
21
- file_path = None
22
- folder = None
23
- for option_flag, option_arg in option_list:
24
- if option_flag.name == "organization":
25
- organization = option_arg
26
- if option_flag.name == "project":
27
- project = option_arg
28
- if option_flag.name == "file_name":
29
- file_name = option_arg
30
- if option_flag.name == "file_path":
31
- file_path = option_arg
32
- if option_flag.name == "folder":
33
- folder = option_arg
18
+ opts = {opt.name: arg for opt, arg in option_list}
19
+
20
+ organization = opts.get('organization')
21
+ project = opts.get('project')
22
+ file_name = opts.get('file_name')
23
+ file_path = opts.get('file_path')
24
+ folder = opts.get('folder')
34
25
 
35
26
  if not (organization and project and file_path):
36
27
  raise MissingRequirementException("Organization ID, Project ID and File path are mandatory parameters in order "
@@ -82,16 +73,11 @@ upload_file_options = [
82
73
 
83
74
 
84
75
  def get_file(option_list: list):
85
- organization = None
86
- project = None
87
- file_id = None
88
- for option_flag, option_arg in option_list:
89
- if option_flag.name == "organization":
90
- organization = option_arg
91
- if option_flag.name == "project":
92
- project = option_arg
93
- if option_flag.name == "file_id":
94
- file_id = option_arg
76
+ opts = {opt.name: arg for opt, arg in option_list}
77
+
78
+ organization = opts.get('organization')
79
+ project = opts.get('project')
80
+ file_id = opts.get('file_id')
95
81
 
96
82
  if not (organization and project and file_id):
97
83
  raise MissingRequirementException("Cannot get file without organization, project and file_id.")
@@ -128,16 +114,11 @@ get_file_options = [
128
114
 
129
115
 
130
116
  def delete_file(option_list: list):
131
- organization = None
132
- project = None
133
- file_id = None
134
- for option_flag, option_arg in option_list:
135
- if option_flag.name == "organization":
136
- organization = option_arg
137
- if option_flag.name == "project":
138
- project = option_arg
139
- if option_flag.name == "file_id":
140
- file_id = option_arg
117
+ opts = {opt.name: arg for opt, arg in option_list}
118
+
119
+ organization = opts.get('organization')
120
+ project = opts.get('project')
121
+ file_id = opts.get('file_id')
141
122
 
142
123
  if not (organization and project and file_id):
143
124
  raise MissingRequirementException("Cannot delete file without organization, project and file_id.")
@@ -174,16 +155,11 @@ delete_file_options = [
174
155
 
175
156
 
176
157
  def get_file_content(option_list: list):
177
- organization = None
178
- project = None
179
- file_id = None
180
- for option_flag, option_arg in option_list:
181
- if option_flag.name == "organization":
182
- organization = option_arg
183
- if option_flag.name == "project":
184
- project = option_arg
185
- if option_flag.name == "file_id":
186
- file_id = option_arg
158
+ opts = {opt.name: arg for opt, arg in option_list}
159
+
160
+ organization = opts.get('organization')
161
+ project = opts.get('project')
162
+ file_id = opts.get('file_id')
187
163
 
188
164
  if not (organization and project and file_id):
189
165
  raise MissingRequirementException("Cannot get file content without organization, project and file_id.")
@@ -220,13 +196,10 @@ get_file_content_options = [
220
196
 
221
197
 
222
198
  def get_file_list(option_list: list):
223
- organization = None
224
- project = None
225
- for option_flag, option_arg in option_list:
226
- if option_flag.name == "organization":
227
- organization = option_arg
228
- if option_flag.name == "project":
229
- project = option_arg
199
+ opts = {opt.name: arg for opt, arg in option_list}
200
+
201
+ organization = opts.get('organization')
202
+ project = opts.get('project')
230
203
 
231
204
  if not (organization and project):
232
205
  raise MissingRequirementException("Cannot file list without organization and project id.")
@@ -1,7 +1,7 @@
1
1
  from pygeai.cli.commands import Command, Option, ArgumentsEnum
2
2
  from pygeai.cli.commands.builders import build_help_text
3
3
  from pygeai.cli.texts.help import GAM_HELP_TEXT
4
- from pygeai.core.common.exceptions import MissingRequirementException, WrongArgumentError
4
+ from pygeai.core.common.exceptions import MissingRequirementException
5
5
  from pygeai.core.utils.console import Console
6
6
  from pygeai.gam.clients import GAMClient
7
7
 
@@ -15,23 +15,13 @@ def show_help():
15
15
 
16
16
 
17
17
  def generate_signin_url(option_list: list):
18
- client_id = None
19
- redirect_uri = None
20
- scope = "gam_user_data"
21
- state = None
22
- response_type = "code"
23
-
24
- for option_flag, option_arg in option_list:
25
- if option_flag.name == "client_id":
26
- client_id = option_arg
27
- if option_flag.name == "redirect_uri":
28
- redirect_uri = option_arg
29
- if option_flag.name == "scope":
30
- scope = option_arg
31
- if option_flag.name == "state":
32
- state = option_arg
33
- if option_flag.name == "response_type":
34
- response_type = option_arg
18
+ opts = {opt.name: arg for opt, arg in option_list}
19
+
20
+ client_id = opts.get('client_id')
21
+ redirect_uri = opts.get('redirect_uri')
22
+ scope = opts.get('scope', "gam_user_data")
23
+ state = opts.get('state')
24
+ response_type = opts.get('response_type', "code")
35
25
 
36
26
  if not all([client_id, redirect_uri, state]):
37
27
  raise MissingRequirementException("client_id, redirect_uri, and state are required for generating signin URL")
@@ -82,38 +72,18 @@ generate_signin_url_options = [
82
72
 
83
73
 
84
74
  def get_access_token(option_list: list):
85
- client_id = None
86
- client_secret = None
87
- grant_type = "password"
88
- authentication_type_name = "local"
89
- scope = "gam_user_data"
90
- username = None
91
- password = None
92
- initial_properties = None
93
- repository = None
94
- request_token_type = "OAuth"
95
-
96
- for option_flag, option_arg in option_list:
97
- if option_flag.name == "client_id":
98
- client_id = option_arg
99
- if option_flag.name == "client_secret":
100
- client_secret = option_arg
101
- if option_flag.name == "grant_type":
102
- grant_type = option_arg
103
- if option_flag.name == "authentication_type_name":
104
- authentication_type_name = option_arg
105
- if option_flag.name == "scope":
106
- scope = option_arg
107
- if option_flag.name == "username":
108
- username = option_arg
109
- if option_flag.name == "password":
110
- password = option_arg
111
- if option_flag.name == "initial_properties":
112
- initial_properties = option_arg
113
- if option_flag.name == "repository":
114
- repository = option_arg
115
- if option_flag.name == "request_token_type":
116
- request_token_type = option_arg
75
+ opts = {opt.name: arg for opt, arg in option_list}
76
+
77
+ client_id = opts.get('client_id')
78
+ client_secret = opts.get('client_secret')
79
+ grant_type = opts.get('grant_type', "password")
80
+ authentication_type_name = opts.get('authentication_type_name', "local")
81
+ scope = opts.get('scope', "gam_user_data")
82
+ username = opts.get('username')
83
+ password = opts.get('password')
84
+ initial_properties = opts.get('initial_properties')
85
+ repository = opts.get('repository')
86
+ request_token_type = opts.get('request_token_type', "OAuth")
117
87
 
118
88
  if not ((client_id and client_secret) or (username and password)):
119
89
  raise MissingRequirementException("Cannot get access token without specifying valid credentials")
@@ -201,11 +171,8 @@ get_access_token_options = [
201
171
 
202
172
 
203
173
  def get_user_info(option_list: list):
204
- access_token = None
205
-
206
- for option_flag, option_arg in option_list:
207
- if option_flag.name == "access_token":
208
- access_token = option_arg
174
+ opts = {opt.name: arg for opt, arg in option_list}
175
+ access_token = opts.get('access_token')
209
176
 
210
177
  if not access_token:
211
178
  raise MissingRequirementException("Cannot get user info without the access token")
@@ -228,20 +195,12 @@ get_user_info_options = [
228
195
 
229
196
 
230
197
  def refresh_access_token(option_list: list):
231
- client_id = None
232
- client_secret = None
233
- grant_type = "refresh_token"
234
- refresh_token = None
235
-
236
- for option_flag, option_arg in option_list:
237
- if option_flag.name == "client_id":
238
- client_id = option_arg
239
- if option_flag.name == "client_secret":
240
- client_secret = option_arg
241
- if option_flag.name == "grant_type":
242
- grant_type = option_arg
243
- if option_flag.name == "refresh_token":
244
- refresh_token = option_arg
198
+ opts = {opt.name: arg for opt, arg in option_list}
199
+
200
+ client_id = opts.get('client_id')
201
+ client_secret = opts.get('client_secret')
202
+ grant_type = opts.get('grant_type', "refresh_token")
203
+ refresh_token = opts.get('refresh_token')
245
204
 
246
205
  if not ((client_id and client_secret) or refresh_token):
247
206
  raise MissingRequirementException("Cannot refresh access token without specifying valid credentials")