| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import Dict, List, Union, Iterable, Optional |
| 4 |
from datetime import datetime |
| 5 |
from itertools import chain |
| 6 |
|
| 7 |
import httpx2 |
| 8 |
|
| 9 |
from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given |
| 10 |
from ..._utils import is_given, path_template, strip_not_given |
| 11 |
from ..._compat import cached_property |
| 12 |
from ..._resource import SyncAPIResource, AsyncAPIResource |
| 13 |
from ..._response import ( |
| 14 |
to_raw_response_wrapper, |
| 15 |
to_streamed_response_wrapper, |
| 16 |
async_to_raw_response_wrapper, |
| 17 |
async_to_streamed_response_wrapper, |
| 18 |
) |
| 19 |
from ...pagination import SyncPageCursor, AsyncPageCursor |
| 20 |
from ...types.beta import ( |
| 21 |
BetaManagedAgentsScheduleParams, |
| 22 |
BetaManagedAgentsDeploymentStatus, |
| 23 |
deployment_create_params, |
| 24 |
deployment_update_params, |
| 25 |
) |
| 26 |
from ..._base_client import AsyncPaginator, make_request_options |
| 27 |
from ...types.anthropic_beta_param import AnthropicBetaParam |
| 28 |
from ...types.beta.beta_managed_agents_deployment import BetaManagedAgentsDeployment |
| 29 |
from ...types.beta.beta_managed_agents_deployment_run import BetaManagedAgentsDeploymentRun |
| 30 |
from ...types.beta.beta_managed_agents_schedule_params import BetaManagedAgentsScheduleParams |
| 31 |
from ...types.beta.beta_managed_agents_deployment_status import BetaManagedAgentsDeploymentStatus |
| 32 |
from ...types.beta.beta_managed_agents_budget_limit_param import BetaManagedAgentsBudgetLimitParam |
| 33 |
from ...types.beta.beta_managed_agents_deployment_initial_event_params import ( |
| 34 |
BetaManagedAgentsDeploymentInitialEventParams, |
| 35 |
) |
| 36 |
|
| 37 |
__all__ = ["Deployments", "AsyncDeployments"] |
| 38 |
|
| 39 |
|
| 40 |
class Deployments(SyncAPIResource): |
| 41 |
@cached_property |
| 42 |
def with_raw_response(self) -> DeploymentsWithRawResponse: |
| 43 |
""" |
| 44 |
This property can be used as a prefix for any HTTP method call to return |
| 45 |
the raw response object instead of the parsed content. |
| 46 |
|
| 47 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 48 |
""" |
| 49 |
return DeploymentsWithRawResponse(self) |
| 50 |
|
| 51 |
@cached_property |
| 52 |
def with_streaming_response(self) -> DeploymentsWithStreamingResponse: |
| 53 |
""" |
| 54 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 55 |
|
| 56 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 57 |
""" |
| 58 |
return DeploymentsWithStreamingResponse(self) |
| 59 |
|
| 60 |
def create( |
| 61 |
self, |
| 62 |
*, |
| 63 |
agent: deployment_create_params.Agent, |
| 64 |
environment_id: str, |
| 65 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams], |
| 66 |
name: str, |
| 67 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 68 |
description: Optional[str] | Omit = omit, |
| 69 |
metadata: Dict[str, str] | Omit = omit, |
| 70 |
resources: Iterable[deployment_create_params.Resource] | Omit = omit, |
| 71 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 72 |
vault_ids: SequenceNotStr[str] | Omit = omit, |
| 73 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 74 |
workspace_id: str | Omit = omit, |
| 75 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 76 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 77 |
extra_headers: Headers | None = None, |
| 78 |
extra_query: Query | None = None, |
| 79 |
extra_body: Body | None = None, |
| 80 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 81 |
) -> BetaManagedAgentsDeployment: |
| 82 |
"""Create Deployment |
| 83 |
|
| 84 |
Args: |
| 85 |
agent: Agent to deploy. |
| 86 |
|
| 87 |
Accepts the `agent` ID string, which pins the latest version, |
| 88 |
or an `agent` object with both id and version specified. The agent must exist |
| 89 |
and not be archived. |
| 90 |
|
| 91 |
environment_id: ID of the `environment` defining the container configuration for sessions |
| 92 |
created from this deployment. |
| 93 |
|
| 94 |
initial_events: Events to send to each session immediately after creation. At least 1, |
| 95 |
maximum 50. |
| 96 |
|
| 97 |
name: Human-readable name for the deployment. |
| 98 |
|
| 99 |
budget: Enforced spend ceiling stamped onto each session created from this deployment, |
| 100 |
copied at session-creation time. Omit to leave sessions uncapped. The deployment |
| 101 |
agent's model must have a public list price, or the request is rejected; a |
| 102 |
multiagent roster is re-validated in full when each fire copies the cap, which |
| 103 |
fails closed the same way. |
| 104 |
|
| 105 |
description: Description of what the deployment does. |
| 106 |
|
| 107 |
metadata: Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up |
| 108 |
to 512 chars. |
| 109 |
|
| 110 |
resources: Resources (e.g. repositories, files) to mount into each session's container. |
| 111 |
Maximum 500. |
| 112 |
|
| 113 |
schedule: Optional recurring cron schedule. When present, the deployment fires |
| 114 |
automatically. Both expression and timezone are required when schedule is set. |
| 115 |
|
| 116 |
vault_ids: Vault IDs for stored credentials the agent can use during sessions created from |
| 117 |
this deployment. Maximum 50. |
| 118 |
|
| 119 |
betas: Optional header to specify the beta version(s) you want to use. |
| 120 |
|
| 121 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 122 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 123 |
|
| 124 |
Only needed for credentials that can act on more than one Workspace. A |
| 125 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 126 |
match that Workspace. |
| 127 |
|
| 128 |
extra_headers: Send extra headers |
| 129 |
|
| 130 |
extra_query: Add additional query parameters to the request |
| 131 |
|
| 132 |
extra_body: Add additional JSON properties to the request |
| 133 |
|
| 134 |
timeout: Override the client-level default timeout for this request, in seconds |
| 135 |
""" |
| 136 |
extra_headers = { |
| 137 |
**strip_not_given( |
| 138 |
{ |
| 139 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 140 |
if is_given(betas) |
| 141 |
else not_given, |
| 142 |
"anthropic-workspace-id": workspace_id, |
| 143 |
} |
| 144 |
), |
| 145 |
**(extra_headers or {}), |
| 146 |
} |
| 147 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 148 |
return self._post( |
| 149 |
"/v1/deployments?beta=true", |
| 150 |
body={ |
| 151 |
"agent": agent, |
| 152 |
"environment_id": environment_id, |
| 153 |
"initial_events": initial_events, |
| 154 |
"name": name, |
| 155 |
"budget": budget, |
| 156 |
"description": description, |
| 157 |
"metadata": metadata, |
| 158 |
"resources": resources, |
| 159 |
"schedule": schedule, |
| 160 |
"vault_ids": vault_ids, |
| 161 |
}, |
| 162 |
options=make_request_options( |
| 163 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 164 |
), |
| 165 |
cast_to=BetaManagedAgentsDeployment, |
| 166 |
) |
| 167 |
|
| 168 |
def retrieve( |
| 169 |
self, |
| 170 |
deployment_id: str, |
| 171 |
*, |
| 172 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 173 |
workspace_id: str | Omit = omit, |
| 174 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 175 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 176 |
extra_headers: Headers | None = None, |
| 177 |
extra_query: Query | None = None, |
| 178 |
extra_body: Body | None = None, |
| 179 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 180 |
) -> BetaManagedAgentsDeployment: |
| 181 |
""" |
| 182 |
Get Deployment |
| 183 |
|
| 184 |
Args: |
| 185 |
deployment_id: Unique identifier of the deployment. |
| 186 |
|
| 187 |
betas: Optional header to specify the beta version(s) you want to use. |
| 188 |
|
| 189 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 190 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 191 |
|
| 192 |
Only needed for credentials that can act on more than one Workspace. A |
| 193 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 194 |
match that Workspace. |
| 195 |
|
| 196 |
extra_headers: Send extra headers |
| 197 |
|
| 198 |
extra_query: Add additional query parameters to the request |
| 199 |
|
| 200 |
extra_body: Add additional JSON properties to the request |
| 201 |
|
| 202 |
timeout: Override the client-level default timeout for this request, in seconds |
| 203 |
""" |
| 204 |
if not deployment_id: |
| 205 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 206 |
extra_headers = { |
| 207 |
**strip_not_given( |
| 208 |
{ |
| 209 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 210 |
if is_given(betas) |
| 211 |
else not_given, |
| 212 |
"anthropic-workspace-id": workspace_id, |
| 213 |
} |
| 214 |
), |
| 215 |
**(extra_headers or {}), |
| 216 |
} |
| 217 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 218 |
return self._get( |
| 219 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 220 |
options=make_request_options( |
| 221 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 222 |
), |
| 223 |
cast_to=BetaManagedAgentsDeployment, |
| 224 |
) |
| 225 |
|
| 226 |
def update( |
| 227 |
self, |
| 228 |
deployment_id: str, |
| 229 |
*, |
| 230 |
agent: deployment_update_params.Agent | Omit = omit, |
| 231 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 232 |
description: Optional[str] | Omit = omit, |
| 233 |
environment_id: str | Omit = omit, |
| 234 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams] | Omit = omit, |
| 235 |
metadata: Optional[Dict[str, Optional[str]]] | Omit = omit, |
| 236 |
name: str | Omit = omit, |
| 237 |
resources: Optional[Iterable[deployment_update_params.Resource]] | Omit = omit, |
| 238 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 239 |
vault_ids: Optional[SequenceNotStr[str]] | Omit = omit, |
| 240 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 241 |
workspace_id: str | Omit = omit, |
| 242 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 243 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 244 |
extra_headers: Headers | None = None, |
| 245 |
extra_query: Query | None = None, |
| 246 |
extra_body: Body | None = None, |
| 247 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 248 |
) -> BetaManagedAgentsDeployment: |
| 249 |
""" |
| 250 |
Update Deployment |
| 251 |
|
| 252 |
Args: |
| 253 |
deployment_id: Unique identifier of the deployment to update. |
| 254 |
|
| 255 |
agent: Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest |
| 256 |
version, or an `agent` object with both id and version specified. Omit to |
| 257 |
preserve. Cannot be cleared. |
| 258 |
|
| 259 |
budget: Spend ceiling for future sessions. Full replacement. Omit to preserve; send null |
| 260 |
to clear (sessions created afterwards are uncapped). The deployment agent's |
| 261 |
model must have a public list price, or the request is rejected; a multiagent |
| 262 |
roster is re-validated in full when each fire copies the cap, which fails closed |
| 263 |
the same way. |
| 264 |
|
| 265 |
description: Description. Omit to preserve; send empty string or null to clear. |
| 266 |
|
| 267 |
environment_id: ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. |
| 268 |
|
| 269 |
initial_events: Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least |
| 270 |
1, maximum 50. |
| 271 |
|
| 272 |
metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it. |
| 273 |
Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars |
| 274 |
each) with values up to 512 chars. |
| 275 |
|
| 276 |
name: Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. |
| 277 |
|
| 278 |
resources: Session resources. Full replacement. Omit to preserve; send empty array or null |
| 279 |
to clear. Maximum 500. |
| 280 |
|
| 281 |
schedule: Cron schedule. Full replacement. Omit to preserve; send null to clear (revert to |
| 282 |
manual-only). |
| 283 |
|
| 284 |
vault_ids: Vault IDs. Full replacement. Omit to preserve; send empty array or null to |
| 285 |
clear. Maximum 50. |
| 286 |
|
| 287 |
betas: Optional header to specify the beta version(s) you want to use. |
| 288 |
|
| 289 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 290 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 291 |
|
| 292 |
Only needed for credentials that can act on more than one Workspace. A |
| 293 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 294 |
match that Workspace. |
| 295 |
|
| 296 |
extra_headers: Send extra headers |
| 297 |
|
| 298 |
extra_query: Add additional query parameters to the request |
| 299 |
|
| 300 |
extra_body: Add additional JSON properties to the request |
| 301 |
|
| 302 |
timeout: Override the client-level default timeout for this request, in seconds |
| 303 |
""" |
| 304 |
if not deployment_id: |
| 305 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 306 |
extra_headers = { |
| 307 |
**strip_not_given( |
| 308 |
{ |
| 309 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 310 |
if is_given(betas) |
| 311 |
else not_given, |
| 312 |
"anthropic-workspace-id": workspace_id, |
| 313 |
} |
| 314 |
), |
| 315 |
**(extra_headers or {}), |
| 316 |
} |
| 317 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 318 |
return self._post( |
| 319 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 320 |
body={ |
| 321 |
"agent": agent, |
| 322 |
"budget": budget, |
| 323 |
"description": description, |
| 324 |
"environment_id": environment_id, |
| 325 |
"initial_events": initial_events, |
| 326 |
"metadata": metadata, |
| 327 |
"name": name, |
| 328 |
"resources": resources, |
| 329 |
"schedule": schedule, |
| 330 |
"vault_ids": vault_ids, |
| 331 |
}, |
| 332 |
options=make_request_options( |
| 333 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 334 |
), |
| 335 |
cast_to=BetaManagedAgentsDeployment, |
| 336 |
) |
| 337 |
|
| 338 |
def list( |
| 339 |
self, |
| 340 |
*, |
| 341 |
agent_id: str | Omit = omit, |
| 342 |
created_at_gte: Union[str, datetime] | Omit = omit, |
| 343 |
created_at_lte: Union[str, datetime] | Omit = omit, |
| 344 |
include_archived: bool | Omit = omit, |
| 345 |
limit: int | Omit = omit, |
| 346 |
page: str | Omit = omit, |
| 347 |
status: BetaManagedAgentsDeploymentStatus | Omit = omit, |
| 348 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 349 |
workspace_id: str | Omit = omit, |
| 350 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 351 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 352 |
extra_headers: Headers | None = None, |
| 353 |
extra_query: Query | None = None, |
| 354 |
extra_body: Body | None = None, |
| 355 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 356 |
) -> SyncPageCursor[BetaManagedAgentsDeployment]: |
| 357 |
""" |
| 358 |
List Deployments |
| 359 |
|
| 360 |
Args: |
| 361 |
agent_id: Filter by agent ID. |
| 362 |
|
| 363 |
created_at_gte: Return deployments created at or after this time (inclusive). |
| 364 |
|
| 365 |
created_at_lte: Return deployments created at or before this time (inclusive). |
| 366 |
|
| 367 |
include_archived: When true, includes archived deployments. Default: false (exclude archived). |
| 368 |
|
| 369 |
limit: Maximum results per page. Default 20, maximum 100. |
| 370 |
|
| 371 |
page: Opaque pagination cursor. |
| 372 |
|
| 373 |
status: Filter by status: `active` or `paused`. Omit for both. To include archived |
| 374 |
deployments, use `include_archived` instead; the two cannot be combined. |
| 375 |
|
| 376 |
betas: Optional header to specify the beta version(s) you want to use. |
| 377 |
|
| 378 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 379 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 380 |
|
| 381 |
Only needed for credentials that can act on more than one Workspace. A |
| 382 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 383 |
match that Workspace. |
| 384 |
|
| 385 |
extra_headers: Send extra headers |
| 386 |
|
| 387 |
extra_query: Add additional query parameters to the request |
| 388 |
|
| 389 |
extra_body: Add additional JSON properties to the request |
| 390 |
|
| 391 |
timeout: Override the client-level default timeout for this request, in seconds |
| 392 |
""" |
| 393 |
extra_headers = { |
| 394 |
**strip_not_given( |
| 395 |
{ |
| 396 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 397 |
if is_given(betas) |
| 398 |
else not_given, |
| 399 |
"anthropic-workspace-id": workspace_id, |
| 400 |
} |
| 401 |
), |
| 402 |
**(extra_headers or {}), |
| 403 |
} |
| 404 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 405 |
return self._get_api_list( |
| 406 |
"/v1/deployments?beta=true", |
| 407 |
page=SyncPageCursor[BetaManagedAgentsDeployment], |
| 408 |
options=make_request_options( |
| 409 |
extra_headers=extra_headers, |
| 410 |
extra_query=extra_query, |
| 411 |
extra_body=extra_body, |
| 412 |
timeout=timeout, |
| 413 |
query={ |
| 414 |
"agent_id": agent_id, |
| 415 |
"created_at[gte]": created_at_gte, |
| 416 |
"created_at[lte]": created_at_lte, |
| 417 |
"include_archived": include_archived, |
| 418 |
"limit": limit, |
| 419 |
"page": page, |
| 420 |
"status": status, |
| 421 |
}, |
| 422 |
), |
| 423 |
model=BetaManagedAgentsDeployment, |
| 424 |
) |
| 425 |
|
| 426 |
def archive( |
| 427 |
self, |
| 428 |
deployment_id: str, |
| 429 |
*, |
| 430 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 431 |
workspace_id: str | Omit = omit, |
| 432 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 433 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 434 |
extra_headers: Headers | None = None, |
| 435 |
extra_query: Query | None = None, |
| 436 |
extra_body: Body | None = None, |
| 437 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 438 |
) -> BetaManagedAgentsDeployment: |
| 439 |
""" |
| 440 |
Archive Deployment |
| 441 |
|
| 442 |
Args: |
| 443 |
deployment_id: Unique identifier of the deployment to archive. |
| 444 |
|
| 445 |
betas: Optional header to specify the beta version(s) you want to use. |
| 446 |
|
| 447 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 448 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 449 |
|
| 450 |
Only needed for credentials that can act on more than one Workspace. A |
| 451 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 452 |
match that Workspace. |
| 453 |
|
| 454 |
extra_headers: Send extra headers |
| 455 |
|
| 456 |
extra_query: Add additional query parameters to the request |
| 457 |
|
| 458 |
extra_body: Add additional JSON properties to the request |
| 459 |
|
| 460 |
timeout: Override the client-level default timeout for this request, in seconds |
| 461 |
""" |
| 462 |
if not deployment_id: |
| 463 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 464 |
extra_headers = { |
| 465 |
**strip_not_given( |
| 466 |
{ |
| 467 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 468 |
if is_given(betas) |
| 469 |
else not_given, |
| 470 |
"anthropic-workspace-id": workspace_id, |
| 471 |
} |
| 472 |
), |
| 473 |
**(extra_headers or {}), |
| 474 |
} |
| 475 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 476 |
return self._post( |
| 477 |
path_template("/v1/deployments/{deployment_id}/archive?beta=true", deployment_id=deployment_id), |
| 478 |
options=make_request_options( |
| 479 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 480 |
), |
| 481 |
cast_to=BetaManagedAgentsDeployment, |
| 482 |
) |
| 483 |
|
| 484 |
def pause( |
| 485 |
self, |
| 486 |
deployment_id: str, |
| 487 |
*, |
| 488 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 489 |
workspace_id: str | Omit = omit, |
| 490 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 491 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 492 |
extra_headers: Headers | None = None, |
| 493 |
extra_query: Query | None = None, |
| 494 |
extra_body: Body | None = None, |
| 495 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 496 |
) -> BetaManagedAgentsDeployment: |
| 497 |
""" |
| 498 |
Pause Deployment |
| 499 |
|
| 500 |
Args: |
| 501 |
deployment_id: Unique identifier of the deployment to pause. |
| 502 |
|
| 503 |
betas: Optional header to specify the beta version(s) you want to use. |
| 504 |
|
| 505 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 506 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 507 |
|
| 508 |
Only needed for credentials that can act on more than one Workspace. A |
| 509 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 510 |
match that Workspace. |
| 511 |
|
| 512 |
extra_headers: Send extra headers |
| 513 |
|
| 514 |
extra_query: Add additional query parameters to the request |
| 515 |
|
| 516 |
extra_body: Add additional JSON properties to the request |
| 517 |
|
| 518 |
timeout: Override the client-level default timeout for this request, in seconds |
| 519 |
""" |
| 520 |
if not deployment_id: |
| 521 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 522 |
extra_headers = { |
| 523 |
**strip_not_given( |
| 524 |
{ |
| 525 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 526 |
if is_given(betas) |
| 527 |
else not_given, |
| 528 |
"anthropic-workspace-id": workspace_id, |
| 529 |
} |
| 530 |
), |
| 531 |
**(extra_headers or {}), |
| 532 |
} |
| 533 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 534 |
return self._post( |
| 535 |
path_template("/v1/deployments/{deployment_id}/pause?beta=true", deployment_id=deployment_id), |
| 536 |
options=make_request_options( |
| 537 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 538 |
), |
| 539 |
cast_to=BetaManagedAgentsDeployment, |
| 540 |
) |
| 541 |
|
| 542 |
def run( |
| 543 |
self, |
| 544 |
deployment_id: str, |
| 545 |
*, |
| 546 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 547 |
workspace_id: str | Omit = omit, |
| 548 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 549 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 550 |
extra_headers: Headers | None = None, |
| 551 |
extra_query: Query | None = None, |
| 552 |
extra_body: Body | None = None, |
| 553 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 554 |
) -> BetaManagedAgentsDeploymentRun: |
| 555 |
""" |
| 556 |
Run Deployment Now |
| 557 |
|
| 558 |
Args: |
| 559 |
deployment_id: Unique identifier of the deployment to run. |
| 560 |
|
| 561 |
betas: Optional header to specify the beta version(s) you want to use. |
| 562 |
|
| 563 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 564 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 565 |
|
| 566 |
Only needed for credentials that can act on more than one Workspace. A |
| 567 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 568 |
match that Workspace. |
| 569 |
|
| 570 |
extra_headers: Send extra headers |
| 571 |
|
| 572 |
extra_query: Add additional query parameters to the request |
| 573 |
|
| 574 |
extra_body: Add additional JSON properties to the request |
| 575 |
|
| 576 |
timeout: Override the client-level default timeout for this request, in seconds |
| 577 |
""" |
| 578 |
if not deployment_id: |
| 579 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 580 |
extra_headers = { |
| 581 |
**strip_not_given( |
| 582 |
{ |
| 583 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 584 |
if is_given(betas) |
| 585 |
else not_given, |
| 586 |
"anthropic-workspace-id": workspace_id, |
| 587 |
} |
| 588 |
), |
| 589 |
**(extra_headers or {}), |
| 590 |
} |
| 591 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 592 |
return self._post( |
| 593 |
path_template("/v1/deployments/{deployment_id}/run?beta=true", deployment_id=deployment_id), |
| 594 |
options=make_request_options( |
| 595 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 596 |
), |
| 597 |
cast_to=BetaManagedAgentsDeploymentRun, |
| 598 |
) |
| 599 |
|
| 600 |
def unpause( |
| 601 |
self, |
| 602 |
deployment_id: str, |
| 603 |
*, |
| 604 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 605 |
workspace_id: str | Omit = omit, |
| 606 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 607 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 608 |
extra_headers: Headers | None = None, |
| 609 |
extra_query: Query | None = None, |
| 610 |
extra_body: Body | None = None, |
| 611 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 612 |
) -> BetaManagedAgentsDeployment: |
| 613 |
""" |
| 614 |
Unpause Deployment |
| 615 |
|
| 616 |
Args: |
| 617 |
deployment_id: Unique identifier of the deployment to unpause. |
| 618 |
|
| 619 |
betas: Optional header to specify the beta version(s) you want to use. |
| 620 |
|
| 621 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 622 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 623 |
|
| 624 |
Only needed for credentials that can act on more than one Workspace. A |
| 625 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 626 |
match that Workspace. |
| 627 |
|
| 628 |
extra_headers: Send extra headers |
| 629 |
|
| 630 |
extra_query: Add additional query parameters to the request |
| 631 |
|
| 632 |
extra_body: Add additional JSON properties to the request |
| 633 |
|
| 634 |
timeout: Override the client-level default timeout for this request, in seconds |
| 635 |
""" |
| 636 |
if not deployment_id: |
| 637 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 638 |
extra_headers = { |
| 639 |
**strip_not_given( |
| 640 |
{ |
| 641 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 642 |
if is_given(betas) |
| 643 |
else not_given, |
| 644 |
"anthropic-workspace-id": workspace_id, |
| 645 |
} |
| 646 |
), |
| 647 |
**(extra_headers or {}), |
| 648 |
} |
| 649 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 650 |
return self._post( |
| 651 |
path_template("/v1/deployments/{deployment_id}/unpause?beta=true", deployment_id=deployment_id), |
| 652 |
options=make_request_options( |
| 653 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 654 |
), |
| 655 |
cast_to=BetaManagedAgentsDeployment, |
| 656 |
) |
| 657 |
|
| 658 |
|
| 659 |
class AsyncDeployments(AsyncAPIResource): |
| 660 |
@cached_property |
| 661 |
def with_raw_response(self) -> AsyncDeploymentsWithRawResponse: |
| 662 |
""" |
| 663 |
This property can be used as a prefix for any HTTP method call to return |
| 664 |
the raw response object instead of the parsed content. |
| 665 |
|
| 666 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers |
| 667 |
""" |
| 668 |
return AsyncDeploymentsWithRawResponse(self) |
| 669 |
|
| 670 |
@cached_property |
| 671 |
def with_streaming_response(self) -> AsyncDeploymentsWithStreamingResponse: |
| 672 |
""" |
| 673 |
An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 674 |
|
| 675 |
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response |
| 676 |
""" |
| 677 |
return AsyncDeploymentsWithStreamingResponse(self) |
| 678 |
|
| 679 |
async def create( |
| 680 |
self, |
| 681 |
*, |
| 682 |
agent: deployment_create_params.Agent, |
| 683 |
environment_id: str, |
| 684 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams], |
| 685 |
name: str, |
| 686 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 687 |
description: Optional[str] | Omit = omit, |
| 688 |
metadata: Dict[str, str] | Omit = omit, |
| 689 |
resources: Iterable[deployment_create_params.Resource] | Omit = omit, |
| 690 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 691 |
vault_ids: SequenceNotStr[str] | Omit = omit, |
| 692 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 693 |
workspace_id: str | Omit = omit, |
| 694 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 695 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 696 |
extra_headers: Headers | None = None, |
| 697 |
extra_query: Query | None = None, |
| 698 |
extra_body: Body | None = None, |
| 699 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 700 |
) -> BetaManagedAgentsDeployment: |
| 701 |
"""Create Deployment |
| 702 |
|
| 703 |
Args: |
| 704 |
agent: Agent to deploy. |
| 705 |
|
| 706 |
Accepts the `agent` ID string, which pins the latest version, |
| 707 |
or an `agent` object with both id and version specified. The agent must exist |
| 708 |
and not be archived. |
| 709 |
|
| 710 |
environment_id: ID of the `environment` defining the container configuration for sessions |
| 711 |
created from this deployment. |
| 712 |
|
| 713 |
initial_events: Events to send to each session immediately after creation. At least 1, |
| 714 |
maximum 50. |
| 715 |
|
| 716 |
name: Human-readable name for the deployment. |
| 717 |
|
| 718 |
budget: Enforced spend ceiling stamped onto each session created from this deployment, |
| 719 |
copied at session-creation time. Omit to leave sessions uncapped. The deployment |
| 720 |
agent's model must have a public list price, or the request is rejected; a |
| 721 |
multiagent roster is re-validated in full when each fire copies the cap, which |
| 722 |
fails closed the same way. |
| 723 |
|
| 724 |
description: Description of what the deployment does. |
| 725 |
|
| 726 |
metadata: Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up |
| 727 |
to 512 chars. |
| 728 |
|
| 729 |
resources: Resources (e.g. repositories, files) to mount into each session's container. |
| 730 |
Maximum 500. |
| 731 |
|
| 732 |
schedule: Optional recurring cron schedule. When present, the deployment fires |
| 733 |
automatically. Both expression and timezone are required when schedule is set. |
| 734 |
|
| 735 |
vault_ids: Vault IDs for stored credentials the agent can use during sessions created from |
| 736 |
this deployment. Maximum 50. |
| 737 |
|
| 738 |
betas: Optional header to specify the beta version(s) you want to use. |
| 739 |
|
| 740 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 741 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 742 |
|
| 743 |
Only needed for credentials that can act on more than one Workspace. A |
| 744 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 745 |
match that Workspace. |
| 746 |
|
| 747 |
extra_headers: Send extra headers |
| 748 |
|
| 749 |
extra_query: Add additional query parameters to the request |
| 750 |
|
| 751 |
extra_body: Add additional JSON properties to the request |
| 752 |
|
| 753 |
timeout: Override the client-level default timeout for this request, in seconds |
| 754 |
""" |
| 755 |
extra_headers = { |
| 756 |
**strip_not_given( |
| 757 |
{ |
| 758 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 759 |
if is_given(betas) |
| 760 |
else not_given, |
| 761 |
"anthropic-workspace-id": workspace_id, |
| 762 |
} |
| 763 |
), |
| 764 |
**(extra_headers or {}), |
| 765 |
} |
| 766 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 767 |
return await self._post( |
| 768 |
"/v1/deployments?beta=true", |
| 769 |
body={ |
| 770 |
"agent": agent, |
| 771 |
"environment_id": environment_id, |
| 772 |
"initial_events": initial_events, |
| 773 |
"name": name, |
| 774 |
"budget": budget, |
| 775 |
"description": description, |
| 776 |
"metadata": metadata, |
| 777 |
"resources": resources, |
| 778 |
"schedule": schedule, |
| 779 |
"vault_ids": vault_ids, |
| 780 |
}, |
| 781 |
options=make_request_options( |
| 782 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 783 |
), |
| 784 |
cast_to=BetaManagedAgentsDeployment, |
| 785 |
) |
| 786 |
|
| 787 |
async def retrieve( |
| 788 |
self, |
| 789 |
deployment_id: str, |
| 790 |
*, |
| 791 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 792 |
workspace_id: str | Omit = omit, |
| 793 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 794 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 795 |
extra_headers: Headers | None = None, |
| 796 |
extra_query: Query | None = None, |
| 797 |
extra_body: Body | None = None, |
| 798 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 799 |
) -> BetaManagedAgentsDeployment: |
| 800 |
""" |
| 801 |
Get Deployment |
| 802 |
|
| 803 |
Args: |
| 804 |
deployment_id: Unique identifier of the deployment. |
| 805 |
|
| 806 |
betas: Optional header to specify the beta version(s) you want to use. |
| 807 |
|
| 808 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 809 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 810 |
|
| 811 |
Only needed for credentials that can act on more than one Workspace. A |
| 812 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 813 |
match that Workspace. |
| 814 |
|
| 815 |
extra_headers: Send extra headers |
| 816 |
|
| 817 |
extra_query: Add additional query parameters to the request |
| 818 |
|
| 819 |
extra_body: Add additional JSON properties to the request |
| 820 |
|
| 821 |
timeout: Override the client-level default timeout for this request, in seconds |
| 822 |
""" |
| 823 |
if not deployment_id: |
| 824 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 825 |
extra_headers = { |
| 826 |
**strip_not_given( |
| 827 |
{ |
| 828 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 829 |
if is_given(betas) |
| 830 |
else not_given, |
| 831 |
"anthropic-workspace-id": workspace_id, |
| 832 |
} |
| 833 |
), |
| 834 |
**(extra_headers or {}), |
| 835 |
} |
| 836 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 837 |
return await self._get( |
| 838 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 839 |
options=make_request_options( |
| 840 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 841 |
), |
| 842 |
cast_to=BetaManagedAgentsDeployment, |
| 843 |
) |
| 844 |
|
| 845 |
async def update( |
| 846 |
self, |
| 847 |
deployment_id: str, |
| 848 |
*, |
| 849 |
agent: deployment_update_params.Agent | Omit = omit, |
| 850 |
budget: Optional[BetaManagedAgentsBudgetLimitParam] | Omit = omit, |
| 851 |
description: Optional[str] | Omit = omit, |
| 852 |
environment_id: str | Omit = omit, |
| 853 |
initial_events: Iterable[BetaManagedAgentsDeploymentInitialEventParams] | Omit = omit, |
| 854 |
metadata: Optional[Dict[str, Optional[str]]] | Omit = omit, |
| 855 |
name: str | Omit = omit, |
| 856 |
resources: Optional[Iterable[deployment_update_params.Resource]] | Omit = omit, |
| 857 |
schedule: Optional[BetaManagedAgentsScheduleParams] | Omit = omit, |
| 858 |
vault_ids: Optional[SequenceNotStr[str]] | Omit = omit, |
| 859 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 860 |
workspace_id: str | Omit = omit, |
| 861 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 862 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 863 |
extra_headers: Headers | None = None, |
| 864 |
extra_query: Query | None = None, |
| 865 |
extra_body: Body | None = None, |
| 866 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 867 |
) -> BetaManagedAgentsDeployment: |
| 868 |
""" |
| 869 |
Update Deployment |
| 870 |
|
| 871 |
Args: |
| 872 |
deployment_id: Unique identifier of the deployment to update. |
| 873 |
|
| 874 |
agent: Agent to deploy. Accepts the `agent` ID string, which re-pins to the latest |
| 875 |
version, or an `agent` object with both id and version specified. Omit to |
| 876 |
preserve. Cannot be cleared. |
| 877 |
|
| 878 |
budget: Spend ceiling for future sessions. Full replacement. Omit to preserve; send null |
| 879 |
to clear (sessions created afterwards are uncapped). The deployment agent's |
| 880 |
model must have a public list price, or the request is rejected; a multiagent |
| 881 |
roster is re-validated in full when each fire copies the cap, which fails closed |
| 882 |
the same way. |
| 883 |
|
| 884 |
description: Description. Omit to preserve; send empty string or null to clear. |
| 885 |
|
| 886 |
environment_id: ID of the `environment` where sessions run. Omit to preserve. Cannot be cleared. |
| 887 |
|
| 888 |
initial_events: Initial events. Full replacement. Omit to preserve. Cannot be cleared. At least |
| 889 |
1, maximum 50. |
| 890 |
|
| 891 |
metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it. |
| 892 |
Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars |
| 893 |
each) with values up to 512 chars. |
| 894 |
|
| 895 |
name: Human-readable name. Must be non-empty. Omit to preserve. Cannot be cleared. |
| 896 |
|
| 897 |
resources: Session resources. Full replacement. Omit to preserve; send empty array or null |
| 898 |
to clear. Maximum 500. |
| 899 |
|
| 900 |
schedule: Cron schedule. Full replacement. Omit to preserve; send null to clear (revert to |
| 901 |
manual-only). |
| 902 |
|
| 903 |
vault_ids: Vault IDs. Full replacement. Omit to preserve; send empty array or null to |
| 904 |
clear. Maximum 50. |
| 905 |
|
| 906 |
betas: Optional header to specify the beta version(s) you want to use. |
| 907 |
|
| 908 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 909 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 910 |
|
| 911 |
Only needed for credentials that can act on more than one Workspace. A |
| 912 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 913 |
match that Workspace. |
| 914 |
|
| 915 |
extra_headers: Send extra headers |
| 916 |
|
| 917 |
extra_query: Add additional query parameters to the request |
| 918 |
|
| 919 |
extra_body: Add additional JSON properties to the request |
| 920 |
|
| 921 |
timeout: Override the client-level default timeout for this request, in seconds |
| 922 |
""" |
| 923 |
if not deployment_id: |
| 924 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 925 |
extra_headers = { |
| 926 |
**strip_not_given( |
| 927 |
{ |
| 928 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 929 |
if is_given(betas) |
| 930 |
else not_given, |
| 931 |
"anthropic-workspace-id": workspace_id, |
| 932 |
} |
| 933 |
), |
| 934 |
**(extra_headers or {}), |
| 935 |
} |
| 936 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 937 |
return await self._post( |
| 938 |
path_template("/v1/deployments/{deployment_id}?beta=true", deployment_id=deployment_id), |
| 939 |
body={ |
| 940 |
"agent": agent, |
| 941 |
"budget": budget, |
| 942 |
"description": description, |
| 943 |
"environment_id": environment_id, |
| 944 |
"initial_events": initial_events, |
| 945 |
"metadata": metadata, |
| 946 |
"name": name, |
| 947 |
"resources": resources, |
| 948 |
"schedule": schedule, |
| 949 |
"vault_ids": vault_ids, |
| 950 |
}, |
| 951 |
options=make_request_options( |
| 952 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 953 |
), |
| 954 |
cast_to=BetaManagedAgentsDeployment, |
| 955 |
) |
| 956 |
|
| 957 |
def list( |
| 958 |
self, |
| 959 |
*, |
| 960 |
agent_id: str | Omit = omit, |
| 961 |
created_at_gte: Union[str, datetime] | Omit = omit, |
| 962 |
created_at_lte: Union[str, datetime] | Omit = omit, |
| 963 |
include_archived: bool | Omit = omit, |
| 964 |
limit: int | Omit = omit, |
| 965 |
page: str | Omit = omit, |
| 966 |
status: BetaManagedAgentsDeploymentStatus | Omit = omit, |
| 967 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 968 |
workspace_id: str | Omit = omit, |
| 969 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 970 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 971 |
extra_headers: Headers | None = None, |
| 972 |
extra_query: Query | None = None, |
| 973 |
extra_body: Body | None = None, |
| 974 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 975 |
) -> AsyncPaginator[BetaManagedAgentsDeployment, AsyncPageCursor[BetaManagedAgentsDeployment]]: |
| 976 |
""" |
| 977 |
List Deployments |
| 978 |
|
| 979 |
Args: |
| 980 |
agent_id: Filter by agent ID. |
| 981 |
|
| 982 |
created_at_gte: Return deployments created at or after this time (inclusive). |
| 983 |
|
| 984 |
created_at_lte: Return deployments created at or before this time (inclusive). |
| 985 |
|
| 986 |
include_archived: When true, includes archived deployments. Default: false (exclude archived). |
| 987 |
|
| 988 |
limit: Maximum results per page. Default 20, maximum 100. |
| 989 |
|
| 990 |
page: Opaque pagination cursor. |
| 991 |
|
| 992 |
status: Filter by status: `active` or `paused`. Omit for both. To include archived |
| 993 |
deployments, use `include_archived` instead; the two cannot be combined. |
| 994 |
|
| 995 |
betas: Optional header to specify the beta version(s) you want to use. |
| 996 |
|
| 997 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 998 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 999 |
|
| 1000 |
Only needed for credentials that can act on more than one Workspace. A |
| 1001 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1002 |
match that Workspace. |
| 1003 |
|
| 1004 |
extra_headers: Send extra headers |
| 1005 |
|
| 1006 |
extra_query: Add additional query parameters to the request |
| 1007 |
|
| 1008 |
extra_body: Add additional JSON properties to the request |
| 1009 |
|
| 1010 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1011 |
""" |
| 1012 |
extra_headers = { |
| 1013 |
**strip_not_given( |
| 1014 |
{ |
| 1015 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1016 |
if is_given(betas) |
| 1017 |
else not_given, |
| 1018 |
"anthropic-workspace-id": workspace_id, |
| 1019 |
} |
| 1020 |
), |
| 1021 |
**(extra_headers or {}), |
| 1022 |
} |
| 1023 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1024 |
return self._get_api_list( |
| 1025 |
"/v1/deployments?beta=true", |
| 1026 |
page=AsyncPageCursor[BetaManagedAgentsDeployment], |
| 1027 |
options=make_request_options( |
| 1028 |
extra_headers=extra_headers, |
| 1029 |
extra_query=extra_query, |
| 1030 |
extra_body=extra_body, |
| 1031 |
timeout=timeout, |
| 1032 |
query={ |
| 1033 |
"agent_id": agent_id, |
| 1034 |
"created_at[gte]": created_at_gte, |
| 1035 |
"created_at[lte]": created_at_lte, |
| 1036 |
"include_archived": include_archived, |
| 1037 |
"limit": limit, |
| 1038 |
"page": page, |
| 1039 |
"status": status, |
| 1040 |
}, |
| 1041 |
), |
| 1042 |
model=BetaManagedAgentsDeployment, |
| 1043 |
) |
| 1044 |
|
| 1045 |
async def archive( |
| 1046 |
self, |
| 1047 |
deployment_id: str, |
| 1048 |
*, |
| 1049 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1050 |
workspace_id: str | Omit = omit, |
| 1051 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1052 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1053 |
extra_headers: Headers | None = None, |
| 1054 |
extra_query: Query | None = None, |
| 1055 |
extra_body: Body | None = None, |
| 1056 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1057 |
) -> BetaManagedAgentsDeployment: |
| 1058 |
""" |
| 1059 |
Archive Deployment |
| 1060 |
|
| 1061 |
Args: |
| 1062 |
deployment_id: Unique identifier of the deployment to archive. |
| 1063 |
|
| 1064 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1065 |
|
| 1066 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1067 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1068 |
|
| 1069 |
Only needed for credentials that can act on more than one Workspace. A |
| 1070 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1071 |
match that Workspace. |
| 1072 |
|
| 1073 |
extra_headers: Send extra headers |
| 1074 |
|
| 1075 |
extra_query: Add additional query parameters to the request |
| 1076 |
|
| 1077 |
extra_body: Add additional JSON properties to the request |
| 1078 |
|
| 1079 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1080 |
""" |
| 1081 |
if not deployment_id: |
| 1082 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1083 |
extra_headers = { |
| 1084 |
**strip_not_given( |
| 1085 |
{ |
| 1086 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1087 |
if is_given(betas) |
| 1088 |
else not_given, |
| 1089 |
"anthropic-workspace-id": workspace_id, |
| 1090 |
} |
| 1091 |
), |
| 1092 |
**(extra_headers or {}), |
| 1093 |
} |
| 1094 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1095 |
return await self._post( |
| 1096 |
path_template("/v1/deployments/{deployment_id}/archive?beta=true", deployment_id=deployment_id), |
| 1097 |
options=make_request_options( |
| 1098 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1099 |
), |
| 1100 |
cast_to=BetaManagedAgentsDeployment, |
| 1101 |
) |
| 1102 |
|
| 1103 |
async def pause( |
| 1104 |
self, |
| 1105 |
deployment_id: str, |
| 1106 |
*, |
| 1107 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1108 |
workspace_id: str | Omit = omit, |
| 1109 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1110 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1111 |
extra_headers: Headers | None = None, |
| 1112 |
extra_query: Query | None = None, |
| 1113 |
extra_body: Body | None = None, |
| 1114 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1115 |
) -> BetaManagedAgentsDeployment: |
| 1116 |
""" |
| 1117 |
Pause Deployment |
| 1118 |
|
| 1119 |
Args: |
| 1120 |
deployment_id: Unique identifier of the deployment to pause. |
| 1121 |
|
| 1122 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1123 |
|
| 1124 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1125 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1126 |
|
| 1127 |
Only needed for credentials that can act on more than one Workspace. A |
| 1128 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1129 |
match that Workspace. |
| 1130 |
|
| 1131 |
extra_headers: Send extra headers |
| 1132 |
|
| 1133 |
extra_query: Add additional query parameters to the request |
| 1134 |
|
| 1135 |
extra_body: Add additional JSON properties to the request |
| 1136 |
|
| 1137 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1138 |
""" |
| 1139 |
if not deployment_id: |
| 1140 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1141 |
extra_headers = { |
| 1142 |
**strip_not_given( |
| 1143 |
{ |
| 1144 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1145 |
if is_given(betas) |
| 1146 |
else not_given, |
| 1147 |
"anthropic-workspace-id": workspace_id, |
| 1148 |
} |
| 1149 |
), |
| 1150 |
**(extra_headers or {}), |
| 1151 |
} |
| 1152 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1153 |
return await self._post( |
| 1154 |
path_template("/v1/deployments/{deployment_id}/pause?beta=true", deployment_id=deployment_id), |
| 1155 |
options=make_request_options( |
| 1156 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1157 |
), |
| 1158 |
cast_to=BetaManagedAgentsDeployment, |
| 1159 |
) |
| 1160 |
|
| 1161 |
async def run( |
| 1162 |
self, |
| 1163 |
deployment_id: str, |
| 1164 |
*, |
| 1165 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1166 |
workspace_id: str | Omit = omit, |
| 1167 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1168 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1169 |
extra_headers: Headers | None = None, |
| 1170 |
extra_query: Query | None = None, |
| 1171 |
extra_body: Body | None = None, |
| 1172 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1173 |
) -> BetaManagedAgentsDeploymentRun: |
| 1174 |
""" |
| 1175 |
Run Deployment Now |
| 1176 |
|
| 1177 |
Args: |
| 1178 |
deployment_id: Unique identifier of the deployment to run. |
| 1179 |
|
| 1180 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1181 |
|
| 1182 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1183 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1184 |
|
| 1185 |
Only needed for credentials that can act on more than one Workspace. A |
| 1186 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1187 |
match that Workspace. |
| 1188 |
|
| 1189 |
extra_headers: Send extra headers |
| 1190 |
|
| 1191 |
extra_query: Add additional query parameters to the request |
| 1192 |
|
| 1193 |
extra_body: Add additional JSON properties to the request |
| 1194 |
|
| 1195 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1196 |
""" |
| 1197 |
if not deployment_id: |
| 1198 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1199 |
extra_headers = { |
| 1200 |
**strip_not_given( |
| 1201 |
{ |
| 1202 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1203 |
if is_given(betas) |
| 1204 |
else not_given, |
| 1205 |
"anthropic-workspace-id": workspace_id, |
| 1206 |
} |
| 1207 |
), |
| 1208 |
**(extra_headers or {}), |
| 1209 |
} |
| 1210 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1211 |
return await self._post( |
| 1212 |
path_template("/v1/deployments/{deployment_id}/run?beta=true", deployment_id=deployment_id), |
| 1213 |
options=make_request_options( |
| 1214 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1215 |
), |
| 1216 |
cast_to=BetaManagedAgentsDeploymentRun, |
| 1217 |
) |
| 1218 |
|
| 1219 |
async def unpause( |
| 1220 |
self, |
| 1221 |
deployment_id: str, |
| 1222 |
*, |
| 1223 |
betas: List[AnthropicBetaParam] | Omit = omit, |
| 1224 |
workspace_id: str | Omit = omit, |
| 1225 |
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 1226 |
# The extra values given here take precedence over values defined on the client or passed to this method. |
| 1227 |
extra_headers: Headers | None = None, |
| 1228 |
extra_query: Query | None = None, |
| 1229 |
extra_body: Body | None = None, |
| 1230 |
timeout: float | httpx2.Timeout | None | NotGiven = not_given, |
| 1231 |
) -> BetaManagedAgentsDeployment: |
| 1232 |
""" |
| 1233 |
Unpause Deployment |
| 1234 |
|
| 1235 |
Args: |
| 1236 |
deployment_id: Unique identifier of the deployment to unpause. |
| 1237 |
|
| 1238 |
betas: Optional header to specify the beta version(s) you want to use. |
| 1239 |
|
| 1240 |
workspace_id: Optional header to select the Workspace for this request. The value is a |
| 1241 |
Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`). |
| 1242 |
|
| 1243 |
Only needed for credentials that can act on more than one Workspace. A |
| 1244 |
credential that belongs to a specific Workspace may omit it; if sent, it must |
| 1245 |
match that Workspace. |
| 1246 |
|
| 1247 |
extra_headers: Send extra headers |
| 1248 |
|
| 1249 |
extra_query: Add additional query parameters to the request |
| 1250 |
|
| 1251 |
extra_body: Add additional JSON properties to the request |
| 1252 |
|
| 1253 |
timeout: Override the client-level default timeout for this request, in seconds |
| 1254 |
""" |
| 1255 |
if not deployment_id: |
| 1256 |
raise ValueError(f"Expected a non-empty value for `deployment_id` but received {deployment_id!r}") |
| 1257 |
extra_headers = { |
| 1258 |
**strip_not_given( |
| 1259 |
{ |
| 1260 |
"anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"])) |
| 1261 |
if is_given(betas) |
| 1262 |
else not_given, |
| 1263 |
"anthropic-workspace-id": workspace_id, |
| 1264 |
} |
| 1265 |
), |
| 1266 |
**(extra_headers or {}), |
| 1267 |
} |
| 1268 |
extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})} |
| 1269 |
return await self._post( |
| 1270 |
path_template("/v1/deployments/{deployment_id}/unpause?beta=true", deployment_id=deployment_id), |
| 1271 |
options=make_request_options( |
| 1272 |
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1273 |
), |
| 1274 |
cast_to=BetaManagedAgentsDeployment, |
| 1275 |
) |
| 1276 |
|
| 1277 |
|
| 1278 |
class DeploymentsWithRawResponse: |
| 1279 |
def __init__(self, deployments: Deployments) -> None: |
| 1280 |
self._deployments = deployments |
| 1281 |
|
| 1282 |
self.create = to_raw_response_wrapper( |
| 1283 |
deployments.create, |
| 1284 |
) |
| 1285 |
self.retrieve = to_raw_response_wrapper( |
| 1286 |
deployments.retrieve, |
| 1287 |
) |
| 1288 |
self.update = to_raw_response_wrapper( |
| 1289 |
deployments.update, |
| 1290 |
) |
| 1291 |
self.list = to_raw_response_wrapper( |
| 1292 |
deployments.list, |
| 1293 |
) |
| 1294 |
self.archive = to_raw_response_wrapper( |
| 1295 |
deployments.archive, |
| 1296 |
) |
| 1297 |
self.pause = to_raw_response_wrapper( |
| 1298 |
deployments.pause, |
| 1299 |
) |
| 1300 |
self.run = to_raw_response_wrapper( |
| 1301 |
deployments.run, |
| 1302 |
) |
| 1303 |
self.unpause = to_raw_response_wrapper( |
| 1304 |
deployments.unpause, |
| 1305 |
) |
| 1306 |
|
| 1307 |
|
| 1308 |
class AsyncDeploymentsWithRawResponse: |
| 1309 |
def __init__(self, deployments: AsyncDeployments) -> None: |
| 1310 |
self._deployments = deployments |
| 1311 |
|
| 1312 |
self.create = async_to_raw_response_wrapper( |
| 1313 |
deployments.create, |
| 1314 |
) |
| 1315 |
self.retrieve = async_to_raw_response_wrapper( |
| 1316 |
deployments.retrieve, |
| 1317 |
) |
| 1318 |
self.update = async_to_raw_response_wrapper( |
| 1319 |
deployments.update, |
| 1320 |
) |
| 1321 |
self.list = async_to_raw_response_wrapper( |
| 1322 |
deployments.list, |
| 1323 |
) |
| 1324 |
self.archive = async_to_raw_response_wrapper( |
| 1325 |
deployments.archive, |
| 1326 |
) |
| 1327 |
self.pause = async_to_raw_response_wrapper( |
| 1328 |
deployments.pause, |
| 1329 |
) |
| 1330 |
self.run = async_to_raw_response_wrapper( |
| 1331 |
deployments.run, |
| 1332 |
) |
| 1333 |
self.unpause = async_to_raw_response_wrapper( |
| 1334 |
deployments.unpause, |
| 1335 |
) |
| 1336 |
|
| 1337 |
|
| 1338 |
class DeploymentsWithStreamingResponse: |
| 1339 |
def __init__(self, deployments: Deployments) -> None: |
| 1340 |
self._deployments = deployments |
| 1341 |
|
| 1342 |
self.create = to_streamed_response_wrapper( |
| 1343 |
deployments.create, |
| 1344 |
) |
| 1345 |
self.retrieve = to_streamed_response_wrapper( |
| 1346 |
deployments.retrieve, |
| 1347 |
) |
| 1348 |
self.update = to_streamed_response_wrapper( |
| 1349 |
deployments.update, |
| 1350 |
) |
| 1351 |
self.list = to_streamed_response_wrapper( |
| 1352 |
deployments.list, |
| 1353 |
) |
| 1354 |
self.archive = to_streamed_response_wrapper( |
| 1355 |
deployments.archive, |
| 1356 |
) |
| 1357 |
self.pause = to_streamed_response_wrapper( |
| 1358 |
deployments.pause, |
| 1359 |
) |
| 1360 |
self.run = to_streamed_response_wrapper( |
| 1361 |
deployments.run, |
| 1362 |
) |
| 1363 |
self.unpause = to_streamed_response_wrapper( |
| 1364 |
deployments.unpause, |
| 1365 |
) |
| 1366 |
|
| 1367 |
|
| 1368 |
class AsyncDeploymentsWithStreamingResponse: |
| 1369 |
def __init__(self, deployments: AsyncDeployments) -> None: |
| 1370 |
self._deployments = deployments |
| 1371 |
|
| 1372 |
self.create = async_to_streamed_response_wrapper( |
| 1373 |
deployments.create, |
| 1374 |
) |
| 1375 |
self.retrieve = async_to_streamed_response_wrapper( |
| 1376 |
deployments.retrieve, |
| 1377 |
) |
| 1378 |
self.update = async_to_streamed_response_wrapper( |
| 1379 |
deployments.update, |
| 1380 |
) |
| 1381 |
self.list = async_to_streamed_response_wrapper( |
| 1382 |
deployments.list, |
| 1383 |
) |
| 1384 |
self.archive = async_to_streamed_response_wrapper( |
| 1385 |
deployments.archive, |
| 1386 |
) |
| 1387 |
self.pause = async_to_streamed_response_wrapper( |
| 1388 |
deployments.pause, |
| 1389 |
) |
| 1390 |
self.run = async_to_streamed_response_wrapper( |
| 1391 |
deployments.run, |
| 1392 |
) |
| 1393 |
self.unpause = async_to_streamed_response_wrapper( |
| 1394 |
deployments.unpause, |
| 1395 |
) |