Skip to content

Commit 7302183

Browse files
refactor(auth): simplify proxy configuration in OpenAPI schema
1 parent cb2010d commit 7302183

3 files changed

Lines changed: 37 additions & 7 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 100
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-13e82ae9e725e2c3ca19da7248a7a9c8696a0dfe088654cf26aea07c76d6567a.yml
3-
openapi_spec_hash: 6d4151a6066a8474bc56923299aec18a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-eaf23b9711c16c82563be76641c9c89988288307278dcd630a36f4f186f85afa.yml
3+
openapi_spec_hash: 369570222f4f725e1de11285422837cc
44
config_hash: 82f0a04081a3ab7111d3a9c68cd3ff2b

authconnection.go

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ func (r *AuthConnectionService) Submit(ctx context.Context, id string, body Auth
156156
type LoginRequestParam struct {
157157
// If provided, saves credentials under this name upon successful login
158158
SaveCredentialAs param.Opt[string] `json:"save_credential_as,omitzero"`
159+
// Proxy selection. Provide either id or name. The proxy must belong to the
160+
// caller's org.
161+
Proxy LoginRequestProxyParam `json:"proxy,omitzero"`
159162
paramObj
160163
}
161164

@@ -167,6 +170,24 @@ func (r *LoginRequestParam) UnmarshalJSON(data []byte) error {
167170
return apijson.UnmarshalRoot(data, r)
168171
}
169172

173+
// Proxy selection. Provide either id or name. The proxy must belong to the
174+
// caller's org.
175+
type LoginRequestProxyParam struct {
176+
// Proxy ID
177+
ID param.Opt[string] `json:"id,omitzero"`
178+
// Proxy name
179+
Name param.Opt[string] `json:"name,omitzero"`
180+
paramObj
181+
}
182+
183+
func (r LoginRequestProxyParam) MarshalJSON() (data []byte, err error) {
184+
type shadow LoginRequestProxyParam
185+
return param.MarshalObject(r, (*shadow)(&r))
186+
}
187+
func (r *LoginRequestProxyParam) UnmarshalJSON(data []byte) error {
188+
return apijson.UnmarshalRoot(data, r)
189+
}
190+
170191
// Response from starting a login flow
171192
type LoginResponse struct {
172193
// Auth connection ID
@@ -537,7 +558,8 @@ type ManagedAuthCreateRequestParam struct {
537558
// - { provider, path } for external provider item
538559
// - { provider, auto: true } for external provider domain lookup
539560
Credential ManagedAuthCreateRequestCredentialParam `json:"credential,omitzero"`
540-
// Optional proxy configuration
561+
// Proxy selection. Provide either id or name. The proxy must belong to the
562+
// caller's org.
541563
Proxy ManagedAuthCreateRequestProxyParam `json:"proxy,omitzero"`
542564
paramObj
543565
}
@@ -575,10 +597,13 @@ func (r *ManagedAuthCreateRequestCredentialParam) UnmarshalJSON(data []byte) err
575597
return apijson.UnmarshalRoot(data, r)
576598
}
577599

578-
// Optional proxy configuration
600+
// Proxy selection. Provide either id or name. The proxy must belong to the
601+
// caller's org.
579602
type ManagedAuthCreateRequestProxyParam struct {
580-
// ID of the proxy to use
581-
ProxyID param.Opt[string] `json:"proxy_id,omitzero"`
603+
// Proxy ID
604+
ID param.Opt[string] `json:"id,omitzero"`
605+
// Proxy name
606+
Name param.Opt[string] `json:"name,omitzero"`
582607
paramObj
583608
}
584609

authconnection_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ func TestAuthConnectionNewWithOptionalParams(t *testing.T) {
4040
HealthCheckInterval: kernel.Int(3600),
4141
LoginURL: kernel.String("https://netflix.com/login"),
4242
Proxy: kernel.ManagedAuthCreateRequestProxyParam{
43-
ProxyID: kernel.String("proxy_id"),
43+
ID: kernel.String("id"),
44+
Name: kernel.String("name"),
4445
},
4546
},
4647
})
@@ -145,6 +146,10 @@ func TestAuthConnectionLoginWithOptionalParams(t *testing.T) {
145146
"id",
146147
kernel.AuthConnectionLoginParams{
147148
LoginRequest: kernel.LoginRequestParam{
149+
Proxy: kernel.LoginRequestProxyParam{
150+
ID: kernel.String("id"),
151+
Name: kernel.String("name"),
152+
},
148153
SaveCredentialAs: kernel.String("my-netflix-login"),
149154
},
150155
},

0 commit comments

Comments
 (0)