Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions components/ambient-api-server/openapi/openapi.sessions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,37 @@ paths:
application/json:
schema:
$ref: 'openapi.yaml#/components/schemas/Error'
delete:
summary: Delete a session by id
security:
- Bearer: []
responses:
'204':
description: Session deleted successfully
'401':
description: Auth token is invalid
content:
application/json:
schema:
$ref: 'openapi.yaml#/components/schemas/Error'
'403':
description: Unauthorized to perform operation
content:
application/json:
schema:
$ref: 'openapi.yaml#/components/schemas/Error'
Comment thread
maskarb marked this conversation as resolved.
'404':
description: No session with specified id exists
content:
application/json:
schema:
$ref: 'openapi.yaml#/components/schemas/Error'
'500':
description: Unexpected error deleting session
content:
application/json:
schema:
$ref: 'openapi.yaml#/components/schemas/Error'
parameters:
- $ref: '#/components/parameters/id'
/api/ambient/v1/sessions/{id}/status:
Expand Down
28 changes: 20 additions & 8 deletions components/ambient-sdk/generator/templates/go/http_client.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package client
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io"
Expand All @@ -23,12 +24,13 @@ import (
)

type Client struct {
httpClient *http.Client
baseURL string
token string
project string
logger *slog.Logger
userAgent string
httpClient *http.Client
baseURL string
token string
project string
logger *slog.Logger
userAgent string
insecureSkipVerify bool
}

type ClientOption func(*Client)
Expand All @@ -39,6 +41,15 @@ func WithTimeout(timeout time.Duration) ClientOption {
}
}

func WithInsecureSkipVerify() ClientOption {
return func(c *Client) {
c.insecureSkipVerify = true
c.httpClient.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
}
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

func WithLogger(logger *slog.Logger) ClientOption {
return func(c *Client) {
c.logger = logger
Expand Down Expand Up @@ -226,7 +237,8 @@ func validateURL(rawURL string) error {
return nil
}

var bearerTokenPattern = regexp.MustCompile(`([Bb]earer\s+)[a-zA-Z0-9\-_~.+/=]+`)

func sanitizeLogURL(rawURL string) string {
tokenPattern := regexp.MustCompile(`([Bb]earer\s+)[a-zA-Z0-9\-_~.+/=]+`)
return tokenPattern.ReplaceAllString(rawURL, "${1}[REDACTED]")
return bearerTokenPattern.ReplaceAllString(rawURL, "${1}[REDACTED]")
}
5 changes: 1 addition & 4 deletions components/ambient-sdk/generator/templates/go/types.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func (b *{{$.Resource.Name}}Builder) {{.GoName}}(v {{.GoType}}) *{{$.Resource.Na
b.resource.{{.GoName}} = v
return b
}
{{end}}{{end}}

{{end}}{{- end}}
func (b *{{.Resource.Name}}Builder) Build() (*{{.Resource.Name}}, error) {
{{- range .Resource.Fields}}
{{- if .Required}}
Expand Down Expand Up @@ -78,7 +77,6 @@ func (b *{{$.Resource.Name}}PatchBuilder) {{.GoName}}(v {{.GoType}}) *{{$.Resour
return b
}
{{end}}

func (b *{{.Resource.Name}}PatchBuilder) Build() map[string]any {
return b.patch
}
Expand All @@ -97,7 +95,6 @@ func (b *{{$.Resource.Name}}StatusPatchBuilder) {{.GoName}}(v {{.GoType}}) *{{$.
return b
}
{{end}}

func (b *{{.Resource.Name}}StatusPatchBuilder) Build() map[string]any {
return b.patch
}
Expand Down
Loading