github.com/anthropics/anthropic-sdk-go@v1.70.1/betaorganizationfederationissuer.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 "github.com/anthropics/anthropic-sdk-go/shared/constant" 23 ) 24 25 // BetaOrganizationFederationIssuerService contains methods and other services that 26 // help with interacting with the anthropic API. 27 // 28 // Note, unlike clients, this service does not read variables from the environment 29 // automatically. You should not instantiate this service directly, and instead use 30 // the [NewBetaOrganizationFederationIssuerService] method instead. 31 type BetaOrganizationFederationIssuerService struct { 32 Options []option.RequestOption 33 } 34 35 // NewBetaOrganizationFederationIssuerService generates a new service that applies 36 // the given options to each request. These options are applied after the parent 37 // client's options (if there is one), and before any request-specific options. 38 func NewBetaOrganizationFederationIssuerService(opts ...option.RequestOption) (r BetaOrganizationFederationIssuerService) { 39 r = BetaOrganizationFederationIssuerService{} 40 r.Options = opts 41 return 42 } 43 44 // **Requires an OAuth access token with the `org:admin` scope**, from 45 // `ant auth login --scope org:admin` or a workload identity federation rule; Admin 46 // API keys are not accepted. See 47 // [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api). 48 // 49 // Register an OIDC issuer that Anthropic will trust for workload identity 50 // federation in your organization. 51 // 52 // The `jwks` field controls how the issuer's signing keys are obtained and takes 53 // one of three shapes selected by `type`: `discovery` (resolve keys through OIDC 54 // discovery), `explicit_url` (fetch keys from a fixed JWKS URL), or `inline` 55 // (provide a static key set). When `jwks.type` is `discovery` and no 56 // `discovery_base` is set, the issuer URL must be publicly reachable over HTTPS so 57 // Anthropic can fetch the discovery document; for `explicit_url` and `inline` 58 // modes the issuer URL is only matched as the JWT's `iss` claim and is not 59 // fetched. 60 func (r *BetaOrganizationFederationIssuerService) New(ctx context.Context, params BetaOrganizationFederationIssuerNewParams, opts ...option.RequestOption) (res *BetaFederationIssuer, err error) { 61 for _, v := range params.Betas { 62 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 63 } 64 opts = slices.Concat(r.Options, opts) 65 path := "v1/organizations/federation_issuers?beta=true" 66 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) 67 return res, err 68 } 69 70 // **Requires an OAuth access token with the `org:admin` scope**, from 71 // `ant auth login --scope org:admin` or a workload identity federation rule; Admin 72 // API keys are not accepted. See 73 // [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api). 74 // 75 // Retrieve a federation issuer by its ID (`fdis_...`). 76 func (r *BetaOrganizationFederationIssuerService) Get(ctx context.Context, federationIssuerID string, query BetaOrganizationFederationIssuerGetParams, opts ...option.RequestOption) (res *BetaFederationIssuer, err error) { 77 for _, v := range query.Betas { 78 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 79 } 80 opts = slices.Concat(r.Options, opts) 81 if federationIssuerID == "" { 82 err = errors.New("missing required federation_issuer_id parameter") 83 return nil, err 84 } 85 path := fmt.Sprintf("v1/organizations/federation_issuers/%s?beta=true", federationIssuerID) 86 err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) 87 return res, err 88 } 89 90 // **Requires an OAuth access token with the `org:admin` scope**, from 91 // `ant auth login --scope org:admin` or a workload identity federation rule; Admin 92 // API keys are not accepted. See 93 // [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api). 94 // 95 // Partially update a federation issuer. 96 // 97 // Setting `jwks` replaces the full JWKS shape at once. Archived issuers cannot be 98 // updated; this returns 400. Create a new issuer instead. 99 // 100 // Updating an issuer that backs a rule with a scope outside `workspace:developer` 101 // or `workspace:inference` requires a Console session. 102 func (r *BetaOrganizationFederationIssuerService) Update(ctx context.Context, federationIssuerID string, params BetaOrganizationFederationIssuerUpdateParams, opts ...option.RequestOption) (res *BetaFederationIssuer, err error) { 103 for _, v := range params.Betas { 104 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 105 } 106 opts = slices.Concat(r.Options, opts) 107 if federationIssuerID == "" { 108 err = errors.New("missing required federation_issuer_id parameter") 109 return nil, err 110 } 111 path := fmt.Sprintf("v1/organizations/federation_issuers/%s?beta=true", federationIssuerID) 112 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) 113 return res, err 114 } 115 116 // **Requires an OAuth access token with the `org:admin` scope**, from 117 // `ant auth login --scope org:admin` or a workload identity federation rule; Admin 118 // API keys are not accepted. See 119 // [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api). 120 // 121 // List federation issuers in your organization. 122 // 123 // Archived issuers are excluded unless `include_archived=true`. 124 func (r *BetaOrganizationFederationIssuerService) List(ctx context.Context, params BetaOrganizationFederationIssuerListParams, opts ...option.RequestOption) (res *pagination.PageCursor[BetaFederationIssuer], err error) { 125 var raw *http.Response 126 for _, v := range params.Betas { 127 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 128 } 129 opts = slices.Concat(r.Options, opts) 130 opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) 131 path := "v1/organizations/federation_issuers?beta=true" 132 cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) 133 if err != nil { 134 return nil, err 135 } 136 err = cfg.Execute() 137 if err != nil { 138 return nil, err 139 } 140 res.SetPageConfig(cfg, raw) 141 return res, nil 142 } 143 144 // **Requires an OAuth access token with the `org:admin` scope**, from 145 // `ant auth login --scope org:admin` or a workload identity federation rule; Admin 146 // API keys are not accepted. See 147 // [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api). 148 // 149 // List federation issuers in your organization. 150 // 151 // Archived issuers are excluded unless `include_archived=true`. 152 func (r *BetaOrganizationFederationIssuerService) ListAutoPaging(ctx context.Context, params BetaOrganizationFederationIssuerListParams, opts ...option.RequestOption) *pagination.PageCursorAutoPager[BetaFederationIssuer] { 153 return pagination.NewPageCursorAutoPager(r.List(ctx, params, opts...)) 154 } 155 156 // **Requires an OAuth access token with the `org:admin` scope**, from 157 // `ant auth login --scope org:admin` or a workload identity federation rule; Admin 158 // API keys are not accepted. See 159 // [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api). 160 // 161 // Archive a federation issuer. 162 // 163 // Idempotent; re-archiving returns the issuer with its original `archived_at`. 164 // Rejected with 400 if any live (non-archived) federation rule still references 165 // the issuer; archive those rules first (a rule's issuer cannot be changed), or 166 // recreate them against another issuer. 167 func (r *BetaOrganizationFederationIssuerService) Archive(ctx context.Context, federationIssuerID string, body BetaOrganizationFederationIssuerArchiveParams, opts ...option.RequestOption) (res *BetaFederationIssuer, err error) { 168 for _, v := range body.Betas { 169 opts = append(opts, option.WithHeaderAdd("anthropic-beta", fmt.Sprintf("%v", v))) 170 } 171 opts = slices.Concat(r.Options, opts) 172 if federationIssuerID == "" { 173 err = errors.New("missing required federation_issuer_id parameter") 174 return nil, err 175 } 176 path := fmt.Sprintf("v1/organizations/federation_issuers/%s/archive?beta=true", federationIssuerID) 177 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...) 178 return res, err 179 } 180 181 // Registered external OIDC identity provider. 182 // 183 // Records an external IdP the organization trusts for the RFC 7523 jwt-bearer 184 // grant. The `issuer_url` must match the JWT `iss` claim exactly. 185 type BetaFederationIssuer struct { 186 // Tagged ID of the federation issuer. 187 ID string `json:"id" api:"required"` 188 // If set, all rules referencing this issuer reject token exchange. 189 ArchivedAt time.Time `json:"archived_at" api:"required" format:"date-time"` 190 // Tagged ID (`user_`/`svac_`) of the actor that archived this issuer. 191 ArchivedByActorID string `json:"archived_by_actor_id" api:"required"` 192 // Whether the jwt-bearer exchange enforces JTI single-use (replay protection) for 193 // tokens from this issuer. Applies only to assertions carrying a `jti` claim; 194 // tokens without one are accepted without single-use enforcement. 195 CheckJTI bool `json:"check_jti" api:"required"` 196 // When this issuer was created. 197 CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"` 198 // Tagged ID (`user_`/`svac_`) of the actor that created this issuer. 199 CreatedByActorID string `json:"created_by_actor_id" api:"required"` 200 // The `iss` claim value. Incoming JWTs must match exactly. 201 IssuerURL string `json:"issuer_url" api:"required"` 202 // How signing keys are obtained for signature verification. 203 JWKS BetaFederationIssuerJWKSUnion `json:"jwks" api:"required"` 204 // If set, Anthropic's JWKS poller has paused polling for this issuer after 205 // repeated fetch failures. Re-enable by sending `jwks_polling_disabled: false` via 206 // the issuer update endpoint (POST) once the upstream JWKS endpoint is fixed. An 207 // OAuth caller cannot send this when the issuer backs a rule with any scope other 208 // than `workspace:developer` or `workspace:inference`; use a Console session. 209 JWKSPollingDisabledAt time.Time `json:"jwks_polling_disabled_at" api:"required" format:"date-time"` 210 // Maximum allowed iat→exp spread for assertions from this issuer (1-176400 211 // seconds, i.e. up to 49h). Assertions must carry both `iat` and `exp`; a missing 212 // `iat` is rejected. 213 MaxJWTLifetimeSeconds int64 `json:"max_jwt_lifetime_seconds" api:"required"` 214 // Admin-chosen slug identifier. 215 Name string `json:"name" api:"required"` 216 // Status of automatic JWKS polling for a federation issuer. 217 // 218 // Anthropic periodically fetches the issuer's signing keys in the background. 219 // These fields summarize the most recent fetches so the health of the JWKS 220 // endpoint can be monitored. 221 PollStatus BetaFederationIssuerPollStatus `json:"poll_status" api:"required"` 222 Type constant.FederationIssuer `json:"type" default:"federation_issuer"` 223 // When this issuer was last updated. 224 UpdatedAt time.Time `json:"updated_at" api:"required" format:"date-time"` 225 // Tagged ID (`user_`/`svac_`) of the actor that last updated this issuer. 226 UpdatedByActorID string `json:"updated_by_actor_id" api:"required"` 227 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 228 JSON struct { 229 ID respjson.Field 230 ArchivedAt respjson.Field 231 ArchivedByActorID respjson.Field 232 CheckJTI respjson.Field 233 CreatedAt respjson.Field 234 CreatedByActorID respjson.Field 235 IssuerURL respjson.Field 236 JWKS respjson.Field 237 JWKSPollingDisabledAt respjson.Field 238 MaxJWTLifetimeSeconds respjson.Field 239 Name respjson.Field 240 PollStatus respjson.Field 241 Type respjson.Field 242 UpdatedAt respjson.Field 243 UpdatedByActorID respjson.Field 244 ExtraFields map[string]respjson.Field 245 raw string 246 } `json:"-"` 247 } 248 249 // Returns the unmodified JSON received from the API 250 func (r BetaFederationIssuer) RawJSON() string { return r.JSON.raw } 251 func (r *BetaFederationIssuer) UnmarshalJSON(data []byte) error { 252 return apijson.UnmarshalRoot(data, r) 253 } 254 255 // BetaFederationIssuerJWKSUnion contains all possible properties and values from 256 // [BetaJWKSDiscovery], [BetaJWKSExplicitURL], [BetaJWKSInline]. 257 // 258 // Use the [BetaFederationIssuerJWKSUnion.AsAny] method to switch on the variant. 259 // 260 // Use the methods beginning with 'As' to cast the union to one of its variants. 261 type BetaFederationIssuerJWKSUnion struct { 262 // Any of "discovery", "explicit_url", "inline". 263 Type string `json:"type"` 264 CACertPEM string `json:"ca_cert_pem"` 265 // This field is from variant [BetaJWKSDiscovery]. 266 DiscoveryBase string `json:"discovery_base"` 267 // This field is from variant [BetaJWKSExplicitURL]. 268 URL string `json:"url"` 269 // This field is from variant [BetaJWKSInline]. 270 Keys []map[string]any `json:"keys"` 271 JSON struct { 272 Type respjson.Field 273 CACertPEM respjson.Field 274 DiscoveryBase respjson.Field 275 URL respjson.Field 276 Keys respjson.Field 277 raw string 278 } `json:"-"` 279 } 280 281 // anyBetaFederationIssuerJWKS is implemented by each variant of 282 // [BetaFederationIssuerJWKSUnion] to add type safety for the return type of 283 // [BetaFederationIssuerJWKSUnion.AsAny] 284 type anyBetaFederationIssuerJWKS interface { 285 implBetaFederationIssuerJWKSUnion() 286 } 287 288 func (BetaJWKSDiscovery) implBetaFederationIssuerJWKSUnion() {} 289 func (BetaJWKSExplicitURL) implBetaFederationIssuerJWKSUnion() {} 290 func (BetaJWKSInline) implBetaFederationIssuerJWKSUnion() {} 291 292 // Use the following switch statement to find the correct variant 293 // 294 // switch variant := BetaFederationIssuerJWKSUnion.AsAny().(type) { 295 // case anthropic.BetaJWKSDiscovery: 296 // case anthropic.BetaJWKSExplicitURL: 297 // case anthropic.BetaJWKSInline: 298 // default: 299 // fmt.Errorf("no variant present") 300 // } 301 func (u BetaFederationIssuerJWKSUnion) AsAny() anyBetaFederationIssuerJWKS { 302 switch u.Type { 303 case "discovery": 304 return u.AsDiscovery() 305 case "explicit_url": 306 return u.AsExplicitURL() 307 case "inline": 308 return u.AsInline() 309 } 310 return nil 311 } 312 313 func (u BetaFederationIssuerJWKSUnion) AsDiscovery() (v BetaJWKSDiscovery) { 314 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 315 return 316 } 317 318 func (u BetaFederationIssuerJWKSUnion) AsExplicitURL() (v BetaJWKSExplicitURL) { 319 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 320 return 321 } 322 323 func (u BetaFederationIssuerJWKSUnion) AsInline() (v BetaJWKSInline) { 324 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) 325 return 326 } 327 328 // Returns the unmodified JSON received from the API 329 func (u BetaFederationIssuerJWKSUnion) RawJSON() string { return u.JSON.raw } 330 331 func (r *BetaFederationIssuerJWKSUnion) UnmarshalJSON(data []byte) error { 332 return apijson.UnmarshalRoot(data, r) 333 } 334 335 // Status of automatic JWKS polling for a federation issuer. 336 // 337 // Anthropic periodically fetches the issuer's signing keys in the background. 338 // These fields summarize the most recent fetches so the health of the JWKS 339 // endpoint can be monitored. 340 type BetaFederationIssuerPollStatus struct { 341 // Consecutive fetch failures since the last success. 342 ConsecutiveFailures int64 `json:"consecutive_failures" api:"required"` 343 // When the last successful fetch completed. 344 LastFetchedAt time.Time `json:"last_fetched_at" api:"required" format:"date-time"` 345 // When the next fetch is scheduled. Null if paused. 346 NextPollAt time.Time `json:"next_poll_at" api:"required" format:"date-time"` 347 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 348 JSON struct { 349 ConsecutiveFailures respjson.Field 350 LastFetchedAt respjson.Field 351 NextPollAt respjson.Field 352 ExtraFields map[string]respjson.Field 353 raw string 354 } `json:"-"` 355 } 356 357 // Returns the unmodified JSON received from the API 358 func (r BetaFederationIssuerPollStatus) RawJSON() string { return r.JSON.raw } 359 func (r *BetaFederationIssuerPollStatus) UnmarshalJSON(data []byte) error { 360 return apijson.UnmarshalRoot(data, r) 361 } 362 363 // JWKS via the issuer's OIDC discovery document. 364 type BetaJWKSDiscovery struct { 365 Type constant.Discovery `json:"type" default:"discovery"` 366 // Optional custom CA (PEM) for TLS verification of the JWKS fetch. 367 CACertPEM string `json:"ca_cert_pem" api:"nullable"` 368 // Set when the discovery URL differs from `issuer_url`. 369 DiscoveryBase string `json:"discovery_base" api:"nullable"` 370 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 371 JSON struct { 372 Type respjson.Field 373 CACertPEM respjson.Field 374 DiscoveryBase respjson.Field 375 ExtraFields map[string]respjson.Field 376 raw string 377 } `json:"-"` 378 } 379 380 // Returns the unmodified JSON received from the API 381 func (r BetaJWKSDiscovery) RawJSON() string { return r.JSON.raw } 382 func (r *BetaJWKSDiscovery) UnmarshalJSON(data []byte) error { 383 return apijson.UnmarshalRoot(data, r) 384 } 385 386 // ToParam converts this BetaJWKSDiscovery to a BetaJWKSDiscoveryParam. 387 // 388 // Warning: the fields of the param type will not be present. ToParam should only 389 // be used at the last possible moment before sending a request. Test for this with 390 // BetaJWKSDiscoveryParam.Overrides() 391 func (r BetaJWKSDiscovery) ToParam() BetaJWKSDiscoveryParam { 392 return param.Override[BetaJWKSDiscoveryParam](json.RawMessage(r.RawJSON())) 393 } 394 395 // JWKS via the issuer's OIDC discovery document. 396 // 397 // The property Type is required. 398 type BetaJWKSDiscoveryParam struct { 399 // Optional custom CA (PEM) for TLS verification of the JWKS fetch. 400 CACertPEM param.Opt[string] `json:"ca_cert_pem,omitzero"` 401 // Set when the discovery URL differs from `issuer_url`. 402 DiscoveryBase param.Opt[string] `json:"discovery_base,omitzero"` 403 // This field can be elided, and will marshal its zero value as "discovery". 404 Type constant.Discovery `json:"type" default:"discovery"` 405 paramObj 406 } 407 408 func (r BetaJWKSDiscoveryParam) MarshalJSON() (data []byte, err error) { 409 type shadow BetaJWKSDiscoveryParam 410 return param.MarshalObject(r, (*shadow)(&r)) 411 } 412 func (r *BetaJWKSDiscoveryParam) UnmarshalJSON(data []byte) error { 413 return apijson.UnmarshalRoot(data, r) 414 } 415 416 // JWKS fetched from a fixed endpoint. 417 type BetaJWKSExplicitURL struct { 418 Type constant.ExplicitURL `json:"type" default:"explicit_url"` 419 // JWKS endpoint. 420 URL string `json:"url" api:"required"` 421 // Optional custom CA (PEM) for TLS verification of the JWKS fetch. 422 CACertPEM string `json:"ca_cert_pem" api:"nullable"` 423 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 424 JSON struct { 425 Type respjson.Field 426 URL respjson.Field 427 CACertPEM respjson.Field 428 ExtraFields map[string]respjson.Field 429 raw string 430 } `json:"-"` 431 } 432 433 // Returns the unmodified JSON received from the API 434 func (r BetaJWKSExplicitURL) RawJSON() string { return r.JSON.raw } 435 func (r *BetaJWKSExplicitURL) UnmarshalJSON(data []byte) error { 436 return apijson.UnmarshalRoot(data, r) 437 } 438 439 // ToParam converts this BetaJWKSExplicitURL to a BetaJWKSExplicitURLParam. 440 // 441 // Warning: the fields of the param type will not be present. ToParam should only 442 // be used at the last possible moment before sending a request. Test for this with 443 // BetaJWKSExplicitURLParam.Overrides() 444 func (r BetaJWKSExplicitURL) ToParam() BetaJWKSExplicitURLParam { 445 return param.Override[BetaJWKSExplicitURLParam](json.RawMessage(r.RawJSON())) 446 } 447 448 // JWKS fetched from a fixed endpoint. 449 // 450 // The properties Type, URL are required. 451 type BetaJWKSExplicitURLParam struct { 452 // JWKS endpoint. 453 URL string `json:"url" api:"required"` 454 // Optional custom CA (PEM) for TLS verification of the JWKS fetch. 455 CACertPEM param.Opt[string] `json:"ca_cert_pem,omitzero"` 456 // This field can be elided, and will marshal its zero value as "explicit_url". 457 Type constant.ExplicitURL `json:"type" default:"explicit_url"` 458 paramObj 459 } 460 461 func (r BetaJWKSExplicitURLParam) MarshalJSON() (data []byte, err error) { 462 type shadow BetaJWKSExplicitURLParam 463 return param.MarshalObject(r, (*shadow)(&r)) 464 } 465 func (r *BetaJWKSExplicitURLParam) UnmarshalJSON(data []byte) error { 466 return apijson.UnmarshalRoot(data, r) 467 } 468 469 // JWKS supplied directly; no network fetch. 470 type BetaJWKSInline struct { 471 // Inline JWK objects. 472 Keys []map[string]any `json:"keys" api:"required"` 473 Type constant.Inline `json:"type" default:"inline"` 474 // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. 475 JSON struct { 476 Keys respjson.Field 477 Type respjson.Field 478 ExtraFields map[string]respjson.Field 479 raw string 480 } `json:"-"` 481 } 482 483 // Returns the unmodified JSON received from the API 484 func (r BetaJWKSInline) RawJSON() string { return r.JSON.raw } 485 func (r *BetaJWKSInline) UnmarshalJSON(data []byte) error { 486 return apijson.UnmarshalRoot(data, r) 487 } 488 489 // ToParam converts this BetaJWKSInline to a BetaJWKSInlineParam. 490 // 491 // Warning: the fields of the param type will not be present. ToParam should only 492 // be used at the last possible moment before sending a request. Test for this with 493 // BetaJWKSInlineParam.Overrides() 494 func (r BetaJWKSInline) ToParam() BetaJWKSInlineParam { 495 return param.Override[BetaJWKSInlineParam](json.RawMessage(r.RawJSON())) 496 } 497 498 // JWKS supplied directly; no network fetch. 499 // 500 // The properties Keys, Type are required. 501 type BetaJWKSInlineParam struct { 502 // Inline JWK objects. 503 Keys []map[string]any `json:"keys,omitzero" api:"required"` 504 // This field can be elided, and will marshal its zero value as "inline". 505 Type constant.Inline `json:"type" default:"inline"` 506 paramObj 507 } 508 509 func (r BetaJWKSInlineParam) MarshalJSON() (data []byte, err error) { 510 type shadow BetaJWKSInlineParam 511 return param.MarshalObject(r, (*shadow)(&r)) 512 } 513 func (r *BetaJWKSInlineParam) UnmarshalJSON(data []byte) error { 514 return apijson.UnmarshalRoot(data, r) 515 } 516 517 type BetaOrganizationFederationIssuerNewParams struct { 518 // The `iss` claim value to match against. 519 IssuerURL string `json:"issuer_url" api:"required"` 520 // Slug identifier (lowercase, digits, hyphens). Unique within the organization; a 521 // duplicate name returns 409. 522 Name string `json:"name" api:"required"` 523 // Whether the jwt-bearer exchange enforces JTI single-use (replay protection) for 524 // tokens from this issuer. Defaults to true. Applies only to assertions carrying a 525 // `jti` claim; tokens without one are accepted without single-use enforcement. 526 CheckJTI param.Opt[bool] `json:"check_jti,omitzero"` 527 // Maximum allowed iat→exp spread for assertions from this issuer (1-176400 528 // seconds, i.e. up to 49h). Defaults to 3600 (1h). Assertions must carry both 529 // `iat` and `exp`; a missing `iat` is rejected. 530 MaxJWTLifetimeSeconds param.Opt[int64] `json:"max_jwt_lifetime_seconds,omitzero"` 531 // How signing keys are obtained. Defaults to OIDC discovery. 532 JWKS BetaOrganizationFederationIssuerNewParamsJWKSUnion `json:"jwks,omitzero"` 533 // Optional header to specify the beta version(s) you want to use. 534 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 535 paramObj 536 } 537 538 func (r BetaOrganizationFederationIssuerNewParams) MarshalJSON() (data []byte, err error) { 539 type shadow BetaOrganizationFederationIssuerNewParams 540 return param.MarshalObject(r, (*shadow)(&r)) 541 } 542 func (r *BetaOrganizationFederationIssuerNewParams) UnmarshalJSON(data []byte) error { 543 return apijson.UnmarshalRoot(data, r) 544 } 545 546 // Only one field can be non-zero. 547 // 548 // Use [param.IsOmitted] to confirm if a field is set. 549 type BetaOrganizationFederationIssuerNewParamsJWKSUnion struct { 550 OfDiscovery *BetaJWKSDiscoveryParam `json:",omitzero,inline"` 551 OfExplicitURL *BetaJWKSExplicitURLParam `json:",omitzero,inline"` 552 OfInline *BetaJWKSInlineParam `json:",omitzero,inline"` 553 paramUnion 554 } 555 556 func (u BetaOrganizationFederationIssuerNewParamsJWKSUnion) MarshalJSON() ([]byte, error) { 557 return param.MarshalUnion(u, u.OfDiscovery, u.OfExplicitURL, u.OfInline) 558 } 559 func (u *BetaOrganizationFederationIssuerNewParamsJWKSUnion) UnmarshalJSON(data []byte) error { 560 return apijson.UnmarshalRoot(data, u) 561 } 562 563 func (u *BetaOrganizationFederationIssuerNewParamsJWKSUnion) asAny() any { 564 if !param.IsOmitted(u.OfDiscovery) { 565 return u.OfDiscovery 566 } else if !param.IsOmitted(u.OfExplicitURL) { 567 return u.OfExplicitURL 568 } else if !param.IsOmitted(u.OfInline) { 569 return u.OfInline 570 } 571 return nil 572 } 573 574 // Returns a pointer to the underlying variant's property, if present. 575 func (u BetaOrganizationFederationIssuerNewParamsJWKSUnion) GetDiscoveryBase() *string { 576 if vt := u.OfDiscovery; vt != nil && vt.DiscoveryBase.Valid() { 577 return &vt.DiscoveryBase.Value 578 } 579 return nil 580 } 581 582 // Returns a pointer to the underlying variant's property, if present. 583 func (u BetaOrganizationFederationIssuerNewParamsJWKSUnion) GetURL() *string { 584 if vt := u.OfExplicitURL; vt != nil { 585 return &vt.URL 586 } 587 return nil 588 } 589 590 // Returns a pointer to the underlying variant's property, if present. 591 func (u BetaOrganizationFederationIssuerNewParamsJWKSUnion) GetKeys() []map[string]any { 592 if vt := u.OfInline; vt != nil { 593 return vt.Keys 594 } 595 return nil 596 } 597 598 // Returns a pointer to the underlying variant's property, if present. 599 func (u BetaOrganizationFederationIssuerNewParamsJWKSUnion) GetType() *string { 600 if vt := u.OfDiscovery; vt != nil { 601 return (*string)(&vt.Type) 602 } else if vt := u.OfExplicitURL; vt != nil { 603 return (*string)(&vt.Type) 604 } else if vt := u.OfInline; vt != nil { 605 return (*string)(&vt.Type) 606 } 607 return nil 608 } 609 610 // Returns a pointer to the underlying variant's property, if present. 611 func (u BetaOrganizationFederationIssuerNewParamsJWKSUnion) GetCACertPEM() *string { 612 if vt := u.OfDiscovery; vt != nil && vt.CACertPEM.Valid() { 613 return &vt.CACertPEM.Value 614 } else if vt := u.OfExplicitURL; vt != nil && vt.CACertPEM.Valid() { 615 return &vt.CACertPEM.Value 616 } 617 return nil 618 } 619 620 func init() { 621 apijson.RegisterUnion[BetaOrganizationFederationIssuerNewParamsJWKSUnion]( 622 "type", 623 apijson.Discriminator[BetaJWKSDiscoveryParam]("discovery"), 624 apijson.Discriminator[BetaJWKSExplicitURLParam]("explicit_url"), 625 apijson.Discriminator[BetaJWKSInlineParam]("inline"), 626 ) 627 } 628 629 type BetaOrganizationFederationIssuerGetParams struct { 630 // Optional header to specify the beta version(s) you want to use. 631 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 632 paramObj 633 } 634 635 type BetaOrganizationFederationIssuerUpdateParams struct { 636 // Whether the jwt-bearer exchange enforces JTI single-use (replay protection) for 637 // tokens from this issuer. Applies only to assertions carrying a `jti` claim; 638 // tokens without one are accepted without single-use enforcement. 639 CheckJTI param.Opt[bool] `json:"check_jti,omitzero"` 640 // Replaces the `iss` claim value to match against. For discovery-mode issuers 641 // without a `discovery_base`, this is also the URL Anthropic fetches the OIDC 642 // discovery document and signing keys from, so changing it repoints the JWKS 643 // source. Changing the issuer URL to a well-known shared platform is rejected 644 // while any live rule under this issuer would not constrain tenant identity. 645 IssuerURL param.Opt[string] `json:"issuer_url,omitzero"` 646 // Only `false` is accepted, to re-enable polling after the system pauses it. 647 // Polling is paused automatically; sending `true` is rejected. 648 JWKSPollingDisabled param.Opt[bool] `json:"jwks_polling_disabled,omitzero"` 649 // Maximum allowed iat→exp spread for assertions from this issuer (1-176400 650 // seconds, i.e. up to 49h). Assertions must carry both `iat` and `exp`; a missing 651 // `iat` is rejected. 652 MaxJWTLifetimeSeconds param.Opt[int64] `json:"max_jwt_lifetime_seconds,omitzero"` 653 // Replaces the slug identifier (lowercase, digits, hyphens). Unique within the 654 // organization; a duplicate name returns 409. 655 Name param.Opt[string] `json:"name,omitzero"` 656 // Replaces the entire JWKS configuration. 657 JWKS BetaOrganizationFederationIssuerUpdateParamsJWKSUnion `json:"jwks,omitzero"` 658 // Optional header to specify the beta version(s) you want to use. 659 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 660 paramObj 661 } 662 663 func (r BetaOrganizationFederationIssuerUpdateParams) MarshalJSON() (data []byte, err error) { 664 type shadow BetaOrganizationFederationIssuerUpdateParams 665 return param.MarshalObject(r, (*shadow)(&r)) 666 } 667 func (r *BetaOrganizationFederationIssuerUpdateParams) UnmarshalJSON(data []byte) error { 668 return apijson.UnmarshalRoot(data, r) 669 } 670 671 // Only one field can be non-zero. 672 // 673 // Use [param.IsOmitted] to confirm if a field is set. 674 type BetaOrganizationFederationIssuerUpdateParamsJWKSUnion struct { 675 OfDiscovery *BetaJWKSDiscoveryParam `json:",omitzero,inline"` 676 OfExplicitURL *BetaJWKSExplicitURLParam `json:",omitzero,inline"` 677 OfInline *BetaJWKSInlineParam `json:",omitzero,inline"` 678 paramUnion 679 } 680 681 func (u BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) MarshalJSON() ([]byte, error) { 682 return param.MarshalUnion(u, u.OfDiscovery, u.OfExplicitURL, u.OfInline) 683 } 684 func (u *BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) UnmarshalJSON(data []byte) error { 685 return apijson.UnmarshalRoot(data, u) 686 } 687 688 func (u *BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) asAny() any { 689 if !param.IsOmitted(u.OfDiscovery) { 690 return u.OfDiscovery 691 } else if !param.IsOmitted(u.OfExplicitURL) { 692 return u.OfExplicitURL 693 } else if !param.IsOmitted(u.OfInline) { 694 return u.OfInline 695 } 696 return nil 697 } 698 699 // Returns a pointer to the underlying variant's property, if present. 700 func (u BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) GetDiscoveryBase() *string { 701 if vt := u.OfDiscovery; vt != nil && vt.DiscoveryBase.Valid() { 702 return &vt.DiscoveryBase.Value 703 } 704 return nil 705 } 706 707 // Returns a pointer to the underlying variant's property, if present. 708 func (u BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) GetURL() *string { 709 if vt := u.OfExplicitURL; vt != nil { 710 return &vt.URL 711 } 712 return nil 713 } 714 715 // Returns a pointer to the underlying variant's property, if present. 716 func (u BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) GetKeys() []map[string]any { 717 if vt := u.OfInline; vt != nil { 718 return vt.Keys 719 } 720 return nil 721 } 722 723 // Returns a pointer to the underlying variant's property, if present. 724 func (u BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) GetType() *string { 725 if vt := u.OfDiscovery; vt != nil { 726 return (*string)(&vt.Type) 727 } else if vt := u.OfExplicitURL; vt != nil { 728 return (*string)(&vt.Type) 729 } else if vt := u.OfInline; vt != nil { 730 return (*string)(&vt.Type) 731 } 732 return nil 733 } 734 735 // Returns a pointer to the underlying variant's property, if present. 736 func (u BetaOrganizationFederationIssuerUpdateParamsJWKSUnion) GetCACertPEM() *string { 737 if vt := u.OfDiscovery; vt != nil && vt.CACertPEM.Valid() { 738 return &vt.CACertPEM.Value 739 } else if vt := u.OfExplicitURL; vt != nil && vt.CACertPEM.Valid() { 740 return &vt.CACertPEM.Value 741 } 742 return nil 743 } 744 745 func init() { 746 apijson.RegisterUnion[BetaOrganizationFederationIssuerUpdateParamsJWKSUnion]( 747 "type", 748 apijson.Discriminator[BetaJWKSDiscoveryParam]("discovery"), 749 apijson.Discriminator[BetaJWKSExplicitURLParam]("explicit_url"), 750 apijson.Discriminator[BetaJWKSInlineParam]("inline"), 751 ) 752 } 753 754 type BetaOrganizationFederationIssuerListParams struct { 755 // Opaque cursor from a previous response's `next_page`. 756 Page param.Opt[string] `query:"page,omitzero" json:"-"` 757 // Include archived resources. Defaults to false. 758 IncludeArchived param.Opt[bool] `query:"include_archived,omitzero" json:"-"` 759 // Number of results per page. 760 Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` 761 // Optional header to specify the beta version(s) you want to use. 762 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 763 paramObj 764 } 765 766 // URLQuery serializes [BetaOrganizationFederationIssuerListParams]'s query 767 // parameters as `url.Values`. 768 func (r BetaOrganizationFederationIssuerListParams) URLQuery() (v url.Values, err error) { 769 return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ 770 ArrayFormat: apiquery.ArrayQueryFormatBrackets, 771 NestedFormat: apiquery.NestedQueryFormatBrackets, 772 }) 773 } 774 775 type BetaOrganizationFederationIssuerArchiveParams struct { 776 // Optional header to specify the beta version(s) you want to use. 777 Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"` 778 paramObj 779 }