File tree Expand file tree Collapse file tree
ambient-api-server/openapi
ambient-sdk/generator/templates/go Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,6 +177,37 @@ paths:
177177 application/json :
178178 schema :
179179 $ref : ' openapi.yaml#/components/schemas/Error'
180+ delete :
181+ summary : Delete a session by id
182+ security :
183+ - Bearer : []
184+ responses :
185+ ' 204 ' :
186+ description : Session deleted successfully
187+ ' 401 ' :
188+ description : Auth token is invalid
189+ content :
190+ application/json :
191+ schema :
192+ $ref : ' openapi.yaml#/components/schemas/Error'
193+ ' 403 ' :
194+ description : Unauthorized to perform operation
195+ content :
196+ application/json :
197+ schema :
198+ $ref : ' openapi.yaml#/components/schemas/Error'
199+ ' 404 ' :
200+ description : No session with specified id exists
201+ content :
202+ application/json :
203+ schema :
204+ $ref : ' openapi.yaml#/components/schemas/Error'
205+ ' 500 ' :
206+ description : Unexpected error deleting session
207+ content :
208+ application/json :
209+ schema :
210+ $ref : ' openapi.yaml#/components/schemas/Error'
180211 parameters :
181212 - $ref : ' #/components/parameters/id'
182213 /api/ambient/v1/sessions/{id}/status :
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ package client
88import (
99 " bytes"
1010 " context"
11+ " crypto/tls"
1112 " encoding/json"
1213 " fmt"
1314 " io"
@@ -23,12 +24,13 @@ import (
2324)
2425
2526type Client struct {
26- httpClient *http.Client
27- baseURL string
28- token string
29- project string
30- logger *slog.Logger
31- userAgent string
27+ httpClient *http.Client
28+ baseURL string
29+ token string
30+ project string
31+ logger *slog.Logger
32+ userAgent string
33+ insecureSkipVerify bool
3234}
3335
3436type ClientOption func(*Client)
@@ -39,6 +41,15 @@ func WithTimeout(timeout time.Duration) ClientOption {
3941 }
4042}
4143
44+ func WithInsecureSkipVerify() ClientOption {
45+ return func(c *Client) {
46+ c.insecureSkipVerify = true
47+ c.httpClient.Transport = &http.Transport {
48+ TLSClientConfig: &tls.Config {InsecureSkipVerify: true}, //nolint:gosec
49+ }
50+ }
51+ }
52+
4253func WithLogger(logger *slog.Logger ) ClientOption {
4354 return func(c *Client) {
4455 c.logger = logger
@@ -226,7 +237,8 @@ func validateURL(rawURL string) error {
226237 return nil
227238}
228239
240+ var bearerTokenPattern = regexp.MustCompile (` ([Bb]earer\s+)[a-zA-Z0-9\-_~.+/=]+` )
241+
229242func sanitizeLogURL(rawURL string) string {
230- tokenPattern := regexp.MustCompile (` ([Bb]earer\s+)[a-zA-Z0-9\-_~.+/=]+` )
231- return tokenPattern.ReplaceAllString (rawURL, " ${1}[REDACTED]" )
243+ return bearerTokenPattern.ReplaceAllString (rawURL, " ${1}[REDACTED]" )
232244}
Original file line number Diff line number Diff line change @@ -44,8 +44,7 @@ func (b *{{$.Resource.Name}}Builder) {{.GoName}}(v {{.GoType}}) *{{$.Resource.Na
4444 b.resource. {{.GoName }} = v
4545 return b
4646}
47- {{end }}{{end }}
48-
47+ {{end }}{{- end }}
4948func (b *{{.Resource.Name }}Builder) Build() (*{{.Resource.Name }}, error) {
5049{{- range .Resource.Fields }}
5150 {{- if .Required }}
@@ -78,7 +77,6 @@ func (b *{{$.Resource.Name}}PatchBuilder) {{.GoName}}(v {{.GoType}}) *{{$.Resour
7877 return b
7978}
8079{{end }}
81-
8280func (b *{{.Resource.Name }}PatchBuilder) Build() map[string]any {
8381 return b.patch
8482}
@@ -97,7 +95,6 @@ func (b *{{$.Resource.Name}}StatusPatchBuilder) {{.GoName}}(v {{.GoType}}) *{{$.
9795 return b
9896}
9997{{end }}
100-
10198func (b *{{.Resource.Name }}StatusPatchBuilder) Build() map[string]any {
10299 return b.patch
103100}
You can’t perform that action at this time.
0 commit comments