Skip to content

Commit c84fb38

Browse files
zimegClaude
andcommitted
feat(web-api): add codeChannels.* methods
Add the codeChannels.* Web API method family to the sync, async, and legacy web clients: create, archive, rename, setProperties, setCommands, setView, listViews, removeView, getCanvas, and setCanvasContent. These let an app manage a code channel — its lifecycle, context bar, per-channel slash commands, view tabs (diff/html/block_kit/canvas), and canvas content. All require the code_channels:manage bot scope. Generated the async and legacy clients via scripts/codegen.py. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent bfb098a commit c84fb38

4 files changed

Lines changed: 511 additions & 1 deletion

File tree

‎slack_sdk/web/async_client.py‎

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,164 @@ async def assistant_threads_setStatus(
21132113
kwargs = _remove_none_values(kwargs)
21142114
return await self.api_call("assistant.threads.setStatus", json=kwargs)
21152115

2116+
async def codeChannels_create(
2117+
self,
2118+
*,
2119+
name: str,
2120+
origin_channel_id: str,
2121+
origin_message_ts: str,
2122+
session_id: Optional[str] = None,
2123+
**kwargs,
2124+
) -> AsyncSlackResponse:
2125+
"""Create a code channel for a session.
2126+
https://docs.slack.dev/reference/methods/codeChannels.create
2127+
"""
2128+
kwargs.update(
2129+
{
2130+
"name": name,
2131+
"origin_channel_id": origin_channel_id,
2132+
"origin_message_ts": origin_message_ts,
2133+
"session_id": session_id,
2134+
}
2135+
)
2136+
kwargs = _remove_none_values(kwargs)
2137+
return await self.api_call("codeChannels.create", json=kwargs)
2138+
2139+
async def codeChannels_archive(
2140+
self,
2141+
*,
2142+
channel_id: str,
2143+
summary_message_ts: Optional[str] = None,
2144+
**kwargs,
2145+
) -> AsyncSlackResponse:
2146+
"""Archive a code channel, optionally recording a summary.
2147+
https://docs.slack.dev/reference/methods/codeChannels.archive
2148+
"""
2149+
kwargs.update({"channel_id": channel_id, "summary_message_ts": summary_message_ts})
2150+
kwargs = _remove_none_values(kwargs)
2151+
return await self.api_call("codeChannels.archive", json=kwargs)
2152+
2153+
async def codeChannels_rename(
2154+
self,
2155+
*,
2156+
channel_id: str,
2157+
name: str,
2158+
**kwargs,
2159+
) -> AsyncSlackResponse:
2160+
"""Rename a code channel.
2161+
https://docs.slack.dev/reference/methods/codeChannels.rename
2162+
"""
2163+
kwargs.update({"channel_id": channel_id, "name": name})
2164+
kwargs = _remove_none_values(kwargs)
2165+
return await self.api_call("codeChannels.rename", json=kwargs)
2166+
2167+
async def codeChannels_setProperties(
2168+
self,
2169+
*,
2170+
channel_id: str,
2171+
code_channel: Optional[Dict[str, Any]] = None,
2172+
**kwargs,
2173+
) -> AsyncSlackResponse:
2174+
"""Set a code channel's context bar items and external resource details.
2175+
https://docs.slack.dev/reference/methods/codeChannels.setProperties
2176+
"""
2177+
kwargs.update({"channel_id": channel_id, "code_channel": code_channel})
2178+
kwargs = _remove_none_values(kwargs)
2179+
return await self.api_call("codeChannels.setProperties", json=kwargs)
2180+
2181+
async def codeChannels_setCommands(
2182+
self,
2183+
*,
2184+
channel_id: str,
2185+
commands: List[Dict[str, Any]],
2186+
**kwargs,
2187+
) -> AsyncSlackResponse:
2188+
"""Register the agent's per-channel slash commands for a code channel.
2189+
https://docs.slack.dev/reference/methods/codeChannels.setCommands
2190+
"""
2191+
kwargs.update({"channel_id": channel_id, "commands": commands})
2192+
kwargs = _remove_none_values(kwargs)
2193+
return await self.api_call("codeChannels.setCommands", json=kwargs)
2194+
2195+
async def codeChannels_setView(
2196+
self,
2197+
*,
2198+
channel_id: str,
2199+
type: str,
2200+
content: Optional[str] = None,
2201+
base_branch: Optional[str] = None,
2202+
head_branch: Optional[str] = None,
2203+
**kwargs,
2204+
) -> AsyncSlackResponse:
2205+
"""Create or update a view tab (html, diff, block_kit, or canvas) on a code channel.
2206+
https://docs.slack.dev/reference/methods/codeChannels.setView
2207+
"""
2208+
kwargs.update(
2209+
{
2210+
"channel_id": channel_id,
2211+
"type": type,
2212+
"content": content,
2213+
"base_branch": base_branch,
2214+
"head_branch": head_branch,
2215+
}
2216+
)
2217+
kwargs = _remove_none_values(kwargs)
2218+
return await self.api_call("codeChannels.setView", json=kwargs)
2219+
2220+
async def codeChannels_listViews(
2221+
self,
2222+
*,
2223+
channel_id: str,
2224+
**kwargs,
2225+
) -> AsyncSlackResponse:
2226+
"""List the view tabs attached to a code channel.
2227+
https://docs.slack.dev/reference/methods/codeChannels.listViews
2228+
"""
2229+
kwargs.update({"channel_id": channel_id})
2230+
kwargs = _remove_none_values(kwargs)
2231+
return await self.api_call("codeChannels.listViews", json=kwargs)
2232+
2233+
async def codeChannels_removeView(
2234+
self,
2235+
*,
2236+
channel_id: str,
2237+
view_id: str,
2238+
**kwargs,
2239+
) -> AsyncSlackResponse:
2240+
"""Remove a view tab from a code channel.
2241+
https://docs.slack.dev/reference/methods/codeChannels.removeView
2242+
"""
2243+
kwargs.update({"channel_id": channel_id, "view_id": view_id})
2244+
kwargs = _remove_none_values(kwargs)
2245+
return await self.api_call("codeChannels.removeView", json=kwargs)
2246+
2247+
async def codeChannels_getCanvas(
2248+
self,
2249+
*,
2250+
channel_id: str,
2251+
**kwargs,
2252+
) -> AsyncSlackResponse:
2253+
"""Read a code channel canvas's content and its comment threads.
2254+
https://docs.slack.dev/reference/methods/codeChannels.getCanvas
2255+
"""
2256+
kwargs.update({"channel_id": channel_id})
2257+
kwargs = _remove_none_values(kwargs)
2258+
return await self.api_call("codeChannels.getCanvas", json=kwargs)
2259+
2260+
async def codeChannels_setCanvasContent(
2261+
self,
2262+
*,
2263+
channel_id: str,
2264+
content: str,
2265+
**kwargs,
2266+
) -> AsyncSlackResponse:
2267+
"""Replace a code channel canvas's content while preserving comment anchors.
2268+
https://docs.slack.dev/reference/methods/codeChannels.setCanvasContent
2269+
"""
2270+
kwargs.update({"channel_id": channel_id, "content": content})
2271+
kwargs = _remove_none_values(kwargs)
2272+
return await self.api_call("codeChannels.setCanvasContent", json=kwargs)
2273+
21162274
async def assistant_threads_setTitle(
21172275
self,
21182276
*,

‎slack_sdk/web/client.py‎

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,164 @@ def assistant_threads_setStatus(
21032103
kwargs = _remove_none_values(kwargs)
21042104
return self.api_call("assistant.threads.setStatus", json=kwargs)
21052105

2106+
def codeChannels_create(
2107+
self,
2108+
*,
2109+
name: str,
2110+
origin_channel_id: str,
2111+
origin_message_ts: str,
2112+
session_id: Optional[str] = None,
2113+
**kwargs,
2114+
) -> SlackResponse:
2115+
"""Create a code channel for a session.
2116+
https://docs.slack.dev/reference/methods/codeChannels.create
2117+
"""
2118+
kwargs.update(
2119+
{
2120+
"name": name,
2121+
"origin_channel_id": origin_channel_id,
2122+
"origin_message_ts": origin_message_ts,
2123+
"session_id": session_id,
2124+
}
2125+
)
2126+
kwargs = _remove_none_values(kwargs)
2127+
return self.api_call("codeChannels.create", json=kwargs)
2128+
2129+
def codeChannels_archive(
2130+
self,
2131+
*,
2132+
channel_id: str,
2133+
summary_message_ts: Optional[str] = None,
2134+
**kwargs,
2135+
) -> SlackResponse:
2136+
"""Archive a code channel, optionally recording a summary.
2137+
https://docs.slack.dev/reference/methods/codeChannels.archive
2138+
"""
2139+
kwargs.update({"channel_id": channel_id, "summary_message_ts": summary_message_ts})
2140+
kwargs = _remove_none_values(kwargs)
2141+
return self.api_call("codeChannels.archive", json=kwargs)
2142+
2143+
def codeChannels_rename(
2144+
self,
2145+
*,
2146+
channel_id: str,
2147+
name: str,
2148+
**kwargs,
2149+
) -> SlackResponse:
2150+
"""Rename a code channel.
2151+
https://docs.slack.dev/reference/methods/codeChannels.rename
2152+
"""
2153+
kwargs.update({"channel_id": channel_id, "name": name})
2154+
kwargs = _remove_none_values(kwargs)
2155+
return self.api_call("codeChannels.rename", json=kwargs)
2156+
2157+
def codeChannels_setProperties(
2158+
self,
2159+
*,
2160+
channel_id: str,
2161+
code_channel: Optional[Dict[str, Any]] = None,
2162+
**kwargs,
2163+
) -> SlackResponse:
2164+
"""Set a code channel's context bar items and external resource details.
2165+
https://docs.slack.dev/reference/methods/codeChannels.setProperties
2166+
"""
2167+
kwargs.update({"channel_id": channel_id, "code_channel": code_channel})
2168+
kwargs = _remove_none_values(kwargs)
2169+
return self.api_call("codeChannels.setProperties", json=kwargs)
2170+
2171+
def codeChannels_setCommands(
2172+
self,
2173+
*,
2174+
channel_id: str,
2175+
commands: List[Dict[str, Any]],
2176+
**kwargs,
2177+
) -> SlackResponse:
2178+
"""Register the agent's per-channel slash commands for a code channel.
2179+
https://docs.slack.dev/reference/methods/codeChannels.setCommands
2180+
"""
2181+
kwargs.update({"channel_id": channel_id, "commands": commands})
2182+
kwargs = _remove_none_values(kwargs)
2183+
return self.api_call("codeChannels.setCommands", json=kwargs)
2184+
2185+
def codeChannels_setView(
2186+
self,
2187+
*,
2188+
channel_id: str,
2189+
type: str,
2190+
content: Optional[str] = None,
2191+
base_branch: Optional[str] = None,
2192+
head_branch: Optional[str] = None,
2193+
**kwargs,
2194+
) -> SlackResponse:
2195+
"""Create or update a view tab (html, diff, block_kit, or canvas) on a code channel.
2196+
https://docs.slack.dev/reference/methods/codeChannels.setView
2197+
"""
2198+
kwargs.update(
2199+
{
2200+
"channel_id": channel_id,
2201+
"type": type,
2202+
"content": content,
2203+
"base_branch": base_branch,
2204+
"head_branch": head_branch,
2205+
}
2206+
)
2207+
kwargs = _remove_none_values(kwargs)
2208+
return self.api_call("codeChannels.setView", json=kwargs)
2209+
2210+
def codeChannels_listViews(
2211+
self,
2212+
*,
2213+
channel_id: str,
2214+
**kwargs,
2215+
) -> SlackResponse:
2216+
"""List the view tabs attached to a code channel.
2217+
https://docs.slack.dev/reference/methods/codeChannels.listViews
2218+
"""
2219+
kwargs.update({"channel_id": channel_id})
2220+
kwargs = _remove_none_values(kwargs)
2221+
return self.api_call("codeChannels.listViews", json=kwargs)
2222+
2223+
def codeChannels_removeView(
2224+
self,
2225+
*,
2226+
channel_id: str,
2227+
view_id: str,
2228+
**kwargs,
2229+
) -> SlackResponse:
2230+
"""Remove a view tab from a code channel.
2231+
https://docs.slack.dev/reference/methods/codeChannels.removeView
2232+
"""
2233+
kwargs.update({"channel_id": channel_id, "view_id": view_id})
2234+
kwargs = _remove_none_values(kwargs)
2235+
return self.api_call("codeChannels.removeView", json=kwargs)
2236+
2237+
def codeChannels_getCanvas(
2238+
self,
2239+
*,
2240+
channel_id: str,
2241+
**kwargs,
2242+
) -> SlackResponse:
2243+
"""Read a code channel canvas's content and its comment threads.
2244+
https://docs.slack.dev/reference/methods/codeChannels.getCanvas
2245+
"""
2246+
kwargs.update({"channel_id": channel_id})
2247+
kwargs = _remove_none_values(kwargs)
2248+
return self.api_call("codeChannels.getCanvas", json=kwargs)
2249+
2250+
def codeChannels_setCanvasContent(
2251+
self,
2252+
*,
2253+
channel_id: str,
2254+
content: str,
2255+
**kwargs,
2256+
) -> SlackResponse:
2257+
"""Replace a code channel canvas's content while preserving comment anchors.
2258+
https://docs.slack.dev/reference/methods/codeChannels.setCanvasContent
2259+
"""
2260+
kwargs.update({"channel_id": channel_id, "content": content})
2261+
kwargs = _remove_none_values(kwargs)
2262+
return self.api_call("codeChannels.setCanvasContent", json=kwargs)
2263+
21062264
def assistant_threads_setTitle(
21072265
self,
21082266
*,

0 commit comments

Comments
 (0)