Skip to content

Commit b71ecfc

Browse files
feat: Deprecate datacenter proxies in the API
Stainless-Generated-From: 4b982125185eccb56b10a1e62c1b0f3359daf186
1 parent 503fb61 commit b71ecfc

6 files changed

Lines changed: 85 additions & 257 deletions

File tree

‎api.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Params Types:
107107

108108
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserMemoryRequest">BrowserMemoryRequest</a>
109109
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserNetworkConfigParam">BrowserNetworkConfigParam</a>
110+
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserNetworkUpdateParam">BrowserNetworkUpdateParam</a>
110111
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserProxyConfigParam">BrowserProxyConfigParam</a>
111112
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserProxyMode">BrowserProxyMode</a>
112113
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserReplRequestParam">BrowserReplRequestParam</a>

‎browser.go‎

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,9 @@ type BrowserNetworkConfig struct {
232232
// or reserved IP ranges are rejected, as are entries that overlap private_hosts.
233233
// Enforced at Kernel's egress proxy only: destinations in private_hosts, and
234234
// processes in the browser VM that do not use the browser's proxy, are not
235-
// filtered, and Kernel's own control traffic is always allowed. Requires proxy v3.
236-
// Not supported on browser pools.
235+
// filtered, and Kernel's own control traffic is always allowed. Can be replaced or
236+
// removed while the session runs with PATCH /browsers/{id_or_name}. Requires proxy
237+
// v3. Not supported on browser pools.
237238
AllowedHosts []string `json:"allowed_hosts"`
238239
// Destinations the browser reaches directly through the session's own network
239240
// instead of through Kernel-managed egress — for private hosts reachable over a
@@ -359,8 +360,9 @@ type BrowserNetworkConfigParam struct {
359360
// or reserved IP ranges are rejected, as are entries that overlap private_hosts.
360361
// Enforced at Kernel's egress proxy only: destinations in private_hosts, and
361362
// processes in the browser VM that do not use the browser's proxy, are not
362-
// filtered, and Kernel's own control traffic is always allowed. Requires proxy v3.
363-
// Not supported on browser pools.
363+
// filtered, and Kernel's own control traffic is always allowed. Can be replaced or
364+
// removed while the session runs with PATCH /browsers/{id_or_name}. Requires proxy
365+
// v3. Not supported on browser pools.
364366
AllowedHosts []string `json:"allowed_hosts,omitzero"`
365367
// Destinations the browser reaches directly through the session's own network
366368
// instead of through Kernel-managed egress — for private hosts reachable over a
@@ -446,6 +448,32 @@ func (r *BrowserNetworkConfigProxyRouteProxyParam) UnmarshalJSON(data []byte) er
446448
return apijson.UnmarshalRoot(data, r)
447449
}
448450

451+
// Network configuration changes for a running browser session. Other network
452+
// settings can only be set at creation.
453+
type BrowserNetworkUpdateParam struct {
454+
// Replaces the session's egress allowlist, using the same entry rules as
455+
// network.allowed_hosts on create. Omit to leave the allowlist unchanged, or set
456+
// to null to remove it and return to unfiltered egress; an empty list is invalid.
457+
// The new list applies without restarting the browser: new requests to
458+
// destinations it no longer allows are refused within a few seconds, and open
459+
// connections to them are closed within about 30 seconds, or up to 10 minutes
460+
// during a Kernel deploy. Connections to destinations it still allows, such as
461+
// WebSockets, stay open. A start_url in the same request must be allowed by the
462+
// updated list, and is loaded only after the list takes effect. Requires a browser
463+
// created with proxy v3, and not supported on pooled browsers. If the request
464+
// fails, retry it: the new list may already apply to some requests.
465+
AllowedHosts []string `json:"allowed_hosts,omitzero"`
466+
paramObj
467+
}
468+
469+
func (r BrowserNetworkUpdateParam) MarshalJSON() (data []byte, err error) {
470+
type shadow BrowserNetworkUpdateParam
471+
return param.MarshalObject(r, (*shadow)(&r))
472+
}
473+
func (r *BrowserNetworkUpdateParam) UnmarshalJSON(data []byte) error {
474+
return apijson.UnmarshalRoot(data, r)
475+
}
476+
449477
// Browser pool this session was acquired from, if any.
450478
type BrowserPoolRef struct {
451479
// Browser pool ID
@@ -1580,7 +1608,8 @@ type BrowserNewParams struct {
15801608
//
15811609
// Any of "8GiB", "16GiB".
15821610
Memory BrowserMemoryRequest `json:"memory,omitzero"`
1583-
// Network configuration for the browser session. Cannot be changed after creation.
1611+
// Network configuration for the browser session. Only allowed_hosts can be changed
1612+
// after creation, with PATCH /browsers/{id_or_name}.
15841613
Network BrowserNetworkConfigParam `json:"network,omitzero"`
15851614
// Profile selection for the browser session. Provide either id or name. If
15861615
// specified, the matching profile will be loaded into the browser session.
@@ -1791,6 +1820,8 @@ type BrowserUpdateParams struct {
17911820
// category settings for per-category updates. Explicitly disabling all four
17921821
// categories also stops capture.
17931822
Telemetry BrowserUpdateParamsTelemetry `json:"telemetry,omitzero"`
1823+
// Network configuration changes to apply to the running browser session.
1824+
Network BrowserNetworkUpdateParam `json:"network,omitzero"`
17941825
// Profile to load into the browser session. Only allowed if the session does not
17951826
// already have a profile loaded.
17961827
Profile shared.BrowserProfileParam `json:"profile,omitzero"`

‎browser_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ func TestBrowserUpdateWithOptionalParams(t *testing.T) {
190190
kernel.BrowserUpdateParams{
191191
DisableDefaultProxy: kernel.Bool(true),
192192
Name: kernel.String("checkout-flow-1"),
193+
Network: kernel.BrowserNetworkUpdateParam{
194+
AllowedHosts: []string{"example.com", "*.example.com"},
195+
},
193196
Profile: shared.BrowserProfileParam{
194197
ID: kernel.String("id"),
195198
Name: kernel.String("name"),

‎configregistry.go‎

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -470,14 +470,11 @@ func (r *ProxyManaged) UnmarshalJSON(data []byte) error {
470470

471471
// Configuration for routing traffic through a proxy.
472472
type ProxyManagedCreate struct {
473-
// Proxy type to use. In terms of quality for avoiding bot-detection, from best to
474-
// worst: `mobile` > `residential` > `isp` > `datacenter`.
475-
//
476-
// Any of "datacenter", "isp", "residential", "mobile", "custom".
473+
// Any of "isp", "residential", "mobile", "custom".
477474
Type string `json:"type" api:"required"`
478475
// Hostnames that should bypass the parent proxy and connect directly.
479476
BypassHosts []string `json:"bypass_hosts"`
480-
// Configuration specific to the selected proxy `type`.
477+
// Configuration for an ISP proxy.
481478
Config ProxyManagedCreateConfigUnion `json:"config"`
482479
// Readable name of the proxy.
483480
Name string `json:"name"`
@@ -504,9 +501,8 @@ func (r *ProxyManagedCreate) UnmarshalJSON(data []byte) error {
504501
}
505502

506503
// ProxyManagedCreateConfigUnion contains all possible properties and values from
507-
// [ProxyManagedCreateConfigDatacenter], [ProxyManagedCreateConfigIsp],
508-
// [ProxyManagedCreateConfigResidential], [ProxyManagedCreateConfigMobile],
509-
// [ProxyManagedCreateConfigCustom].
504+
// [ProxyManagedCreateConfigIsp], [ProxyManagedCreateConfigResidential],
505+
// [ProxyManagedCreateConfigMobile], [ProxyManagedCreateConfigCustom].
510506
//
511507
// Use the methods beginning with 'As' to cast the union to one of its variants.
512508
type ProxyManagedCreateConfigUnion struct {
@@ -545,11 +541,6 @@ type ProxyManagedCreateConfigUnion struct {
545541
} `json:"-"`
546542
}
547543

548-
func (u ProxyManagedCreateConfigUnion) AsDatacenter() (v ProxyManagedCreateConfigDatacenter) {
549-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
550-
return
551-
}
552-
553544
func (u ProxyManagedCreateConfigUnion) AsIsp() (v ProxyManagedCreateConfigIsp) {
554545
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
555546
return
@@ -577,24 +568,6 @@ func (r *ProxyManagedCreateConfigUnion) UnmarshalJSON(data []byte) error {
577568
return apijson.UnmarshalRoot(data, r)
578569
}
579570

580-
// Configuration for a datacenter proxy.
581-
type ProxyManagedCreateConfigDatacenter struct {
582-
// ISO 3166 country code. Defaults to US if not provided.
583-
Country string `json:"country"`
584-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
585-
JSON struct {
586-
Country respjson.Field
587-
ExtraFields map[string]respjson.Field
588-
raw string
589-
} `json:"-"`
590-
}
591-
592-
// Returns the unmodified JSON received from the API
593-
func (r ProxyManagedCreateConfigDatacenter) RawJSON() string { return r.JSON.raw }
594-
func (r *ProxyManagedCreateConfigDatacenter) UnmarshalJSON(data []byte) error {
595-
return apijson.UnmarshalRoot(data, r)
596-
}
597-
598571
// Configuration for an ISP proxy.
599572
type ProxyManagedCreateConfigIsp struct {
600573
// ISO 3166 country code. Supported countries are US, GB, FR, DE, and SG. Defaults

0 commit comments

Comments
 (0)