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.
- egain_api_python/__init__.py +17 -0
- egain_api_python/_hooks/__init__.py +5 -0
- egain_api_python/_hooks/registration.py +13 -0
- egain_api_python/_hooks/sdkhooks.py +76 -0
- egain_api_python/_hooks/types.py +112 -0
- egain_api_python/_version.py +15 -0
- egain_api_python/aiservices.py +23 -0
- egain_api_python/answers.py +281 -0
- egain_api_python/articlelists.py +469 -0
- egain_api_python/basesdk.py +368 -0
- egain_api_python/connectorssearchevents.py +537 -0
- egain_api_python/content.py +23 -0
- egain_api_python/errors/__init__.py +78 -0
- egain_api_python/errors/egaindefaulterror.py +40 -0
- egain_api_python/errors/egainerror.py +30 -0
- egain_api_python/errors/gethealthop.py +74 -0
- egain_api_python/errors/no_response_error.py +17 -0
- egain_api_python/errors/responsevalidationerror.py +27 -0
- egain_api_python/errors/schemas_wserrorcommon.py +51 -0
- egain_api_python/errors/wserrorcommon.py +49 -0
- egain_api_python/escalation.py +955 -0
- egain_api_python/export.py +487 -0
- egain_api_python/federatedsearchevent.py +287 -0
- egain_api_python/general.py +925 -0
- egain_api_python/guidedhelp.py +3373 -0
- egain_api_python/health.py +253 -0
- egain_api_python/httpclient.py +125 -0
- egain_api_python/import_.py +1161 -0
- egain_api_python/models/__init__.py +2136 -0
- egain_api_python/models/acceptghsolutionop.py +52 -0
- egain_api_python/models/acceptlanguage.py +23 -0
- egain_api_python/models/accessibleportal.py +37 -0
- egain_api_python/models/action.py +56 -0
- egain_api_python/models/actionsearch.py +92 -0
- egain_api_python/models/addasreferenceop.py +52 -0
- egain_api_python/models/addbookmarkop.py +43 -0
- egain_api_python/models/additionalsnippets.py +57 -0
- egain_api_python/models/addtoreplyop.py +52 -0
- egain_api_python/models/aisearchop.py +131 -0
- egain_api_python/models/aisearchresponse.py +67 -0
- egain_api_python/models/allaccessibleportals.py +28 -0
- egain_api_python/models/answer.py +21 -0
- egain_api_python/models/answeredquestion.py +125 -0
- egain_api_python/models/answerrange.py +41 -0
- egain_api_python/models/answersrequest.py +78 -0
- egain_api_python/models/answersresponse.py +93 -0
- egain_api_python/models/article.py +241 -0
- egain_api_python/models/articleactivitylink.py +62 -0
- egain_api_python/models/articleadditionalattributes.py +23 -0
- egain_api_python/models/articleaisearchresult.py +254 -0
- egain_api_python/models/articleattachment.py +44 -0
- egain_api_python/models/articlelist.py +48 -0
- egain_api_python/models/articlelistresult.py +38 -0
- egain_api_python/models/articlelistsresult.py +22 -0
- egain_api_python/models/articlepermissions.py +25 -0
- egain_api_python/models/articlepermissionsresult.py +27 -0
- egain_api_python/models/articlerating.py +51 -0
- egain_api_python/models/articleratingsresponse.py +28 -0
- egain_api_python/models/articleresult.py +159 -0
- egain_api_python/models/articleresultadditionalattributes.py +22 -0
- egain_api_python/models/articleresults.py +32 -0
- egain_api_python/models/articlesearchresult.py +243 -0
- egain_api_python/models/articlesearchresults.py +32 -0
- egain_api_python/models/articlesort.py +11 -0
- egain_api_python/models/articlesortorder.py +11 -0
- egain_api_python/models/articletype.py +56 -0
- egain_api_python/models/articlewitheditions.py +227 -0
- egain_api_python/models/attachment.py +31 -0
- egain_api_python/models/attachmentadditionalattributes.py +10 -0
- egain_api_python/models/attachmentcontent.py +57 -0
- egain_api_python/models/attachmentcontentresult.py +22 -0
- egain_api_python/models/attachmentforcreatesuggestion.py +25 -0
- egain_api_python/models/attachments.py +35 -0
- egain_api_python/models/attachmentsummary.py +37 -0
- egain_api_python/models/attachmentupload.py +20 -0
- egain_api_python/models/avertcustomerescalationop.py +44 -0
- egain_api_python/models/bookmark.py +57 -0
- egain_api_python/models/bookmarkresult.py +26 -0
- egain_api_python/models/bookmarkstatus.py +34 -0
- egain_api_python/models/case.py +158 -0
- egain_api_python/models/caseadditionalattributes.py +11 -0
- egain_api_python/models/caseanswer.py +21 -0
- egain_api_python/models/casebase.py +67 -0
- egain_api_python/models/casebaseresult.py +28 -0
- egain_api_python/models/casebasesearchsettings.py +26 -0
- egain_api_python/models/caselistresult.py +74 -0
- egain_api_python/models/caselistresults.py +28 -0
- egain_api_python/models/casequestion.py +16 -0
- egain_api_python/models/casequestiondetail.py +29 -0
- egain_api_python/models/casesearch.py +80 -0
- egain_api_python/models/clusterid.py +16 -0
- egain_api_python/models/clusterresult.py +37 -0
- egain_api_python/models/clusterresults.py +28 -0
- egain_api_python/models/comment.py +33 -0
- egain_api_python/models/comments.py +26 -0
- egain_api_python/models/completecustomerescalationop.py +44 -0
- egain_api_python/models/compliancearticleresult.py +166 -0
- egain_api_python/models/compliancearticleresultadditionalattributes.py +22 -0
- egain_api_python/models/compliancearticleresults.py +35 -0
- egain_api_python/models/complianceforarticle.py +59 -0
- egain_api_python/models/complyarticleop.py +40 -0
- egain_api_python/models/components_schemas_tag.py +25 -0
- egain_api_python/models/components_schemas_tagcategory.py +39 -0
- egain_api_python/models/components_schemas_taggroup.py +25 -0
- egain_api_python/models/configurableattribute.py +25 -0
- egain_api_python/models/configurableattributes.py +15 -0
- egain_api_python/models/contactperson.py +43 -0
- egain_api_python/models/contacts.py +21 -0
- egain_api_python/models/createbookmark.py +64 -0
- egain_api_python/models/createdby.py +37 -0
- egain_api_python/models/createfederatedsearchevent.py +85 -0
- egain_api_python/models/createfederatedsearchresulteventop.py +46 -0
- egain_api_python/models/createimportop.py +20 -0
- egain_api_python/models/createimportvalidationop.py +20 -0
- egain_api_python/models/createquickpick.py +34 -0
- egain_api_python/models/createquickpickop.py +55 -0
- egain_api_python/models/createsearchresulteventforconnectors.py +71 -0
- egain_api_python/models/createsearchresulteventforconnectorsop.py +48 -0
- egain_api_python/models/createsignedurlop.py +29 -0
- egain_api_python/models/createsuggestion.py +126 -0
- egain_api_python/models/createviewedsearchresulteventforconnectors.py +76 -0
- egain_api_python/models/createviewedsearchresultseventforconnectorsop.py +48 -0
- egain_api_python/models/customattribute.py +35 -0
- egain_api_python/models/deletebookmarkop.py +40 -0
- egain_api_python/models/deletesuggestionop.py +40 -0
- egain_api_python/models/department.py +21 -0
- egain_api_python/models/detailfield.py +32 -0
- egain_api_python/models/displayfield.py +27 -0
- egain_api_python/models/dynamiccluster.py +21 -0
- egain_api_python/models/dynamicsearch.py +40 -0
- egain_api_python/models/edition.py +79 -0
- egain_api_python/models/editionwithcontent.py +68 -0
- egain_api_python/models/email.py +21 -0
- egain_api_python/models/exportcontentop.py +14 -0
- egain_api_python/models/exportstatus.py +106 -0
- egain_api_python/models/exportstatusop.py +31 -0
- egain_api_python/models/feedbackarticleforsuggestion.py +34 -0
- egain_api_python/models/folderbreadcrumb.py +24 -0
- egain_api_python/models/foldersummary.py +29 -0
- egain_api_python/models/getacknowledgedcompliancearticlesop.py +119 -0
- egain_api_python/models/getallarticlelistsop.py +47 -0
- egain_api_python/models/getallcasebasesreleasesop.py +65 -0
- egain_api_python/models/getallcasesop.py +83 -0
- egain_api_python/models/getallportalsop.py +60 -0
- egain_api_python/models/getallprofilesinportalop.py +64 -0
- egain_api_python/models/getallquickpicksop.py +83 -0
- egain_api_python/models/getalltopicsop.py +132 -0
- egain_api_python/models/getalluserprofilesop.py +47 -0
- egain_api_python/models/getancestortopicsop.py +133 -0
- egain_api_python/models/getannouncementarticlesop.py +134 -0
- egain_api_python/models/getarticleattachmentbyidop.py +31 -0
- egain_api_python/models/getarticlebyidop.py +257 -0
- egain_api_python/models/getarticlebyidwitheditionsop.py +46 -0
- egain_api_python/models/getarticleeditiondetailsop.py +55 -0
- egain_api_python/models/getarticlelistdetailsop.py +115 -0
- egain_api_python/models/getarticlepermissionsbyidop.py +40 -0
- egain_api_python/models/getarticlepersonalizationop.py +73 -0
- egain_api_python/models/getarticleratingsop.py +74 -0
- egain_api_python/models/getarticlesintopicop.py +172 -0
- egain_api_python/models/getattachmentbyidinportalop.py +56 -0
- egain_api_python/models/getbookmarkop.py +31 -0
- egain_api_python/models/getcasebasereleasebyidop.py +64 -0
- egain_api_python/models/getcasebyidop.py +75 -0
- egain_api_python/models/getchildtopicsop.py +150 -0
- egain_api_python/models/getclusterbycasebasereleaseidop.py +74 -0
- egain_api_python/models/gethealthop.py +130 -0
- egain_api_python/models/getimportcontentop.py +46 -0
- egain_api_python/models/getmyportalsop.py +97 -0
- egain_api_python/models/getmysubscriptionop.py +115 -0
- egain_api_python/models/getpendingcompliancearticlesop.py +119 -0
- egain_api_python/models/getpopulararticlesop.py +133 -0
- egain_api_python/models/getportaldetailsbyidop.py +47 -0
- egain_api_python/models/getrelatedarticlesforsuggestionop.py +96 -0
- egain_api_python/models/getrelatedarticlesop.py +143 -0
- egain_api_python/models/getsuggestionattachmentbyidop.py +76 -0
- egain_api_python/models/getsuggestionattachmentsop.py +40 -0
- egain_api_python/models/getsuggestioncommentsop.py +40 -0
- egain_api_python/models/getsuggestionop.py +107 -0
- egain_api_python/models/gettagcategoriesforinterestforportalop.py +46 -0
- egain_api_python/models/gettopicbreadcrumbforarticleop.py +55 -0
- egain_api_python/models/getuserdetailsop.py +22 -0
- egain_api_python/models/getusermilestonesop.py +22 -0
- egain_api_python/models/ghsearchrequest.py +67 -0
- egain_api_python/models/ghsearchresult.py +75 -0
- egain_api_python/models/ghstepsearchrequest.py +64 -0
- egain_api_python/models/image.py +17 -0
- egain_api_python/models/importcontent.py +79 -0
- egain_api_python/models/importstatus.py +29 -0
- egain_api_python/models/kblanguage.py +63 -0
- egain_api_python/models/kblanguagecode.py +48 -0
- egain_api_python/models/kblanguages.py +22 -0
- egain_api_python/models/knowledgeexport.py +237 -0
- egain_api_python/models/l10nstring.py +22 -0
- egain_api_python/models/languagecode.py +39 -0
- egain_api_python/models/languagecode_parameter.py +39 -0
- egain_api_python/models/languagequeryparameter.py +39 -0
- egain_api_python/models/link.py +25 -0
- egain_api_python/models/makesuggestionop.py +44 -0
- egain_api_python/models/mandatorylanguagequeryparameter.py +38 -0
- egain_api_python/models/metadata.py +29 -0
- egain_api_python/models/milestone.py +21 -0
- egain_api_python/models/milestonename.py +26 -0
- egain_api_python/models/milestones.py +21 -0
- egain_api_python/models/modifiedby.py +37 -0
- egain_api_python/models/modifysuggestion.py +78 -0
- egain_api_python/models/modifysuggestionsop.py +44 -0
- egain_api_python/models/optionalarticleattributes.py +20 -0
- egain_api_python/models/order.py +10 -0
- egain_api_python/models/ownedby.py +37 -0
- egain_api_python/models/paginationinfo.py +32 -0
- egain_api_python/models/patchimportcontentvalidationop.py +46 -0
- egain_api_python/models/personalization.py +67 -0
- egain_api_python/models/phone.py +21 -0
- egain_api_python/models/portal.py +102 -0
- egain_api_python/models/portalresult.py +28 -0
- egain_api_python/models/portalsettings.py +398 -0
- egain_api_python/models/post_portalid_answersop.py +88 -0
- egain_api_python/models/post_portalid_retrieveop.py +88 -0
- egain_api_python/models/profile.py +26 -0
- egain_api_python/models/profileresult.py +24 -0
- egain_api_python/models/publishprofile.py +30 -0
- egain_api_python/models/publishview.py +38 -0
- egain_api_python/models/question.py +101 -0
- egain_api_python/models/questionandanswer.py +26 -0
- egain_api_python/models/quickpickrating.py +32 -0
- egain_api_python/models/quickpickresult.py +38 -0
- egain_api_python/models/quickpickresults.py +28 -0
- egain_api_python/models/ratearticleop.py +71 -0
- egain_api_python/models/referenceresponse.py +80 -0
- egain_api_python/models/rejectghsolutionop.py +52 -0
- egain_api_python/models/relatedquestions.py +28 -0
- egain_api_python/models/resourcetype_parameter.py +10 -0
- egain_api_python/models/restorequickpickop.py +63 -0
- egain_api_python/models/retrieverequest.py +47 -0
- egain_api_python/models/retrieveresponse.py +96 -0
- egain_api_python/models/role.py +26 -0
- egain_api_python/models/roletemplate.py +25 -0
- egain_api_python/models/schemas_answer.py +94 -0
- egain_api_python/models/schemas_customattribute.py +35 -0
- egain_api_python/models/schemas_link.py +27 -0
- egain_api_python/models/schemas_tag.py +21 -0
- egain_api_python/models/schemas_tagcategory.py +75 -0
- egain_api_python/models/schemas_taggroup.py +31 -0
- egain_api_python/models/schemas_tags.py +19 -0
- egain_api_python/models/schemas_wserrorcommon.py +17 -0
- egain_api_python/models/searchfilterattribute.py +61 -0
- egain_api_python/models/searchpriortoescalationop.py +108 -0
- egain_api_python/models/searchresult.py +101 -0
- egain_api_python/models/searchsuggestionop.py +93 -0
- egain_api_python/models/security.py +25 -0
- egain_api_python/models/selectuserprofileop.py +44 -0
- egain_api_python/models/sessioncontextvariable.py +17 -0
- egain_api_python/models/shorturl.py +32 -0
- egain_api_python/models/sortidname.py +10 -0
- egain_api_python/models/sortidnamedepartment.py +11 -0
- egain_api_python/models/stage.py +26 -0
- egain_api_python/models/startcustomerescalationop.py +66 -0
- egain_api_python/models/startescalationrequest.py +94 -0
- egain_api_python/models/startghsearchop.py +74 -0
- egain_api_python/models/startquestionandanswer.py +26 -0
- egain_api_python/models/stepghsearchop.py +62 -0
- egain_api_python/models/stringattributevalue.py +30 -0
- egain_api_python/models/structuredauthoringfields.py +33 -0
- egain_api_python/models/subscribearticleop.py +40 -0
- egain_api_python/models/suggestion.py +190 -0
- egain_api_python/models/suggestionadditionalattributes.py +11 -0
- egain_api_python/models/suggestionattachment.py +46 -0
- egain_api_python/models/suggestions.py +28 -0
- egain_api_python/models/tag.py +17 -0
- egain_api_python/models/tagcategoriesforinterest.py +22 -0
- egain_api_python/models/tagcategory.py +34 -0
- egain_api_python/models/taggroup.py +17 -0
- egain_api_python/models/taggroups.py +20 -0
- egain_api_python/models/tags.py +17 -0
- egain_api_python/models/topic.py +113 -0
- egain_api_python/models/topicadditionalattributes.py +20 -0
- egain_api_python/models/topicaisearchresult.py +67 -0
- egain_api_python/models/topicbreadcrumb.py +24 -0
- egain_api_python/models/topicresult.py +26 -0
- egain_api_python/models/topicsummary.py +31 -0
- egain_api_python/models/topictreenode.py +27 -0
- egain_api_python/models/topictreeresult.py +28 -0
- egain_api_python/models/unsubscribearticleop.py +55 -0
- egain_api_python/models/uploadattachmentop.py +36 -0
- egain_api_python/models/userdetails.py +44 -0
- egain_api_python/models/userprofile.py +33 -0
- egain_api_python/models/userprofiles.py +21 -0
- egain_api_python/models/userview.py +33 -0
- egain_api_python/models/validateimportcontent.py +58 -0
- egain_api_python/models/virtualcase.py +52 -0
- egain_api_python/models/workflow.py +21 -0
- egain_api_python/models/workflowmilestone.py +11 -0
- egain_api_python/models/wserrorcommon.py +17 -0
- egain_api_python/populararticles.py +287 -0
- egain_api_python/portal_article.py +4935 -0
- egain_api_python/portal_attachment.py +494 -0
- egain_api_python/portal_bookmark.py +707 -0
- egain_api_python/portal_sdk.py +88 -0
- egain_api_python/portal_suggestion.py +2283 -0
- egain_api_python/portal_topic.py +975 -0
- egain_api_python/portal_userdetails.py +211 -0
- egain_api_python/portal_userprofile.py +431 -0
- egain_api_python/py.typed +1 -0
- egain_api_python/retrieve.py +265 -0
- egain_api_python/sdk.py +216 -0
- egain_api_python/sdkconfiguration.py +50 -0
- egain_api_python/search.py +251 -0
- egain_api_python/types/__init__.py +21 -0
- egain_api_python/types/basemodel.py +39 -0
- egain_api_python/usermilestones.py +219 -0
- egain_api_python/utils/__init__.py +200 -0
- egain_api_python/utils/annotations.py +79 -0
- egain_api_python/utils/datetimes.py +23 -0
- egain_api_python/utils/enums.py +74 -0
- egain_api_python/utils/eventstreaming.py +248 -0
- egain_api_python/utils/forms.py +223 -0
- egain_api_python/utils/headers.py +136 -0
- egain_api_python/utils/logger.py +27 -0
- egain_api_python/utils/metadata.py +118 -0
- egain_api_python/utils/queryparams.py +205 -0
- egain_api_python/utils/requestbodies.py +66 -0
- egain_api_python/utils/retries.py +217 -0
- egain_api_python/utils/security.py +192 -0
- egain_api_python/utils/serializers.py +249 -0
- egain_api_python/utils/unmarshal_json_response.py +24 -0
- egain_api_python/utils/url.py +155 -0
- egain_api_python/utils/values.py +137 -0
- egain_api_python-0.1.1.dist-info/METADATA +827 -0
- egain_api_python-0.1.1.dist-info/RECORD +332 -0
- egain_api_python-0.1.1.dist-info/WHEEL +5 -0
- egain_api_python-0.1.1.dist-info/licenses/LICENSE +21 -0
- egain_api_python-0.1.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,368 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from .sdkconfiguration import SDKConfiguration
|
4
|
+
from egain_api_python import errors, models, utils
|
5
|
+
from egain_api_python._hooks import (
|
6
|
+
AfterErrorContext,
|
7
|
+
AfterSuccessContext,
|
8
|
+
BeforeRequestContext,
|
9
|
+
)
|
10
|
+
from egain_api_python.utils import RetryConfig, SerializedRequestBody, get_body_content
|
11
|
+
import httpx
|
12
|
+
from typing import Callable, List, Mapping, Optional, Tuple
|
13
|
+
from urllib.parse import parse_qs, urlparse
|
14
|
+
|
15
|
+
|
16
|
+
class BaseSDK:
|
17
|
+
sdk_configuration: SDKConfiguration
|
18
|
+
parent_ref: Optional[object] = None
|
19
|
+
"""
|
20
|
+
Reference to the root SDK instance, if any. This will prevent it from
|
21
|
+
being garbage collected while there are active streams.
|
22
|
+
"""
|
23
|
+
|
24
|
+
def __init__(
|
25
|
+
self,
|
26
|
+
sdk_config: SDKConfiguration,
|
27
|
+
parent_ref: Optional[object] = None,
|
28
|
+
) -> None:
|
29
|
+
self.sdk_configuration = sdk_config
|
30
|
+
self.parent_ref = parent_ref
|
31
|
+
|
32
|
+
def _get_url(self, base_url, url_variables):
|
33
|
+
sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
|
34
|
+
|
35
|
+
if base_url is None:
|
36
|
+
base_url = sdk_url
|
37
|
+
|
38
|
+
if url_variables is None:
|
39
|
+
url_variables = sdk_variables
|
40
|
+
|
41
|
+
return utils.template_url(base_url, url_variables)
|
42
|
+
|
43
|
+
def _build_request_async(
|
44
|
+
self,
|
45
|
+
method,
|
46
|
+
path,
|
47
|
+
base_url,
|
48
|
+
url_variables,
|
49
|
+
request,
|
50
|
+
request_body_required,
|
51
|
+
request_has_path_params,
|
52
|
+
request_has_query_params,
|
53
|
+
user_agent_header,
|
54
|
+
accept_header_value,
|
55
|
+
_globals=None,
|
56
|
+
security=None,
|
57
|
+
timeout_ms: Optional[int] = None,
|
58
|
+
get_serialized_body: Optional[
|
59
|
+
Callable[[], Optional[SerializedRequestBody]]
|
60
|
+
] = None,
|
61
|
+
url_override: Optional[str] = None,
|
62
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
63
|
+
) -> httpx.Request:
|
64
|
+
client = self.sdk_configuration.async_client
|
65
|
+
return self._build_request_with_client(
|
66
|
+
client,
|
67
|
+
method,
|
68
|
+
path,
|
69
|
+
base_url,
|
70
|
+
url_variables,
|
71
|
+
request,
|
72
|
+
request_body_required,
|
73
|
+
request_has_path_params,
|
74
|
+
request_has_query_params,
|
75
|
+
user_agent_header,
|
76
|
+
accept_header_value,
|
77
|
+
_globals,
|
78
|
+
security,
|
79
|
+
timeout_ms,
|
80
|
+
get_serialized_body,
|
81
|
+
url_override,
|
82
|
+
http_headers,
|
83
|
+
)
|
84
|
+
|
85
|
+
def _build_request(
|
86
|
+
self,
|
87
|
+
method,
|
88
|
+
path,
|
89
|
+
base_url,
|
90
|
+
url_variables,
|
91
|
+
request,
|
92
|
+
request_body_required,
|
93
|
+
request_has_path_params,
|
94
|
+
request_has_query_params,
|
95
|
+
user_agent_header,
|
96
|
+
accept_header_value,
|
97
|
+
_globals=None,
|
98
|
+
security=None,
|
99
|
+
timeout_ms: Optional[int] = None,
|
100
|
+
get_serialized_body: Optional[
|
101
|
+
Callable[[], Optional[SerializedRequestBody]]
|
102
|
+
] = None,
|
103
|
+
url_override: Optional[str] = None,
|
104
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
105
|
+
) -> httpx.Request:
|
106
|
+
client = self.sdk_configuration.client
|
107
|
+
return self._build_request_with_client(
|
108
|
+
client,
|
109
|
+
method,
|
110
|
+
path,
|
111
|
+
base_url,
|
112
|
+
url_variables,
|
113
|
+
request,
|
114
|
+
request_body_required,
|
115
|
+
request_has_path_params,
|
116
|
+
request_has_query_params,
|
117
|
+
user_agent_header,
|
118
|
+
accept_header_value,
|
119
|
+
_globals,
|
120
|
+
security,
|
121
|
+
timeout_ms,
|
122
|
+
get_serialized_body,
|
123
|
+
url_override,
|
124
|
+
http_headers,
|
125
|
+
)
|
126
|
+
|
127
|
+
def _build_request_with_client(
|
128
|
+
self,
|
129
|
+
client,
|
130
|
+
method,
|
131
|
+
path,
|
132
|
+
base_url,
|
133
|
+
url_variables,
|
134
|
+
request,
|
135
|
+
request_body_required,
|
136
|
+
request_has_path_params,
|
137
|
+
request_has_query_params,
|
138
|
+
user_agent_header,
|
139
|
+
accept_header_value,
|
140
|
+
_globals=None,
|
141
|
+
security=None,
|
142
|
+
timeout_ms: Optional[int] = None,
|
143
|
+
get_serialized_body: Optional[
|
144
|
+
Callable[[], Optional[SerializedRequestBody]]
|
145
|
+
] = None,
|
146
|
+
url_override: Optional[str] = None,
|
147
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
148
|
+
) -> httpx.Request:
|
149
|
+
query_params = {}
|
150
|
+
|
151
|
+
url = url_override
|
152
|
+
if url is None:
|
153
|
+
url = utils.generate_url(
|
154
|
+
self._get_url(base_url, url_variables),
|
155
|
+
path,
|
156
|
+
request if request_has_path_params else None,
|
157
|
+
_globals if request_has_path_params else None,
|
158
|
+
)
|
159
|
+
|
160
|
+
query_params = utils.get_query_params(
|
161
|
+
request if request_has_query_params else None,
|
162
|
+
_globals if request_has_query_params else None,
|
163
|
+
)
|
164
|
+
else:
|
165
|
+
# Pick up the query parameter from the override so they can be
|
166
|
+
# preserved when building the request later on (necessary as of
|
167
|
+
# httpx 0.28).
|
168
|
+
parsed_override = urlparse(str(url_override))
|
169
|
+
query_params = parse_qs(parsed_override.query, keep_blank_values=True)
|
170
|
+
|
171
|
+
headers = utils.get_headers(request, _globals)
|
172
|
+
headers["Accept"] = accept_header_value
|
173
|
+
headers[user_agent_header] = self.sdk_configuration.user_agent
|
174
|
+
|
175
|
+
if security is not None:
|
176
|
+
if callable(security):
|
177
|
+
security = security()
|
178
|
+
security = utils.get_security_from_env(security, models.Security)
|
179
|
+
if security is not None:
|
180
|
+
security_headers, security_query_params = utils.get_security(security)
|
181
|
+
headers = {**headers, **security_headers}
|
182
|
+
query_params = {**query_params, **security_query_params}
|
183
|
+
|
184
|
+
serialized_request_body = SerializedRequestBody()
|
185
|
+
if get_serialized_body is not None:
|
186
|
+
rb = get_serialized_body()
|
187
|
+
if request_body_required and rb is None:
|
188
|
+
raise ValueError("request body is required")
|
189
|
+
|
190
|
+
if rb is not None:
|
191
|
+
serialized_request_body = rb
|
192
|
+
|
193
|
+
if (
|
194
|
+
serialized_request_body.media_type is not None
|
195
|
+
and serialized_request_body.media_type
|
196
|
+
not in (
|
197
|
+
"multipart/form-data",
|
198
|
+
"multipart/mixed",
|
199
|
+
)
|
200
|
+
):
|
201
|
+
headers["content-type"] = serialized_request_body.media_type
|
202
|
+
|
203
|
+
if http_headers is not None:
|
204
|
+
for header, value in http_headers.items():
|
205
|
+
headers[header] = value
|
206
|
+
|
207
|
+
timeout = timeout_ms / 1000 if timeout_ms is not None else None
|
208
|
+
|
209
|
+
return client.build_request(
|
210
|
+
method,
|
211
|
+
url,
|
212
|
+
params=query_params,
|
213
|
+
content=serialized_request_body.content,
|
214
|
+
data=serialized_request_body.data,
|
215
|
+
files=serialized_request_body.files,
|
216
|
+
headers=headers,
|
217
|
+
timeout=timeout,
|
218
|
+
)
|
219
|
+
|
220
|
+
def do_request(
|
221
|
+
self,
|
222
|
+
hook_ctx,
|
223
|
+
request,
|
224
|
+
error_status_codes,
|
225
|
+
stream=False,
|
226
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
227
|
+
) -> httpx.Response:
|
228
|
+
client = self.sdk_configuration.client
|
229
|
+
logger = self.sdk_configuration.debug_logger
|
230
|
+
|
231
|
+
hooks = self.sdk_configuration.__dict__["_hooks"]
|
232
|
+
|
233
|
+
def do():
|
234
|
+
http_res = None
|
235
|
+
try:
|
236
|
+
req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
|
237
|
+
logger.debug(
|
238
|
+
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
239
|
+
req.method,
|
240
|
+
req.url,
|
241
|
+
req.headers,
|
242
|
+
get_body_content(req),
|
243
|
+
)
|
244
|
+
|
245
|
+
if client is None:
|
246
|
+
raise ValueError("client is required")
|
247
|
+
|
248
|
+
http_res = client.send(req, stream=stream)
|
249
|
+
except Exception as e:
|
250
|
+
_, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
|
251
|
+
if e is not None:
|
252
|
+
logger.debug("Request Exception", exc_info=True)
|
253
|
+
raise e
|
254
|
+
|
255
|
+
if http_res is None:
|
256
|
+
logger.debug("Raising no response SDK error")
|
257
|
+
raise errors.NoResponseError("No response received")
|
258
|
+
|
259
|
+
logger.debug(
|
260
|
+
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
261
|
+
http_res.status_code,
|
262
|
+
http_res.url,
|
263
|
+
http_res.headers,
|
264
|
+
"<streaming response>" if stream else http_res.text,
|
265
|
+
)
|
266
|
+
|
267
|
+
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
268
|
+
result, err = hooks.after_error(
|
269
|
+
AfterErrorContext(hook_ctx), http_res, None
|
270
|
+
)
|
271
|
+
if err is not None:
|
272
|
+
logger.debug("Request Exception", exc_info=True)
|
273
|
+
raise err
|
274
|
+
if result is not None:
|
275
|
+
http_res = result
|
276
|
+
else:
|
277
|
+
logger.debug("Raising unexpected SDK error")
|
278
|
+
raise errors.EgainDefaultError(
|
279
|
+
"Unexpected error occurred", http_res
|
280
|
+
)
|
281
|
+
|
282
|
+
return http_res
|
283
|
+
|
284
|
+
if retry_config is not None:
|
285
|
+
http_res = utils.retry(do, utils.Retries(retry_config[0], retry_config[1]))
|
286
|
+
else:
|
287
|
+
http_res = do()
|
288
|
+
|
289
|
+
if not utils.match_status_codes(error_status_codes, http_res.status_code):
|
290
|
+
http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
|
291
|
+
|
292
|
+
return http_res
|
293
|
+
|
294
|
+
async def do_request_async(
|
295
|
+
self,
|
296
|
+
hook_ctx,
|
297
|
+
request,
|
298
|
+
error_status_codes,
|
299
|
+
stream=False,
|
300
|
+
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
301
|
+
) -> httpx.Response:
|
302
|
+
client = self.sdk_configuration.async_client
|
303
|
+
logger = self.sdk_configuration.debug_logger
|
304
|
+
|
305
|
+
hooks = self.sdk_configuration.__dict__["_hooks"]
|
306
|
+
|
307
|
+
async def do():
|
308
|
+
http_res = None
|
309
|
+
try:
|
310
|
+
req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
|
311
|
+
logger.debug(
|
312
|
+
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
313
|
+
req.method,
|
314
|
+
req.url,
|
315
|
+
req.headers,
|
316
|
+
get_body_content(req),
|
317
|
+
)
|
318
|
+
|
319
|
+
if client is None:
|
320
|
+
raise ValueError("client is required")
|
321
|
+
|
322
|
+
http_res = await client.send(req, stream=stream)
|
323
|
+
except Exception as e:
|
324
|
+
_, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
|
325
|
+
if e is not None:
|
326
|
+
logger.debug("Request Exception", exc_info=True)
|
327
|
+
raise e
|
328
|
+
|
329
|
+
if http_res is None:
|
330
|
+
logger.debug("Raising no response SDK error")
|
331
|
+
raise errors.NoResponseError("No response received")
|
332
|
+
|
333
|
+
logger.debug(
|
334
|
+
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
335
|
+
http_res.status_code,
|
336
|
+
http_res.url,
|
337
|
+
http_res.headers,
|
338
|
+
"<streaming response>" if stream else http_res.text,
|
339
|
+
)
|
340
|
+
|
341
|
+
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
342
|
+
result, err = hooks.after_error(
|
343
|
+
AfterErrorContext(hook_ctx), http_res, None
|
344
|
+
)
|
345
|
+
if err is not None:
|
346
|
+
logger.debug("Request Exception", exc_info=True)
|
347
|
+
raise err
|
348
|
+
if result is not None:
|
349
|
+
http_res = result
|
350
|
+
else:
|
351
|
+
logger.debug("Raising unexpected SDK error")
|
352
|
+
raise errors.EgainDefaultError(
|
353
|
+
"Unexpected error occurred", http_res
|
354
|
+
)
|
355
|
+
|
356
|
+
return http_res
|
357
|
+
|
358
|
+
if retry_config is not None:
|
359
|
+
http_res = await utils.retry_async(
|
360
|
+
do, utils.Retries(retry_config[0], retry_config[1])
|
361
|
+
)
|
362
|
+
else:
|
363
|
+
http_res = await do()
|
364
|
+
|
365
|
+
if not utils.match_status_codes(error_status_codes, http_res.status_code):
|
366
|
+
http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
|
367
|
+
|
368
|
+
return http_res
|