MCPcopy Create free account
hub / github.com/slackapi/python-slack-sdk / __init__

Method __init__

slack_sdk/web/base_client.py:44–93  ·  view source on GitHub ↗
(
        self,
        token: Optional[str] = None,
        base_url: str = BASE_URL,
        timeout: int = 30,
        ssl: Optional[SSLContext] = None,
        proxy: Optional[str] = None,
        headers: Optional[dict] = None,
        user_agent_prefix: Optional[str] = None,
        user_agent_suffix: Optional[str] = None,
        # for Org-Wide App installation
        team_id: Optional[str] = None,
        logger: Optional[logging.Logger] = None,
        retry_handlers: Optional[List[RetryHandler]] = None,
    )

Source from the content-addressed store, hash-verified

42 BASE_URL = "https://slack.com/api/"
43
44 def __init__(
45 self,
46 token: Optional[str] = None,
47 base_url: str = BASE_URL,
48 timeout: int = 30,
49 ssl: Optional[SSLContext] = None,
50 proxy: Optional[str] = None,
51 headers: Optional[dict] = None,
52 user_agent_prefix: Optional[str] = None,
53 user_agent_suffix: Optional[str] = None,
54 # for Org-Wide App installation
55 team_id: Optional[str] = None,
56 logger: Optional[logging.Logger] = None,
57 retry_handlers: Optional[List[RetryHandler]] = None,
58 ):
59 self.token = None if token is None else token.strip()
60 """A string specifying an `xoxp-*` or `xoxb-*` token."""
61 if not base_url.endswith("/"):
62 base_url += "/"
63 self.base_url = base_url
64 """A string representing the Slack API base URL.
65 Default is `'https://slack.com/api/'`."""
66 self.timeout = timeout
67 """The maximum number of seconds the client will wait
68 to connect and receive a response from Slack.
69 Default is 30 seconds."""
70 self.ssl = ssl
71 """An [`ssl.SSLContext`](https://docs.python.org/3/library/ssl.html#ssl.SSLContext)
72 instance, helpful for specifying your own custom
73 certificate chain."""
74 self.proxy = proxy
75 """String representing a fully-qualified URL to a proxy through which
76 to route all requests to the Slack API. Even if this parameter
77 is not specified, if any of the following environment variables are
78 present, they will be loaded into this parameter: `HTTPS_PROXY`,
79 `https_proxy`, `HTTP_PROXY` or `http_proxy`."""
80 self.headers = headers or {}
81 """`dict` representing additional request headers to attach to all requests."""
82 self.headers["User-Agent"] = get_user_agent(user_agent_prefix, user_agent_suffix)
83 self.default_params = {}
84 if team_id is not None:
85 self.default_params["team_id"] = team_id
86 self._logger = logger if logger is not None else logging.getLogger(__name__)
87
88 self.retry_handlers = retry_handlers if retry_handlers is not None else default_retry_handlers()
89
90 if self.proxy is None or len(self.proxy.strip()) == 0:
91 env_variable = load_http_proxy_from_env(self._logger)
92 if env_variable is not None:
93 self.proxy = env_variable
94
95 # -------------------------
96 # accessors

Callers

nothing calls this directly

Calls 3

default_retry_handlersFunction · 0.90
load_http_proxy_from_envFunction · 0.90
get_user_agentFunction · 0.85

Tested by

no test coverage detected