Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func (e *DevEnvImpl) OverrideDatabase(c *pkgenv.Database) error {

func (e *DevEnvImpl) OverrideConfig(c *config.ApplicationConfig) error {
c.Server.CORSAllowedHeaders = []string{"X-Ambient-Project"}
c.Server.JwkCertFile = "secrets/kind-jwks.json"
c.Server.JwkCertURL = ""
c.Auth.JwkCertFile = "secrets/kind-jwks.json"
c.Auth.JwkCertURL = ""
c.Auth.EnableJWT = false
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ func (e *ProductionEnvImpl) OverrideDatabase(c *pkgenv.Database) error {

func (e *ProductionEnvImpl) OverrideConfig(c *config.ApplicationConfig) error {
c.Server.CORSAllowedHeaders = []string{"X-Ambient-Project"}
c.Server.JwkCertURL = "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs"
c.Server.JwkCertFile = ""
c.Auth.JwkCertURL = "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/certs"
c.Auth.JwkCertFile = ""
return nil
}

Expand Down
22 changes: 11 additions & 11 deletions components/ambient-api-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ go 1.24.0
toolchain go1.24.9

require (
github.com/go-gormigrate/gormigrate/v2 v2.0.0
github.com/go-gormigrate/gormigrate/v2 v2.1.5
github.com/golang/glog v1.2.5
github.com/gorilla/mux v1.7.3
github.com/onsi/gomega v1.27.1
github.com/openshift-online/ocm-sdk-go v0.1.334
github.com/openshift-online/rh-trex-ai v0.0.19 // v0.0.14→v0.0.19: gRPC TLS support, JWT audience validation fix, OpenAPI generator improvements
github.com/openshift-online/rh-trex-ai v0.0.23 // v0.0.19→v0.0.23: auth config consolidation, JWK key rotation, user scoping
github.com/spf13/pflag v1.0.6
google.golang.org/grpc v1.75.1
google.golang.org/protobuf v1.36.11
gopkg.in/resty.v1 v1.12.0
gorm.io/gorm v1.20.5
gorm.io/gorm v1.31.1
)

require (
Expand Down Expand Up @@ -54,16 +54,13 @@ require (
github.com/gorilla/css v1.0.0 // indirect
github.com/gorilla/handlers v1.4.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.3 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v4 v4.18.2 // indirect
github.com/jackc/pgx/v5 v5.6.0 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.1 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
Expand Down Expand Up @@ -113,12 +110,15 @@ require (
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251014184007-4626949a642f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/postgres v1.0.5 // indirect
gorm.io/driver/postgres v1.6.0 // indirect
)

replace github.com/openshift-online/rh-trex-ai => ../../../rh-trex-ai
95 changes: 21 additions & 74 deletions components/ambient-api-server/go.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions components/ambient-api-server/pkg/api/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Class | Method | HTTP request | Description
*DefaultAPI* | [**ApiAmbientV1ProjectsIdPatch**](docs/DefaultAPI.md#apiambientv1projectsidpatch) | **Patch** /api/ambient/v1/projects/{id} | Update a project
*DefaultAPI* | [**ApiAmbientV1ProjectsPost**](docs/DefaultAPI.md#apiambientv1projectspost) | **Post** /api/ambient/v1/projects | Create a new project
*DefaultAPI* | [**ApiAmbientV1SessionsGet**](docs/DefaultAPI.md#apiambientv1sessionsget) | **Get** /api/ambient/v1/sessions | Returns a list of sessions
*DefaultAPI* | [**ApiAmbientV1SessionsIdDelete**](docs/DefaultAPI.md#apiambientv1sessionsiddelete) | **Delete** /api/ambient/v1/sessions/{id} | Delete a session by id
*DefaultAPI* | [**ApiAmbientV1SessionsIdGet**](docs/DefaultAPI.md#apiambientv1sessionsidget) | **Get** /api/ambient/v1/sessions/{id} | Get an session by id
*DefaultAPI* | [**ApiAmbientV1SessionsIdPatch**](docs/DefaultAPI.md#apiambientv1sessionsidpatch) | **Patch** /api/ambient/v1/sessions/{id} | Update an session
*DefaultAPI* | [**ApiAmbientV1SessionsIdStartPost**](docs/DefaultAPI.md#apiambientv1sessionsidstartpost) | **Post** /api/ambient/v1/sessions/{id}/start | Start a session
Expand Down
40 changes: 40 additions & 0 deletions components/ambient-api-server/pkg/api/openapi/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,46 @@ paths:
- Bearer: []
summary: Create a new session
/api/ambient/v1/sessions/{id}:
delete:
parameters:
- description: The id of record
explode: false
in: path
name: id
required: true
schema:
type: string
style: simple
responses:
"204":
description: Session deleted successfully
"401":
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
description: Auth token is invalid
"403":
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
description: Unauthorized to perform operation
"404":
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
description: No session with specified id exists
"500":
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
description: Unexpected error deleting session
security:
- Bearer: []
summary: Delete a session by id
get:
parameters:
- description: The id of record
Expand Down
133 changes: 133 additions & 0 deletions components/ambient-api-server/pkg/api/openapi/api_default.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions components/ambient-api-server/pkg/api/openapi/docs/DefaultAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Method | HTTP request | Description
[**ApiAmbientV1ProjectsIdPatch**](DefaultAPI.md#ApiAmbientV1ProjectsIdPatch) | **Patch** /api/ambient/v1/projects/{id} | Update a project
[**ApiAmbientV1ProjectsPost**](DefaultAPI.md#ApiAmbientV1ProjectsPost) | **Post** /api/ambient/v1/projects | Create a new project
[**ApiAmbientV1SessionsGet**](DefaultAPI.md#ApiAmbientV1SessionsGet) | **Get** /api/ambient/v1/sessions | Returns a list of sessions
[**ApiAmbientV1SessionsIdDelete**](DefaultAPI.md#ApiAmbientV1SessionsIdDelete) | **Delete** /api/ambient/v1/sessions/{id} | Delete a session by id
[**ApiAmbientV1SessionsIdGet**](DefaultAPI.md#ApiAmbientV1SessionsIdGet) | **Get** /api/ambient/v1/sessions/{id} | Get an session by id
[**ApiAmbientV1SessionsIdPatch**](DefaultAPI.md#ApiAmbientV1SessionsIdPatch) | **Patch** /api/ambient/v1/sessions/{id} | Update an session
[**ApiAmbientV1SessionsIdStartPost**](DefaultAPI.md#ApiAmbientV1SessionsIdStartPost) | **Post** /api/ambient/v1/sessions/{id}/start | Start a session
Expand Down Expand Up @@ -780,6 +781,72 @@ Name | Type | Description | Notes
[[Back to README]](../README.md)


## ApiAmbientV1SessionsIdDelete

> ApiAmbientV1SessionsIdDelete(ctx, id).Execute()

Delete a session by id

### Example

```go
package main

import (
"context"
"fmt"
"os"
openapiclient "github.com/GIT_USER_ID/GIT_REPO_ID"
)

func main() {
id := "id_example" // string | The id of record

configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
r, err := apiClient.DefaultAPI.ApiAmbientV1SessionsIdDelete(context.Background(), id).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultAPI.ApiAmbientV1SessionsIdDelete``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
}
```

### Path Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**id** | **string** | The id of record |

### Other Parameters

Other parameters are passed through a pointer to a apiApiAmbientV1SessionsIdDeleteRequest struct via the builder pattern


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------


### Return type

(empty response body)

### Authorization

[Bearer](../README.md#Bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)


## ApiAmbientV1SessionsIdGet

> Session ApiAmbientV1SessionsIdGet(ctx, id).Execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ambient-code/platform/components/ambient-api-server/pkg/api"
localgrpc "github.com/ambient-code/platform/components/ambient-api-server/pkg/api/grpc"
pb "github.com/ambient-code/platform/components/ambient-api-server/pkg/api/grpc/ambient/v1"
"github.com/openshift-online/rh-trex-ai/pkg/auth"
"github.com/openshift-online/rh-trex-ai/pkg/server"
"github.com/openshift-online/rh-trex-ai/pkg/server/grpcutil"
"github.com/openshift-online/rh-trex-ai/pkg/services"
Expand Down Expand Up @@ -113,7 +114,8 @@ func (h *projectSettingsGRPCHandler) ListProjectSettings(ctx context.Context, re
}

var psList []ProjectSettings
paging, svcErr := h.generic.List(ctx, "id", &listArgs, &psList)
username := auth.GetUsernameFromContext(ctx)
paging, svcErr := h.generic.List(ctx, username, &listArgs, &psList)
if svcErr != nil {
return nil, grpcutil.ServiceErrorToGRPC(svcErr)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/ambient-code/platform/components/ambient-api-server/pkg/api/openapi"
"github.com/openshift-online/rh-trex-ai/pkg/api/presenters"
"github.com/openshift-online/rh-trex-ai/pkg/auth"
"github.com/openshift-online/rh-trex-ai/pkg/errors"
"github.com/openshift-online/rh-trex-ai/pkg/handlers"
"github.com/openshift-online/rh-trex-ai/pkg/services"
Expand Down Expand Up @@ -106,7 +107,8 @@ func (h projectSettingsHandler) List(w http.ResponseWriter, r *http.Request) {
}
}
var items []ProjectSettings
paging, err := h.generic.List(ctx, "id", listArgs, &items)
username := auth.GetUsernameFromContext(ctx)
paging, err := h.generic.List(ctx, username, listArgs, &items)
if err != nil {
return nil, err
}
Expand Down
Loading
Loading