github.com/anthropics/anthropic-sdk-go@v1.70.1/betadeploymentrun.go (about) 1 // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. 2 3 package anthropic 4 5 import ( 6 "context" 7 "encoding/json" 8 "errors" 9 "fmt" 10 "net/http" 11 "net/url" 12 "slices" 13 "time" 14 15 "github.com/anthropics/anthropic-sdk-go/internal/apijson" 16 "github.com/anthropics/anthropic-sdk-go/internal/apiquery" 17 "github.com/anthropics/anthropic-sdk-go/internal/requestconfig" 18 "github.com/anthropics/anthropic-sdk-go/option" 19 "github.com/anthropics/anthropic-sdk-go/packages/pagination" 20 "github.com/anthropics/anthropic-sdk-go/packages/param" 21 "github.com/anthropics/anthropic-sdk-go/packages/respjson" 22 ) 23 24 // BetaDeploymentRunService contains methods and other services that help with 25 // interacting with the anthropic API. 26 // 27 // Note, unlike clients, this service does not read variables from the environment 28 // automatically. You should not instantiate this service directly, and instead use 29 // the [NewBetaDeploymentRunService] method instead. 30 type BetaDeploymentRunService struct { 31 Options []option.RequestOption 32 } 33 34 // NewBetaDeploymentRunService generates a new service that applies the given 35 // options to each request. These options are applied after the parent client's 36 // options (if there is one), and before any request-specific options. 37 func NewBetaDeploymentRunService(opts ...option.RequestOption) (r BetaDeploymentRunService) { 38 r = BetaDeploymentRunService{} 39 r.Options = opts 40 return 41 } 42 43 // Get Deployment Run 44 func (r *BetaDeploymentRunService) Get(ctx context.Context, deploymentRunID string, query BetaDeploymentRunGetParams, opts ...option.RequestOption) (res *BetaManagedAgentsDeploymentRun, err error) { 45 for _, v := range query.Betas { 46 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 47 } 48 if !param.IsOmitted(query.WorkspaceID) { 49 opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", query.WorkspaceID.Value))) 50 } 51 opts = slices.Concat(r.Options, opts) 52 opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01")}, opts...) 53 if deploymentRunID == "" { 54 err = errors.New("missing required deployment_run_id parameter") 55 return nil, err 56 } 57 path := fmt.Sprintf("v1/deployment_runs/%s?beta=true", deploymentRunID) 58 err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) 59 return res, err 60 } 61 62 // List Deployment Runs 63 func (r *BetaDeploymentRunService) List(ctx context.Context, params BetaDeploymentRunListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaManagedAgentsDeploymentRun], err error) { 64 var raw *http.Response 65 for _, v := range params.Betas { 66 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 67 } 68 if !param.IsOmitted(params.WorkspaceID) { 69 opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value))) 70 } 71 opts = slices.Concat(r.Options, opts) 72 opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01"), option.WithResponseInto(&raw)}, opts...) 73 path := "v1/deployment_runs?beta=true" 74 cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) 75 if err != nil { 76 return nil, err 77 } 78 err = cfg.Execute() 79 if err != nil { 80 return nil, err 81 } 82 res.SetPageConfig(cfg, raw) 83 return res, nil 84 } 85 86 // List Deployment Runs 87 func (r *BetaDeploymentRunService) ListAutoPaging(ctx context.Context, params BetaDeploymentRunListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaManagedAgentsDeploymentRun] { 88 return pagination.NewPageCursorAutoPager(r.List(ctx, params, opts...)) 89 } 90 91 // The deployment's agent was archived. 92 type BetaManagedAgentsAgentArchivedRunError struct { 93 // Human-readable error description. 94 Message string `json:"message" api:"required"` 95 // Any of "agent_archived_error". 96 Type BetaManagedAgentsAgentArchivedRunErrorType `json:"type" api:"required"` 97 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 98 JSON struct { 99 Message respjson.Field 100 Type respjson.Field 101 ExtraFields map[string]respjson.Field 102 raw string 103 } `json:"-"` 104 } 105 106 // Returns the unmodified JSON received from the API 107 func (r BetaManagedAgentsAgentArchivedRunError) RawJSON() string { return r.JSON.raw } 108 func (r *BetaManagedAgentsAgentArchivedRunError) UnmarshalJSON(data []byte) error { 109 return apijson.UnmarshalRoot(data, r) 110 } 111 112 type BetaManagedAgentsAgentArchivedRunErrorType string 113 114 const ( 115 BetaManagedAgentsAgentArchivedRunErrorTypeAgentArchivedError BetaManagedAgentsAgentArchivedRunErrorType = "agent_archived_error" 116 ) 117 118 // A persistent, append-only record of a single deployment execution. Records 119 // session creation success or failure — no session lifecycle tracking. 120 type BetaManagedAgentsDeploymentRun struct { 121 // Unique identifier for this run (`drun_...`). 122 ID string `json:"id" api:"required"` 123 // A resolved agent reference with a concrete version. 124 Agent BetaManagedAgentsAgentReference `json:"agent" api:"required"` 125 // A timestamp in RFC 3339 format 126 CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"` 127 // ID of the deployment that produced this run. 128 DeploymentID string `json:"deployment_id" api:"required"` 129 // Why the run failed to create a session. The type identifies the failure; message 130 // is human-readable detail. 131 Error BetaManagedAgentsDeploymentRunErrorUnion `json:"error" api:"required"` 132 // Populated on success. Null on creation failure. Exactly one of `session_id` or 133 // `error` is non-null. 134 SessionID string `json:"session_id" api:"required"` 135 // Describes what triggered a deployment run, with trigger-specific metadata. 136 TriggerContext BetaManagedAgentsTriggerContextUnion `json:"trigger_context" api:"required"` 137 // Any of "deployment_run". 138 Type BetaManagedAgentsDeploymentRunType `json:"type" api:"required"` 139 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 140 JSON struct { 141 ID respjson.Field 142 Agent respjson.Field 143 CreatedAt respjson.Field 144 DeploymentID respjson.Field 145 Error respjson.Field 146 SessionID respjson.Field 147 TriggerContext respjson.Field 148 Type respjson.Field 149 ExtraFields map[string]respjson.Field 150 raw string 151 } `json:"-"` 152 } 153 154 // Returns the unmodified JSON received from the API 155 func (r BetaManagedAgentsDeploymentRun) RawJSON() string { return r.JSON.raw } 156 func (r *BetaManagedAgentsDeploymentRun) UnmarshalJSON(data []byte) error { 157 return apijson.UnmarshalRoot(data, r) 158 } 159 160 // BetaManagedAgentsDeploymentRunErrorUnion contains all possible properties and 161 // values from [BetaManagedAgentsEnvironmentArchivedRunError], 162 // [BetaManagedAgentsAgentArchivedRunError], 163 // [BetaManagedAgentsEnvironmentNotFoundRunError], 164 // [BetaManagedAgentsVaultNotFoundRunError], 165 // [BetaManagedAgentsVaultArchivedRunError], 166 // [BetaManagedAgentsFileNotFoundRunError], 167 // [BetaManagedAgentsMemoryStoreArchivedRunError], 168 // [BetaManagedAgentsSkillNotFoundRunError], 169 // [BetaManagedAgentsSessionResourceNotFoundRunError], 170 // [BetaManagedAgentsWorkspaceArchivedRunError], 171 // [BetaManagedAgentsOrganizationDisabledRunError], 172 // [BetaManagedAgentsSessionRateLimitedRunError], 173 // [BetaManagedAgentsSessionCreationRejectedRunError], 174 // [BetaManagedAgentsUnknownRunError], 175 // [BetaManagedAgentsSelfHostedResourcesUnsupportedRunError], 176 // [BetaManagedAgentsMCPEgressBlockedRunError]. 177 // 178 // Use the [BetaManagedAgentsDeploymentRunErrorUnion.AsAny] method to switch on the 179 // variant. 180 // 181 // Use the methods beginning with 'As' to cast the union to one of its variants. 182 type BetaManagedAgentsDeploymentRunErrorUnion struct { 183 Message string `json:"message"` 184 // Any of "environment_archived_error", "agent_archived_error", 185 // "environment_not_found_error", "vault_not_found_error", "vault_archived_error", 186 // "file_not_found_error", "memory_store_archived_error", "skill_not_found_error", 187 // "session_resource_not_found_error", "workspace_archived_error", 188 // "organization_disabled_error", "session_rate_limited_error", 189 // "session_creation_rejected_error", "unknown_error", 190 // "self_hosted_resources_unsupported_error", "mcp_egress_blocked_error". 191 Type string `json:"type"` 192 JSON struct { 193 Message respjson.Field 194 Type respjson.Field 195 raw string 196 } `json:"-"` 197 } 198 199 // anyBetaManagedAgentsDeploymentRunError is implemented by each variant of 200 // [BetaManagedAgentsDeploymentRunErrorUnion] to add type safety for the return 201 // type of [BetaManagedAgentsDeploymentRunErrorUnion.AsAny] 202 type anyBetaManagedAgentsDeploymentRunError interface { 203 implBetaManagedAgentsDeploymentRunErrorUnion() 204 } 205 206 func (BetaManagedAgentsEnvironmentArchivedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 207 func (BetaManagedAgentsAgentArchivedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 208 func (BetaManagedAgentsEnvironmentNotFoundRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 209 func (BetaManagedAgentsVaultNotFoundRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 210 func (BetaManagedAgentsVaultArchivedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 211 func (BetaManagedAgentsFileNotFoundRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 212 func (BetaManagedAgentsMemoryStoreArchivedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 213 func (BetaManagedAgentsSkillNotFoundRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 214 func (BetaManagedAgentsSessionResourceNotFoundRunError) implBetaManagedAgentsDeploymentRunErrorUnion() { 215 } 216 func (BetaManagedAgentsWorkspaceArchivedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 217 func (BetaManagedAgentsOrganizationDisabledRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 218 func (BetaManagedAgentsSessionRateLimitedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 219 func (BetaManagedAgentsSessionCreationRejectedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() { 220 } 221 func (BetaManagedAgentsUnknownRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 222 func (BetaManagedAgentsSelfHostedResourcesUnsupportedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() { 223 } 224 func (BetaManagedAgentsMCPEgressBlockedRunError) implBetaManagedAgentsDeploymentRunErrorUnion() {} 225 226 // Use the following switch statement to find the correct variant 227 // 228 // switch variant := BetaManagedAgentsDeploymentRunErrorUnion.AsAny().(type) { 229 // case anthropic.BetaManagedAgentsEnvironmentArchivedRunError: 230 // case anthropic.BetaManagedAgentsAgentArchivedRunError: 231 // case anthropic.BetaManagedAgentsEnvironmentNotFoundRunError: 232 // case anthropic.BetaManagedAgentsVaultNotFoundRunError: 233 // case anthropic.BetaManagedAgentsVaultArchivedRunError: 234 // case anthropic.BetaManagedAgentsFileNotFoundRunError: 235 // case anthropic.BetaManagedAgentsMemoryStoreArchivedRunError: 236 // case anthropic.BetaManagedAgentsSkillNotFoundRunError: 237 // case anthropic.BetaManagedAgentsSessionResourceNotFoundRunError: 238 // case anthropic.BetaManagedAgentsWorkspaceArchivedRunError: 239 // case anthropic.BetaManagedAgentsOrganizationDisabledRunError: 240 // case anthropic.BetaManagedAgentsSessionRateLimitedRunError: 241 // case anthropic.BetaManagedAgentsSessionCreationRejectedRunError: 242 // case anthropic.BetaManagedAgentsUnknownRunError: 243 // case anthropic.BetaManagedAgentsSelfHostedResourcesUnsupportedRunError: 244 // case anthropic.BetaManagedAgentsMCPEgressBlockedRunError: 245 // default: 246 // fmt.Errorf("no variant present") 247 // } 248 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsAny() anyBetaManagedAgentsDeploymentRunError { 249 switch u.Type { 250 case "environment_archived_error": 251 return u.AsEnvironmentArchivedError() 252 case "agent_archived_error": 253 return u.AsAgentArchivedError() 254 case "environment_not_found_error": 255 return u.AsEnvironmentNotFoundError() 256 case "vault_not_found_error": 257 return u.AsVaultNotFoundError() 258 case "vault_archived_error": 259 return u.AsVaultArchivedError() 260 case "file_not_found_error": 261 return u.AsFileNotFoundError() 262 case "memory_store_archived_error": 263 return u.AsMemoryStoreArchivedError() 264 case "skill_not_found_error": 265 return u.AsSkillNotFoundError() 266 case "session_resource_not_found_error": 267 return u.AsSessionResourceNotFoundError() 268 case "workspace_archived_error": 269 return u.AsWorkspaceArchivedError() 270 case "organization_disabled_error": 271 return u.AsOrganizationDisabledError() 272 case "session_rate_limited_error": 273 return u.AsSessionRateLimitedError() 274 case "session_creation_rejected_error": 275 return u.AsSessionCreationRejectedError() 276 case "unknown_error": 277 return u.AsUnknownError() 278 case "self_hosted_resources_unsupported_error": 279 return u.AsSelfHostedResourcesUnsupportedError() 280 case "mcp_egress_blocked_error": 281 return u.AsMCPEgressBlockedError() 282 } 283 return nil 284 } 285 286 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsEnvironmentArchivedError() (v BetaManagedAgentsEnvironmentArchivedRunError) { 287 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 288 return 289 } 290 291 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsAgentArchivedError() (v BetaManagedAgentsAgentArchivedRunError) { 292 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 293 return 294 } 295 296 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsEnvironmentNotFoundError() (v BetaManagedAgentsEnvironmentNotFoundRunError) { 297 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 298 return 299 } 300 301 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsVaultNotFoundError() (v BetaManagedAgentsVaultNotFoundRunError) { 302 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 303 return 304 } 305 306 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsVaultArchivedError() (v BetaManagedAgentsVaultArchivedRunError) { 307 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 308 return 309 } 310 311 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsFileNotFoundError() (v BetaManagedAgentsFileNotFoundRunError) { 312 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 313 return 314 } 315 316 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsMemoryStoreArchivedError() (v BetaManagedAgentsMemoryStoreArchivedRunError) { 317 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 318 return 319 } 320 321 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsSkillNotFoundError() (v BetaManagedAgentsSkillNotFoundRunError) { 322 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 323 return 324 } 325 326 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsSessionResourceNotFoundError() (v BetaManagedAgentsSessionResourceNotFoundRunError) { 327 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 328 return 329 } 330 331 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsWorkspaceArchivedError() (v BetaManagedAgentsWorkspaceArchivedRunError) { 332 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 333 return 334 } 335 336 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsOrganizationDisabledError() (v BetaManagedAgentsOrganizationDisabledRunError) { 337 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 338 return 339 } 340 341 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsSessionRateLimitedError() (v BetaManagedAgentsSessionRateLimitedRunError) { 342 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 343 return 344 } 345 346 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsSessionCreationRejectedError() (v BetaManagedAgentsSessionCreationRejectedRunError) { 347 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 348 return 349 } 350 351 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsUnknownError() (v BetaManagedAgentsUnknownRunError) { 352 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 353 return 354 } 355 356 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsSelfHostedResourcesUnsupportedError() (v BetaManagedAgentsSelfHostedResourcesUnsupportedRunError) { 357 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 358 return 359 } 360 361 func (u BetaManagedAgentsDeploymentRunErrorUnion) AsMCPEgressBlockedError() (v BetaManagedAgentsMCPEgressBlockedRunError) { 362 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 363 return 364 } 365 366 // Returns the unmodified JSON received from the API 367 func (u BetaManagedAgentsDeploymentRunErrorUnion) RawJSON() string { return u.JSON.raw } 368 369 func (r *BetaManagedAgentsDeploymentRunErrorUnion) UnmarshalJSON(data []byte) error { 370 return apijson.UnmarshalRoot(data, r) 371 } 372 373 type BetaManagedAgentsDeploymentRunType string 374 375 const ( 376 BetaManagedAgentsDeploymentRunTypeDeploymentRun BetaManagedAgentsDeploymentRunType = "deployment_run" 377 ) 378 379 // The deployment's environment was archived. 380 type BetaManagedAgentsEnvironmentArchivedRunError struct { 381 // Human-readable error description. 382 Message string `json:"message" api:"required"` 383 // Any of "environment_archived_error". 384 Type BetaManagedAgentsEnvironmentArchivedRunErrorType `json:"type" api:"required"` 385 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 386 JSON struct { 387 Message respjson.Field 388 Type respjson.Field 389 ExtraFields map[string]respjson.Field 390 raw string 391 } `json:"-"` 392 } 393 394 // Returns the unmodified JSON received from the API 395 func (r BetaManagedAgentsEnvironmentArchivedRunError) RawJSON() string { return r.JSON.raw } 396 func (r *BetaManagedAgentsEnvironmentArchivedRunError) UnmarshalJSON(data []byte) error { 397 return apijson.UnmarshalRoot(data, r) 398 } 399 400 type BetaManagedAgentsEnvironmentArchivedRunErrorType string 401 402 const ( 403 BetaManagedAgentsEnvironmentArchivedRunErrorTypeEnvironmentArchivedError BetaManagedAgentsEnvironmentArchivedRunErrorType = "environment_archived_error" 404 ) 405 406 // The deployment's environment no longer exists. 407 type BetaManagedAgentsEnvironmentNotFoundRunError struct { 408 // Human-readable error description. 409 Message string `json:"message" api:"required"` 410 // Any of "environment_not_found_error". 411 Type BetaManagedAgentsEnvironmentNotFoundRunErrorType `json:"type" api:"required"` 412 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 413 JSON struct { 414 Message respjson.Field 415 Type respjson.Field 416 ExtraFields map[string]respjson.Field 417 raw string 418 } `json:"-"` 419 } 420 421 // Returns the unmodified JSON received from the API 422 func (r BetaManagedAgentsEnvironmentNotFoundRunError) RawJSON() string { return r.JSON.raw } 423 func (r *BetaManagedAgentsEnvironmentNotFoundRunError) UnmarshalJSON(data []byte) error { 424 return apijson.UnmarshalRoot(data, r) 425 } 426 427 type BetaManagedAgentsEnvironmentNotFoundRunErrorType string 428 429 const ( 430 BetaManagedAgentsEnvironmentNotFoundRunErrorTypeEnvironmentNotFoundError BetaManagedAgentsEnvironmentNotFoundRunErrorType = "environment_not_found_error" 431 ) 432 433 // A file resource referenced by the deployment no longer exists. 434 type BetaManagedAgentsFileNotFoundRunError struct { 435 // Human-readable error description. 436 Message string `json:"message" api:"required"` 437 // Any of "file_not_found_error". 438 Type BetaManagedAgentsFileNotFoundRunErrorType `json:"type" api:"required"` 439 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 440 JSON struct { 441 Message respjson.Field 442 Type respjson.Field 443 ExtraFields map[string]respjson.Field 444 raw string 445 } `json:"-"` 446 } 447 448 // Returns the unmodified JSON received from the API 449 func (r BetaManagedAgentsFileNotFoundRunError) RawJSON() string { return r.JSON.raw } 450 func (r *BetaManagedAgentsFileNotFoundRunError) UnmarshalJSON(data []byte) error { 451 return apijson.UnmarshalRoot(data, r) 452 } 453 454 type BetaManagedAgentsFileNotFoundRunErrorType string 455 456 const ( 457 BetaManagedAgentsFileNotFoundRunErrorTypeFileNotFoundError BetaManagedAgentsFileNotFoundRunErrorType = "file_not_found_error" 458 ) 459 460 // The run was started manually by creating a session directly against the 461 // deployment. 462 type BetaManagedAgentsManualTriggerContext struct { 463 // Any of "manual". 464 Type BetaManagedAgentsManualTriggerContextType `json:"type" api:"required"` 465 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 466 JSON struct { 467 Type respjson.Field 468 ExtraFields map[string]respjson.Field 469 raw string 470 } `json:"-"` 471 } 472 473 // Returns the unmodified JSON received from the API 474 func (r BetaManagedAgentsManualTriggerContext) RawJSON() string { return r.JSON.raw } 475 func (r *BetaManagedAgentsManualTriggerContext) UnmarshalJSON(data []byte) error { 476 return apijson.UnmarshalRoot(data, r) 477 } 478 479 type BetaManagedAgentsManualTriggerContextType string 480 481 const ( 482 BetaManagedAgentsManualTriggerContextTypeManual BetaManagedAgentsManualTriggerContextType = "manual" 483 ) 484 485 // An MCP server host used by the deployment's agent is blocked by the 486 // environment's network policy. 487 type BetaManagedAgentsMCPEgressBlockedRunError struct { 488 // Human-readable error description. 489 Message string `json:"message" api:"required"` 490 // Any of "mcp_egress_blocked_error". 491 Type BetaManagedAgentsMCPEgressBlockedRunErrorType `json:"type" api:"required"` 492 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 493 JSON struct { 494 Message respjson.Field 495 Type respjson.Field 496 ExtraFields map[string]respjson.Field 497 raw string 498 } `json:"-"` 499 } 500 501 // Returns the unmodified JSON received from the API 502 func (r BetaManagedAgentsMCPEgressBlockedRunError) RawJSON() string { return r.JSON.raw } 503 func (r *BetaManagedAgentsMCPEgressBlockedRunError) UnmarshalJSON(data []byte) error { 504 return apijson.UnmarshalRoot(data, r) 505 } 506 507 type BetaManagedAgentsMCPEgressBlockedRunErrorType string 508 509 const ( 510 BetaManagedAgentsMCPEgressBlockedRunErrorTypeMCPEgressBlockedError BetaManagedAgentsMCPEgressBlockedRunErrorType = "mcp_egress_blocked_error" 511 ) 512 513 // A memory store referenced by the deployment is archived. 514 type BetaManagedAgentsMemoryStoreArchivedRunError struct { 515 // Human-readable error description. 516 Message string `json:"message" api:"required"` 517 // Any of "memory_store_archived_error". 518 Type BetaManagedAgentsMemoryStoreArchivedRunErrorType `json:"type" api:"required"` 519 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 520 JSON struct { 521 Message respjson.Field 522 Type respjson.Field 523 ExtraFields map[string]respjson.Field 524 raw string 525 } `json:"-"` 526 } 527 528 // Returns the unmodified JSON received from the API 529 func (r BetaManagedAgentsMemoryStoreArchivedRunError) RawJSON() string { return r.JSON.raw } 530 func (r *BetaManagedAgentsMemoryStoreArchivedRunError) UnmarshalJSON(data []byte) error { 531 return apijson.UnmarshalRoot(data, r) 532 } 533 534 type BetaManagedAgentsMemoryStoreArchivedRunErrorType string 535 536 const ( 537 BetaManagedAgentsMemoryStoreArchivedRunErrorTypeMemoryStoreArchivedError BetaManagedAgentsMemoryStoreArchivedRunErrorType = "memory_store_archived_error" 538 ) 539 540 // The deployment's organization is disabled. 541 type BetaManagedAgentsOrganizationDisabledRunError struct { 542 // Human-readable error description. 543 Message string `json:"message" api:"required"` 544 // Any of "organization_disabled_error". 545 Type BetaManagedAgentsOrganizationDisabledRunErrorType `json:"type" api:"required"` 546 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 547 JSON struct { 548 Message respjson.Field 549 Type respjson.Field 550 ExtraFields map[string]respjson.Field 551 raw string 552 } `json:"-"` 553 } 554 555 // Returns the unmodified JSON received from the API 556 func (r BetaManagedAgentsOrganizationDisabledRunError) RawJSON() string { return r.JSON.raw } 557 func (r *BetaManagedAgentsOrganizationDisabledRunError) UnmarshalJSON(data []byte) error { 558 return apijson.UnmarshalRoot(data, r) 559 } 560 561 type BetaManagedAgentsOrganizationDisabledRunErrorType string 562 563 const ( 564 BetaManagedAgentsOrganizationDisabledRunErrorTypeOrganizationDisabledError BetaManagedAgentsOrganizationDisabledRunErrorType = "organization_disabled_error" 565 ) 566 567 // The run was fired by the deployment's cron schedule. 568 type BetaManagedAgentsScheduleTriggerContext struct { 569 // A timestamp in RFC 3339 format 570 ScheduledAt time.Time `json:"scheduled_at" api:"required" format:"date-time"` 571 // Any of "schedule". 572 Type BetaManagedAgentsScheduleTriggerContextType `json:"type" api:"required"` 573 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 574 JSON struct { 575 ScheduledAt respjson.Field 576 Type respjson.Field 577 ExtraFields map[string]respjson.Field 578 raw string 579 } `json:"-"` 580 } 581 582 // Returns the unmodified JSON received from the API 583 func (r BetaManagedAgentsScheduleTriggerContext) RawJSON() string { return r.JSON.raw } 584 func (r *BetaManagedAgentsScheduleTriggerContext) UnmarshalJSON(data []byte) error { 585 return apijson.UnmarshalRoot(data, r) 586 } 587 588 type BetaManagedAgentsScheduleTriggerContextType string 589 590 const ( 591 BetaManagedAgentsScheduleTriggerContextTypeSchedule BetaManagedAgentsScheduleTriggerContextType = "schedule" 592 ) 593 594 // The deployment configures resources, but its environment is self-hosted and 595 // cannot mount them. 596 type BetaManagedAgentsSelfHostedResourcesUnsupportedRunError struct { 597 // Human-readable error description. 598 Message string `json:"message" api:"required"` 599 // Any of "self_hosted_resources_unsupported_error". 600 Type BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorType `json:"type" api:"required"` 601 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 602 JSON struct { 603 Message respjson.Field 604 Type respjson.Field 605 ExtraFields map[string]respjson.Field 606 raw string 607 } `json:"-"` 608 } 609 610 // Returns the unmodified JSON received from the API 611 func (r BetaManagedAgentsSelfHostedResourcesUnsupportedRunError) RawJSON() string { return r.JSON.raw } 612 func (r *BetaManagedAgentsSelfHostedResourcesUnsupportedRunError) UnmarshalJSON(data []byte) error { 613 return apijson.UnmarshalRoot(data, r) 614 } 615 616 type BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorType string 617 618 const ( 619 BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorTypeSelfHostedResourcesUnsupportedError BetaManagedAgentsSelfHostedResourcesUnsupportedRunErrorType = "self_hosted_resources_unsupported_error" 620 ) 621 622 // The session create request was rejected with a non-retryable validation error. 623 type BetaManagedAgentsSessionCreationRejectedRunError struct { 624 // Human-readable error description. 625 Message string `json:"message" api:"required"` 626 // Any of "session_creation_rejected_error". 627 Type BetaManagedAgentsSessionCreationRejectedRunErrorType `json:"type" api:"required"` 628 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 629 JSON struct { 630 Message respjson.Field 631 Type respjson.Field 632 ExtraFields map[string]respjson.Field 633 raw string 634 } `json:"-"` 635 } 636 637 // Returns the unmodified JSON received from the API 638 func (r BetaManagedAgentsSessionCreationRejectedRunError) RawJSON() string { return r.JSON.raw } 639 func (r *BetaManagedAgentsSessionCreationRejectedRunError) UnmarshalJSON(data []byte) error { 640 return apijson.UnmarshalRoot(data, r) 641 } 642 643 type BetaManagedAgentsSessionCreationRejectedRunErrorType string 644 645 const ( 646 BetaManagedAgentsSessionCreationRejectedRunErrorTypeSessionCreationRejectedError BetaManagedAgentsSessionCreationRejectedRunErrorType = "session_creation_rejected_error" 647 ) 648 649 // Session creation was rejected due to rate limiting. The schedule keeps firing; 650 // subsequent runs may succeed. 651 type BetaManagedAgentsSessionRateLimitedRunError struct { 652 // Human-readable error description. 653 Message string `json:"message" api:"required"` 654 // Any of "session_rate_limited_error". 655 Type BetaManagedAgentsSessionRateLimitedRunErrorType `json:"type" api:"required"` 656 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 657 JSON struct { 658 Message respjson.Field 659 Type respjson.Field 660 ExtraFields map[string]respjson.Field 661 raw string 662 } `json:"-"` 663 } 664 665 // Returns the unmodified JSON received from the API 666 func (r BetaManagedAgentsSessionRateLimitedRunError) RawJSON() string { return r.JSON.raw } 667 func (r *BetaManagedAgentsSessionRateLimitedRunError) UnmarshalJSON(data []byte) error { 668 return apijson.UnmarshalRoot(data, r) 669 } 670 671 type BetaManagedAgentsSessionRateLimitedRunErrorType string 672 673 const ( 674 BetaManagedAgentsSessionRateLimitedRunErrorTypeSessionRateLimitedError BetaManagedAgentsSessionRateLimitedRunErrorType = "session_rate_limited_error" 675 ) 676 677 // A referenced resource no longer exists and its kind was not reported. 678 type BetaManagedAgentsSessionResourceNotFoundRunError struct { 679 // Human-readable error description. 680 Message string `json:"message" api:"required"` 681 // Any of "session_resource_not_found_error". 682 Type BetaManagedAgentsSessionResourceNotFoundRunErrorType `json:"type" api:"required"` 683 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 684 JSON struct { 685 Message respjson.Field 686 Type respjson.Field 687 ExtraFields map[string]respjson.Field 688 raw string 689 } `json:"-"` 690 } 691 692 // Returns the unmodified JSON received from the API 693 func (r BetaManagedAgentsSessionResourceNotFoundRunError) RawJSON() string { return r.JSON.raw } 694 func (r *BetaManagedAgentsSessionResourceNotFoundRunError) UnmarshalJSON(data []byte) error { 695 return apijson.UnmarshalRoot(data, r) 696 } 697 698 type BetaManagedAgentsSessionResourceNotFoundRunErrorType string 699 700 const ( 701 BetaManagedAgentsSessionResourceNotFoundRunErrorTypeSessionResourceNotFoundError BetaManagedAgentsSessionResourceNotFoundRunErrorType = "session_resource_not_found_error" 702 ) 703 704 // A skill referenced by the deployment's agent no longer exists. 705 type BetaManagedAgentsSkillNotFoundRunError struct { 706 // Human-readable error description. 707 Message string `json:"message" api:"required"` 708 // Any of "skill_not_found_error". 709 Type BetaManagedAgentsSkillNotFoundRunErrorType `json:"type" api:"required"` 710 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 711 JSON struct { 712 Message respjson.Field 713 Type respjson.Field 714 ExtraFields map[string]respjson.Field 715 raw string 716 } `json:"-"` 717 } 718 719 // Returns the unmodified JSON received from the API 720 func (r BetaManagedAgentsSkillNotFoundRunError) RawJSON() string { return r.JSON.raw } 721 func (r *BetaManagedAgentsSkillNotFoundRunError) UnmarshalJSON(data []byte) error { 722 return apijson.UnmarshalRoot(data, r) 723 } 724 725 type BetaManagedAgentsSkillNotFoundRunErrorType string 726 727 const ( 728 BetaManagedAgentsSkillNotFoundRunErrorTypeSkillNotFoundError BetaManagedAgentsSkillNotFoundRunErrorType = "skill_not_found_error" 729 ) 730 731 // BetaManagedAgentsTriggerContextUnion contains all possible properties and values 732 // from [BetaManagedAgentsScheduleTriggerContext], 733 // [BetaManagedAgentsManualTriggerContext]. 734 // 735 // Use the [BetaManagedAgentsTriggerContextUnion.AsAny] method to switch on the 736 // variant. 737 // 738 // Use the methods beginning with 'As' to cast the union to one of its variants. 739 type BetaManagedAgentsTriggerContextUnion struct { 740 // This field is from variant [BetaManagedAgentsScheduleTriggerContext]. 741 ScheduledAt time.Time `json:"scheduled_at"` 742 // Any of "schedule", "manual". 743 Type string `json:"type"` 744 JSON struct { 745 ScheduledAt respjson.Field 746 Type respjson.Field 747 raw string 748 } `json:"-"` 749 } 750 751 // anyBetaManagedAgentsTriggerContext is implemented by each variant of 752 // [BetaManagedAgentsTriggerContextUnion] to add type safety for the return type of 753 // [BetaManagedAgentsTriggerContextUnion.AsAny] 754 type anyBetaManagedAgentsTriggerContext interface { 755 implBetaManagedAgentsTriggerContextUnion() 756 } 757 758 func (BetaManagedAgentsScheduleTriggerContext) implBetaManagedAgentsTriggerContextUnion() {} 759 func (BetaManagedAgentsManualTriggerContext) implBetaManagedAgentsTriggerContextUnion() {} 760 761 // Use the following switch statement to find the correct variant 762 // 763 // switch variant := BetaManagedAgentsTriggerContextUnion.AsAny().(type) { 764 // case anthropic.BetaManagedAgentsScheduleTriggerContext: 765 // case anthropic.BetaManagedAgentsManualTriggerContext: 766 // default: 767 // fmt.Errorf("no variant present") 768 // } 769 func (u BetaManagedAgentsTriggerContextUnion) AsAny() anyBetaManagedAgentsTriggerContext { 770 switch u.Type { 771 case "schedule": 772 return u.AsSchedule() 773 case "manual": 774 return u.AsManual() 775 } 776 return nil 777 } 778 779 func (u BetaManagedAgentsTriggerContextUnion) AsSchedule() (v BetaManagedAgentsScheduleTriggerContext) { 780 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 781 return 782 } 783 784 func (u BetaManagedAgentsTriggerContextUnion) AsManual() (v BetaManagedAgentsManualTriggerContext) { 785 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 786 return 787 } 788 789 // Returns the unmodified JSON received from the API 790 func (u BetaManagedAgentsTriggerContextUnion) RawJSON() string { return u.JSON.raw } 791 792 func (r *BetaManagedAgentsTriggerContextUnion) UnmarshalJSON(data []byte) error { 793 return apijson.UnmarshalRoot(data, r) 794 } 795 796 // What triggered a deployment run. 797 type BetaManagedAgentsTriggerType string 798 799 const ( 800 BetaManagedAgentsTriggerTypeSchedule BetaManagedAgentsTriggerType = "schedule" 801 BetaManagedAgentsTriggerTypeManual BetaManagedAgentsTriggerType = "manual" 802 ) 803 804 // An unknown or unexpected error caused the run to fail. A fallback variant; 805 // clients that do not recognize a new error type can match on message alone. 806 type BetaManagedAgentsUnknownRunError struct { 807 // Human-readable error description. 808 Message string `json:"message" api:"required"` 809 // Any of "unknown_error". 810 Type BetaManagedAgentsUnknownRunErrorType `json:"type" api:"required"` 811 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 812 JSON struct { 813 Message respjson.Field 814 Type respjson.Field 815 ExtraFields map[string]respjson.Field 816 raw string 817 } `json:"-"` 818 } 819 820 // Returns the unmodified JSON received from the API 821 func (r BetaManagedAgentsUnknownRunError) RawJSON() string { return r.JSON.raw } 822 func (r *BetaManagedAgentsUnknownRunError) UnmarshalJSON(data []byte) error { 823 return apijson.UnmarshalRoot(data, r) 824 } 825 826 type BetaManagedAgentsUnknownRunErrorType string 827 828 const ( 829 BetaManagedAgentsUnknownRunErrorTypeUnknownError BetaManagedAgentsUnknownRunErrorType = "unknown_error" 830 ) 831 832 // A vault referenced by the deployment is archived. 833 type BetaManagedAgentsVaultArchivedRunError struct { 834 // Human-readable error description. 835 Message string `json:"message" api:"required"` 836 // Any of "vault_archived_error". 837 Type BetaManagedAgentsVaultArchivedRunErrorType `json:"type" api:"required"` 838 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 839 JSON struct { 840 Message respjson.Field 841 Type respjson.Field 842 ExtraFields map[string]respjson.Field 843 raw string 844 } `json:"-"` 845 } 846 847 // Returns the unmodified JSON received from the API 848 func (r BetaManagedAgentsVaultArchivedRunError) RawJSON() string { return r.JSON.raw } 849 func (r *BetaManagedAgentsVaultArchivedRunError) UnmarshalJSON(data []byte) error { 850 return apijson.UnmarshalRoot(data, r) 851 } 852 853 type BetaManagedAgentsVaultArchivedRunErrorType string 854 855 const ( 856 BetaManagedAgentsVaultArchivedRunErrorTypeVaultArchivedError BetaManagedAgentsVaultArchivedRunErrorType = "vault_archived_error" 857 ) 858 859 // A vault referenced by the deployment no longer exists. 860 type BetaManagedAgentsVaultNotFoundRunError struct { 861 // Human-readable error description. 862 Message string `json:"message" api:"required"` 863 // Any of "vault_not_found_error". 864 Type BetaManagedAgentsVaultNotFoundRunErrorType `json:"type" api:"required"` 865 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 866 JSON struct { 867 Message respjson.Field 868 Type respjson.Field 869 ExtraFields map[string]respjson.Field 870 raw string 871 } `json:"-"` 872 } 873 874 // Returns the unmodified JSON received from the API 875 func (r BetaManagedAgentsVaultNotFoundRunError) RawJSON() string { return r.JSON.raw } 876 func (r *BetaManagedAgentsVaultNotFoundRunError) UnmarshalJSON(data []byte) error { 877 return apijson.UnmarshalRoot(data, r) 878 } 879 880 type BetaManagedAgentsVaultNotFoundRunErrorType string 881 882 const ( 883 BetaManagedAgentsVaultNotFoundRunErrorTypeVaultNotFoundError BetaManagedAgentsVaultNotFoundRunErrorType = "vault_not_found_error" 884 ) 885 886 // The deployment's workspace was archived. 887 type BetaManagedAgentsWorkspaceArchivedRunError struct { 888 // Human-readable error description. 889 Message string `json:"message" api:"required"` 890 // Any of "workspace_archived_error". 891 Type BetaManagedAgentsWorkspaceArchivedRunErrorType `json:"type" api:"required"` 892 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 893 JSON struct { 894 Message respjson.Field 895 Type respjson.Field 896 ExtraFields map[string]respjson.Field 897 raw string 898 } `json:"-"` 899 } 900 901 // Returns the unmodified JSON received from the API 902 func (r BetaManagedAgentsWorkspaceArchivedRunError) RawJSON() string { return r.JSON.raw } 903 func (r *BetaManagedAgentsWorkspaceArchivedRunError) UnmarshalJSON(data []byte) error { 904 return apijson.UnmarshalRoot(data, r) 905 } 906 907 type BetaManagedAgentsWorkspaceArchivedRunErrorType string 908 909 const ( 910 BetaManagedAgentsWorkspaceArchivedRunErrorTypeWorkspaceArchivedError BetaManagedAgentsWorkspaceArchivedRunErrorType = "workspace_archived_error" 911 ) 912 913 type BetaDeploymentRunGetParams struct { 914 WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"` 915 // Optional header to specify the beta version(s) you want to use. 916 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 917 paramObj 918 } 919 920 type BetaDeploymentRunListParams struct { 921 // Return runs created strictly after this time (exclusive). 922 CreatedAtGt param.Opt[time.Time] `query:"created_at[gt],omitzero" format:"date-time" json:"-"` 923 // Return runs created at or after this time (inclusive). 924 CreatedAtGte param.Opt[time.Time] `query:"created_at[gte],omitzero" format:"date-time" json:"-"` 925 // Return runs created strictly before this time (exclusive). 926 CreatedAtLt param.Opt[time.Time] `query:"created_at[lt],omitzero" format:"date-time" json:"-"` 927 // Return runs created at or before this time (inclusive). 928 CreatedAtLte param.Opt[time.Time] `query:"created_at[lte],omitzero" format:"date-time" json:"-"` 929 // Filter to a specific deployment. Omit to list across all deployments in the 930 // workspace. Filtering by a non-existent `deployment_id` returns 200 with empty 931 // data. 932 DeploymentID param.Opt[string] `query:"deployment_id,omitzero" json:"-"` 933 // Filter: true for runs with non-null `error`, false for runs with non-null 934 // `session_id`. Omit for all. 935 HasError param.Opt[bool] `query:"has_error,omitzero" json:"-"` 936 // Maximum results per page. Default 20, maximum 1000. 937 Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` 938 // Opaque pagination cursor. Pass `next_page` from the previous response. Invalid 939 // or expired cursors return 400. 940 Page param.Opt[string] `query:"page,omitzero" json:"-"` 941 WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"` 942 // Filter runs by what triggered them. Omit to return all runs. 943 // 944 // Any of "schedule", "manual". 945 TriggerType BetaManagedAgentsTriggerType `query:"trigger_type,omitzero" json:"-"` 946 // Optional header to specify the beta version(s) you want to use. 947 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 948 paramObj 949 } 950 951 // URLQuery serializes [BetaDeploymentRunListParams]'s query parameters as 952 // `url.Values`. 953 func (r BetaDeploymentRunListParams) URLQuery() (v url.Values, err error) { 954 return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ 955 ArrayFormat: apiquery.ArrayQueryFormatBrackets, 956 NestedFormat: apiquery.NestedQueryFormatBrackets, 957 }) 958 }