github.com/anthropics/anthropic-sdk-go@v1.70.1/betaagentversion.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 "errors" 8 "fmt" 9 "net/http" 10 "net/url" 11 "slices" 12 13 "github.com/anthropics/anthropic-sdk-go/internal/apiquery" 14 "github.com/anthropics/anthropic-sdk-go/internal/requestconfig" 15 "github.com/anthropics/anthropic-sdk-go/option" 16 "github.com/anthropics/anthropic-sdk-go/packages/pagination" 17 "github.com/anthropics/anthropic-sdk-go/packages/param" 18 ) 19 20 // BetaAgentVersionService contains methods and other services that help with 21 // interacting with the anthropic API. 22 // 23 // Note, unlike clients, this service does not read variables from the environment 24 // automatically. You should not instantiate this service directly, and instead use 25 // the [NewBetaAgentVersionService] method instead. 26 type BetaAgentVersionService struct { 27 Options []option.RequestOption 28 } 29 30 // NewBetaAgentVersionService generates a new service that applies the given 31 // options to each request. These options are applied after the parent client's 32 // options (if there is one), and before any request-specific options. 33 func NewBetaAgentVersionService(opts ...option.RequestOption) (r BetaAgentVersionService) { 34 r = BetaAgentVersionService{} 35 r.Options = opts 36 return 37 } 38 39 // List Agent Versions 40 func (r *BetaAgentVersionService) List(ctx context.Context, agentID string, params BetaAgentVersionListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaManagedAgentsAgent], err error) { 41 var raw *http.Response 42 for _, v := range params.Betas { 43 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 44 } 45 if !param.IsOmitted(params.WorkspaceID) { 46 opts = append(opts, option.WithHeader("anthropic-workspace-id", fmt.Sprintf("%v", params.WorkspaceID.Value))) 47 } 48 opts = slices.Concat(r.Options, opts) 49 opts = append([]option.RequestOption{option.WithHeader("anthropic-beta", "managed-agents-2026-04-01"), option.WithResponseInto(&raw)}, opts...) 50 if agentID == "" { 51 err = errors.New("missing required agent_id parameter") 52 return nil, err 53 } 54 path := fmt.Sprintf("v1/agents/%s/versions?beta=true", agentID) 55 cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) 56 if err != nil { 57 return nil, err 58 } 59 err = cfg.Execute() 60 if err != nil { 61 return nil, err 62 } 63 res.SetPageConfig(cfg, raw) 64 return res, nil 65 } 66 67 // List Agent Versions 68 func (r *BetaAgentVersionService) ListAutoPaging(ctx context.Context, agentID string, params BetaAgentVersionListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaManagedAgentsAgent] { 69 return pagination.NewPageCursorAutoPager(r.List(ctx, agentID, params, opts...)) 70 } 71 72 type BetaAgentVersionListParams struct { 73 // Maximum results per page. Default 20, maximum 100. 74 Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` 75 // Opaque pagination cursor. 76 Page param.Opt[string] `query:"page,omitzero" json:"-"` 77 WorkspaceID param.Opt[string] `header:"anthropic-workspace-id,omitzero" json:"-"` 78 // Optional header to specify the beta version(s) you want to use. 79 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 80 paramObj 81 } 82 83 // URLQuery serializes [BetaAgentVersionListParams]'s query parameters as 84 // `url.Values`. 85 func (r BetaAgentVersionListParams) URLQuery() (v url.Values, err error) { 86 return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ 87 ArrayFormat: apiquery.ArrayQueryFormatBrackets, 88 NestedFormat: apiquery.NestedQueryFormatBrackets, 89 }) 90 }