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,249 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from decimal import Decimal
|
4
|
+
import functools
|
5
|
+
import json
|
6
|
+
import typing
|
7
|
+
from typing import Any, Dict, List, Tuple, Union, get_args
|
8
|
+
import typing_extensions
|
9
|
+
from typing_extensions import get_origin
|
10
|
+
|
11
|
+
import httpx
|
12
|
+
from pydantic import ConfigDict, create_model
|
13
|
+
from pydantic_core import from_json
|
14
|
+
|
15
|
+
from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
|
16
|
+
|
17
|
+
|
18
|
+
def serialize_decimal(as_str: bool):
|
19
|
+
def serialize(d):
|
20
|
+
# Optional[T] is a Union[T, None]
|
21
|
+
if is_union(type(d)) and type(None) in get_args(type(d)) and d is None:
|
22
|
+
return None
|
23
|
+
if isinstance(d, Unset):
|
24
|
+
return d
|
25
|
+
|
26
|
+
if not isinstance(d, Decimal):
|
27
|
+
raise ValueError("Expected Decimal object")
|
28
|
+
|
29
|
+
return str(d) if as_str else float(d)
|
30
|
+
|
31
|
+
return serialize
|
32
|
+
|
33
|
+
|
34
|
+
def validate_decimal(d):
|
35
|
+
if d is None:
|
36
|
+
return None
|
37
|
+
|
38
|
+
if isinstance(d, (Decimal, Unset)):
|
39
|
+
return d
|
40
|
+
|
41
|
+
if not isinstance(d, (str, int, float)):
|
42
|
+
raise ValueError("Expected string, int or float")
|
43
|
+
|
44
|
+
return Decimal(str(d))
|
45
|
+
|
46
|
+
|
47
|
+
def serialize_float(as_str: bool):
|
48
|
+
def serialize(f):
|
49
|
+
# Optional[T] is a Union[T, None]
|
50
|
+
if is_union(type(f)) and type(None) in get_args(type(f)) and f is None:
|
51
|
+
return None
|
52
|
+
if isinstance(f, Unset):
|
53
|
+
return f
|
54
|
+
|
55
|
+
if not isinstance(f, float):
|
56
|
+
raise ValueError("Expected float")
|
57
|
+
|
58
|
+
return str(f) if as_str else f
|
59
|
+
|
60
|
+
return serialize
|
61
|
+
|
62
|
+
|
63
|
+
def validate_float(f):
|
64
|
+
if f is None:
|
65
|
+
return None
|
66
|
+
|
67
|
+
if isinstance(f, (float, Unset)):
|
68
|
+
return f
|
69
|
+
|
70
|
+
if not isinstance(f, str):
|
71
|
+
raise ValueError("Expected string")
|
72
|
+
|
73
|
+
return float(f)
|
74
|
+
|
75
|
+
|
76
|
+
def serialize_int(as_str: bool):
|
77
|
+
def serialize(i):
|
78
|
+
# Optional[T] is a Union[T, None]
|
79
|
+
if is_union(type(i)) and type(None) in get_args(type(i)) and i is None:
|
80
|
+
return None
|
81
|
+
if isinstance(i, Unset):
|
82
|
+
return i
|
83
|
+
|
84
|
+
if not isinstance(i, int):
|
85
|
+
raise ValueError("Expected int")
|
86
|
+
|
87
|
+
return str(i) if as_str else i
|
88
|
+
|
89
|
+
return serialize
|
90
|
+
|
91
|
+
|
92
|
+
def validate_int(b):
|
93
|
+
if b is None:
|
94
|
+
return None
|
95
|
+
|
96
|
+
if isinstance(b, (int, Unset)):
|
97
|
+
return b
|
98
|
+
|
99
|
+
if not isinstance(b, str):
|
100
|
+
raise ValueError("Expected string")
|
101
|
+
|
102
|
+
return int(b)
|
103
|
+
|
104
|
+
|
105
|
+
def validate_open_enum(is_int: bool):
|
106
|
+
def validate(e):
|
107
|
+
if e is None:
|
108
|
+
return None
|
109
|
+
|
110
|
+
if isinstance(e, Unset):
|
111
|
+
return e
|
112
|
+
|
113
|
+
if is_int:
|
114
|
+
if not isinstance(e, int):
|
115
|
+
raise ValueError("Expected int")
|
116
|
+
else:
|
117
|
+
if not isinstance(e, str):
|
118
|
+
raise ValueError("Expected string")
|
119
|
+
|
120
|
+
return e
|
121
|
+
|
122
|
+
return validate
|
123
|
+
|
124
|
+
|
125
|
+
def validate_const(v):
|
126
|
+
def validate(c):
|
127
|
+
# Optional[T] is a Union[T, None]
|
128
|
+
if is_union(type(c)) and type(None) in get_args(type(c)) and c is None:
|
129
|
+
return None
|
130
|
+
|
131
|
+
if v != c:
|
132
|
+
raise ValueError(f"Expected {v}")
|
133
|
+
|
134
|
+
return c
|
135
|
+
|
136
|
+
return validate
|
137
|
+
|
138
|
+
|
139
|
+
def unmarshal_json(raw, typ: Any) -> Any:
|
140
|
+
return unmarshal(from_json(raw), typ)
|
141
|
+
|
142
|
+
|
143
|
+
def unmarshal(val, typ: Any) -> Any:
|
144
|
+
unmarshaller = create_model(
|
145
|
+
"Unmarshaller",
|
146
|
+
body=(typ, ...),
|
147
|
+
__config__=ConfigDict(populate_by_name=True, arbitrary_types_allowed=True),
|
148
|
+
)
|
149
|
+
|
150
|
+
m = unmarshaller(body=val)
|
151
|
+
|
152
|
+
# pyright: ignore[reportAttributeAccessIssue]
|
153
|
+
return m.body # type: ignore
|
154
|
+
|
155
|
+
|
156
|
+
def marshal_json(val, typ):
|
157
|
+
if is_nullable(typ) and val is None:
|
158
|
+
return "null"
|
159
|
+
|
160
|
+
marshaller = create_model(
|
161
|
+
"Marshaller",
|
162
|
+
body=(typ, ...),
|
163
|
+
__config__=ConfigDict(populate_by_name=True, arbitrary_types_allowed=True),
|
164
|
+
)
|
165
|
+
|
166
|
+
m = marshaller(body=val)
|
167
|
+
|
168
|
+
d = m.model_dump(by_alias=True, mode="json", exclude_none=True)
|
169
|
+
|
170
|
+
if len(d) == 0:
|
171
|
+
return ""
|
172
|
+
|
173
|
+
return json.dumps(d[next(iter(d))], separators=(",", ":"))
|
174
|
+
|
175
|
+
|
176
|
+
def is_nullable(field):
|
177
|
+
origin = get_origin(field)
|
178
|
+
if origin is Nullable or origin is OptionalNullable:
|
179
|
+
return True
|
180
|
+
|
181
|
+
if not origin is Union or type(None) not in get_args(field):
|
182
|
+
return False
|
183
|
+
|
184
|
+
for arg in get_args(field):
|
185
|
+
if get_origin(arg) is Nullable or get_origin(arg) is OptionalNullable:
|
186
|
+
return True
|
187
|
+
|
188
|
+
return False
|
189
|
+
|
190
|
+
|
191
|
+
def is_union(obj: object) -> bool:
|
192
|
+
"""
|
193
|
+
Returns True if the given object is a typing.Union or typing_extensions.Union.
|
194
|
+
"""
|
195
|
+
return any(
|
196
|
+
obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union")
|
197
|
+
)
|
198
|
+
|
199
|
+
|
200
|
+
def stream_to_text(stream: httpx.Response) -> str:
|
201
|
+
return "".join(stream.iter_text())
|
202
|
+
|
203
|
+
|
204
|
+
async def stream_to_text_async(stream: httpx.Response) -> str:
|
205
|
+
return "".join([chunk async for chunk in stream.aiter_text()])
|
206
|
+
|
207
|
+
|
208
|
+
def stream_to_bytes(stream: httpx.Response) -> bytes:
|
209
|
+
return stream.content
|
210
|
+
|
211
|
+
|
212
|
+
async def stream_to_bytes_async(stream: httpx.Response) -> bytes:
|
213
|
+
return await stream.aread()
|
214
|
+
|
215
|
+
|
216
|
+
def get_pydantic_model(data: Any, typ: Any) -> Any:
|
217
|
+
if not _contains_pydantic_model(data):
|
218
|
+
return unmarshal(data, typ)
|
219
|
+
|
220
|
+
return data
|
221
|
+
|
222
|
+
|
223
|
+
def _contains_pydantic_model(data: Any) -> bool:
|
224
|
+
if isinstance(data, BaseModel):
|
225
|
+
return True
|
226
|
+
if isinstance(data, List):
|
227
|
+
return any(_contains_pydantic_model(item) for item in data)
|
228
|
+
if isinstance(data, Dict):
|
229
|
+
return any(_contains_pydantic_model(value) for value in data.values())
|
230
|
+
|
231
|
+
return False
|
232
|
+
|
233
|
+
|
234
|
+
@functools.cache
|
235
|
+
def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
|
236
|
+
"""
|
237
|
+
Get typing objects by name from typing and typing_extensions.
|
238
|
+
Reference: https://typing-extensions.readthedocs.io/en/latest/#runtime-use-of-types
|
239
|
+
"""
|
240
|
+
result = tuple(
|
241
|
+
getattr(module, name)
|
242
|
+
for module in (typing, typing_extensions)
|
243
|
+
if hasattr(module, name)
|
244
|
+
)
|
245
|
+
if not result:
|
246
|
+
raise ValueError(
|
247
|
+
f"Neither typing nor typing_extensions has an object called {name!r}"
|
248
|
+
)
|
249
|
+
return result
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from typing import Any, Optional
|
4
|
+
|
5
|
+
import httpx
|
6
|
+
|
7
|
+
from .serializers import unmarshal_json
|
8
|
+
from egain_api_python import errors
|
9
|
+
|
10
|
+
|
11
|
+
def unmarshal_json_response(
|
12
|
+
typ: Any, http_res: httpx.Response, body: Optional[str] = None
|
13
|
+
) -> Any:
|
14
|
+
if body is None:
|
15
|
+
body = http_res.text
|
16
|
+
try:
|
17
|
+
return unmarshal_json(body, typ)
|
18
|
+
except Exception as e:
|
19
|
+
raise errors.ResponseValidationError(
|
20
|
+
"Response validation failed",
|
21
|
+
http_res,
|
22
|
+
e,
|
23
|
+
body,
|
24
|
+
) from e
|
@@ -0,0 +1,155 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from decimal import Decimal
|
4
|
+
from typing import (
|
5
|
+
Any,
|
6
|
+
Dict,
|
7
|
+
get_type_hints,
|
8
|
+
List,
|
9
|
+
Optional,
|
10
|
+
Union,
|
11
|
+
get_args,
|
12
|
+
get_origin,
|
13
|
+
)
|
14
|
+
from pydantic import BaseModel
|
15
|
+
from pydantic.fields import FieldInfo
|
16
|
+
|
17
|
+
from .metadata import (
|
18
|
+
PathParamMetadata,
|
19
|
+
find_field_metadata,
|
20
|
+
)
|
21
|
+
from .values import (
|
22
|
+
_get_serialized_params,
|
23
|
+
_is_set,
|
24
|
+
_populate_from_globals,
|
25
|
+
_val_to_string,
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
def generate_url(
|
30
|
+
server_url: str,
|
31
|
+
path: str,
|
32
|
+
path_params: Any,
|
33
|
+
gbls: Optional[Any] = None,
|
34
|
+
) -> str:
|
35
|
+
path_param_values: Dict[str, str] = {}
|
36
|
+
|
37
|
+
globals_already_populated = _populate_path_params(
|
38
|
+
path_params, gbls, path_param_values, []
|
39
|
+
)
|
40
|
+
if _is_set(gbls):
|
41
|
+
_populate_path_params(gbls, None, path_param_values, globals_already_populated)
|
42
|
+
|
43
|
+
for key, value in path_param_values.items():
|
44
|
+
path = path.replace("{" + key + "}", value, 1)
|
45
|
+
|
46
|
+
return remove_suffix(server_url, "/") + path
|
47
|
+
|
48
|
+
|
49
|
+
def _populate_path_params(
|
50
|
+
path_params: Any,
|
51
|
+
gbls: Any,
|
52
|
+
path_param_values: Dict[str, str],
|
53
|
+
skip_fields: List[str],
|
54
|
+
) -> List[str]:
|
55
|
+
globals_already_populated: List[str] = []
|
56
|
+
|
57
|
+
if not isinstance(path_params, BaseModel):
|
58
|
+
return globals_already_populated
|
59
|
+
|
60
|
+
path_param_fields: Dict[str, FieldInfo] = path_params.__class__.model_fields
|
61
|
+
path_param_field_types = get_type_hints(path_params.__class__)
|
62
|
+
for name in path_param_fields:
|
63
|
+
if name in skip_fields:
|
64
|
+
continue
|
65
|
+
|
66
|
+
field = path_param_fields[name]
|
67
|
+
|
68
|
+
param_metadata = find_field_metadata(field, PathParamMetadata)
|
69
|
+
if param_metadata is None:
|
70
|
+
continue
|
71
|
+
|
72
|
+
param = getattr(path_params, name) if _is_set(path_params) else None
|
73
|
+
param, global_found = _populate_from_globals(
|
74
|
+
name, param, PathParamMetadata, gbls
|
75
|
+
)
|
76
|
+
if global_found:
|
77
|
+
globals_already_populated.append(name)
|
78
|
+
|
79
|
+
if not _is_set(param):
|
80
|
+
continue
|
81
|
+
|
82
|
+
f_name = field.alias if field.alias is not None else name
|
83
|
+
serialization = param_metadata.serialization
|
84
|
+
if serialization is not None:
|
85
|
+
serialized_params = _get_serialized_params(
|
86
|
+
param_metadata, f_name, param, path_param_field_types[name]
|
87
|
+
)
|
88
|
+
for key, value in serialized_params.items():
|
89
|
+
path_param_values[key] = value
|
90
|
+
else:
|
91
|
+
pp_vals: List[str] = []
|
92
|
+
if param_metadata.style == "simple":
|
93
|
+
if isinstance(param, List):
|
94
|
+
for pp_val in param:
|
95
|
+
if not _is_set(pp_val):
|
96
|
+
continue
|
97
|
+
pp_vals.append(_val_to_string(pp_val))
|
98
|
+
path_param_values[f_name] = ",".join(pp_vals)
|
99
|
+
elif isinstance(param, Dict):
|
100
|
+
for pp_key in param:
|
101
|
+
if not _is_set(param[pp_key]):
|
102
|
+
continue
|
103
|
+
if param_metadata.explode:
|
104
|
+
pp_vals.append(f"{pp_key}={_val_to_string(param[pp_key])}")
|
105
|
+
else:
|
106
|
+
pp_vals.append(f"{pp_key},{_val_to_string(param[pp_key])}")
|
107
|
+
path_param_values[f_name] = ",".join(pp_vals)
|
108
|
+
elif not isinstance(param, (str, int, float, complex, bool, Decimal)):
|
109
|
+
param_fields: Dict[str, FieldInfo] = param.__class__.model_fields
|
110
|
+
for name in param_fields:
|
111
|
+
param_field = param_fields[name]
|
112
|
+
|
113
|
+
param_value_metadata = find_field_metadata(
|
114
|
+
param_field, PathParamMetadata
|
115
|
+
)
|
116
|
+
if param_value_metadata is None:
|
117
|
+
continue
|
118
|
+
|
119
|
+
param_name = (
|
120
|
+
param_field.alias if param_field.alias is not None else name
|
121
|
+
)
|
122
|
+
|
123
|
+
param_field_val = getattr(param, name)
|
124
|
+
if not _is_set(param_field_val):
|
125
|
+
continue
|
126
|
+
if param_metadata.explode:
|
127
|
+
pp_vals.append(
|
128
|
+
f"{param_name}={_val_to_string(param_field_val)}"
|
129
|
+
)
|
130
|
+
else:
|
131
|
+
pp_vals.append(
|
132
|
+
f"{param_name},{_val_to_string(param_field_val)}"
|
133
|
+
)
|
134
|
+
path_param_values[f_name] = ",".join(pp_vals)
|
135
|
+
elif _is_set(param):
|
136
|
+
path_param_values[f_name] = _val_to_string(param)
|
137
|
+
|
138
|
+
return globals_already_populated
|
139
|
+
|
140
|
+
|
141
|
+
def is_optional(field):
|
142
|
+
return get_origin(field) is Union and type(None) in get_args(field)
|
143
|
+
|
144
|
+
|
145
|
+
def template_url(url_with_params: str, params: Dict[str, str]) -> str:
|
146
|
+
for key, value in params.items():
|
147
|
+
url_with_params = url_with_params.replace("{" + key + "}", value)
|
148
|
+
|
149
|
+
return url_with_params
|
150
|
+
|
151
|
+
|
152
|
+
def remove_suffix(input_string, suffix):
|
153
|
+
if suffix and input_string.endswith(suffix):
|
154
|
+
return input_string[: -len(suffix)]
|
155
|
+
return input_string
|
@@ -0,0 +1,137 @@
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
2
|
+
|
3
|
+
from datetime import datetime
|
4
|
+
from enum import Enum
|
5
|
+
from email.message import Message
|
6
|
+
from functools import partial
|
7
|
+
import os
|
8
|
+
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, cast
|
9
|
+
|
10
|
+
from httpx import Response
|
11
|
+
from pydantic import BaseModel
|
12
|
+
from pydantic.fields import FieldInfo
|
13
|
+
|
14
|
+
from ..types.basemodel import Unset
|
15
|
+
|
16
|
+
from .serializers import marshal_json
|
17
|
+
|
18
|
+
from .metadata import ParamMetadata, find_field_metadata
|
19
|
+
|
20
|
+
|
21
|
+
def match_content_type(content_type: str, pattern: str) -> bool:
|
22
|
+
if pattern in (content_type, "*", "*/*"):
|
23
|
+
return True
|
24
|
+
|
25
|
+
msg = Message()
|
26
|
+
msg["content-type"] = content_type
|
27
|
+
media_type = msg.get_content_type()
|
28
|
+
|
29
|
+
if media_type == pattern:
|
30
|
+
return True
|
31
|
+
|
32
|
+
parts = media_type.split("/")
|
33
|
+
if len(parts) == 2:
|
34
|
+
if pattern in (f"{parts[0]}/*", f"*/{parts[1]}"):
|
35
|
+
return True
|
36
|
+
|
37
|
+
return False
|
38
|
+
|
39
|
+
|
40
|
+
def match_status_codes(status_codes: List[str], status_code: int) -> bool:
|
41
|
+
if "default" in status_codes:
|
42
|
+
return True
|
43
|
+
|
44
|
+
for code in status_codes:
|
45
|
+
if code == str(status_code):
|
46
|
+
return True
|
47
|
+
|
48
|
+
if code.endswith("XX") and code.startswith(str(status_code)[:1]):
|
49
|
+
return True
|
50
|
+
return False
|
51
|
+
|
52
|
+
|
53
|
+
T = TypeVar("T")
|
54
|
+
|
55
|
+
def cast_partial(typ):
|
56
|
+
return partial(cast, typ)
|
57
|
+
|
58
|
+
def get_global_from_env(
|
59
|
+
value: Optional[T], env_key: str, type_cast: Callable[[str], T]
|
60
|
+
) -> Optional[T]:
|
61
|
+
if value is not None:
|
62
|
+
return value
|
63
|
+
env_value = os.getenv(env_key)
|
64
|
+
if env_value is not None:
|
65
|
+
try:
|
66
|
+
return type_cast(env_value)
|
67
|
+
except ValueError:
|
68
|
+
pass
|
69
|
+
return None
|
70
|
+
|
71
|
+
|
72
|
+
def match_response(
|
73
|
+
response: Response, code: Union[str, List[str]], content_type: str
|
74
|
+
) -> bool:
|
75
|
+
codes = code if isinstance(code, list) else [code]
|
76
|
+
return match_status_codes(codes, response.status_code) and match_content_type(
|
77
|
+
response.headers.get("content-type", "application/octet-stream"), content_type
|
78
|
+
)
|
79
|
+
|
80
|
+
|
81
|
+
def _populate_from_globals(
|
82
|
+
param_name: str, value: Any, param_metadata_type: type, gbls: Any
|
83
|
+
) -> Tuple[Any, bool]:
|
84
|
+
if gbls is None:
|
85
|
+
return value, False
|
86
|
+
|
87
|
+
if not isinstance(gbls, BaseModel):
|
88
|
+
raise TypeError("globals must be a pydantic model")
|
89
|
+
|
90
|
+
global_fields: Dict[str, FieldInfo] = gbls.__class__.model_fields
|
91
|
+
found = False
|
92
|
+
for name in global_fields:
|
93
|
+
field = global_fields[name]
|
94
|
+
if name is not param_name:
|
95
|
+
continue
|
96
|
+
|
97
|
+
found = True
|
98
|
+
|
99
|
+
if value is not None:
|
100
|
+
return value, True
|
101
|
+
|
102
|
+
global_value = getattr(gbls, name)
|
103
|
+
|
104
|
+
param_metadata = find_field_metadata(field, param_metadata_type)
|
105
|
+
if param_metadata is None:
|
106
|
+
return value, True
|
107
|
+
|
108
|
+
return global_value, True
|
109
|
+
|
110
|
+
return value, found
|
111
|
+
|
112
|
+
|
113
|
+
def _val_to_string(val) -> str:
|
114
|
+
if isinstance(val, bool):
|
115
|
+
return str(val).lower()
|
116
|
+
if isinstance(val, datetime):
|
117
|
+
return str(val.isoformat().replace("+00:00", "Z"))
|
118
|
+
if isinstance(val, Enum):
|
119
|
+
return str(val.value)
|
120
|
+
|
121
|
+
return str(val)
|
122
|
+
|
123
|
+
|
124
|
+
def _get_serialized_params(
|
125
|
+
metadata: ParamMetadata, field_name: str, obj: Any, typ: type
|
126
|
+
) -> Dict[str, str]:
|
127
|
+
params: Dict[str, str] = {}
|
128
|
+
|
129
|
+
serialization = metadata.serialization
|
130
|
+
if serialization == "json":
|
131
|
+
params[field_name] = marshal_json(obj, typ)
|
132
|
+
|
133
|
+
return params
|
134
|
+
|
135
|
+
|
136
|
+
def _is_set(value: Any) -> bool:
|
137
|
+
return value is not None and not isinstance(value, Unset)
|