| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import List, Mapping, Optional, cast |
| 4 |
|
| 5 |
import httpx2 |
| 6 |
|
| 7 |
from ...._files import deepcopy_with_paths |
| 8 |
from ...._types import ( |
| 9 |
Body, |
| 10 |
Omit, |
| 11 |
Query, |
| 12 |
Headers, |
| 13 |
NotGiven, |
| 14 |
FileTypes, |
| 15 |
SequenceNotStr, |
| 16 |
omit, |
| 17 |
not_given, |
| 18 |
) |
| 19 |
from ...._utils import is_given, extract_files, path_template, strip_not_given |
| 20 |
from ...._compat import cached_property |
| 21 |
from ...._resource import SyncAPIResource, AsyncAPIResource |
| 22 |
from ...._response import ( |
| 23 |
BinaryAPIResponse, |
| 24 |
AsyncBinaryAPIResponse, |
| 25 |
StreamedBinaryAPIResponse, |
| 26 |
AsyncStreamedBinaryAPIResponse, |
| 27 |
to_raw_response_wrapper, |
| 28 |
to_streamed_response_wrapper, |
| 29 |
async_to_raw_response_wrapper, |
| 30 |
to_custom_raw_response_wrapper, |
| 31 |
async_to_streamed_response_wrapper, |
| 32 |
to_custom_streamed_response_wrapper, |
| 33 |
async_to_custom_raw_response_wrapper, |
| 34 |
async_to_custom_streamed_response_wrapper, |
| 35 |
) |
| 36 |
from ....pagination import SyncPageCursor, AsyncPageCursor |
| 37 |
from ...._base_client import AsyncPaginator, make_request_options |
| 38 |
from ....types.anthropic_beta_param import AnthropicBetaParam |
| 39 |
from ....types.beta.skills.beta_skill_version import BetaSkillVersion |
| 40 |
from ....types.beta.skills.beta_deleted_skill_version import BetaDeletedSkillVersion |
| 41 |
|
| 42 |
__all__ = ["Versions", "AsyncVersions"] |
| 43 |
|
| 44 |
|
| 45 |
class Versions(SyncAPIResource): |
| 46 |
@cached_property |
| 47 |
def with_raw_response(self) -> VersionsWithRawResponse: |
| 48 |
""" |
| 49 |
This property can be used as a prefix for any HTTP method call to return |
| 50 |
the raw response object instead of the parsed content. |
| 51 |
|
| 52 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 53 |
""" |
| 54 |
return VersionsWithRawResponse(self) |
| 55 |
|
| 56 |
@cached_property |
| 57 |
def with_streaming_response(self) -> VersionsWithStreamingResponse: |
| 58 |
""" |
| 59 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 60 |
|
| 61 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 62 |
""" |
| 63 |
return VersionsWithStreamingResponse(self) |
| 64 |
|
| 65 |
def create( |
| 66 |
self, |
| 67 |
skill_id: str, |
| 68 |
*, |
| 69 |
files: SequenceNotStr[FileTypes], |
| 70 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 71 |
workspace_id: str | Omit = omit, |
| 72 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 73 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 74 |
extra_headers: Headers | None = None, |
| 75 |
extra_query: Query | None = None, |
| 76 |
extra_body: Body | None = None, |
| 77 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 78 |
) -> BetaSkillVersion: |
| 79 |
""" |
| 80 |
Create Skill Version |
| 81 |
|
| 82 |
Args: |
| 83 |
skill_id: Unique identifier for the skill. |
| 84 |
|
| 85 |
The format and length of IDs may change over time. |
| 86 |
|
| 87 |
files: Files to upload for the skill. |
| 88 |
|
| 89 |
All files must be in the same top-level directory and must include a SKILL.md |
| 90 |
file at the root of that directory. |
| 91 |
|
| 92 |
betas: Optional header to specify the beta version(s) you want to use. |
| 93 |
|
| 94 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 95 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 96 |
|
| 97 |
Only needed for credentials that can act on more than one Workspace. A |
| 98 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 99 |
match that Workspace. |
| 100 |
|
| 101 |
extra_headers: Send extra headers |
| 102 |
|
| 103 |
extra_query: Add additional query parameters to the request |
| 104 |
|
| 105 |
extra_body: Add additional JSON properties to the request |
| 106 |
|
| 107 |
timeout: Override the client-level default timeout for this request, in seconds |
| 108 |
""" |
| 109 |
if not skill_id: |
| 110 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 111 |
extra_headers = { |
| 112 |
**strip_not_given( |
| 113 |
{ |
| 114 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 115 |
"anthropic-workspace-id": workspace_id, |
| 116 |
} |
| 117 |
), |
| 118 |
**(extra_headers or {}), |
| 119 |
} |
| 120 |
body = deepcopy_with_paths({"files": files}, [["files", "<array>"]]) |
| 121 |
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]]) |
| 122 |
# It should be noted that the actual Content-Type header that will be |
| 123 |
# sent to the server will contain a `boundary` parameter, e.g. |
| 124 |
# multipart/form-data; boundary=---abc-- |
| 125 |
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} |
| 126 |
return self._post( |
| 127 |
path_template("/v1/skills/{skill_id}/versions?beta=true", skill_id=skill_id), |
| 128 |
body=body, |
| 129 |
files=extracted_files, |
| 130 |
options=make_request_options( |
| 131 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 132 |
), |
| 133 |
cast_to=BetaSkillVersion, |
| 134 |
) |
| 135 |
|
| 136 |
def retrieve( |
| 137 |
self, |
| 138 |
version: str, |
| 139 |
*, |
| 140 |
skill_id: str, |
| 141 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 142 |
workspace_id: str | Omit = omit, |
| 143 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 144 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 145 |
extra_headers: Headers | None = None, |
| 146 |
extra_query: Query | None = None, |
| 147 |
extra_body: Body | None = None, |
| 148 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 149 |
) -> BetaSkillVersion: |
| 150 |
""" |
| 151 |
Get Skill Version |
| 152 |
|
| 153 |
Args: |
| 154 |
skill_id: Unique identifier for the skill. |
| 155 |
|
| 156 |
The format and length of IDs may change over time. |
| 157 |
|
| 158 |
version: Identifies the skill version: a version ID, or the literal `latest` for the |
| 159 |
skill's most recent version. |
| 160 |
|
| 161 |
Requests carrying the `skills-2025-10-02` beta header address versions by their |
| 162 |
Unix epoch timestamp instead (e.g., "1759178010641129"). |
| 163 |
|
| 164 |
betas: Optional header to specify the beta version(s) you want to use. |
| 165 |
|
| 166 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 167 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 168 |
|
| 169 |
Only needed for credentials that can act on more than one Workspace. A |
| 170 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 171 |
match that Workspace. |
| 172 |
|
| 173 |
extra_headers: Send extra headers |
| 174 |
|
| 175 |
extra_query: Add additional query parameters to the request |
| 176 |
|
| 177 |
extra_body: Add additional JSON properties to the request |
| 178 |
|
| 179 |
timeout: Override the client-level default timeout for this request, in seconds |
| 180 |
""" |
| 181 |
if not skill_id: |
| 182 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 183 |
if not version: |
| 184 |
raise ValueError(f"Expected a non-empty value for `version` but received {version!r}") |
| 185 |
extra_headers = { |
| 186 |
**strip_not_given( |
| 187 |
{ |
| 188 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 189 |
"anthropic-workspace-id": workspace_id, |
| 190 |
} |
| 191 |
), |
| 192 |
**(extra_headers or {}), |
| 193 |
} |
| 194 |
return self._get( |
| 195 |
path_template("/v1/skills/{skill_id}/versions/{version}?beta=true", skill_id=skill_id, version=version), |
| 196 |
options=make_request_options( |
| 197 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 198 |
), |
| 199 |
cast_to=BetaSkillVersion, |
| 200 |
) |
| 201 |
|
| 202 |
def list( |
| 203 |
self, |
| 204 |
skill_id: str, |
| 205 |
*, |
| 206 |
limit: Optional[int] | Omit = omit, |
| 207 |
page: Optional[str] | Omit = omit, |
| 208 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 209 |
workspace_id: str | Omit = omit, |
| 210 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 211 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 212 |
extra_headers: Headers | None = None, |
| 213 |
extra_query: Query | None = None, |
| 214 |
extra_body: Body | None = None, |
| 215 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 216 |
) -> SyncPageCursor[BetaSkillVersion]: |
| 217 |
""" |
| 218 |
List Skill Versions |
| 219 |
|
| 220 |
Args: |
| 221 |
skill_id: Unique identifier for the skill. |
| 222 |
|
| 223 |
The format and length of IDs may change over time. |
| 224 |
|
| 225 |
limit: Number of results to return per page. |
| 226 |
|
| 227 |
Ranges from `1` to `1000`. Defaults to `20`. |
| 228 |
|
| 229 |
page: Optionally set to the `next_page` token from the previous response. |
| 230 |
|
| 231 |
betas: Optional header to specify the beta version(s) you want to use. |
| 232 |
|
| 233 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 234 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 235 |
|
| 236 |
Only needed for credentials that can act on more than one Workspace. A |
| 237 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 238 |
match that Workspace. |
| 239 |
|
| 240 |
extra_headers: Send extra headers |
| 241 |
|
| 242 |
extra_query: Add additional query parameters to the request |
| 243 |
|
| 244 |
extra_body: Add additional JSON properties to the request |
| 245 |
|
| 246 |
timeout: Override the client-level default timeout for this request, in seconds |
| 247 |
""" |
| 248 |
if not skill_id: |
| 249 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 250 |
extra_headers = { |
| 251 |
**strip_not_given( |
| 252 |
{ |
| 253 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 254 |
"anthropic-workspace-id": workspace_id, |
| 255 |
} |
| 256 |
), |
| 257 |
**(extra_headers or {}), |
| 258 |
} |
| 259 |
return self._get_api_list( |
| 260 |
path_template("/v1/skills/{skill_id}/versions?beta=true", skill_id=skill_id), |
| 261 |
page=SyncPageCursor[BetaSkillVersion], |
| 262 |
options=make_request_options( |
| 263 |
extra_headers=extra_headers, |
| 264 |
extra_query=extra_query, |
| 265 |
extra_body=extra_body, |
| 266 |
timeout=timeout, |
| 267 |
query={ |
| 268 |
"limit": limit, |
| 269 |
"page": page, |
| 270 |
}, |
| 271 |
), |
| 272 |
model=BetaSkillVersion, |
| 273 |
) |
| 274 |
|
| 275 |
def delete( |
| 276 |
self, |
| 277 |
version: str, |
| 278 |
*, |
| 279 |
skill_id: str, |
| 280 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 281 |
workspace_id: str | Omit = omit, |
| 282 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 283 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 284 |
extra_headers: Headers | None = None, |
| 285 |
extra_query: Query | None = None, |
| 286 |
extra_body: Body | None = None, |
| 287 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 288 |
) -> BetaDeletedSkillVersion: |
| 289 |
""" |
| 290 |
Delete Skill Version |
| 291 |
|
| 292 |
Args: |
| 293 |
skill_id: Unique identifier for the skill. |
| 294 |
|
| 295 |
The format and length of IDs may change over time. |
| 296 |
|
| 297 |
version: Identifies the skill version by its version ID. |
| 298 |
|
| 299 |
Requests carrying the `skills-2025-10-02` beta header address versions by their |
| 300 |
Unix epoch timestamp instead (e.g., "1759178010641129"). |
| 301 |
|
| 302 |
betas: Optional header to specify the beta version(s) you want to use. |
| 303 |
|
| 304 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 305 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 306 |
|
| 307 |
Only needed for credentials that can act on more than one Workspace. A |
| 308 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 309 |
match that Workspace. |
| 310 |
|
| 311 |
extra_headers: Send extra headers |
| 312 |
|
| 313 |
extra_query: Add additional query parameters to the request |
| 314 |
|
| 315 |
extra_body: Add additional JSON properties to the request |
| 316 |
|
| 317 |
timeout: Override the client-level default timeout for this request, in seconds |
| 318 |
""" |
| 319 |
if not skill_id: |
| 320 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 321 |
if not version: |
| 322 |
raise ValueError(f"Expected a non-empty value for `version` but received {version!r}") |
| 323 |
extra_headers = { |
| 324 |
**strip_not_given( |
| 325 |
{ |
| 326 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 327 |
"anthropic-workspace-id": workspace_id, |
| 328 |
} |
| 329 |
), |
| 330 |
**(extra_headers or {}), |
| 331 |
} |
| 332 |
return self._delete( |
| 333 |
path_template("/v1/skills/{skill_id}/versions/{version}?beta=true", skill_id=skill_id, version=version), |
| 334 |
options=make_request_options( |
| 335 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 336 |
), |
| 337 |
cast_to=BetaDeletedSkillVersion, |
| 338 |
) |
| 339 |
|
| 340 |
def download( |
| 341 |
self, |
| 342 |
version: str, |
| 343 |
*, |
| 344 |
skill_id: str, |
| 345 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 346 |
workspace_id: str | Omit = omit, |
| 347 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 348 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 349 |
extra_headers: Headers | None = None, |
| 350 |
extra_query: Query | None = None, |
| 351 |
extra_body: Body | None = None, |
| 352 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 353 |
) -> BinaryAPIResponse: |
| 354 |
""" |
| 355 |
Download a skill version's content as a zip archive. |
| 356 |
|
| 357 |
Args: |
| 358 |
skill_id: Unique identifier for the skill. |
| 359 |
|
| 360 |
The format and length of IDs may change over time. |
| 361 |
|
| 362 |
version: Identifies the skill version by its version ID. |
| 363 |
|
| 364 |
Requests carrying the `skills-2025-10-02` beta header address versions by their |
| 365 |
Unix epoch timestamp instead (e.g., "1759178010641129"). |
| 366 |
|
| 367 |
betas: Optional header to specify the beta version(s) you want to use. |
| 368 |
|
| 369 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 370 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 371 |
|
| 372 |
Only needed for credentials that can act on more than one Workspace. A |
| 373 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 374 |
match that Workspace. |
| 375 |
|
| 376 |
extra_headers: Send extra headers |
| 377 |
|
| 378 |
extra_query: Add additional query parameters to the request |
| 379 |
|
| 380 |
extra_body: Add additional JSON properties to the request |
| 381 |
|
| 382 |
timeout: Override the client-level default timeout for this request, in seconds |
| 383 |
""" |
| 384 |
if not skill_id: |
| 385 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 386 |
if not version: |
| 387 |
raise ValueError(f"Expected a non-empty value for `version` but received {version!r}") |
| 388 |
extra_headers = {"Accept": "application/binary", **(extra_headers or {})} |
| 389 |
extra_headers = { |
| 390 |
**strip_not_given( |
| 391 |
{ |
| 392 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 393 |
"anthropic-workspace-id": workspace_id, |
| 394 |
} |
| 395 |
), |
| 396 |
**(extra_headers or {}), |
| 397 |
} |
| 398 |
return self._get( |
| 399 |
path_template( |
| 400 |
"/v1/skills/{skill_id}/versions/{version}/content?beta=true", skill_id=skill_id, version=version |
| 401 |
), |
| 402 |
options=make_request_options( |
| 403 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 404 |
), |
| 405 |
cast_to=BinaryAPIResponse, |
| 406 |
) |
| 407 |
|
| 408 |
|
| 409 |
class AsyncVersions(AsyncAPIResource): |
| 410 |
@cached_property |
| 411 |
def with_raw_response(self) -> AsyncVersionsWithRawResponse: |
| 412 |
""" |
| 413 |
This property can be used as a prefix for any HTTP method call to return |
| 414 |
the raw response object instead of the parsed content. |
| 415 |
|
| 416 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 417 |
""" |
| 418 |
return AsyncVersionsWithRawResponse(self) |
| 419 |
|
| 420 |
@cached_property |
| 421 |
def with_streaming_response(self) -> AsyncVersionsWithStreamingResponse: |
| 422 |
""" |
| 423 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 424 |
|
| 425 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 426 |
""" |
| 427 |
return AsyncVersionsWithStreamingResponse(self) |
| 428 |
|
| 429 |
async def create( |
| 430 |
self, |
| 431 |
skill_id: str, |
| 432 |
*, |
| 433 |
files: SequenceNotStr[FileTypes], |
| 434 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 435 |
workspace_id: str | Omit = omit, |
| 436 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 437 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 438 |
extra_headers: Headers | None = None, |
| 439 |
extra_query: Query | None = None, |
| 440 |
extra_body: Body | None = None, |
| 441 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 442 |
) -> BetaSkillVersion: |
| 443 |
""" |
| 444 |
Create Skill Version |
| 445 |
|
| 446 |
Args: |
| 447 |
skill_id: Unique identifier for the skill. |
| 448 |
|
| 449 |
The format and length of IDs may change over time. |
| 450 |
|
| 451 |
files: Files to upload for the skill. |
| 452 |
|
| 453 |
All files must be in the same top-level directory and must include a SKILL.md |
| 454 |
file at the root of that directory. |
| 455 |
|
| 456 |
betas: Optional header to specify the beta version(s) you want to use. |
| 457 |
|
| 458 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 459 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 460 |
|
| 461 |
Only needed for credentials that can act on more than one Workspace. A |
| 462 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 463 |
match that Workspace. |
| 464 |
|
| 465 |
extra_headers: Send extra headers |
| 466 |
|
| 467 |
extra_query: Add additional query parameters to the request |
| 468 |
|
| 469 |
extra_body: Add additional JSON properties to the request |
| 470 |
|
| 471 |
timeout: Override the client-level default timeout for this request, in seconds |
| 472 |
""" |
| 473 |
if not skill_id: |
| 474 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 475 |
extra_headers = { |
| 476 |
**strip_not_given( |
| 477 |
{ |
| 478 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 479 |
"anthropic-workspace-id": workspace_id, |
| 480 |
} |
| 481 |
), |
| 482 |
**(extra_headers or {}), |
| 483 |
} |
| 484 |
body = deepcopy_with_paths({"files": files}, [["files", "<array>"]]) |
| 485 |
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]]) |
| 486 |
# It should be noted that the actual Content-Type header that will be |
| 487 |
# sent to the server will contain a `boundary` parameter, e.g. |
| 488 |
# multipart/form-data; boundary=---abc-- |
| 489 |
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} |
| 490 |
return await self._post( |
| 491 |
path_template("/v1/skills/{skill_id}/versions?beta=true", skill_id=skill_id), |
| 492 |
body=body, |
| 493 |
files=extracted_files, |
| 494 |
options=make_request_options( |
| 495 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 496 |
), |
| 497 |
cast_to=BetaSkillVersion, |
| 498 |
) |
| 499 |
|
| 500 |
async def retrieve( |
| 501 |
self, |
| 502 |
version: str, |
| 503 |
*, |
| 504 |
skill_id: str, |
| 505 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 506 |
workspace_id: str | Omit = omit, |
| 507 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 508 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 509 |
extra_headers: Headers | None = None, |
| 510 |
extra_query: Query | None = None, |
| 511 |
extra_body: Body | None = None, |
| 512 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 513 |
) -> BetaSkillVersion: |
| 514 |
""" |
| 515 |
Get Skill Version |
| 516 |
|
| 517 |
Args: |
| 518 |
skill_id: Unique identifier for the skill. |
| 519 |
|
| 520 |
The format and length of IDs may change over time. |
| 521 |
|
| 522 |
version: Identifies the skill version: a version ID, or the literal `latest` for the |
| 523 |
skill's most recent version. |
| 524 |
|
| 525 |
Requests carrying the `skills-2025-10-02` beta header address versions by their |
| 526 |
Unix epoch timestamp instead (e.g., "1759178010641129"). |
| 527 |
|
| 528 |
betas: Optional header to specify the beta version(s) you want to use. |
| 529 |
|
| 530 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 531 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 532 |
|
| 533 |
Only needed for credentials that can act on more than one Workspace. A |
| 534 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 535 |
match that Workspace. |
| 536 |
|
| 537 |
extra_headers: Send extra headers |
| 538 |
|
| 539 |
extra_query: Add additional query parameters to the request |
| 540 |
|
| 541 |
extra_body: Add additional JSON properties to the request |
| 542 |
|
| 543 |
timeout: Override the client-level default timeout for this request, in seconds |
| 544 |
""" |
| 545 |
if not skill_id: |
| 546 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 547 |
if not version: |
| 548 |
raise ValueError(f"Expected a non-empty value for `version` but received {version!r}") |
| 549 |
extra_headers = { |
| 550 |
**strip_not_given( |
| 551 |
{ |
| 552 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 553 |
"anthropic-workspace-id": workspace_id, |
| 554 |
} |
| 555 |
), |
| 556 |
**(extra_headers or {}), |
| 557 |
} |
| 558 |
return await self._get( |
| 559 |
path_template("/v1/skills/{skill_id}/versions/{version}?beta=true", skill_id=skill_id, version=version), |
| 560 |
options=make_request_options( |
| 561 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 562 |
), |
| 563 |
cast_to=BetaSkillVersion, |
| 564 |
) |
| 565 |
|
| 566 |
def list( |
| 567 |
self, |
| 568 |
skill_id: str, |
| 569 |
*, |
| 570 |
limit: Optional[int] | Omit = omit, |
| 571 |
page: Optional[str] | Omit = omit, |
| 572 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 573 |
workspace_id: str | Omit = omit, |
| 574 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 575 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 576 |
extra_headers: Headers | None = None, |
| 577 |
extra_query: Query | None = None, |
| 578 |
extra_body: Body | None = None, |
| 579 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 580 |
) -> AsyncPaginator[BetaSkillVersion, AsyncPageCursor[BetaSkillVersion]]: |
| 581 |
""" |
| 582 |
List Skill Versions |
| 583 |
|
| 584 |
Args: |
| 585 |
skill_id: Unique identifier for the skill. |
| 586 |
|
| 587 |
The format and length of IDs may change over time. |
| 588 |
|
| 589 |
limit: Number of results to return per page. |
| 590 |
|
| 591 |
Ranges from `1` to `1000`. Defaults to `20`. |
| 592 |
|
| 593 |
page: Optionally set to the `next_page` token from the previous response. |
| 594 |
|
| 595 |
betas: Optional header to specify the beta version(s) you want to use. |
| 596 |
|
| 597 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 598 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 599 |
|
| 600 |
Only needed for credentials that can act on more than one Workspace. A |
| 601 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 602 |
match that Workspace. |
| 603 |
|
| 604 |
extra_headers: Send extra headers |
| 605 |
|
| 606 |
extra_query: Add additional query parameters to the request |
| 607 |
|
| 608 |
extra_body: Add additional JSON properties to the request |
| 609 |
|
| 610 |
timeout: Override the client-level default timeout for this request, in seconds |
| 611 |
""" |
| 612 |
if not skill_id: |
| 613 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 614 |
extra_headers = { |
| 615 |
**strip_not_given( |
| 616 |
{ |
| 617 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 618 |
"anthropic-workspace-id": workspace_id, |
| 619 |
} |
| 620 |
), |
| 621 |
**(extra_headers or {}), |
| 622 |
} |
| 623 |
return self._get_api_list( |
| 624 |
path_template("/v1/skills/{skill_id}/versions?beta=true", skill_id=skill_id), |
| 625 |
page=AsyncPageCursor[BetaSkillVersion], |
| 626 |
options=make_request_options( |
| 627 |
extra_headers=extra_headers, |
| 628 |
extra_query=extra_query, |
| 629 |
extra_body=extra_body, |
| 630 |
timeout=timeout, |
| 631 |
query={ |
| 632 |
"limit": limit, |
| 633 |
"page": page, |
| 634 |
}, |
| 635 |
), |
| 636 |
model=BetaSkillVersion, |
| 637 |
) |
| 638 |
|
| 639 |
async def delete( |
| 640 |
self, |
| 641 |
version: str, |
| 642 |
*, |
| 643 |
skill_id: str, |
| 644 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 645 |
workspace_id: str | Omit = omit, |
| 646 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 647 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 648 |
extra_headers: Headers | None = None, |
| 649 |
extra_query: Query | None = None, |
| 650 |
extra_body: Body | None = None, |
| 651 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 652 |
) -> BetaDeletedSkillVersion: |
| 653 |
""" |
| 654 |
Delete Skill Version |
| 655 |
|
| 656 |
Args: |
| 657 |
skill_id: Unique identifier for the skill. |
| 658 |
|
| 659 |
The format and length of IDs may change over time. |
| 660 |
|
| 661 |
version: Identifies the skill version by its version ID. |
| 662 |
|
| 663 |
Requests carrying the `skills-2025-10-02` beta header address versions by their |
| 664 |
Unix epoch timestamp instead (e.g., "1759178010641129"). |
| 665 |
|
| 666 |
betas: Optional header to specify the beta version(s) you want to use. |
| 667 |
|
| 668 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 669 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 670 |
|
| 671 |
Only needed for credentials that can act on more than one Workspace. A |
| 672 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 673 |
match that Workspace. |
| 674 |
|
| 675 |
extra_headers: Send extra headers |
| 676 |
|
| 677 |
extra_query: Add additional query parameters to the request |
| 678 |
|
| 679 |
extra_body: Add additional JSON properties to the request |
| 680 |
|
| 681 |
timeout: Override the client-level default timeout for this request, in seconds |
| 682 |
""" |
| 683 |
if not skill_id: |
| 684 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 685 |
if not version: |
| 686 |
raise ValueError(f"Expected a non-empty value for `version` but received {version!r}") |
| 687 |
extra_headers = { |
| 688 |
**strip_not_given( |
| 689 |
{ |
| 690 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 691 |
"anthropic-workspace-id": workspace_id, |
| 692 |
} |
| 693 |
), |
| 694 |
**(extra_headers or {}), |
| 695 |
} |
| 696 |
return await self._delete( |
| 697 |
path_template("/v1/skills/{skill_id}/versions/{version}?beta=true", skill_id=skill_id, version=version), |
| 698 |
options=make_request_options( |
| 699 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 700 |
), |
| 701 |
cast_to=BetaDeletedSkillVersion, |
| 702 |
) |
| 703 |
|
| 704 |
async def download( |
| 705 |
self, |
| 706 |
version: str, |
| 707 |
*, |
| 708 |
skill_id: str, |
| 709 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 710 |
workspace_id: str | Omit = omit, |
| 711 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 712 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 713 |
extra_headers: Headers | None = None, |
| 714 |
extra_query: Query | None = None, |
| 715 |
extra_body: Body | None = None, |
| 716 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 717 |
) -> AsyncBinaryAPIResponse: |
| 718 |
""" |
| 719 |
Download a skill version's content as a zip archive. |
| 720 |
|
| 721 |
Args: |
| 722 |
skill_id: Unique identifier for the skill. |
| 723 |
|
| 724 |
The format and length of IDs may change over time. |
| 725 |
|
| 726 |
version: Identifies the skill version by its version ID. |
| 727 |
|
| 728 |
Requests carrying the `skills-2025-10-02` beta header address versions by their |
| 729 |
Unix epoch timestamp instead (e.g., "1759178010641129"). |
| 730 |
|
| 731 |
betas: Optional header to specify the beta version(s) you want to use. |
| 732 |
|
| 733 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 734 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 735 |
|
| 736 |
Only needed for credentials that can act on more than one Workspace. A |
| 737 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 738 |
match that Workspace. |
| 739 |
|
| 740 |
extra_headers: Send extra headers |
| 741 |
|
| 742 |
extra_query: Add additional query parameters to the request |
| 743 |
|
| 744 |
extra_body: Add additional JSON properties to the request |
| 745 |
|
| 746 |
timeout: Override the client-level default timeout for this request, in seconds |
| 747 |
""" |
| 748 |
if not skill_id: |
| 749 |
raise ValueError(f"Expected a non-empty value for `skill_id` but received {skill_id!r}") |
| 750 |
if not version: |
| 751 |
raise ValueError(f"Expected a non-empty value for `version` but received {version!r}") |
| 752 |
extra_headers = {"Accept": "application/binary", **(extra_headers or {})} |
| 753 |
extra_headers = { |
| 754 |
**strip_not_given( |
| 755 |
{ |
| 756 |
"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given, |
| 757 |
"anthropic-workspace-id": workspace_id, |
| 758 |
} |
| 759 |
), |
| 760 |
**(extra_headers or {}), |
| 761 |
} |
| 762 |
return await self._get( |
| 763 |
path_template( |
| 764 |
"/v1/skills/{skill_id}/versions/{version}/content?beta=true", skill_id=skill_id, version=version |
| 765 |
), |
| 766 |
options=make_request_options( |
| 767 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 768 |
), |
| 769 |
cast_to=AsyncBinaryAPIResponse, |
| 770 |
) |
| 771 |
|
| 772 |
|
| 773 |
class VersionsWithRawResponse: |
| 774 |
def __init__(self, versions: Versions) -> None: |
| 775 |
self._versions = versions |
| 776 |
|
| 777 |
self.create = to_raw_response_wrapper( |
| 778 |
versions.create, |
| 779 |
) |
| 780 |
self.retrieve = to_raw_response_wrapper( |
| 781 |
versions.retrieve, |
| 782 |
) |
| 783 |
self.list = to_raw_response_wrapper( |
| 784 |
versions.list, |
| 785 |
) |
| 786 |
self.delete = to_raw_response_wrapper( |
| 787 |
versions.delete, |
| 788 |
) |
| 789 |
self.download = to_custom_raw_response_wrapper( |
| 790 |
versions.download, |
| 791 |
BinaryAPIResponse, |
| 792 |
) |
| 793 |
|
| 794 |
|
| 795 |
class AsyncVersionsWithRawResponse: |
| 796 |
def __init__(self, versions: AsyncVersions) -> None: |
| 797 |
self._versions = versions |
| 798 |
|
| 799 |
self.create = async_to_raw_response_wrapper( |
| 800 |
versions.create, |
| 801 |
) |
| 802 |
self.retrieve = async_to_raw_response_wrapper( |
| 803 |
versions.retrieve, |
| 804 |
) |
| 805 |
self.list = async_to_raw_response_wrapper( |
| 806 |
versions.list, |
| 807 |
) |
| 808 |
self.delete = async_to_raw_response_wrapper( |
| 809 |
versions.delete, |
| 810 |
) |
| 811 |
self.download = async_to_custom_raw_response_wrapper( |
| 812 |
versions.download, |
| 813 |
AsyncBinaryAPIResponse, |
| 814 |
) |
| 815 |
|
| 816 |
|
| 817 |
class VersionsWithStreamingResponse: |
| 818 |
def __init__(self, versions: Versions) -> None: |
| 819 |
self._versions = versions |
| 820 |
|
| 821 |
self.create = to_streamed_response_wrapper( |
| 822 |
versions.create, |
| 823 |
) |
| 824 |
self.retrieve = to_streamed_response_wrapper( |
| 825 |
versions.retrieve, |
| 826 |
) |
| 827 |
self.list = to_streamed_response_wrapper( |
| 828 |
versions.list, |
| 829 |
) |
| 830 |
self.delete = to_streamed_response_wrapper( |
| 831 |
versions.delete, |
| 832 |
) |
| 833 |
self.download = to_custom_streamed_response_wrapper( |
| 834 |
versions.download, |
| 835 |
StreamedBinaryAPIResponse, |
| 836 |
) |
| 837 |
|
| 838 |
|
| 839 |
class AsyncVersionsWithStreamingResponse: |
| 840 |
def __init__(self, versions: AsyncVersions) -> None: |
| 841 |
self._versions = versions |
| 842 |
|
| 843 |
self.create = async_to_streamed_response_wrapper( |
| 844 |
versions.create, |
| 845 |
) |
| 846 |
self.retrieve = async_to_streamed_response_wrapper( |
| 847 |
versions.retrieve, |
| 848 |
) |
| 849 |
self.list = async_to_streamed_response_wrapper( |
| 850 |
versions.list, |
| 851 |
) |
| 852 |
self.delete = async_to_streamed_response_wrapper( |
| 853 |
versions.delete, |
| 854 |
) |
| 855 |
self.download = async_to_custom_streamed_response_wrapper( |
| 856 |
versions.download, |
| 857 |
AsyncStreamedBinaryAPIResponse, |
| 858 |
) |