egain-api-python 0.1.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 (332) hide show
  1. egain_api_python/__init__.py +17 -0
  2. egain_api_python/_hooks/__init__.py +5 -0
  3. egain_api_python/_hooks/registration.py +13 -0
  4. egain_api_python/_hooks/sdkhooks.py +76 -0
  5. egain_api_python/_hooks/types.py +112 -0
  6. egain_api_python/_version.py +15 -0
  7. egain_api_python/aiservices.py +23 -0
  8. egain_api_python/answers.py +281 -0
  9. egain_api_python/articlelists.py +469 -0
  10. egain_api_python/basesdk.py +368 -0
  11. egain_api_python/connectorssearchevents.py +537 -0
  12. egain_api_python/content.py +23 -0
  13. egain_api_python/errors/__init__.py +78 -0
  14. egain_api_python/errors/egaindefaulterror.py +40 -0
  15. egain_api_python/errors/egainerror.py +30 -0
  16. egain_api_python/errors/gethealthop.py +74 -0
  17. egain_api_python/errors/no_response_error.py +17 -0
  18. egain_api_python/errors/responsevalidationerror.py +27 -0
  19. egain_api_python/errors/schemas_wserrorcommon.py +51 -0
  20. egain_api_python/errors/wserrorcommon.py +49 -0
  21. egain_api_python/escalation.py +955 -0
  22. egain_api_python/export.py +487 -0
  23. egain_api_python/federatedsearchevent.py +287 -0
  24. egain_api_python/general.py +925 -0
  25. egain_api_python/guidedhelp.py +3373 -0
  26. egain_api_python/health.py +253 -0
  27. egain_api_python/httpclient.py +125 -0
  28. egain_api_python/import_.py +1161 -0
  29. egain_api_python/models/__init__.py +2136 -0
  30. egain_api_python/models/acceptghsolutionop.py +52 -0
  31. egain_api_python/models/acceptlanguage.py +23 -0
  32. egain_api_python/models/accessibleportal.py +37 -0
  33. egain_api_python/models/action.py +56 -0
  34. egain_api_python/models/actionsearch.py +92 -0
  35. egain_api_python/models/addasreferenceop.py +52 -0
  36. egain_api_python/models/addbookmarkop.py +43 -0
  37. egain_api_python/models/additionalsnippets.py +57 -0
  38. egain_api_python/models/addtoreplyop.py +52 -0
  39. egain_api_python/models/aisearchop.py +131 -0
  40. egain_api_python/models/aisearchresponse.py +67 -0
  41. egain_api_python/models/allaccessibleportals.py +28 -0
  42. egain_api_python/models/answer.py +21 -0
  43. egain_api_python/models/answeredquestion.py +125 -0
  44. egain_api_python/models/answerrange.py +41 -0
  45. egain_api_python/models/answersrequest.py +78 -0
  46. egain_api_python/models/answersresponse.py +93 -0
  47. egain_api_python/models/article.py +241 -0
  48. egain_api_python/models/articleactivitylink.py +62 -0
  49. egain_api_python/models/articleadditionalattributes.py +23 -0
  50. egain_api_python/models/articleaisearchresult.py +254 -0
  51. egain_api_python/models/articleattachment.py +44 -0
  52. egain_api_python/models/articlelist.py +48 -0
  53. egain_api_python/models/articlelistresult.py +38 -0
  54. egain_api_python/models/articlelistsresult.py +22 -0
  55. egain_api_python/models/articlepermissions.py +25 -0
  56. egain_api_python/models/articlepermissionsresult.py +27 -0
  57. egain_api_python/models/articlerating.py +51 -0
  58. egain_api_python/models/articleratingsresponse.py +28 -0
  59. egain_api_python/models/articleresult.py +159 -0
  60. egain_api_python/models/articleresultadditionalattributes.py +22 -0
  61. egain_api_python/models/articleresults.py +32 -0
  62. egain_api_python/models/articlesearchresult.py +243 -0
  63. egain_api_python/models/articlesearchresults.py +32 -0
  64. egain_api_python/models/articlesort.py +11 -0
  65. egain_api_python/models/articlesortorder.py +11 -0
  66. egain_api_python/models/articletype.py +56 -0
  67. egain_api_python/models/articlewitheditions.py +227 -0
  68. egain_api_python/models/attachment.py +31 -0
  69. egain_api_python/models/attachmentadditionalattributes.py +10 -0
  70. egain_api_python/models/attachmentcontent.py +57 -0
  71. egain_api_python/models/attachmentcontentresult.py +22 -0
  72. egain_api_python/models/attachmentforcreatesuggestion.py +25 -0
  73. egain_api_python/models/attachments.py +35 -0
  74. egain_api_python/models/attachmentsummary.py +37 -0
  75. egain_api_python/models/attachmentupload.py +20 -0
  76. egain_api_python/models/avertcustomerescalationop.py +44 -0
  77. egain_api_python/models/bookmark.py +57 -0
  78. egain_api_python/models/bookmarkresult.py +26 -0
  79. egain_api_python/models/bookmarkstatus.py +34 -0
  80. egain_api_python/models/case.py +158 -0
  81. egain_api_python/models/caseadditionalattributes.py +11 -0
  82. egain_api_python/models/caseanswer.py +21 -0
  83. egain_api_python/models/casebase.py +67 -0
  84. egain_api_python/models/casebaseresult.py +28 -0
  85. egain_api_python/models/casebasesearchsettings.py +26 -0
  86. egain_api_python/models/caselistresult.py +74 -0
  87. egain_api_python/models/caselistresults.py +28 -0
  88. egain_api_python/models/casequestion.py +16 -0
  89. egain_api_python/models/casequestiondetail.py +29 -0
  90. egain_api_python/models/casesearch.py +80 -0
  91. egain_api_python/models/clusterid.py +16 -0
  92. egain_api_python/models/clusterresult.py +37 -0
  93. egain_api_python/models/clusterresults.py +28 -0
  94. egain_api_python/models/comment.py +33 -0
  95. egain_api_python/models/comments.py +26 -0
  96. egain_api_python/models/completecustomerescalationop.py +44 -0
  97. egain_api_python/models/compliancearticleresult.py +166 -0
  98. egain_api_python/models/compliancearticleresultadditionalattributes.py +22 -0
  99. egain_api_python/models/compliancearticleresults.py +35 -0
  100. egain_api_python/models/complianceforarticle.py +59 -0
  101. egain_api_python/models/complyarticleop.py +40 -0
  102. egain_api_python/models/components_schemas_tag.py +25 -0
  103. egain_api_python/models/components_schemas_tagcategory.py +39 -0
  104. egain_api_python/models/components_schemas_taggroup.py +25 -0
  105. egain_api_python/models/configurableattribute.py +25 -0
  106. egain_api_python/models/configurableattributes.py +15 -0
  107. egain_api_python/models/contactperson.py +43 -0
  108. egain_api_python/models/contacts.py +21 -0
  109. egain_api_python/models/createbookmark.py +64 -0
  110. egain_api_python/models/createdby.py +37 -0
  111. egain_api_python/models/createfederatedsearchevent.py +85 -0
  112. egain_api_python/models/createfederatedsearchresulteventop.py +46 -0
  113. egain_api_python/models/createimportop.py +20 -0
  114. egain_api_python/models/createimportvalidationop.py +20 -0
  115. egain_api_python/models/createquickpick.py +34 -0
  116. egain_api_python/models/createquickpickop.py +55 -0
  117. egain_api_python/models/createsearchresulteventforconnectors.py +71 -0
  118. egain_api_python/models/createsearchresulteventforconnectorsop.py +48 -0
  119. egain_api_python/models/createsignedurlop.py +29 -0
  120. egain_api_python/models/createsuggestion.py +126 -0
  121. egain_api_python/models/createviewedsearchresulteventforconnectors.py +76 -0
  122. egain_api_python/models/createviewedsearchresultseventforconnectorsop.py +48 -0
  123. egain_api_python/models/customattribute.py +35 -0
  124. egain_api_python/models/deletebookmarkop.py +40 -0
  125. egain_api_python/models/deletesuggestionop.py +40 -0
  126. egain_api_python/models/department.py +21 -0
  127. egain_api_python/models/detailfield.py +32 -0
  128. egain_api_python/models/displayfield.py +27 -0
  129. egain_api_python/models/dynamiccluster.py +21 -0
  130. egain_api_python/models/dynamicsearch.py +40 -0
  131. egain_api_python/models/edition.py +79 -0
  132. egain_api_python/models/editionwithcontent.py +68 -0
  133. egain_api_python/models/email.py +21 -0
  134. egain_api_python/models/exportcontentop.py +14 -0
  135. egain_api_python/models/exportstatus.py +106 -0
  136. egain_api_python/models/exportstatusop.py +31 -0
  137. egain_api_python/models/feedbackarticleforsuggestion.py +34 -0
  138. egain_api_python/models/folderbreadcrumb.py +24 -0
  139. egain_api_python/models/foldersummary.py +29 -0
  140. egain_api_python/models/getacknowledgedcompliancearticlesop.py +119 -0
  141. egain_api_python/models/getallarticlelistsop.py +47 -0
  142. egain_api_python/models/getallcasebasesreleasesop.py +65 -0
  143. egain_api_python/models/getallcasesop.py +83 -0
  144. egain_api_python/models/getallportalsop.py +60 -0
  145. egain_api_python/models/getallprofilesinportalop.py +64 -0
  146. egain_api_python/models/getallquickpicksop.py +83 -0
  147. egain_api_python/models/getalltopicsop.py +132 -0
  148. egain_api_python/models/getalluserprofilesop.py +47 -0
  149. egain_api_python/models/getancestortopicsop.py +133 -0
  150. egain_api_python/models/getannouncementarticlesop.py +134 -0
  151. egain_api_python/models/getarticleattachmentbyidop.py +31 -0
  152. egain_api_python/models/getarticlebyidop.py +257 -0
  153. egain_api_python/models/getarticlebyidwitheditionsop.py +46 -0
  154. egain_api_python/models/getarticleeditiondetailsop.py +55 -0
  155. egain_api_python/models/getarticlelistdetailsop.py +115 -0
  156. egain_api_python/models/getarticlepermissionsbyidop.py +40 -0
  157. egain_api_python/models/getarticlepersonalizationop.py +73 -0
  158. egain_api_python/models/getarticleratingsop.py +74 -0
  159. egain_api_python/models/getarticlesintopicop.py +172 -0
  160. egain_api_python/models/getattachmentbyidinportalop.py +56 -0
  161. egain_api_python/models/getbookmarkop.py +31 -0
  162. egain_api_python/models/getcasebasereleasebyidop.py +64 -0
  163. egain_api_python/models/getcasebyidop.py +75 -0
  164. egain_api_python/models/getchildtopicsop.py +150 -0
  165. egain_api_python/models/getclusterbycasebasereleaseidop.py +74 -0
  166. egain_api_python/models/gethealthop.py +130 -0
  167. egain_api_python/models/getimportcontentop.py +46 -0
  168. egain_api_python/models/getmyportalsop.py +97 -0
  169. egain_api_python/models/getmysubscriptionop.py +115 -0
  170. egain_api_python/models/getpendingcompliancearticlesop.py +119 -0
  171. egain_api_python/models/getpopulararticlesop.py +133 -0
  172. egain_api_python/models/getportaldetailsbyidop.py +47 -0
  173. egain_api_python/models/getrelatedarticlesforsuggestionop.py +96 -0
  174. egain_api_python/models/getrelatedarticlesop.py +143 -0
  175. egain_api_python/models/getsuggestionattachmentbyidop.py +76 -0
  176. egain_api_python/models/getsuggestionattachmentsop.py +40 -0
  177. egain_api_python/models/getsuggestioncommentsop.py +40 -0
  178. egain_api_python/models/getsuggestionop.py +107 -0
  179. egain_api_python/models/gettagcategoriesforinterestforportalop.py +46 -0
  180. egain_api_python/models/gettopicbreadcrumbforarticleop.py +55 -0
  181. egain_api_python/models/getuserdetailsop.py +22 -0
  182. egain_api_python/models/getusermilestonesop.py +22 -0
  183. egain_api_python/models/ghsearchrequest.py +67 -0
  184. egain_api_python/models/ghsearchresult.py +75 -0
  185. egain_api_python/models/ghstepsearchrequest.py +64 -0
  186. egain_api_python/models/image.py +17 -0
  187. egain_api_python/models/importcontent.py +79 -0
  188. egain_api_python/models/importstatus.py +29 -0
  189. egain_api_python/models/kblanguage.py +63 -0
  190. egain_api_python/models/kblanguagecode.py +48 -0
  191. egain_api_python/models/kblanguages.py +22 -0
  192. egain_api_python/models/knowledgeexport.py +237 -0
  193. egain_api_python/models/l10nstring.py +22 -0
  194. egain_api_python/models/languagecode.py +39 -0
  195. egain_api_python/models/languagecode_parameter.py +39 -0
  196. egain_api_python/models/languagequeryparameter.py +39 -0
  197. egain_api_python/models/link.py +25 -0
  198. egain_api_python/models/makesuggestionop.py +44 -0
  199. egain_api_python/models/mandatorylanguagequeryparameter.py +38 -0
  200. egain_api_python/models/metadata.py +29 -0
  201. egain_api_python/models/milestone.py +21 -0
  202. egain_api_python/models/milestonename.py +26 -0
  203. egain_api_python/models/milestones.py +21 -0
  204. egain_api_python/models/modifiedby.py +37 -0
  205. egain_api_python/models/modifysuggestion.py +78 -0
  206. egain_api_python/models/modifysuggestionsop.py +44 -0
  207. egain_api_python/models/optionalarticleattributes.py +20 -0
  208. egain_api_python/models/order.py +10 -0
  209. egain_api_python/models/ownedby.py +37 -0
  210. egain_api_python/models/paginationinfo.py +32 -0
  211. egain_api_python/models/patchimportcontentvalidationop.py +46 -0
  212. egain_api_python/models/personalization.py +67 -0
  213. egain_api_python/models/phone.py +21 -0
  214. egain_api_python/models/portal.py +102 -0
  215. egain_api_python/models/portalresult.py +28 -0
  216. egain_api_python/models/portalsettings.py +398 -0
  217. egain_api_python/models/post_portalid_answersop.py +88 -0
  218. egain_api_python/models/post_portalid_retrieveop.py +88 -0
  219. egain_api_python/models/profile.py +26 -0
  220. egain_api_python/models/profileresult.py +24 -0
  221. egain_api_python/models/publishprofile.py +30 -0
  222. egain_api_python/models/publishview.py +38 -0
  223. egain_api_python/models/question.py +101 -0
  224. egain_api_python/models/questionandanswer.py +26 -0
  225. egain_api_python/models/quickpickrating.py +32 -0
  226. egain_api_python/models/quickpickresult.py +38 -0
  227. egain_api_python/models/quickpickresults.py +28 -0
  228. egain_api_python/models/ratearticleop.py +71 -0
  229. egain_api_python/models/referenceresponse.py +80 -0
  230. egain_api_python/models/rejectghsolutionop.py +52 -0
  231. egain_api_python/models/relatedquestions.py +28 -0
  232. egain_api_python/models/resourcetype_parameter.py +10 -0
  233. egain_api_python/models/restorequickpickop.py +63 -0
  234. egain_api_python/models/retrieverequest.py +47 -0
  235. egain_api_python/models/retrieveresponse.py +96 -0
  236. egain_api_python/models/role.py +26 -0
  237. egain_api_python/models/roletemplate.py +25 -0
  238. egain_api_python/models/schemas_answer.py +94 -0
  239. egain_api_python/models/schemas_customattribute.py +35 -0
  240. egain_api_python/models/schemas_link.py +27 -0
  241. egain_api_python/models/schemas_tag.py +21 -0
  242. egain_api_python/models/schemas_tagcategory.py +75 -0
  243. egain_api_python/models/schemas_taggroup.py +31 -0
  244. egain_api_python/models/schemas_tags.py +19 -0
  245. egain_api_python/models/schemas_wserrorcommon.py +17 -0
  246. egain_api_python/models/searchfilterattribute.py +61 -0
  247. egain_api_python/models/searchpriortoescalationop.py +108 -0
  248. egain_api_python/models/searchresult.py +101 -0
  249. egain_api_python/models/searchsuggestionop.py +93 -0
  250. egain_api_python/models/security.py +25 -0
  251. egain_api_python/models/selectuserprofileop.py +44 -0
  252. egain_api_python/models/sessioncontextvariable.py +17 -0
  253. egain_api_python/models/shorturl.py +32 -0
  254. egain_api_python/models/sortidname.py +10 -0
  255. egain_api_python/models/sortidnamedepartment.py +11 -0
  256. egain_api_python/models/stage.py +26 -0
  257. egain_api_python/models/startcustomerescalationop.py +66 -0
  258. egain_api_python/models/startescalationrequest.py +94 -0
  259. egain_api_python/models/startghsearchop.py +74 -0
  260. egain_api_python/models/startquestionandanswer.py +26 -0
  261. egain_api_python/models/stepghsearchop.py +62 -0
  262. egain_api_python/models/stringattributevalue.py +30 -0
  263. egain_api_python/models/structuredauthoringfields.py +33 -0
  264. egain_api_python/models/subscribearticleop.py +40 -0
  265. egain_api_python/models/suggestion.py +190 -0
  266. egain_api_python/models/suggestionadditionalattributes.py +11 -0
  267. egain_api_python/models/suggestionattachment.py +46 -0
  268. egain_api_python/models/suggestions.py +28 -0
  269. egain_api_python/models/tag.py +17 -0
  270. egain_api_python/models/tagcategoriesforinterest.py +22 -0
  271. egain_api_python/models/tagcategory.py +34 -0
  272. egain_api_python/models/taggroup.py +17 -0
  273. egain_api_python/models/taggroups.py +20 -0
  274. egain_api_python/models/tags.py +17 -0
  275. egain_api_python/models/topic.py +113 -0
  276. egain_api_python/models/topicadditionalattributes.py +20 -0
  277. egain_api_python/models/topicaisearchresult.py +67 -0
  278. egain_api_python/models/topicbreadcrumb.py +24 -0
  279. egain_api_python/models/topicresult.py +26 -0
  280. egain_api_python/models/topicsummary.py +31 -0
  281. egain_api_python/models/topictreenode.py +27 -0
  282. egain_api_python/models/topictreeresult.py +28 -0
  283. egain_api_python/models/unsubscribearticleop.py +55 -0
  284. egain_api_python/models/uploadattachmentop.py +36 -0
  285. egain_api_python/models/userdetails.py +44 -0
  286. egain_api_python/models/userprofile.py +33 -0
  287. egain_api_python/models/userprofiles.py +21 -0
  288. egain_api_python/models/userview.py +33 -0
  289. egain_api_python/models/validateimportcontent.py +58 -0
  290. egain_api_python/models/virtualcase.py +52 -0
  291. egain_api_python/models/workflow.py +21 -0
  292. egain_api_python/models/workflowmilestone.py +11 -0
  293. egain_api_python/models/wserrorcommon.py +17 -0
  294. egain_api_python/populararticles.py +287 -0
  295. egain_api_python/portal_article.py +4935 -0
  296. egain_api_python/portal_attachment.py +494 -0
  297. egain_api_python/portal_bookmark.py +707 -0
  298. egain_api_python/portal_sdk.py +88 -0
  299. egain_api_python/portal_suggestion.py +2283 -0
  300. egain_api_python/portal_topic.py +975 -0
  301. egain_api_python/portal_userdetails.py +211 -0
  302. egain_api_python/portal_userprofile.py +431 -0
  303. egain_api_python/py.typed +1 -0
  304. egain_api_python/retrieve.py +265 -0
  305. egain_api_python/sdk.py +216 -0
  306. egain_api_python/sdkconfiguration.py +50 -0
  307. egain_api_python/search.py +251 -0
  308. egain_api_python/types/__init__.py +21 -0
  309. egain_api_python/types/basemodel.py +39 -0
  310. egain_api_python/usermilestones.py +219 -0
  311. egain_api_python/utils/__init__.py +200 -0
  312. egain_api_python/utils/annotations.py +79 -0
  313. egain_api_python/utils/datetimes.py +23 -0
  314. egain_api_python/utils/enums.py +74 -0
  315. egain_api_python/utils/eventstreaming.py +248 -0
  316. egain_api_python/utils/forms.py +223 -0
  317. egain_api_python/utils/headers.py +136 -0
  318. egain_api_python/utils/logger.py +27 -0
  319. egain_api_python/utils/metadata.py +118 -0
  320. egain_api_python/utils/queryparams.py +205 -0
  321. egain_api_python/utils/requestbodies.py +66 -0
  322. egain_api_python/utils/retries.py +217 -0
  323. egain_api_python/utils/security.py +192 -0
  324. egain_api_python/utils/serializers.py +249 -0
  325. egain_api_python/utils/unmarshal_json_response.py +24 -0
  326. egain_api_python/utils/url.py +155 -0
  327. egain_api_python/utils/values.py +137 -0
  328. egain_api_python-0.1.1.dist-info/METADATA +827 -0
  329. egain_api_python-0.1.1.dist-info/RECORD +332 -0
  330. egain_api_python-0.1.1.dist-info/WHEEL +5 -0
  331. egain_api_python-0.1.1.dist-info/licenses/LICENSE +21 -0
  332. egain_api_python-0.1.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,223 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import (
4
+ Any,
5
+ Dict,
6
+ get_type_hints,
7
+ List,
8
+ Tuple,
9
+ )
10
+ from pydantic import BaseModel
11
+ from pydantic.fields import FieldInfo
12
+
13
+ from .serializers import marshal_json
14
+
15
+ from .metadata import (
16
+ FormMetadata,
17
+ MultipartFormMetadata,
18
+ find_field_metadata,
19
+ )
20
+ from .values import _is_set, _val_to_string
21
+
22
+
23
+ def _populate_form(
24
+ field_name: str,
25
+ explode: bool,
26
+ obj: Any,
27
+ delimiter: str,
28
+ form: Dict[str, List[str]],
29
+ ):
30
+ if not _is_set(obj):
31
+ return form
32
+
33
+ if isinstance(obj, BaseModel):
34
+ items = []
35
+
36
+ obj_fields: Dict[str, FieldInfo] = obj.__class__.model_fields
37
+ for name in obj_fields:
38
+ obj_field = obj_fields[name]
39
+ obj_field_name = obj_field.alias if obj_field.alias is not None else name
40
+ if obj_field_name == "":
41
+ continue
42
+
43
+ val = getattr(obj, name)
44
+ if not _is_set(val):
45
+ continue
46
+
47
+ if explode:
48
+ form[obj_field_name] = [_val_to_string(val)]
49
+ else:
50
+ items.append(f"{obj_field_name}{delimiter}{_val_to_string(val)}")
51
+
52
+ if len(items) > 0:
53
+ form[field_name] = [delimiter.join(items)]
54
+ elif isinstance(obj, Dict):
55
+ items = []
56
+ for key, value in obj.items():
57
+ if not _is_set(value):
58
+ continue
59
+
60
+ if explode:
61
+ form[key] = [_val_to_string(value)]
62
+ else:
63
+ items.append(f"{key}{delimiter}{_val_to_string(value)}")
64
+
65
+ if len(items) > 0:
66
+ form[field_name] = [delimiter.join(items)]
67
+ elif isinstance(obj, List):
68
+ items = []
69
+
70
+ for value in obj:
71
+ if not _is_set(value):
72
+ continue
73
+
74
+ if explode:
75
+ if not field_name in form:
76
+ form[field_name] = []
77
+ form[field_name].append(_val_to_string(value))
78
+ else:
79
+ items.append(_val_to_string(value))
80
+
81
+ if len(items) > 0:
82
+ form[field_name] = [delimiter.join([str(item) for item in items])]
83
+ else:
84
+ form[field_name] = [_val_to_string(obj)]
85
+
86
+ return form
87
+
88
+
89
+ def _extract_file_properties(file_obj: Any) -> Tuple[str, Any, Any]:
90
+ """Extract file name, content, and content type from a file object."""
91
+ file_fields: Dict[str, FieldInfo] = file_obj.__class__.model_fields
92
+
93
+ file_name = ""
94
+ content = None
95
+ content_type = None
96
+
97
+ for file_field_name in file_fields:
98
+ file_field = file_fields[file_field_name]
99
+
100
+ file_metadata = find_field_metadata(file_field, MultipartFormMetadata)
101
+ if file_metadata is None:
102
+ continue
103
+
104
+ if file_metadata.content:
105
+ content = getattr(file_obj, file_field_name, None)
106
+ elif file_field_name == "content_type":
107
+ content_type = getattr(file_obj, file_field_name, None)
108
+ else:
109
+ file_name = getattr(file_obj, file_field_name)
110
+
111
+ if file_name == "" or content is None:
112
+ raise ValueError("invalid multipart/form-data file")
113
+
114
+ return file_name, content, content_type
115
+
116
+
117
+ def serialize_multipart_form(
118
+ media_type: str, request: Any
119
+ ) -> Tuple[str, Dict[str, Any], List[Tuple[str, Any]]]:
120
+ form: Dict[str, Any] = {}
121
+ files: List[Tuple[str, Any]] = []
122
+
123
+ if not isinstance(request, BaseModel):
124
+ raise TypeError("invalid request body type")
125
+
126
+ request_fields: Dict[str, FieldInfo] = request.__class__.model_fields
127
+ request_field_types = get_type_hints(request.__class__)
128
+
129
+ for name in request_fields:
130
+ field = request_fields[name]
131
+
132
+ val = getattr(request, name)
133
+ if not _is_set(val):
134
+ continue
135
+
136
+ field_metadata = find_field_metadata(field, MultipartFormMetadata)
137
+ if not field_metadata:
138
+ continue
139
+
140
+ f_name = field.alias if field.alias else name
141
+
142
+ if field_metadata.file:
143
+ if isinstance(val, List):
144
+ # Handle array of files
145
+ for file_obj in val:
146
+ if not _is_set(file_obj):
147
+ continue
148
+
149
+ file_name, content, content_type = _extract_file_properties(file_obj)
150
+
151
+ if content_type is not None:
152
+ files.append((f_name + "[]", (file_name, content, content_type)))
153
+ else:
154
+ files.append((f_name + "[]", (file_name, content)))
155
+ else:
156
+ # Handle single file
157
+ file_name, content, content_type = _extract_file_properties(val)
158
+
159
+ if content_type is not None:
160
+ files.append((f_name, (file_name, content, content_type)))
161
+ else:
162
+ files.append((f_name, (file_name, content)))
163
+ elif field_metadata.json:
164
+ files.append((f_name, (
165
+ None,
166
+ marshal_json(val, request_field_types[name]),
167
+ "application/json",
168
+ )))
169
+ else:
170
+ if isinstance(val, List):
171
+ values = []
172
+
173
+ for value in val:
174
+ if not _is_set(value):
175
+ continue
176
+ values.append(_val_to_string(value))
177
+
178
+ form[f_name + "[]"] = values
179
+ else:
180
+ form[f_name] = _val_to_string(val)
181
+ return media_type, form, files
182
+
183
+
184
+ def serialize_form_data(data: Any) -> Dict[str, Any]:
185
+ form: Dict[str, List[str]] = {}
186
+
187
+ if isinstance(data, BaseModel):
188
+ data_fields: Dict[str, FieldInfo] = data.__class__.model_fields
189
+ data_field_types = get_type_hints(data.__class__)
190
+ for name in data_fields:
191
+ field = data_fields[name]
192
+
193
+ val = getattr(data, name)
194
+ if not _is_set(val):
195
+ continue
196
+
197
+ metadata = find_field_metadata(field, FormMetadata)
198
+ if metadata is None:
199
+ continue
200
+
201
+ f_name = field.alias if field.alias is not None else name
202
+
203
+ if metadata.json:
204
+ form[f_name] = [marshal_json(val, data_field_types[name])]
205
+ else:
206
+ if metadata.style == "form":
207
+ _populate_form(
208
+ f_name,
209
+ metadata.explode,
210
+ val,
211
+ ",",
212
+ form,
213
+ )
214
+ else:
215
+ raise ValueError(f"Invalid form style for field {name}")
216
+ elif isinstance(data, Dict):
217
+ for key, value in data.items():
218
+ if _is_set(value):
219
+ form[key] = [_val_to_string(value)]
220
+ else:
221
+ raise TypeError(f"Invalid request body type {type(data)} for form data")
222
+
223
+ return form
@@ -0,0 +1,136 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import (
4
+ Any,
5
+ Dict,
6
+ List,
7
+ Optional,
8
+ )
9
+ from httpx import Headers
10
+ from pydantic import BaseModel
11
+ from pydantic.fields import FieldInfo
12
+
13
+ from .metadata import (
14
+ HeaderMetadata,
15
+ find_field_metadata,
16
+ )
17
+
18
+ from .values import _is_set, _populate_from_globals, _val_to_string
19
+
20
+
21
+ def get_headers(headers_params: Any, gbls: Optional[Any] = None) -> Dict[str, str]:
22
+ headers: Dict[str, str] = {}
23
+
24
+ globals_already_populated = []
25
+ if _is_set(headers_params):
26
+ globals_already_populated = _populate_headers(headers_params, gbls, headers, [])
27
+ if _is_set(gbls):
28
+ _populate_headers(gbls, None, headers, globals_already_populated)
29
+
30
+ return headers
31
+
32
+
33
+ def _populate_headers(
34
+ headers_params: Any,
35
+ gbls: Any,
36
+ header_values: Dict[str, str],
37
+ skip_fields: List[str],
38
+ ) -> List[str]:
39
+ globals_already_populated: List[str] = []
40
+
41
+ if not isinstance(headers_params, BaseModel):
42
+ return globals_already_populated
43
+
44
+ param_fields: Dict[str, FieldInfo] = headers_params.__class__.model_fields
45
+ for name in param_fields:
46
+ if name in skip_fields:
47
+ continue
48
+
49
+ field = param_fields[name]
50
+ f_name = field.alias if field.alias is not None else name
51
+
52
+ metadata = find_field_metadata(field, HeaderMetadata)
53
+ if metadata is None:
54
+ continue
55
+
56
+ value, global_found = _populate_from_globals(
57
+ name, getattr(headers_params, name), HeaderMetadata, gbls
58
+ )
59
+ if global_found:
60
+ globals_already_populated.append(name)
61
+ value = _serialize_header(metadata.explode, value)
62
+
63
+ if value != "":
64
+ header_values[f_name] = value
65
+
66
+ return globals_already_populated
67
+
68
+
69
+ def _serialize_header(explode: bool, obj: Any) -> str:
70
+ if not _is_set(obj):
71
+ return ""
72
+
73
+ if isinstance(obj, BaseModel):
74
+ items = []
75
+ obj_fields: Dict[str, FieldInfo] = obj.__class__.model_fields
76
+ for name in obj_fields:
77
+ obj_field = obj_fields[name]
78
+ obj_param_metadata = find_field_metadata(obj_field, HeaderMetadata)
79
+
80
+ if not obj_param_metadata:
81
+ continue
82
+
83
+ f_name = obj_field.alias if obj_field.alias is not None else name
84
+
85
+ val = getattr(obj, name)
86
+ if not _is_set(val):
87
+ continue
88
+
89
+ if explode:
90
+ items.append(f"{f_name}={_val_to_string(val)}")
91
+ else:
92
+ items.append(f_name)
93
+ items.append(_val_to_string(val))
94
+
95
+ if len(items) > 0:
96
+ return ",".join(items)
97
+ elif isinstance(obj, Dict):
98
+ items = []
99
+
100
+ for key, value in obj.items():
101
+ if not _is_set(value):
102
+ continue
103
+
104
+ if explode:
105
+ items.append(f"{key}={_val_to_string(value)}")
106
+ else:
107
+ items.append(key)
108
+ items.append(_val_to_string(value))
109
+
110
+ if len(items) > 0:
111
+ return ",".join([str(item) for item in items])
112
+ elif isinstance(obj, List):
113
+ items = []
114
+
115
+ for value in obj:
116
+ if not _is_set(value):
117
+ continue
118
+
119
+ items.append(_val_to_string(value))
120
+
121
+ if len(items) > 0:
122
+ return ",".join(items)
123
+ elif _is_set(obj):
124
+ return f"{_val_to_string(obj)}"
125
+
126
+ return ""
127
+
128
+
129
+ def get_response_headers(headers: Headers) -> Dict[str, List[str]]:
130
+ res: Dict[str, List[str]] = {}
131
+ for k, v in headers.items():
132
+ if not k in res:
133
+ res[k] = []
134
+
135
+ res[k].append(v)
136
+ return res
@@ -0,0 +1,27 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import httpx
4
+ import logging
5
+ import os
6
+ from typing import Any, Protocol
7
+
8
+
9
+ class Logger(Protocol):
10
+ def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
11
+ pass
12
+
13
+
14
+ class NoOpLogger:
15
+ def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
16
+ pass
17
+
18
+
19
+ def get_body_content(req: httpx.Request) -> str:
20
+ return "<streaming body>" if not hasattr(req, "_content") else str(req.content)
21
+
22
+
23
+ def get_default_logger() -> Logger:
24
+ if os.getenv("EGAIN_DEBUG"):
25
+ logging.basicConfig(level=logging.DEBUG)
26
+ return logging.getLogger("egain_api_python")
27
+ return NoOpLogger()
@@ -0,0 +1,118 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import Optional, Type, TypeVar, Union
4
+ from dataclasses import dataclass
5
+ from pydantic.fields import FieldInfo
6
+
7
+
8
+ T = TypeVar("T")
9
+
10
+
11
+ @dataclass
12
+ class SecurityMetadata:
13
+ option: bool = False
14
+ scheme: bool = False
15
+ scheme_type: Optional[str] = None
16
+ sub_type: Optional[str] = None
17
+ field_name: Optional[str] = None
18
+
19
+ def get_field_name(self, default: str) -> str:
20
+ return self.field_name or default
21
+
22
+
23
+ @dataclass
24
+ class ParamMetadata:
25
+ serialization: Optional[str] = None
26
+ style: str = "simple"
27
+ explode: bool = False
28
+
29
+
30
+ @dataclass
31
+ class PathParamMetadata(ParamMetadata):
32
+ pass
33
+
34
+
35
+ @dataclass
36
+ class QueryParamMetadata(ParamMetadata):
37
+ style: str = "form"
38
+ explode: bool = True
39
+
40
+
41
+ @dataclass
42
+ class HeaderMetadata(ParamMetadata):
43
+ pass
44
+
45
+
46
+ @dataclass
47
+ class RequestMetadata:
48
+ media_type: str = "application/octet-stream"
49
+
50
+
51
+ @dataclass
52
+ class MultipartFormMetadata:
53
+ file: bool = False
54
+ content: bool = False
55
+ json: bool = False
56
+
57
+
58
+ @dataclass
59
+ class FormMetadata:
60
+ json: bool = False
61
+ style: str = "form"
62
+ explode: bool = True
63
+
64
+
65
+ class FieldMetadata:
66
+ security: Optional[SecurityMetadata] = None
67
+ path: Optional[PathParamMetadata] = None
68
+ query: Optional[QueryParamMetadata] = None
69
+ header: Optional[HeaderMetadata] = None
70
+ request: Optional[RequestMetadata] = None
71
+ form: Optional[FormMetadata] = None
72
+ multipart: Optional[MultipartFormMetadata] = None
73
+
74
+ def __init__(
75
+ self,
76
+ security: Optional[SecurityMetadata] = None,
77
+ path: Optional[Union[PathParamMetadata, bool]] = None,
78
+ query: Optional[Union[QueryParamMetadata, bool]] = None,
79
+ header: Optional[Union[HeaderMetadata, bool]] = None,
80
+ request: Optional[Union[RequestMetadata, bool]] = None,
81
+ form: Optional[Union[FormMetadata, bool]] = None,
82
+ multipart: Optional[Union[MultipartFormMetadata, bool]] = None,
83
+ ):
84
+ self.security = security
85
+ self.path = PathParamMetadata() if isinstance(path, bool) else path
86
+ self.query = QueryParamMetadata() if isinstance(query, bool) else query
87
+ self.header = HeaderMetadata() if isinstance(header, bool) else header
88
+ self.request = RequestMetadata() if isinstance(request, bool) else request
89
+ self.form = FormMetadata() if isinstance(form, bool) else form
90
+ self.multipart = (
91
+ MultipartFormMetadata() if isinstance(multipart, bool) else multipart
92
+ )
93
+
94
+
95
+ def find_field_metadata(field_info: FieldInfo, metadata_type: Type[T]) -> Optional[T]:
96
+ metadata = find_metadata(field_info, FieldMetadata)
97
+ if not metadata:
98
+ return None
99
+
100
+ fields = metadata.__dict__
101
+
102
+ for field in fields:
103
+ if isinstance(fields[field], metadata_type):
104
+ return fields[field]
105
+
106
+ return None
107
+
108
+
109
+ def find_metadata(field_info: FieldInfo, metadata_type: Type[T]) -> Optional[T]:
110
+ metadata = field_info.metadata
111
+ if not metadata:
112
+ return None
113
+
114
+ for md in metadata:
115
+ if isinstance(md, metadata_type):
116
+ return md
117
+
118
+ return None
@@ -0,0 +1,205 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from typing import (
4
+ Any,
5
+ Dict,
6
+ get_type_hints,
7
+ List,
8
+ Optional,
9
+ )
10
+
11
+ from pydantic import BaseModel
12
+ from pydantic.fields import FieldInfo
13
+
14
+ from .metadata import (
15
+ QueryParamMetadata,
16
+ find_field_metadata,
17
+ )
18
+ from .values import (
19
+ _get_serialized_params,
20
+ _is_set,
21
+ _populate_from_globals,
22
+ _val_to_string,
23
+ )
24
+ from .forms import _populate_form
25
+
26
+
27
+ def get_query_params(
28
+ query_params: Any,
29
+ gbls: Optional[Any] = None,
30
+ ) -> Dict[str, List[str]]:
31
+ params: Dict[str, List[str]] = {}
32
+
33
+ globals_already_populated = _populate_query_params(query_params, gbls, params, [])
34
+ if _is_set(gbls):
35
+ _populate_query_params(gbls, None, params, globals_already_populated)
36
+
37
+ return params
38
+
39
+
40
+ def _populate_query_params(
41
+ query_params: Any,
42
+ gbls: Any,
43
+ query_param_values: Dict[str, List[str]],
44
+ skip_fields: List[str],
45
+ ) -> List[str]:
46
+ globals_already_populated: List[str] = []
47
+
48
+ if not isinstance(query_params, BaseModel):
49
+ return globals_already_populated
50
+
51
+ param_fields: Dict[str, FieldInfo] = query_params.__class__.model_fields
52
+ param_field_types = get_type_hints(query_params.__class__)
53
+ for name in param_fields:
54
+ if name in skip_fields:
55
+ continue
56
+
57
+ field = param_fields[name]
58
+
59
+ metadata = find_field_metadata(field, QueryParamMetadata)
60
+ if not metadata:
61
+ continue
62
+
63
+ value = getattr(query_params, name) if _is_set(query_params) else None
64
+
65
+ value, global_found = _populate_from_globals(
66
+ name, value, QueryParamMetadata, gbls
67
+ )
68
+ if global_found:
69
+ globals_already_populated.append(name)
70
+
71
+ f_name = field.alias if field.alias is not None else name
72
+ serialization = metadata.serialization
73
+ if serialization is not None:
74
+ serialized_parms = _get_serialized_params(
75
+ metadata, f_name, value, param_field_types[name]
76
+ )
77
+ for key, value in serialized_parms.items():
78
+ if key in query_param_values:
79
+ query_param_values[key].extend(value)
80
+ else:
81
+ query_param_values[key] = [value]
82
+ else:
83
+ style = metadata.style
84
+ if style == "deepObject":
85
+ _populate_deep_object_query_params(f_name, value, query_param_values)
86
+ elif style == "form":
87
+ _populate_delimited_query_params(
88
+ metadata, f_name, value, ",", query_param_values
89
+ )
90
+ elif style == "pipeDelimited":
91
+ _populate_delimited_query_params(
92
+ metadata, f_name, value, "|", query_param_values
93
+ )
94
+ else:
95
+ raise NotImplementedError(
96
+ f"query param style {style} not yet supported"
97
+ )
98
+
99
+ return globals_already_populated
100
+
101
+
102
+ def _populate_deep_object_query_params(
103
+ field_name: str,
104
+ obj: Any,
105
+ params: Dict[str, List[str]],
106
+ ):
107
+ if not _is_set(obj):
108
+ return
109
+
110
+ if isinstance(obj, BaseModel):
111
+ _populate_deep_object_query_params_basemodel(field_name, obj, params)
112
+ elif isinstance(obj, Dict):
113
+ _populate_deep_object_query_params_dict(field_name, obj, params)
114
+
115
+
116
+ def _populate_deep_object_query_params_basemodel(
117
+ prior_params_key: str,
118
+ obj: Any,
119
+ params: Dict[str, List[str]],
120
+ ):
121
+ if not _is_set(obj) or not isinstance(obj, BaseModel):
122
+ return
123
+
124
+ obj_fields: Dict[str, FieldInfo] = obj.__class__.model_fields
125
+ for name in obj_fields:
126
+ obj_field = obj_fields[name]
127
+
128
+ f_name = obj_field.alias if obj_field.alias is not None else name
129
+
130
+ params_key = f"{prior_params_key}[{f_name}]"
131
+
132
+ obj_param_metadata = find_field_metadata(obj_field, QueryParamMetadata)
133
+ if not _is_set(obj_param_metadata):
134
+ continue
135
+
136
+ obj_val = getattr(obj, name)
137
+ if not _is_set(obj_val):
138
+ continue
139
+
140
+ if isinstance(obj_val, BaseModel):
141
+ _populate_deep_object_query_params_basemodel(params_key, obj_val, params)
142
+ elif isinstance(obj_val, Dict):
143
+ _populate_deep_object_query_params_dict(params_key, obj_val, params)
144
+ elif isinstance(obj_val, List):
145
+ _populate_deep_object_query_params_list(params_key, obj_val, params)
146
+ else:
147
+ params[params_key] = [_val_to_string(obj_val)]
148
+
149
+
150
+ def _populate_deep_object_query_params_dict(
151
+ prior_params_key: str,
152
+ value: Dict,
153
+ params: Dict[str, List[str]],
154
+ ):
155
+ if not _is_set(value):
156
+ return
157
+
158
+ for key, val in value.items():
159
+ if not _is_set(val):
160
+ continue
161
+
162
+ params_key = f"{prior_params_key}[{key}]"
163
+
164
+ if isinstance(val, BaseModel):
165
+ _populate_deep_object_query_params_basemodel(params_key, val, params)
166
+ elif isinstance(val, Dict):
167
+ _populate_deep_object_query_params_dict(params_key, val, params)
168
+ elif isinstance(val, List):
169
+ _populate_deep_object_query_params_list(params_key, val, params)
170
+ else:
171
+ params[params_key] = [_val_to_string(val)]
172
+
173
+
174
+ def _populate_deep_object_query_params_list(
175
+ params_key: str,
176
+ value: List,
177
+ params: Dict[str, List[str]],
178
+ ):
179
+ if not _is_set(value):
180
+ return
181
+
182
+ for val in value:
183
+ if not _is_set(val):
184
+ continue
185
+
186
+ if params.get(params_key) is None:
187
+ params[params_key] = []
188
+
189
+ params[params_key].append(_val_to_string(val))
190
+
191
+
192
+ def _populate_delimited_query_params(
193
+ metadata: QueryParamMetadata,
194
+ field_name: str,
195
+ obj: Any,
196
+ delimiter: str,
197
+ query_param_values: Dict[str, List[str]],
198
+ ):
199
+ _populate_form(
200
+ field_name,
201
+ metadata.explode,
202
+ obj,
203
+ delimiter,
204
+ query_param_values,
205
+ )