melara 0.1.0__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.
Potentially problematic release.
This version of melara might be problematic. Click here for more details.
- melara/__init__.py +18 -0
- melara/_hooks/__init__.py +6 -0
- melara/_hooks/registration.py +14 -0
- melara/_hooks/sdkhooks.py +77 -0
- melara/_hooks/types.py +125 -0
- melara/_version.py +16 -0
- melara/basesdk.py +408 -0
- melara/beta.py +24 -0
- melara/beta_responses.py +4 -0
- melara/chat.py +1915 -0
- melara/components/__init__.py +4937 -0
- melara/components/additionaltoolsitem.py +284 -0
- melara/components/agentmessageitem.py +217 -0
- melara/components/alignment.py +22 -0
- melara/components/alignmentallowedcallrecord.py +29 -0
- melara/components/alignmentblockedcallrecord.py +29 -0
- melara/components/alignmentcallrecord.py +69 -0
- melara/components/alignmentchataudio.py +43 -0
- melara/components/alignmentchatimage.py +29 -0
- melara/components/alignmentchatrejected.py +68 -0
- melara/components/alignmentchattoolcall.py +35 -0
- melara/components/alignmentplugin.py +74 -0
- melara/components/alignmentrejected.py +22 -0
- melara/components/alignmentresponsesrejected.py +105 -0
- melara/components/alignmentrulerecord.py +21 -0
- melara/components/alignmentunavailablecallrecord.py +37 -0
- melara/components/annotationaddedevent.py +44 -0
- melara/components/anthropicadvisormessageusageiteration.py +80 -0
- melara/components/anthropiccachecontroldirective.py +43 -0
- melara/components/anthropiccachecontrolttl.py +15 -0
- melara/components/anthropiccachecreation.py +17 -0
- melara/components/anthropiccompactionusageiteration.py +77 -0
- melara/components/anthropiciterationcachecreation.py +37 -0
- melara/components/anthropicmessageusageiteration.py +81 -0
- melara/components/anthropicspeed.py +15 -0
- melara/components/anthropicunknownusageiteration.py +74 -0
- melara/components/anthropicusageiteration.py +44 -0
- melara/components/apierrortype.py +41 -0
- melara/components/applypatchcallitem.py +75 -0
- melara/components/applypatchcalloperation.py +71 -0
- melara/components/applypatchcalloperationdiffdeltaevent.py +36 -0
- melara/components/applypatchcalloperationdiffdoneevent.py +36 -0
- melara/components/applypatchcalloutputitem.py +76 -0
- melara/components/applypatchcallstatus.py +16 -0
- melara/components/applypatchcreatefileoperation.py +28 -0
- melara/components/applypatchdeletefileoperation.py +25 -0
- melara/components/applypatchservertool.py +22 -0
- melara/components/applypatchupdatefileoperation.py +28 -0
- melara/components/autobetarouterplugin.py +87 -0
- melara/components/autorouterplugin.py +93 -0
- melara/components/badgatewayresponseerrordata.py +57 -0
- melara/components/badrequestresponseerrordata.py +57 -0
- melara/components/baseinputs_union.py +245 -0
- melara/components/basereasoningconfig.py +63 -0
- melara/components/chatassistantimages.py +24 -0
- melara/components/chatassistantmessage.py +128 -0
- melara/components/chataudiooutput.py +53 -0
- melara/components/chatchoice.py +68 -0
- melara/components/chatcontentaudio.py +47 -0
- melara/components/chatcontentcachecontrol.py +43 -0
- melara/components/chatcontentfile.py +62 -0
- melara/components/chatcontentimage.py +69 -0
- melara/components/chatcontentitems.py +77 -0
- melara/components/chatcontenttext.py +72 -0
- melara/components/chatcontentvideo.py +28 -0
- melara/components/chatcontentvideoinput.py +53 -0
- melara/components/chatdebugoptions.py +38 -0
- melara/components/chatdevelopermessage.py +104 -0
- melara/components/chatdynamicservertool.py +39 -0
- melara/components/chatfinishreasonenum.py +18 -0
- melara/components/chatformatgrammarconfig.py +27 -0
- melara/components/chatformatjsonobjectconfig.py +22 -0
- melara/components/chatformatjsonschemaconfig.py +28 -0
- melara/components/chatformatpythonconfig.py +22 -0
- melara/components/chatformattextconfig.py +22 -0
- melara/components/chatfunctiontool.py +152 -0
- melara/components/chatjsonschemaconfig.py +75 -0
- melara/components/chatmessages.py +39 -0
- melara/components/chatnamedtoolchoice.py +35 -0
- melara/components/chatreasoningsummaryverbosityenum.py +16 -0
- melara/components/chatrequest.py +551 -0
- melara/components/chatresult.py +92 -0
- melara/components/chatservertoolchoice.py +20 -0
- melara/components/chatstreamchoice.py +68 -0
- melara/components/chatstreamchunk.py +181 -0
- melara/components/chatstreamdelta.py +98 -0
- melara/components/chatstreamingresponse.py +17 -0
- melara/components/chatstreamoptions.py +38 -0
- melara/components/chatstreamtoolcall.py +92 -0
- melara/components/chatsystemmessage.py +102 -0
- melara/components/chattokenlogprob.py +90 -0
- melara/components/chattokenlogprobs.py +59 -0
- melara/components/chattoolcall.py +45 -0
- melara/components/chattoolchoice.py +43 -0
- melara/components/chattoolmessage.py +45 -0
- melara/components/chatusage.py +231 -0
- melara/components/chatusermessage.py +62 -0
- melara/components/chatwebsearchshorthand.py +129 -0
- melara/components/codeinterpretercallcodedeltaevent.py +36 -0
- melara/components/codeinterpretercallcodedoneevent.py +36 -0
- melara/components/codeinterpretercallcompletedevent.py +33 -0
- melara/components/codeinterpretercallinprogressevent.py +33 -0
- melara/components/codeinterpretercallinterpretingevent.py +33 -0
- melara/components/codeinterpreterfileoutput.py +97 -0
- melara/components/codeinterpreterimageoutput.py +21 -0
- melara/components/codeinterpreterlogsoutput.py +21 -0
- melara/components/codeinterpreterservertool.py +94 -0
- melara/components/codexlocalshelltool.py +22 -0
- melara/components/compactionitem.py +77 -0
- melara/components/compoundfilter.py +31 -0
- melara/components/computeruseservertool.py +43 -0
- melara/components/configurationupdateitem.py +66 -0
- melara/components/configurationupdatereasoning.py +36 -0
- melara/components/contentpartaddedevent.py +93 -0
- melara/components/contentpartdoneevent.py +93 -0
- melara/components/contentpartimage.py +29 -0
- melara/components/contentpartinputaudio.py +22 -0
- melara/components/contentpartinputfile.py +22 -0
- melara/components/contentpartinputvideo.py +22 -0
- melara/components/contextcompactionitem.py +77 -0
- melara/components/contextcompressionengine.py +9 -0
- melara/components/contextcompressionplugin.py +46 -0
- melara/components/costdetails.py +61 -0
- melara/components/customtool.py +138 -0
- melara/components/customtoolcallinputdeltaevent.py +34 -0
- melara/components/customtoolcallinputdoneevent.py +34 -0
- melara/components/customtoolcallitem.py +87 -0
- melara/components/customtoolcalloutputitem.py +150 -0
- melara/components/debugevent.py +81 -0
- melara/components/deferredbm25search.py +42 -0
- melara/components/deferredcustomsearch.py +48 -0
- melara/components/deferredregexsearch.py +42 -0
- melara/components/deferredtoolscontrol.py +49 -0
- melara/components/deferredtoolssearchstrategy.py +33 -0
- melara/components/easyinputmessage.py +216 -0
- melara/components/edgenetworktimeoutresponseerrordata.py +57 -0
- melara/components/errorevent.py +49 -0
- melara/components/failabletoolcallstatus.py +17 -0
- melara/components/filecitation.py +27 -0
- melara/components/fileparserplugin.py +46 -0
- melara/components/filepath.py +24 -0
- melara/components/filesearchservertool.py +161 -0
- melara/components/forbiddenresponseerrordata.py +57 -0
- melara/components/formatjsonobjectconfig.py +22 -0
- melara/components/formatjsonschemaconfig.py +73 -0
- melara/components/formats.py +65 -0
- melara/components/formattextconfig.py +22 -0
- melara/components/functioncallargsdeltaevent.py +34 -0
- melara/components/functioncallargsdoneevent.py +37 -0
- melara/components/functioncallitem.py +122 -0
- melara/components/functioncalloutputitem.py +163 -0
- melara/components/fusionanalysisresult.py +75 -0
- melara/components/fusioncallanalysiscompletedevent.py +39 -0
- melara/components/fusioncallanalysisinprogressevent.py +49 -0
- melara/components/fusioncallcompletedevent.py +31 -0
- melara/components/fusioncallinprogressevent.py +31 -0
- melara/components/fusioncallpaneladdedevent.py +34 -0
- melara/components/fusioncallpanelcompletedevent.py +37 -0
- melara/components/fusioncallpaneldeltaevent.py +37 -0
- melara/components/fusioncallpanelfailedevent.py +57 -0
- melara/components/fusioncallpanelreasoningdeltaevent.py +39 -0
- melara/components/fusionplugin.py +141 -0
- melara/components/gatewaytimeoutresponseerrordata.py +57 -0
- melara/components/imageconfig.py +14 -0
- melara/components/imagegencallcompletedevent.py +31 -0
- melara/components/imagegencallgeneratingevent.py +31 -0
- melara/components/imagegencallinprogressevent.py +31 -0
- melara/components/imagegencallpartialimageevent.py +39 -0
- melara/components/imagegencompletedevent.py +63 -0
- melara/components/imagegenerationproviderpreferences.py +761 -0
- melara/components/imagegenerationrequest.py +227 -0
- melara/components/imagegenerationresponse.py +84 -0
- melara/components/imagegenerationservertool.py +174 -0
- melara/components/imagegenerationstatus.py +17 -0
- melara/components/imagegenerationusage.py +321 -0
- melara/components/imagegenpartialimageevent.py +35 -0
- melara/components/imagegenstreamerrorevent.py +91 -0
- melara/components/imagegentextchunkevent.py +46 -0
- melara/components/imagestreamingresponse.py +84 -0
- melara/components/incompletedetails.py +41 -0
- melara/components/inputaudio.py +52 -0
- melara/components/inputfile.py +66 -0
- melara/components/inputimage.py +75 -0
- melara/components/inputmessageitem.py +178 -0
- melara/components/inputs_union.py +402 -0
- melara/components/inputtext.py +63 -0
- melara/components/inputvideo.py +59 -0
- melara/components/internalserverresponseerrordata.py +57 -0
- melara/components/itemreferenceitem.py +25 -0
- melara/components/jevrouterplugin.py +57 -0
- melara/components/legacy_chatcontentvideo.py +38 -0
- melara/components/legacy_chatcontentvideoinput.py +53 -0
- melara/components/legacy_websearchservertool.py +109 -0
- melara/components/localshellcallitem.py +93 -0
- melara/components/localshellcalloutputitem.py +64 -0
- melara/components/mcpapprovalrequestitem.py +34 -0
- melara/components/mcpapprovalresponseitem.py +66 -0
- melara/components/mcpcallitem.py +75 -0
- melara/components/mcphttperror.py +28 -0
- melara/components/mcplisttoolsitem.py +108 -0
- melara/components/mcpprotocolerror.py +28 -0
- melara/components/mcpservertool.py +232 -0
- melara/components/mcptoolcallerror.py +28 -0
- melara/components/mcptoolexecutionerror.py +42 -0
- melara/components/model.py +27 -0
- melara/components/modelslistresponse.py +16 -0
- melara/components/moderationplugin.py +18 -0
- melara/components/multimodalmedia.py +42 -0
- melara/components/namespacefunctiontool.py +109 -0
- melara/components/namespacetool.py +73 -0
- melara/components/notfoundresponseerrordata.py +57 -0
- melara/components/openairesponsecustomtoolcall.py +64 -0
- melara/components/openairesponsecustomtoolcalloutput.py +104 -0
- melara/components/openairesponsefunctiontoolcall.py +103 -0
- melara/components/openairesponsefunctiontoolcalloutput.py +123 -0
- melara/components/openairesponseinputmessageitem.py +126 -0
- melara/components/openairesponsesannotation.py +51 -0
- melara/components/openairesponsesrefusalcontent.py +21 -0
- melara/components/openairesponsesresponsestatus.py +19 -0
- melara/components/openairesponsestoolchoice_union.py +117 -0
- melara/components/openairesponsestruncation.py +15 -0
- melara/components/openresponsescreatedevent.py +31 -0
- melara/components/openresponseserrorfield.py +77 -0
- melara/components/openresponseserrormetadata.py +73 -0
- melara/components/openresponsesinprogressevent.py +31 -0
- melara/components/openresponsesresult.py +608 -0
- melara/components/outputapplypatchcallitem.py +43 -0
- melara/components/outputcodeinterpretercallitem.py +160 -0
- melara/components/outputcomputercallitem.py +74 -0
- melara/components/outputcustomtoolcallitem.py +81 -0
- melara/components/outputfilesearchcallitem.py +28 -0
- melara/components/outputfunctioncallitem.py +129 -0
- melara/components/outputimagegenerationcallitem.py +63 -0
- melara/components/outputitemapplypatchcall.py +120 -0
- melara/components/outputitemcodeinterpretercall.py +156 -0
- melara/components/outputitemcustomtoolcall.py +77 -0
- melara/components/outputitemfilesearchcall.py +28 -0
- melara/components/outputitemfunctioncall.py +96 -0
- melara/components/outputitemimagegenerationcall.py +58 -0
- melara/components/outputitemreasoning.py +96 -0
- melara/components/outputitems.py +139 -0
- melara/components/outputitemwebsearchcall.py +210 -0
- melara/components/outputmessage.py +165 -0
- melara/components/outputmessageitem.py +171 -0
- melara/components/outputmodalityenum.py +15 -0
- melara/components/outputreasoningitem.py +120 -0
- melara/components/outputshellcallitem.py +102 -0
- melara/components/outputshellcalloutputitem.py +117 -0
- melara/components/outputtoolsearchcallitem.py +58 -0
- melara/components/outputwebsearchcallitem.py +210 -0
- melara/components/outputwebsearchservertoolitem.py +107 -0
- melara/components/paretorouterplugin.py +67 -0
- melara/components/payloadtoolargeresponseerrordata.py +57 -0
- melara/components/paymentrequiredresponseerrordata.py +57 -0
- melara/components/pdfparserengine.py +32 -0
- melara/components/pdfparseroptions.py +39 -0
- melara/components/percentilelatencycutoffs.py +67 -0
- melara/components/percentilethroughputcutoffs.py +67 -0
- melara/components/prediction.py +36 -0
- melara/components/predictioncontenttext.py +25 -0
- melara/components/preferredmaxlatency.py +22 -0
- melara/components/preferredminthroughput.py +23 -0
- melara/components/preview_20250311_websearchservertool.py +110 -0
- melara/components/preview_websearchservertool.py +110 -0
- melara/components/preview_websearchuserlocation.py +62 -0
- melara/components/promptcachebreakpoint.py +22 -0
- melara/components/promptcacheoptions.py +57 -0
- melara/components/providername.py +12 -0
- melara/components/provideroptions.py +635 -0
- melara/components/provideroverloadedresponseerrordata.py +57 -0
- melara/components/providerpreferences.py +283 -0
- melara/components/providersort.py +18 -0
- melara/components/providersortconfig.py +81 -0
- melara/components/quantization.py +25 -0
- melara/components/reasoningcontext.py +17 -0
- melara/components/reasoningdeltaevent.py +37 -0
- melara/components/reasoningdetailencrypted.py +76 -0
- melara/components/reasoningdetailservertoolcall.py +85 -0
- melara/components/reasoningdetailsummary.py +76 -0
- melara/components/reasoningdetailtext.py +79 -0
- melara/components/reasoningdetailunion.py +75 -0
- melara/components/reasoningdoneevent.py +37 -0
- melara/components/reasoningeffort.py +20 -0
- melara/components/reasoningformat.py +19 -0
- melara/components/reasoningitem.py +118 -0
- melara/components/reasoningmode.py +16 -0
- melara/components/reasoningsummarypartaddedevent.py +38 -0
- melara/components/reasoningsummarypartdoneevent.py +38 -0
- melara/components/reasoningsummarytext.py +21 -0
- melara/components/reasoningsummarytextdeltaevent.py +37 -0
- melara/components/reasoningsummarytextdoneevent.py +37 -0
- melara/components/reasoningsummaryverbosity.py +16 -0
- melara/components/reasoningtextcontent.py +21 -0
- melara/components/refusaldeltaevent.py +37 -0
- melara/components/refusaldoneevent.py +37 -0
- melara/components/requesttimeoutresponseerrordata.py +57 -0
- melara/components/responsehealingplugin.py +40 -0
- melara/components/responseincludesenum.py +18 -0
- melara/components/responseoutputtext.py +90 -0
- melara/components/responsesrequest.py +624 -0
- melara/components/responsesstreamingresponse.py +17 -0
- melara/components/searchcontextsizeenum.py +17 -0
- melara/components/searchqualitylevel.py +17 -0
- melara/components/security.py +43 -0
- melara/components/servertoolusedetails.py +66 -0
- melara/components/serviceunavailableresponseerrordata.py +57 -0
- melara/components/shellcallitem.py +114 -0
- melara/components/shellcalloutputcontent.py +129 -0
- melara/components/shellcalloutputitem.py +117 -0
- melara/components/shellcallstatus.py +17 -0
- melara/components/shellservertool.py +22 -0
- melara/components/speechinput.py +17 -0
- melara/components/speechinputreference.py +42 -0
- melara/components/speechinputreferenceaudio.py +31 -0
- melara/components/speechinputreferenceaudioinput.py +55 -0
- melara/components/speechinputreferenceimage.py +31 -0
- melara/components/speechinputreferenceimageinput.py +20 -0
- melara/components/speechinputreferencetext.py +27 -0
- melara/components/speechrequest.py +192 -0
- melara/components/speechturn.py +44 -0
- melara/components/stopservertoolswhencondition.py +54 -0
- melara/components/stopservertoolswhenfinishreasonis.py +25 -0
- melara/components/stopservertoolswhenhastoolcall.py +25 -0
- melara/components/stopservertoolswhenmaxcost.py +25 -0
- melara/components/stopservertoolswhenmaxtokensused.py +25 -0
- melara/components/stopservertoolswhenstepcountis.py +25 -0
- melara/components/storedprompttemplate.py +62 -0
- melara/components/streamevents.py +360 -0
- melara/components/streameventsresponsecompleted.py +31 -0
- melara/components/streameventsresponsefailed.py +31 -0
- melara/components/streameventsresponseincomplete.py +31 -0
- melara/components/streameventsresponseoutputitemadded.py +34 -0
- melara/components/streameventsresponseoutputitemdone.py +34 -0
- melara/components/streamlogprob.py +56 -0
- melara/components/streamlogprobtoplogprob.py +49 -0
- melara/components/sttentity.py +35 -0
- melara/components/sttresponse.py +99 -0
- melara/components/sttsegment.py +110 -0
- melara/components/sttusage.py +60 -0
- melara/components/sttword.py +85 -0
- melara/components/switchyardrouterplugin.py +59 -0
- melara/components/textdeltaevent.py +41 -0
- melara/components/textdoneevent.py +41 -0
- melara/components/textextendedconfig.py +77 -0
- melara/components/toolcallstatus.py +16 -0
- melara/components/toolchoiceallowed.py +40 -0
- melara/components/toolsearchcallitem.py +89 -0
- melara/components/toolsearchoutputitem.py +294 -0
- melara/components/toomanyrequestsresponseerrordata.py +57 -0
- melara/components/traceconfig.py +67 -0
- melara/components/truncation.py +15 -0
- melara/components/unauthorizedresponseerrordata.py +57 -0
- melara/components/unprocessableentityresponseerrordata.py +57 -0
- melara/components/urlcitation.py +50 -0
- melara/components/webfetchplugin.py +57 -0
- melara/components/websearchcallcompletedevent.py +31 -0
- melara/components/websearchcallinprogressevent.py +31 -0
- melara/components/websearchcallsearchingevent.py +31 -0
- melara/components/websearchconfig.py +106 -0
- melara/components/websearchdomainfilter.py +57 -0
- melara/components/websearchengine.py +19 -0
- melara/components/websearchengineenum.py +20 -0
- melara/components/websearchmode.py +23 -0
- melara/components/websearchplugin.py +162 -0
- melara/components/websearchservertool.py +109 -0
- melara/components/websearchsource.py +21 -0
- melara/components/websearchstatus.py +17 -0
- melara/components/websearchuserlocation.py +66 -0
- melara/components/websearchuserlocationservertool.py +66 -0
- melara/components/xsearchoptions.py +73 -0
- melara/embeddings.py +479 -0
- melara/endpoints.json +3 -0
- melara/errors/__init__.py +151 -0
- melara/errors/badgatewayresponse_error.py +36 -0
- melara/errors/badrequestresponse_error.py +36 -0
- melara/errors/edgenetworktimeoutresponse_error.py +36 -0
- melara/errors/forbiddenresponse_error.py +36 -0
- melara/errors/gatewaytimeoutresponse_error.py +36 -0
- melara/errors/internalserverresponse_error.py +36 -0
- melara/errors/melaradefaulterror.py +17 -0
- melara/errors/melaraerror.py +31 -0
- melara/errors/no_response_error.py +19 -0
- melara/errors/notfoundresponse_error.py +36 -0
- melara/errors/payloadtoolargeresponse_error.py +36 -0
- melara/errors/paymentrequiredresponse_error.py +36 -0
- melara/errors/provideroverloadedresponse_error.py +36 -0
- melara/errors/requesttimeoutresponse_error.py +36 -0
- melara/errors/responsevalidationerror.py +28 -0
- melara/errors/serviceunavailableresponse_error.py +36 -0
- melara/errors/toomanyrequestsresponse_error.py +36 -0
- melara/errors/unauthorizedresponse_error.py +36 -0
- melara/errors/unprocessableentityresponse_error.py +36 -0
- melara/httpclient.py +126 -0
- melara/images.py +1017 -0
- melara/locales/__init__.py +1 -0
- melara/locales/en.py +54 -0
- melara/models/__init__.py +24 -0
- melara/models/internal/__init__.py +26 -0
- melara/models/internal/globals.py +60 -0
- melara/models_.py +393 -0
- melara/operations/__init__.py +272 -0
- melara/operations/createaudiospeech.py +117 -0
- melara/operations/createaudiotranscriptions_multipart.py +289 -0
- melara/operations/createembeddings.py +559 -0
- melara/operations/createimages.py +160 -0
- melara/operations/createresponses.py +154 -0
- melara/operations/getmodels.py +277 -0
- melara/operations/sendchatcompletionrequest.py +156 -0
- melara/py.typed +2 -0
- melara/realtime.py +253 -0
- melara/responses.py +1833 -0
- melara/sdk.py +222 -0
- melara/sdkconfiguration.py +63 -0
- melara/stt.py +469 -0
- melara/tts.py +520 -0
- melara/types/__init__.py +25 -0
- melara/types/base64fileinput.py +45 -0
- melara/types/basemodel.py +78 -0
- melara/utils/__init__.py +182 -0
- melara/utils/annotations.py +81 -0
- melara/utils/datetimes.py +24 -0
- melara/utils/dynamic_imports.py +56 -0
- melara/utils/enums.py +135 -0
- melara/utils/eventstreaming.py +347 -0
- melara/utils/forms.py +241 -0
- melara/utils/headers.py +137 -0
- melara/utils/logger.py +29 -0
- melara/utils/metadata.py +120 -0
- melara/utils/queryparams.py +219 -0
- melara/utils/requestbodies.py +69 -0
- melara/utils/retries.py +358 -0
- melara/utils/security.py +217 -0
- melara/utils/serializers.py +308 -0
- melara/utils/unions.py +43 -0
- melara/utils/unmarshal_json_response.py +40 -0
- melara/utils/url.py +156 -0
- melara/utils/values.py +139 -0
- melara-0.1.0.dist-info/METADATA +106 -0
- melara-0.1.0.dist-info/RECORD +443 -0
- melara-0.1.0.dist-info/WHEEL +5 -0
- melara-0.1.0.dist-info/licenses/LICENSE +201 -0
- melara-0.1.0.dist-info/licenses/NOTICE +1 -0
- melara-0.1.0.dist-info/top_level.txt +1 -0
melara/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Modified for Melara under Apache-2.0.
|
|
2
|
+
"""Code generated by Speakeasy (https://speakeasy.com)."""
|
|
3
|
+
|
|
4
|
+
from ._version import (
|
|
5
|
+
__title__,
|
|
6
|
+
__version__,
|
|
7
|
+
__openapi_doc_version__,
|
|
8
|
+
__gen_version__,
|
|
9
|
+
__user_agent__,
|
|
10
|
+
)
|
|
11
|
+
from .sdk import *
|
|
12
|
+
from .sdkconfiguration import *
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
VERSION: str = __version__
|
|
16
|
+
OPENAPI_DOC_VERSION = __openapi_doc_version__
|
|
17
|
+
SPEAKEASY_GENERATOR_VERSION = __gen_version__
|
|
18
|
+
USER_AGENT = __user_agent__
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Modified for Melara under Apache-2.0.
|
|
2
|
+
from .types import Hooks
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# This file is only ever generated once on the first generation and then is free to be modified.
|
|
6
|
+
# Any hooks you wish to add should be registered in the init_hooks function. Feel free to define them
|
|
7
|
+
# in this file or in separate files in the hooks folder.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def init_hooks(hooks: Hooks):
|
|
11
|
+
# pylint: disable=unused-argument
|
|
12
|
+
"""Add hooks by calling hooks.register{sdk_init/before_request/after_success/after_error}Hook
|
|
13
|
+
with an instance of a hook that implements that specific Hook interface
|
|
14
|
+
Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance"""
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Modified for Melara under Apache-2.0.
|
|
2
|
+
"""Code generated by Speakeasy (https://speakeasy.com)."""
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from .types import (
|
|
6
|
+
SDKInitHook,
|
|
7
|
+
BeforeRequestContext,
|
|
8
|
+
BeforeRequestHook,
|
|
9
|
+
AfterSuccessContext,
|
|
10
|
+
AfterSuccessHook,
|
|
11
|
+
AfterErrorContext,
|
|
12
|
+
AfterErrorHook,
|
|
13
|
+
Hooks,
|
|
14
|
+
)
|
|
15
|
+
from .registration import init_hooks
|
|
16
|
+
from typing import List, Optional, Tuple
|
|
17
|
+
from melara.sdkconfiguration import SDKConfiguration
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SDKHooks(Hooks):
|
|
21
|
+
def __init__(self) -> None:
|
|
22
|
+
self.sdk_init_hooks: List[SDKInitHook] = []
|
|
23
|
+
self.before_request_hooks: List[BeforeRequestHook] = []
|
|
24
|
+
self.after_success_hooks: List[AfterSuccessHook] = []
|
|
25
|
+
self.after_error_hooks: List[AfterErrorHook] = []
|
|
26
|
+
init_hooks(self)
|
|
27
|
+
|
|
28
|
+
def register_sdk_init_hook(self, hook: SDKInitHook) -> None:
|
|
29
|
+
self.sdk_init_hooks.append(hook)
|
|
30
|
+
|
|
31
|
+
def register_before_request_hook(self, hook: BeforeRequestHook) -> None:
|
|
32
|
+
self.before_request_hooks.append(hook)
|
|
33
|
+
|
|
34
|
+
def register_after_success_hook(self, hook: AfterSuccessHook) -> None:
|
|
35
|
+
self.after_success_hooks.append(hook)
|
|
36
|
+
|
|
37
|
+
def register_after_error_hook(self, hook: AfterErrorHook) -> None:
|
|
38
|
+
self.after_error_hooks.append(hook)
|
|
39
|
+
|
|
40
|
+
def sdk_init(self, config: SDKConfiguration) -> SDKConfiguration:
|
|
41
|
+
for hook in self.sdk_init_hooks:
|
|
42
|
+
config = hook.sdk_init(config)
|
|
43
|
+
return config
|
|
44
|
+
|
|
45
|
+
def before_request(
|
|
46
|
+
self, hook_ctx: BeforeRequestContext, request: httpx.Request
|
|
47
|
+
) -> httpx.Request:
|
|
48
|
+
for hook in self.before_request_hooks:
|
|
49
|
+
out = hook.before_request(hook_ctx, request)
|
|
50
|
+
if isinstance(out, Exception):
|
|
51
|
+
raise out
|
|
52
|
+
request = out
|
|
53
|
+
|
|
54
|
+
return request
|
|
55
|
+
|
|
56
|
+
def after_success(
|
|
57
|
+
self, hook_ctx: AfterSuccessContext, response: httpx.Response
|
|
58
|
+
) -> httpx.Response:
|
|
59
|
+
for hook in self.after_success_hooks:
|
|
60
|
+
out = hook.after_success(hook_ctx, response)
|
|
61
|
+
if isinstance(out, Exception):
|
|
62
|
+
raise out
|
|
63
|
+
response = out
|
|
64
|
+
return response
|
|
65
|
+
|
|
66
|
+
def after_error(
|
|
67
|
+
self,
|
|
68
|
+
hook_ctx: AfterErrorContext,
|
|
69
|
+
response: Optional[httpx.Response],
|
|
70
|
+
error: Optional[Exception],
|
|
71
|
+
) -> Tuple[Optional[httpx.Response], Optional[Exception]]:
|
|
72
|
+
for hook in self.after_error_hooks:
|
|
73
|
+
result = hook.after_error(hook_ctx, response, error)
|
|
74
|
+
if isinstance(result, Exception):
|
|
75
|
+
raise result
|
|
76
|
+
response, error = result
|
|
77
|
+
return response, error
|
melara/_hooks/types.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Modified for Melara under Apache-2.0.
|
|
2
|
+
"""Code generated by Speakeasy (https://speakeasy.com)."""
|
|
3
|
+
|
|
4
|
+
from abc import ABC, abstractmethod
|
|
5
|
+
import httpx
|
|
6
|
+
from melara.sdkconfiguration import SDKConfiguration
|
|
7
|
+
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class HookContext:
|
|
11
|
+
config: SDKConfiguration
|
|
12
|
+
base_url: str
|
|
13
|
+
operation_id: str
|
|
14
|
+
oauth2_scopes: Optional[List[str]] = None
|
|
15
|
+
security_source: Optional[Union[Any, Callable[[], Any]]] = None
|
|
16
|
+
tags: Optional[List[str]] = None
|
|
17
|
+
extensions: Optional[Dict[str, Any]] = None
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
config: SDKConfiguration,
|
|
22
|
+
base_url: str,
|
|
23
|
+
operation_id: str,
|
|
24
|
+
oauth2_scopes: Optional[List[str]],
|
|
25
|
+
security_source: Optional[Union[Any, Callable[[], Any]]],
|
|
26
|
+
tags: Optional[List[str]],
|
|
27
|
+
extensions: Optional[Dict[str, Any]],
|
|
28
|
+
):
|
|
29
|
+
self.config = config
|
|
30
|
+
self.base_url = base_url
|
|
31
|
+
self.operation_id = operation_id
|
|
32
|
+
self.oauth2_scopes = oauth2_scopes
|
|
33
|
+
self.security_source = security_source
|
|
34
|
+
self.tags = tags
|
|
35
|
+
self.extensions = extensions
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class BeforeRequestContext(HookContext):
|
|
39
|
+
def __init__(self, hook_ctx: HookContext):
|
|
40
|
+
super().__init__(
|
|
41
|
+
hook_ctx.config,
|
|
42
|
+
hook_ctx.base_url,
|
|
43
|
+
hook_ctx.operation_id,
|
|
44
|
+
hook_ctx.oauth2_scopes,
|
|
45
|
+
hook_ctx.security_source,
|
|
46
|
+
hook_ctx.tags,
|
|
47
|
+
hook_ctx.extensions,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class AfterSuccessContext(HookContext):
|
|
52
|
+
def __init__(self, hook_ctx: HookContext):
|
|
53
|
+
super().__init__(
|
|
54
|
+
hook_ctx.config,
|
|
55
|
+
hook_ctx.base_url,
|
|
56
|
+
hook_ctx.operation_id,
|
|
57
|
+
hook_ctx.oauth2_scopes,
|
|
58
|
+
hook_ctx.security_source,
|
|
59
|
+
hook_ctx.tags,
|
|
60
|
+
hook_ctx.extensions,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class AfterErrorContext(HookContext):
|
|
65
|
+
def __init__(self, hook_ctx: HookContext):
|
|
66
|
+
super().__init__(
|
|
67
|
+
hook_ctx.config,
|
|
68
|
+
hook_ctx.base_url,
|
|
69
|
+
hook_ctx.operation_id,
|
|
70
|
+
hook_ctx.oauth2_scopes,
|
|
71
|
+
hook_ctx.security_source,
|
|
72
|
+
hook_ctx.tags,
|
|
73
|
+
hook_ctx.extensions,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class SDKInitHook(ABC):
|
|
78
|
+
@abstractmethod
|
|
79
|
+
def sdk_init(self, config: SDKConfiguration) -> SDKConfiguration:
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class BeforeRequestHook(ABC):
|
|
84
|
+
@abstractmethod
|
|
85
|
+
def before_request(
|
|
86
|
+
self, hook_ctx: BeforeRequestContext, request: httpx.Request
|
|
87
|
+
) -> Union[httpx.Request, Exception]:
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class AfterSuccessHook(ABC):
|
|
92
|
+
@abstractmethod
|
|
93
|
+
def after_success(
|
|
94
|
+
self, hook_ctx: AfterSuccessContext, response: httpx.Response
|
|
95
|
+
) -> Union[httpx.Response, Exception]:
|
|
96
|
+
pass
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class AfterErrorHook(ABC):
|
|
100
|
+
@abstractmethod
|
|
101
|
+
def after_error(
|
|
102
|
+
self,
|
|
103
|
+
hook_ctx: AfterErrorContext,
|
|
104
|
+
response: Optional[httpx.Response],
|
|
105
|
+
error: Optional[Exception],
|
|
106
|
+
) -> Union[Tuple[Optional[httpx.Response], Optional[Exception]], Exception]:
|
|
107
|
+
pass
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class Hooks(ABC):
|
|
111
|
+
@abstractmethod
|
|
112
|
+
def register_sdk_init_hook(self, hook: SDKInitHook):
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
@abstractmethod
|
|
116
|
+
def register_before_request_hook(self, hook: BeforeRequestHook):
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
@abstractmethod
|
|
120
|
+
def register_after_success_hook(self, hook: AfterSuccessHook):
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
@abstractmethod
|
|
124
|
+
def register_after_error_hook(self, hook: AfterErrorHook):
|
|
125
|
+
pass
|
melara/_version.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Modified for Melara under Apache-2.0.
|
|
2
|
+
"""Code generated by Speakeasy (https://speakeasy.com)."""
|
|
3
|
+
|
|
4
|
+
import importlib.metadata
|
|
5
|
+
|
|
6
|
+
__title__: str = "melara"
|
|
7
|
+
__version__: str = "0.1.0"
|
|
8
|
+
__openapi_doc_version__: str = "1.0.0"
|
|
9
|
+
__gen_version__: str = "2.914.0"
|
|
10
|
+
__user_agent__: str = "melara-python/0.1.0"
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
if __package__ is not None:
|
|
14
|
+
__version__ = importlib.metadata.version(__package__)
|
|
15
|
+
except importlib.metadata.PackageNotFoundError:
|
|
16
|
+
pass
|
melara/basesdk.py
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
# Modified for Melara under Apache-2.0.
|
|
2
|
+
"""Code generated by Speakeasy (https://speakeasy.com)."""
|
|
3
|
+
|
|
4
|
+
from .sdkconfiguration import SDKConfiguration
|
|
5
|
+
import httpx
|
|
6
|
+
from melara.locales import en as messages
|
|
7
|
+
from melara import components, errors, utils
|
|
8
|
+
from melara._hooks import (
|
|
9
|
+
AfterErrorContext,
|
|
10
|
+
AfterSuccessContext,
|
|
11
|
+
BeforeRequestContext,
|
|
12
|
+
HookContext,
|
|
13
|
+
)
|
|
14
|
+
from melara.utils import (
|
|
15
|
+
RetryConfig,
|
|
16
|
+
SerializedRequestBody,
|
|
17
|
+
get_body_content,
|
|
18
|
+
run_sync_in_thread,
|
|
19
|
+
)
|
|
20
|
+
from typing import Callable, List, Mapping, Optional, Tuple
|
|
21
|
+
from urllib.parse import parse_qs, urlparse
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class BaseSDK:
|
|
25
|
+
sdk_configuration: SDKConfiguration
|
|
26
|
+
parent_ref: Optional[object] = None
|
|
27
|
+
"""
|
|
28
|
+
Reference to the root SDK instance, if any. This will prevent it from
|
|
29
|
+
being garbage collected while there are active streams.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
sdk_config: SDKConfiguration,
|
|
35
|
+
parent_ref: Optional[object] = None,
|
|
36
|
+
) -> None:
|
|
37
|
+
self.sdk_configuration = sdk_config
|
|
38
|
+
self.parent_ref = parent_ref
|
|
39
|
+
|
|
40
|
+
def _get_url(self, base_url, url_variables):
|
|
41
|
+
sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
|
|
42
|
+
|
|
43
|
+
if base_url is None:
|
|
44
|
+
base_url = sdk_url
|
|
45
|
+
|
|
46
|
+
if url_variables is None:
|
|
47
|
+
url_variables = sdk_variables
|
|
48
|
+
|
|
49
|
+
return utils.template_url(base_url, url_variables)
|
|
50
|
+
|
|
51
|
+
def _build_request_async(
|
|
52
|
+
self,
|
|
53
|
+
method,
|
|
54
|
+
path,
|
|
55
|
+
base_url,
|
|
56
|
+
url_variables,
|
|
57
|
+
request,
|
|
58
|
+
request_body_required,
|
|
59
|
+
request_has_path_params,
|
|
60
|
+
request_has_query_params,
|
|
61
|
+
user_agent_header,
|
|
62
|
+
accept_header_value,
|
|
63
|
+
_globals=None,
|
|
64
|
+
security=None,
|
|
65
|
+
timeout_ms: Optional[int] = None,
|
|
66
|
+
get_serialized_body: Optional[
|
|
67
|
+
Callable[[], Optional[SerializedRequestBody]]
|
|
68
|
+
] = None,
|
|
69
|
+
url_override: Optional[str] = None,
|
|
70
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
71
|
+
allow_empty_value: Optional[List[str]] = None,
|
|
72
|
+
allowed_fields: Optional[List[str]] = None,
|
|
73
|
+
) -> httpx.Request:
|
|
74
|
+
client = self.sdk_configuration.async_client
|
|
75
|
+
return self._build_request_with_client(
|
|
76
|
+
client,
|
|
77
|
+
method,
|
|
78
|
+
path,
|
|
79
|
+
base_url,
|
|
80
|
+
url_variables,
|
|
81
|
+
request,
|
|
82
|
+
request_body_required,
|
|
83
|
+
request_has_path_params,
|
|
84
|
+
request_has_query_params,
|
|
85
|
+
user_agent_header,
|
|
86
|
+
accept_header_value,
|
|
87
|
+
_globals,
|
|
88
|
+
security,
|
|
89
|
+
timeout_ms,
|
|
90
|
+
get_serialized_body,
|
|
91
|
+
url_override,
|
|
92
|
+
http_headers,
|
|
93
|
+
allow_empty_value,
|
|
94
|
+
allowed_fields,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def _build_request(
|
|
98
|
+
self,
|
|
99
|
+
method,
|
|
100
|
+
path,
|
|
101
|
+
base_url,
|
|
102
|
+
url_variables,
|
|
103
|
+
request,
|
|
104
|
+
request_body_required,
|
|
105
|
+
request_has_path_params,
|
|
106
|
+
request_has_query_params,
|
|
107
|
+
user_agent_header,
|
|
108
|
+
accept_header_value,
|
|
109
|
+
_globals=None,
|
|
110
|
+
security=None,
|
|
111
|
+
timeout_ms: Optional[int] = None,
|
|
112
|
+
get_serialized_body: Optional[
|
|
113
|
+
Callable[[], Optional[SerializedRequestBody]]
|
|
114
|
+
] = None,
|
|
115
|
+
url_override: Optional[str] = None,
|
|
116
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
117
|
+
allow_empty_value: Optional[List[str]] = None,
|
|
118
|
+
allowed_fields: Optional[List[str]] = None,
|
|
119
|
+
) -> httpx.Request:
|
|
120
|
+
client = self.sdk_configuration.client
|
|
121
|
+
return self._build_request_with_client(
|
|
122
|
+
client,
|
|
123
|
+
method,
|
|
124
|
+
path,
|
|
125
|
+
base_url,
|
|
126
|
+
url_variables,
|
|
127
|
+
request,
|
|
128
|
+
request_body_required,
|
|
129
|
+
request_has_path_params,
|
|
130
|
+
request_has_query_params,
|
|
131
|
+
user_agent_header,
|
|
132
|
+
accept_header_value,
|
|
133
|
+
_globals,
|
|
134
|
+
security,
|
|
135
|
+
timeout_ms,
|
|
136
|
+
get_serialized_body,
|
|
137
|
+
url_override,
|
|
138
|
+
http_headers,
|
|
139
|
+
allow_empty_value,
|
|
140
|
+
allowed_fields,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
def _build_request_with_client(
|
|
144
|
+
self,
|
|
145
|
+
client,
|
|
146
|
+
method,
|
|
147
|
+
path,
|
|
148
|
+
base_url,
|
|
149
|
+
url_variables,
|
|
150
|
+
request,
|
|
151
|
+
request_body_required,
|
|
152
|
+
request_has_path_params,
|
|
153
|
+
request_has_query_params,
|
|
154
|
+
user_agent_header,
|
|
155
|
+
accept_header_value,
|
|
156
|
+
_globals=None,
|
|
157
|
+
security=None,
|
|
158
|
+
timeout_ms: Optional[int] = None,
|
|
159
|
+
get_serialized_body: Optional[
|
|
160
|
+
Callable[[], Optional[SerializedRequestBody]]
|
|
161
|
+
] = None,
|
|
162
|
+
url_override: Optional[str] = None,
|
|
163
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
164
|
+
allow_empty_value: Optional[List[str]] = None,
|
|
165
|
+
allowed_fields: Optional[List[str]] = None,
|
|
166
|
+
) -> httpx.Request:
|
|
167
|
+
query_params = {}
|
|
168
|
+
|
|
169
|
+
url = url_override
|
|
170
|
+
if url is None:
|
|
171
|
+
url = utils.generate_url(
|
|
172
|
+
self._get_url(base_url, url_variables),
|
|
173
|
+
path,
|
|
174
|
+
request if request_has_path_params else None,
|
|
175
|
+
_globals if request_has_path_params else None,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
query_params = utils.get_query_params(
|
|
179
|
+
request if request_has_query_params else None,
|
|
180
|
+
_globals if request_has_query_params else None,
|
|
181
|
+
allow_empty_value,
|
|
182
|
+
)
|
|
183
|
+
else:
|
|
184
|
+
# Pick up the query parameter from the override so they can be
|
|
185
|
+
# preserved when building the request later on (necessary as of
|
|
186
|
+
# httpx 0.28).
|
|
187
|
+
parsed_override = urlparse(str(url_override))
|
|
188
|
+
query_params = parse_qs(parsed_override.query, keep_blank_values=True)
|
|
189
|
+
|
|
190
|
+
headers = utils.get_headers(request, _globals)
|
|
191
|
+
headers["Accept"] = accept_header_value
|
|
192
|
+
headers[user_agent_header] = self.sdk_configuration.user_agent
|
|
193
|
+
|
|
194
|
+
if security is not None:
|
|
195
|
+
if callable(security):
|
|
196
|
+
security = security()
|
|
197
|
+
security = utils.get_security_from_env(security, components.Security)
|
|
198
|
+
if security is not None:
|
|
199
|
+
security_headers, security_query_params = utils.get_security(
|
|
200
|
+
security, allowed_fields
|
|
201
|
+
)
|
|
202
|
+
headers = {**headers, **security_headers}
|
|
203
|
+
query_params = {**query_params, **security_query_params}
|
|
204
|
+
|
|
205
|
+
serialized_request_body = SerializedRequestBody()
|
|
206
|
+
if get_serialized_body is not None:
|
|
207
|
+
rb = get_serialized_body()
|
|
208
|
+
if request_body_required and rb is None:
|
|
209
|
+
raise ValueError(messages.REQUEST_BODY_IS_REQUIRED)
|
|
210
|
+
|
|
211
|
+
if rb is not None:
|
|
212
|
+
serialized_request_body = rb
|
|
213
|
+
|
|
214
|
+
if (
|
|
215
|
+
serialized_request_body.media_type is not None
|
|
216
|
+
and serialized_request_body.media_type
|
|
217
|
+
not in (
|
|
218
|
+
"multipart/form-data",
|
|
219
|
+
"multipart/mixed",
|
|
220
|
+
)
|
|
221
|
+
):
|
|
222
|
+
headers["content-type"] = serialized_request_body.media_type
|
|
223
|
+
|
|
224
|
+
# Normalize attribution at the shared sync and async request boundary.
|
|
225
|
+
attribution = {
|
|
226
|
+
"http-referer": "X-Melara-App-Url",
|
|
227
|
+
"x-title": "X-Melara-App-Name",
|
|
228
|
+
}
|
|
229
|
+
request_headers = httpx.Headers(headers)
|
|
230
|
+
if http_headers is not None:
|
|
231
|
+
explicit_headers = {header.lower() for header in http_headers}
|
|
232
|
+
for header, value in http_headers.items():
|
|
233
|
+
canonical = attribution.get(header.lower())
|
|
234
|
+
if canonical is not None and canonical.lower() in explicit_headers:
|
|
235
|
+
continue
|
|
236
|
+
request_headers[canonical or header] = value
|
|
237
|
+
|
|
238
|
+
timeout = timeout_ms / 1000 if timeout_ms is not None else None
|
|
239
|
+
|
|
240
|
+
return client.build_request(
|
|
241
|
+
method,
|
|
242
|
+
url,
|
|
243
|
+
params=query_params,
|
|
244
|
+
content=serialized_request_body.content,
|
|
245
|
+
data=serialized_request_body.data,
|
|
246
|
+
files=serialized_request_body.files,
|
|
247
|
+
headers=request_headers,
|
|
248
|
+
timeout=timeout if timeout is not None else httpx.USE_CLIENT_DEFAULT,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
def do_request(
|
|
252
|
+
self,
|
|
253
|
+
hook_ctx: HookContext,
|
|
254
|
+
request: httpx.Request,
|
|
255
|
+
is_error_status_code: Callable[[int], bool],
|
|
256
|
+
stream: bool = False,
|
|
257
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
|
258
|
+
) -> httpx.Response:
|
|
259
|
+
client = self.sdk_configuration.client
|
|
260
|
+
logger = self.sdk_configuration.debug_logger
|
|
261
|
+
|
|
262
|
+
hooks = self.sdk_configuration.__dict__["_hooks"]
|
|
263
|
+
|
|
264
|
+
def do():
|
|
265
|
+
http_res = None
|
|
266
|
+
try:
|
|
267
|
+
req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
|
|
268
|
+
if "timeout" in request.extensions and "timeout" not in req.extensions:
|
|
269
|
+
req.extensions["timeout"] = request.extensions["timeout"]
|
|
270
|
+
logger.debug(
|
|
271
|
+
messages.REQUEST_METHOD_S_URL_S_HEADERS_S_BODY_S,
|
|
272
|
+
req.method,
|
|
273
|
+
req.url,
|
|
274
|
+
req.headers,
|
|
275
|
+
get_body_content(req),
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
if client is None:
|
|
279
|
+
raise ValueError(messages.CLIENT_IS_REQUIRED)
|
|
280
|
+
|
|
281
|
+
http_res = client.send(req, stream=stream)
|
|
282
|
+
except Exception as e:
|
|
283
|
+
_, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
|
|
284
|
+
if e is not None:
|
|
285
|
+
logger.debug(messages.REQUEST_EXCEPTION, exc_info=True)
|
|
286
|
+
raise e
|
|
287
|
+
|
|
288
|
+
if http_res is None:
|
|
289
|
+
logger.debug(messages.RAISING_NO_RESPONSE_SDK_ERROR)
|
|
290
|
+
raise errors.NoResponseError(messages.NO_RESPONSE_RECEIVED)
|
|
291
|
+
|
|
292
|
+
logger.debug(
|
|
293
|
+
messages.RESPONSE_STATUS_CODE_S_URL_S_HEADERS_S_BODY,
|
|
294
|
+
http_res.status_code,
|
|
295
|
+
http_res.url,
|
|
296
|
+
http_res.headers,
|
|
297
|
+
messages.STREAMING_RESPONSE if stream else http_res.text,
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
return http_res
|
|
301
|
+
|
|
302
|
+
if retry_config is not None:
|
|
303
|
+
http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1]))
|
|
304
|
+
else:
|
|
305
|
+
http_res = do()
|
|
306
|
+
|
|
307
|
+
if is_error_status_code(http_res.status_code):
|
|
308
|
+
result, err = hooks.after_error(AfterErrorContext(hook_ctx), http_res, None)
|
|
309
|
+
if err is not None:
|
|
310
|
+
logger.debug(messages.REQUEST_EXCEPTION, exc_info=True)
|
|
311
|
+
raise err
|
|
312
|
+
if result is not None:
|
|
313
|
+
http_res = result
|
|
314
|
+
else:
|
|
315
|
+
logger.debug(messages.RAISING_UNEXPECTED_SDK_ERROR)
|
|
316
|
+
raise errors.MelaraDefaultError(
|
|
317
|
+
messages.UNEXPECTED_ERROR_OCCURRED, http_res
|
|
318
|
+
)
|
|
319
|
+
else:
|
|
320
|
+
http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
|
|
321
|
+
|
|
322
|
+
return http_res
|
|
323
|
+
|
|
324
|
+
async def do_request_async(
|
|
325
|
+
self,
|
|
326
|
+
hook_ctx: HookContext,
|
|
327
|
+
request: httpx.Request,
|
|
328
|
+
is_error_status_code: Callable[[int], bool],
|
|
329
|
+
stream: bool = False,
|
|
330
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
|
331
|
+
) -> httpx.Response:
|
|
332
|
+
client = self.sdk_configuration.async_client
|
|
333
|
+
logger = self.sdk_configuration.debug_logger
|
|
334
|
+
|
|
335
|
+
hooks = self.sdk_configuration.__dict__["_hooks"]
|
|
336
|
+
|
|
337
|
+
async def do():
|
|
338
|
+
http_res = None
|
|
339
|
+
try:
|
|
340
|
+
req = await run_sync_in_thread(
|
|
341
|
+
hooks.before_request, BeforeRequestContext(hook_ctx), request
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
if "timeout" in request.extensions and "timeout" not in req.extensions:
|
|
345
|
+
req.extensions["timeout"] = request.extensions["timeout"]
|
|
346
|
+
logger.debug(
|
|
347
|
+
messages.REQUEST_METHOD_S_URL_S_HEADERS_S_BODY_S,
|
|
348
|
+
req.method,
|
|
349
|
+
req.url,
|
|
350
|
+
req.headers,
|
|
351
|
+
get_body_content(req),
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
if client is None:
|
|
355
|
+
raise ValueError(messages.CLIENT_IS_REQUIRED)
|
|
356
|
+
|
|
357
|
+
http_res = await client.send(req, stream=stream)
|
|
358
|
+
except Exception as e:
|
|
359
|
+
_, e = await run_sync_in_thread(
|
|
360
|
+
hooks.after_error, AfterErrorContext(hook_ctx), None, e
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
if e is not None:
|
|
364
|
+
logger.debug(messages.REQUEST_EXCEPTION, exc_info=True)
|
|
365
|
+
raise e
|
|
366
|
+
|
|
367
|
+
if http_res is None:
|
|
368
|
+
logger.debug(messages.RAISING_NO_RESPONSE_SDK_ERROR)
|
|
369
|
+
raise errors.NoResponseError(messages.NO_RESPONSE_RECEIVED)
|
|
370
|
+
|
|
371
|
+
logger.debug(
|
|
372
|
+
messages.RESPONSE_STATUS_CODE_S_URL_S_HEADERS_S_BODY,
|
|
373
|
+
http_res.status_code,
|
|
374
|
+
http_res.url,
|
|
375
|
+
http_res.headers,
|
|
376
|
+
messages.STREAMING_RESPONSE if stream else http_res.text,
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
return http_res
|
|
380
|
+
|
|
381
|
+
if retry_config is not None:
|
|
382
|
+
http_res = await utils.retry_async(
|
|
383
|
+
do, utils.Retries(retry_config[0], retry_config[1])
|
|
384
|
+
)
|
|
385
|
+
else:
|
|
386
|
+
http_res = await do()
|
|
387
|
+
|
|
388
|
+
if is_error_status_code(http_res.status_code):
|
|
389
|
+
result, err = await run_sync_in_thread(
|
|
390
|
+
hooks.after_error, AfterErrorContext(hook_ctx), http_res, None
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
if err is not None:
|
|
394
|
+
logger.debug(messages.REQUEST_EXCEPTION, exc_info=True)
|
|
395
|
+
raise err
|
|
396
|
+
if result is not None:
|
|
397
|
+
http_res = result
|
|
398
|
+
else:
|
|
399
|
+
logger.debug(messages.RAISING_UNEXPECTED_SDK_ERROR)
|
|
400
|
+
raise errors.MelaraDefaultError(
|
|
401
|
+
messages.UNEXPECTED_ERROR_OCCURRED, http_res
|
|
402
|
+
)
|
|
403
|
+
else:
|
|
404
|
+
http_res = await run_sync_in_thread(
|
|
405
|
+
hooks.after_success, AfterSuccessContext(hook_ctx), http_res
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
return http_res
|
melara/beta.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Modified for Melara under Apache-2.0.
|
|
2
|
+
"""Code generated by Speakeasy (https://speakeasy.com)."""
|
|
3
|
+
|
|
4
|
+
from .basesdk import BaseSDK
|
|
5
|
+
from .sdkconfiguration import SDKConfiguration
|
|
6
|
+
from melara.beta_responses import BetaResponses
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Beta(BaseSDK):
|
|
11
|
+
responses: BetaResponses
|
|
12
|
+
r"""Deprecated alias for responses endpoints. Use responses instead. Scheduled for removal (sunset date TBD)."""
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self, sdk_config: SDKConfiguration, parent_ref: Optional[object] = None
|
|
16
|
+
) -> None:
|
|
17
|
+
BaseSDK.__init__(self, sdk_config, parent_ref=parent_ref)
|
|
18
|
+
self.sdk_configuration = sdk_config
|
|
19
|
+
self._init_sdks()
|
|
20
|
+
|
|
21
|
+
def _init_sdks(self):
|
|
22
|
+
self.responses = BetaResponses(
|
|
23
|
+
self.sdk_configuration, parent_ref=self.parent_ref
|
|
24
|
+
)
|
melara/beta_responses.py
ADDED