-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathregistration.py
More file actions
33 lines (24 loc) · 1.59 KB
/
registration.py
File metadata and controls
33 lines (24 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from .types import Hooks
from .answer_likes_null_fix_hook import AnswerLikesNullFixHook
from .server_url_normalizer import ServerURLNormalizerHook
from .multipart_fix_hook import MultipartFileFieldFixHook
from .agent_file_upload_error_hook import AgentFileUploadErrorHook
from .x_glean import XGlean
# This file is only ever generated once on the first generation and then is free to be modified.
# Any hooks you wish to add should be registered in the init_hooks function. Feel free to define them
# in this file or in separate files in the hooks folder.
def init_hooks(hooks: Hooks):
# pylint: disable=unused-argument
"""Add hooks by calling hooks.register{sdk_init/before_request/after_success/after_error}Hook
with an instance of a hook that implements that specific Hook interface
Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance"""
# Register hook to normalize server URLs (prepend https:// if no scheme provided)
hooks.register_sdk_init_hook(ServerURLNormalizerHook())
# Register hook to fix multipart file field names that incorrectly have '[]' suffix
hooks.register_sdk_init_hook(MultipartFileFieldFixHook())
# Register hook to normalize null likedBy payloads before response validation
hooks.register_sdk_init_hook(AnswerLikesNullFixHook())
# Register hook to provide helpful error messages for agent file upload issues
hooks.register_after_error_hook(AgentFileUploadErrorHook())
# Register hook for X-Glean headers (experimental features and deprecation testing)
hooks.register_before_request_hook(XGlean())