Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os
import warnings
from io import IOBase
from typing import Any, Dict, List, Optional, Sequence, Union
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union

import slack_sdk.errors as e
from slack_sdk.models.messages.chunk import Chunk
Expand All @@ -35,6 +35,21 @@
_warn_if_message_text_content_is_missing,
)

if TYPE_CHECKING:
try:
from typing import Literal, TypedDict
except ImportError:
from typing_extensions import Literal, TypedDict

class AdminAppsConfigSetDomainRestrictions(TypedDict, total=False):
urls: Sequence[str]
emails: Sequence[str]

AdminAppsConfigSetWorkflowAuthStrategy = Literal["builder_choice", "end_user_strategy"]
else:
AdminAppsConfigSetDomainRestrictions = Dict[str, Any]
AdminAppsConfigSetWorkflowAuthStrategy = str


class AsyncWebClient(AsyncBaseClient):
"""A WebClient allows apps to communicate with the Slack Platform's Web API.
Expand Down Expand Up @@ -375,8 +390,8 @@ async def admin_apps_config_set(
self,
*,
app_id: str,
domain_restrictions: Optional[Dict[str, Any]] = None,
workflow_auth_strategy: Optional[str] = None,
domain_restrictions: Optional[AdminAppsConfigSetDomainRestrictions] = None,
workflow_auth_strategy: Optional[AdminAppsConfigSetWorkflowAuthStrategy] = None,
**kwargs,
) -> AsyncSlackResponse:
"""Set the app config for a connector.
Expand Down
21 changes: 18 additions & 3 deletions slack_sdk/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import warnings
from io import IOBase
from typing import Any, Dict, List, Optional, Sequence, Union
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union

import slack_sdk.errors as e
from slack_sdk.models.messages.chunk import Chunk
Expand All @@ -25,6 +25,21 @@
_warn_if_message_text_content_is_missing,
)

if TYPE_CHECKING:
try:
from typing import Literal, TypedDict
except ImportError:
from typing_extensions import Literal, TypedDict

class AdminAppsConfigSetDomainRestrictions(TypedDict, total=False):
urls: Sequence[str]
emails: Sequence[str]

AdminAppsConfigSetWorkflowAuthStrategy = Literal["builder_choice", "end_user_strategy"]
else:
AdminAppsConfigSetDomainRestrictions = Dict[str, Any]
AdminAppsConfigSetWorkflowAuthStrategy = str


class WebClient(BaseClient):
"""A WebClient allows apps to communicate with the Slack Platform's Web API.
Expand Down Expand Up @@ -365,8 +380,8 @@ def admin_apps_config_set(
self,
*,
app_id: str,
domain_restrictions: Optional[Dict[str, Any]] = None,
workflow_auth_strategy: Optional[str] = None,
domain_restrictions: Optional[AdminAppsConfigSetDomainRestrictions] = None,
workflow_auth_strategy: Optional[AdminAppsConfigSetWorkflowAuthStrategy] = None,
**kwargs,
) -> SlackResponse:
"""Set the app config for a connector.
Expand Down
21 changes: 18 additions & 3 deletions slack_sdk/web/legacy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os
import warnings
from io import IOBase
from typing import Any, Dict, List, Optional, Sequence, Union
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union

import slack_sdk.errors as e
from slack_sdk.models.messages.chunk import Chunk
Expand All @@ -36,6 +36,21 @@
_warn_if_message_text_content_is_missing,
)

if TYPE_CHECKING:
try:
from typing import Literal, TypedDict
except ImportError:
from typing_extensions import Literal, TypedDict

class AdminAppsConfigSetDomainRestrictions(TypedDict, total=False):
urls: Sequence[str]
emails: Sequence[str]

AdminAppsConfigSetWorkflowAuthStrategy = Literal["builder_choice", "end_user_strategy"]
else:
AdminAppsConfigSetDomainRestrictions = Dict[str, Any]
AdminAppsConfigSetWorkflowAuthStrategy = str


class LegacyWebClient(LegacyBaseClient):
"""A WebClient allows apps to communicate with the Slack Platform's Web API.
Expand Down Expand Up @@ -376,8 +391,8 @@ def admin_apps_config_set(
self,
*,
app_id: str,
domain_restrictions: Optional[Dict[str, Any]] = None,
workflow_auth_strategy: Optional[str] = None,
domain_restrictions: Optional[AdminAppsConfigSetDomainRestrictions] = None,
workflow_auth_strategy: Optional[AdminAppsConfigSetWorkflowAuthStrategy] = None,
**kwargs,
) -> Union[Future, SlackResponse]:
"""Set the app config for a connector.
Expand Down
15 changes: 13 additions & 2 deletions tests/slack_sdk_async/web/test_web_client_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,19 @@ async def run_method(self, method_name, method, async_method):
self.api_methods_to_call.remove(method(app_ids=["A111"])["method"])
await async_method(app_ids=["A111"])
elif method_name == "admin_apps_config_set":
self.api_methods_to_call.remove(method(app_id="A111")["method"])
await async_method(app_id="A111")
domain_restrictions = {"urls": ["https://example.com"], "emails": ["admin@example.com"]}
self.api_methods_to_call.remove(
method(
app_id="A111",
domain_restrictions=domain_restrictions,
workflow_auth_strategy="builder_choice",
)["method"]
)
await async_method(
app_id="A111",
domain_restrictions=domain_restrictions,
workflow_auth_strategy="end_user_strategy",
)
elif method_name == "admin_auth_policy_getEntities":
self.api_methods_to_call.remove(method(policy_name="policyname")["method"])
await async_method(policy_name="policyname")
Expand Down